|
|
|
|
|
by Buttons840
1 day ago
|
|
> the running debate between dynamic typed and static typed computer languages Actually, I haven't seen a good dynamic vs static types debate for a long long time. Some of these fundamental debates have become tired and people don't debate them anymore, which is understandable. But, in the age of LLMs, maybe it's time to have that debate again. The major disadvantage of typed languages is they're harder to write at times, the type checker gets in your hair. But if LLMs write the code, what argument remains against static types? |
|
One of the primary structures that the project concerned itself with was written as a big fat z.object with all optional keys. In the logic, there were all kinds of runtime checks as nested if/else ifs looking for the presence of the keys and branching on their value if they existed. I discovered z.discriminatedUnions and realized that this could be checked once at compile time by defining the possible states of this structure, which progressed monotonically from one state to the next, never backwards
The logic then became a single comprehensive switch statement with an assert never default. Vastly simplified the rest of the application and obviated the nullish guards that were interspersed throughout the front- and backend logic. Life changing.
Now, I only use dynamic languages for trivial scripting or where the type system would be unneeded overhead. I am finding this to be rarer as my ambitions grow.
Also, the benefits of a good LSP provided by strongly typed languages with a robust ecosystem are huge. Makes reasoning about code so much simpler for me when I can peek any object's type in my IDE and go to definition. Ruby LSP is awful at this, you can't rename a variable globally nor can you go to a function's implementation if it cannot be determined. Not so with out-of-the-box tooling in strongly typed languages.