7 ms·
That’s the beauty though, isn’t it. Most bugs are trivial. I appreciate typescript getting the trivial bugs right more often than I’d trust myself to do so.
by vsnf 4y ago
That’s the beauty though, isn’t it. Most bugs are trivial. I appreciate typescript getting the trivial bugs right more often than I’d trust myself to do so.
- dleslie 4y agoRight? The argument that static/strict typing mostly catches trivial bugs isn't an argument against the value of that language, and yet people seem to think it is!
- alrlroipsp 4y agoLet them fight windmills while we have a good time.
- DogLover_ 4y agoI have to disagree. Adding the types will increase the number of the characters/lines of code which with a 80-char formatter limit can make functions look almost gibberish at a glance. Do that on a whole codebase and it becomes a mess to look at.
- eyelidlessness 4y agoAnd I have to disagree in turn. Those additional characters and lines of code are documentation, and turn gibberish into not only human-readable clarity about the code you’re reading, but a machine-traversable dependency graph as well.
- hbrn 4y agoThe problem is that they are forced documentation. You can't choose to skip it after you became familiar with it.
- eyelidlessness 4y agoThat sounds like a VSCode extension I could write on a Saturday morning but whatever.
- _0w8t 4y agoThe verbosity of TypeScript types can be attributed to poor choice of syntax and names that became obvious retrospectively. Still even with TypeScript if types makes your functions ugly, then it shows the complexity of the code. Often it also suggests sensible refactoring that without types would not be apparent.
- DogLover_ 4y agoTypscript: "function area(left: number, top: number, right: number, bottom: number): number {" Javascript: "function area(left, top, right, bottom)" In an editor the typescript function would likely be split into five separate lines. "function area( left: number, top: number, right: number, bottom: number) : number {" None of the functions are complex but the the typescript function with the formatter creates a lot of noise.
- dleslie 4y agoIt's not noise, it's informative content. It also means it's not going to explode when fed the wrong types, because that's not possible.
- BigJono 4y agoThe only way it can not be noise is if you have no idea what your types are. That's a terrible way to code. If I'm working on a function foo(bar, baz), I know exactly what bar and baz are before looking at a single line of it, I've been tracing the code through to that function, how could I not know what the data types are at that point?
- atom_arranger 4y agoThe other people on/joining your team probably don’t know.
- dleslie 4y agoIt's normal not to be aware of the types when encountering code for the first time, or after a long absence. Your described experience is the rare exception when working with third party vendors, on long lived projects, or with teams that are not trivially small.
- dleslie 4y agoCharacter input time is a vanishingly small concern for overall productivity. If it's a concern then you'll probably catch more bugs by slowing down to think.
- DogLover_ 4y agoTyping it is not the problem. It is reading at a glance that becomes much harder since lines oftentimes get split into multilines. I get less of an overview.
- dleslie 4y agoIt's all still there, except with even more helpful information. If there are so many parameters that it falls out of mental context then there's too many parameters.