3 ms·
> I feel like this misses the point of high-level languages. In my experience, higher-level code is easier to read and write. For one thing, there's simply a lo
by thomascgalvin 7y ago
> I feel like this misses the point of high-level languages. In my experience, higher-level code is easier to read and write. For one thing, there's simply a lot less of it.
High level code shifts the burned of understanding the type system from the author and the compiler to the reader.
Yes, there is more text to read in a strongly, strictly typed language, but that extra syntax conveys a lot of important information quickly and cheaply, and this is information that the reader will need to know.
The difference between:
cat( first, second ){ ... }
And
cat( first: LogEntry, second: LogEntry): void { ... }
Is immense. In the later case, I know exactly what this function wants me to provide, what contracts the arguments must honor, and I know something about what the function intends to do with those arguments; it's void, so there are probably side-effects.
In the first case, I have to figure that out by reading the body of the method. The signature could tell me all of this, but it doesn't.
> After all, if you haven't written it correctly, the user will notice right away, too!
My users are not paid well enough to debug my code for me.
- sooheon 7y agoWhat's wrong with: (cat-logs [& entries] ...) If we care about human understanding of the contract, types are no better than names. reverse :: [a] -> [a] (reverse [xs] ...)
- asdfasdfasdfa 7y agoNames can and do lie, types are checked by the compiler. Also in you example, is an entry a string? a dict? its own class? who knows.
- zmmmmm 7y ago> If we care about human understanding of the contract, types are no better than names. That depends on your familiarity with the code though. Yes if you are deeply familiar with the code you probably know what data type an "entry" is. But come to it cold and trying to reverse engineer code like that in the middle of a complex system to understand it is frightening (at least, in my experience).
- ken 7y agoIn a higher-level language, I tend to have a "cat" which is generic-by-default. In a functional language, functions tend to have no side effects. What exactly is the purpose of specialization here, or mutation? Arguments like this against Lisp tend to invent examples like this which sound reasonable in a Java program but don't exactly make sense in Lisp. Yes, static type systems can be handy if your program is based on the concept of defining new types and mutating them through new specialized methods. None of the programs I write are like that. That's not the only way to write a program.
- simplify 7y agoIn TypeScript I define new types (aliases) and update them without mutation nor methods. It's a pleasure.