Programming thread

  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
Absolutely. All your code is written against your data structures, so they determine what code you can even write to begin with. They're also a great starting point when diving into a code base. Without fail, the most horrible code bases all have horrifically muddled data structures that do multiple unrelated things at once and have weird implicit invariants that nobody can (or does) keep track of.
As Fred Brooks said in The Mythical Man-Month:
Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious.
 
Absolutely. All your code is written against your data structures, so they determine what code you can even write to begin with. They're also a great starting point when diving into a code base. Without fail, the most horrible code bases all have horrifically muddled data structures that do multiple unrelated things at once and have weird implicit invariants that nobody can (or does) keep track of.
I remember trying to write parentheses matching code for a coding challenge and for some reason I started by using a dogshit system of setting a bunch of Boolean flags that didn't work at all and it was fixed immediately by using a stack instead
 
Last edited:
I remember trying to write parentheses matching code for a coding challenge and for some reason I started by using a dogshit system of setting a bunch of Boolean flags that didn't work at all and it was fixed immediately by using a stack instead
When I was first getting into programming, a similar problem led to me discovering stacks, I felt like a wizard
 
When I was first getting into programming, a similar problem led to me discovering stacks, I felt like a wizard
I always feel like a wizard when I'm programming
pepe-wizard-birthday-cake.jpg
 
All your code is written against your data structures
All my this. To drive the point home, MIT/GNU Scheme offers a bunch of different "hashtable" or "dictionary" like things that all have their own engineering tradeoffs: https://www.gnu.org/software/mit-scheme/documentation/stable/mit-scheme-ref/Associations.html

And none of them are the data structure "trie", which is another way to look at a similar problem on a slightly lower level.

You can get mad pussy while being a MEGA nerd if you balance things; I promise. ❤️
Yeah, learning how not to partake of what is offered was a harder lesson to learn.
 
Kid got a reflected XSS on some big tech domain names by finding a bug in some AI documentation slop service. It was worth 11k bucks.
Good for him but look at his friends, that 11k is going to pay for a stinkditch in two years. I'd rather have no money than no money and a stinkditch.
 
Fuck it, check this out.
pleasing pattern producer.gif


Using Decker feels more like sculpting than other kinds of programming, even Lisp, I suppose in part because I'm entirely unconcerned with building anything reusable. The only goal is that it works, and it doesn't need to scale to any kinds of arbitrary data or anything whatsoever.

The Clear button got added soon after I got the basics of drawing on the canvas and updating the other buttons working. It sets the text field of all widgets to the empty string, the canvas just ignores this, which made it very confusing for a moment when I tested it without noticing that the text on the Clear button itself would also be wiped. I returned to work on it more much later and couldn't tell why it was cleared, but when I added it back and later used it again, I realized what was happening.
:story:
 
Depending on the application, a tree may be the more appropriate structure. (like for html)
In the case of html, chances are you will end up using a stack (i.e. for tracking tag nesting) to assemble the tree (AST).
 
In the case of html, chances are you will end up using a stack (i.e. for tracking tag nesting) to assemble the tree (AST).
My personal favourite approach is to use a recursive constructor to construct the tree directly from the text stream. I guess if you count the program stack it's using a stack to assemble the tree?
 
My personal favourite approach is to use a recursive constructor to construct the tree directly from the text stream. I guess if you count the program stack it's using a stack to assemble the tree?
Yes, but using an explicit stack uses less memory, since you only need one pointer per node, while recursive descent parsing uses an entire activation record per node.
 
Yes, but using an explicit stack uses less memory, since you only need one pointer per node, while recursive descent parsing uses an entire activation record per node.
You can also build your tree in an already allocated buffer and replace pointers with indices, I use this for a tree in my current project, and I just store the pointer to the region as the graph, and the pointer to the root element as my root. It works well.
 
Yes, but using an explicit stack uses less memory, since you only need one pointer per node, while recursive descent parsing uses an entire activation record per node.
You can also build your tree in an already allocated buffer and replace pointers with indices, I use this for a tree in my current project, and I just store the pointer to the region as the graph, and the pointer to the root element as my root. It works well.
Yeah those are pretty valid reasons to prefer the explicit stack. I still default to recursive descent because it gives me better error handling, IMO, and can work with streaming the data quite well. And is dead easy to implement. And, hell, even allows to try to parse broken html (which is still surprisingly common)
 
have programming in a nutshell View attachment 8321752
Yeah, I'll reply too. Not only has Lisp always had more types than the CONS, but Armed Bear Common Lisp ran on the JVM before Clojure existed. Rich Hickey created Clojure rather than contributing to an existing system because it's much easier to get attention that way. Clojure is also more complicated than Common Lisp by now, from what I've read, but the reversed impression remains.

Everything really is an array of numbers or characters in APL, however, or a tensor if one wishes to be fancy about it.
 
Yeah, I'll reply too. Not only has Lisp always had more types than the CONS, but Armed Bear Common Lisp ran on the JVM before Clojure existed. Rich Hickey created Clojure rather than contributing to an existing system because it's much easier to get attention that way.
My understanding is that Clojure, somewhat like Erlang and Elixir, leans a lot into immutability and making concurrency easier with that fact
 
My understanding is that Clojure, somewhat like Erlang and Elixir, leans a lot into immutability and making concurrency easier with that fact
The main idea with concurrency is you want to share data by communicating, not communicate by sharing data. In languages like these, you're communicating over channels (fancy queue structures), passing data around instead of relying on mutable references (e.g. pointers or values in object). Thread safety stops being much of a concern when you don't have to guess what state a value may be in at a given time; ensuring only one thread manages that value is an easy way to achieve this.
 
The main idea with concurrency is you want to share data by communicating, not communicate by sharing data. In languages like these, you're communicating over channels (fancy queue structures), passing data around instead of relying on mutable references (e.g. pointers or values in object). Thread safety stops being much of a concern when you don't have to guess what state a value may be in at a given time; ensuring only one thread manages that value is an easy way to achieve this.
1766545518639.png
There's this evergreen chart for thread safety, I use all the time.
 
Back
Top Bottom