Earlier quoted context omitted.
> TS catches me writing numerous bugs a day I see this sentiment a lot but I honestly can't think of any non-trivial bugs that TS has caught for me. 99% of the bugs it catches I would see 1 second later when my page hot reloads and crashes.
Exactly, you have to run the code before you realize it’s defective and even then only the defects that execute will get any attention. With TypeScript the defects yell at you before executing the code.
TypeScript is now officially 10 years old
141–150 of 207 posts
Re: TypeScript is now officially 10 years old
#142Earlier quoted context omitted.
Wait until you try a language that was supposed to have a decent type system from the beginning!
I like type systems as you can design with types and check things tie together before even running the code. This gives you very fast iteration cycles compared to CMD-R refreshing the browser/code. Some issues with TS are: - There is no hard guarantee at runtime as everything is partially/optionally typed (including your deps). - The types are not used to produce faster code at runtime (like in a compiled language).…
Most typed languages don't have hard guarantees at runtime. With java, using reflection you can do all kinds of weird things at runtime. C++ has fewer guarantees because there is no VM and can't even introspect objects to see their real type. Dependencies are a real issue with TS, but many libraries are written in typescript and the type files are really robust.
>> The types are not used to produce faster code at runtime (like in a compiled language).
The V8 intepreter will actually do this at runtime. Usually it takes less than a second for v8 to optimize the javascript, and it will recognize that many functions and objects use the same interface and optimize appropriately. If you think about it the types only help so much because once you have the code graph, it becomes really easy to find the type and optimize the memory layout.
Re: TypeScript is now officially 10 years old
#143Earlier quoted context omitted.
I 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.
The 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.
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.
Re: TypeScript is now officially 10 years old
#144Earlier quoted context omitted.
> TS catches me writing numerous bugs a day I see this sentiment a lot but I honestly can't think of any non-trivial bugs that TS has caught for me. 99% of the bugs it catches I would see 1 second later when my page hot reloads and crashes.
I find it catches a lot of design mistakes for me which I would put in the non-trivial bugs category. Many bugs that result from design mistakes are less immediate, like hard to spot edge cases (a better design makes them impossible) or code that lends itself to becoming messier and more bug prone in the future as it's changed/extended (a better design makes this less likely).
Re: TypeScript is now officially 10 years old
#145TS on frontend feels like devs making their editor choice (VScode) a hard dependancy
What? Works fine in my editor (neovim). It also worked fine in helix when I gave it a try.
Re: TypeScript is now officially 10 years old
#146I feel like I am the only one in the world not liking typescript. It is not that I don't like types, it is what those types do to the readability of the codebase in terms of verbosity. My original programming language was Java but I switched to Node.js because I liked the simplicity of the code written in it. Nowadays every Javascript project seems worse than a Java project in terms of verbosity. My main gripe with p…
The typings on the class variables are useful to have. There are also typings on the function signatures, not a huge deal.
In the method bodies there are almost no typings as all of it is already inferred. Seems pretty readable to me.
Re: TypeScript is now officially 10 years old
#147Earlier quoted context omitted.
> There's even the future possibility of much of its type syntax being absorbed back into JavaScript: https://github.com/tc39/proposal-type-annotations ... as comments. Which superficially resemble the syntax of type hints but do nothing. Which has to be one of the worst language design decisions of all time.
I'd disagree that its a poor decision, some help is better than no help when reading code - and if it's inline then it's intrinsically meaningful. By no means is it perfect, the language doesn't enforce the type rules, but that the developer has the option is far better than not. As far as I can tell the proposal would pretty similar to Python; one can misleadingly or accidentally misuse type hints like the following…
There's also no way to share and reuse types in comments. Do you copy paste comments to "type" things? What about complex objects? What happens if the comments get out of sync? How do you test them?
I used to be a typescript skeptic too, but much of that skepticism tends to come from drastically underestimating the power of the TS type system.
Re: TypeScript is now officially 10 years old
#148I feel like I am the only one in the world not liking typescript. It is not that I don't like types, it is what those types do to the readability of the codebase in terms of verbosity. My original programming language was Java but I switched to Node.js because I liked the simplicity of the code written in it. Nowadays every Javascript project seems worse than a Java project in terms of verbosity. My main gripe with p…
I tried to find an example to see what you mean, take this file - https://github.com/microsoft/vscode/blob/main/src/vs/editor/... The typings on the class variables are useful to have. There are also typings on the function signatures, not a huge deal. In the method bodies there are almost no typings as all of it is already inferred. Seems pretty readable to me.
Looking at the code there is an awful lot of 'null's returned which I find hard to work with but that is a different topic.
Re: TypeScript is now officially 10 years old
#149Earlier quoted context omitted.
I 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.
Character 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.
Re: TypeScript is now officially 10 years old
#150Earlier quoted context omitted.
Exactly, you have to run the code before you realize it’s defective and even then only the defects that execute will get any attention. With TypeScript the defects yell at you before executing the code.
But at what cost? We shouldn’t assume it’s free