Echo JS 0.11.0

<~>
harambe 1684 days ago. link parent 2 points
TypeScript is super cool. It’s totally worth it for intellisense alone. I also find it very good in documenting my React components. The benefits have outweighed the downsides by far for us. I went from “meh” in the beginning of my TS project to “I dont want to work on js code anymore” a few days after. Give it a try ;)

Replies

jaleksic 1684 days ago. link 2 points
I'm still in the "meh" phase, even after months of working on some projects that use typescript as well.
I do see the benefits, no question, but I'm still not 100% convinced. It might be more pleasant to write, but it's terribly noisy to read.
It does encourage writing more performant code tho. The stricter you type, the better your resulting JS can be optimized by e.g. V8.
You can write performant JS manually too, but it takes a lot of experience and discipline.

Just recently I migrated a library of mine to TS where the very complicated typing basically rubbed in my face that my JS was simply bad. It was about a flags object in the concrete case, and usually it had string keys and boolean values, but in some cases it could have string values for certain keys. After struggling a lot to properly type all modules and functions that consuming that object, I gave up, accepted that my approach was shite, and rewrote the architecture to use monomorphic objects instead, introducing a new and separate logic that deals with the string case. Now stuff is much cleaner, overall and if it were to scale, it would surely even perform better.

Still, I'm not 100% convinced yet. You read a lot that you don't have to type everything, and you can just add TS on top of js because it's a superset blah blah. In my experience, that's not realistic, and going Typescript does take away the expressivity of Javascript (one of its best features). 
Let's see. Hated Javascript for years, now I love it :)
tracker1 1684 days ago. link 2 points
> You can write performant JS manually too, but it takes a lot of experience and discipline.

There are a lot of times I specifically write less performing code for clarity... Unless it's a real world performance issue in a given use case.  To me, TS is a lot like testing, it guides you into thinking things through.  Writing testable code, and having a disciplined directory/feature/module structure helps a lot too.