We’re now considering switching from coffeescript to ES6 (or maybe also Typescript). But coffeescript is seeing a bit of a revival, and I’m starting to wonder if we should stick with it?? Tooling seems a bit behind and also lacking things like tree shaking etc (??). But coffeescript is so clean and fun...
YMMV, but I’m less worried about “clean and fun” and much more worried about rugged and correct. TypeScript makes it easier to unambiguously express intent both inside an application and when talking to external modules. Some parts of the syntax are unfortunate but I care about that a lot less than I do not having my systems break.
I’d switch and I wouldn’t look back. I did switch my focus of learning and use, albeit from Ruby and Kotlin (which is better than nothing but nominative typing is insufficient IMO) to TypeScript, and it was among the best decisions I’ve made in my professional career.
What do you think about nominal typing vs structural typing?
My friends that have been only used to statically typed, nominal programming languages, thinks this is the worst feature of TypeScript.
I don’t hate nominative typing but TypeScript has definitely coached me towards thinking more about data and operations on data. It does a lot to encourage you to move away from the traditional OOP patterns that make most people dunk on Java.
If I had to directly compare the two I think nominative typing is superior only in the case where you have two identically-shaped (down to the property name) classes that have different semantics. I feel like if you are in this situation you should take a very large step back and re-think your decisions.
I've written an enormous amount of code in CoffeeScript since 2013, but have been migrating it to Typescript during the last year, after it became very clear that CoffeeScript is a dead end. One thing that helps a lot with all the braces (instead of whitespace) is using prettier. My editor is heavily integrated with prettier, so with the touch of a key my code is always formatted in some (almost) canonical way.
Depends on your team size. 5+ engineers and need to refactor things? Typescript will make those needs far easier. Tooling support is amazing, for things like autocomplete, module import insertion and sorting, symbol renaming, function extraction, linting capabilities, correctness of code after changing designs.
There’s some learning around how to type things, but not too hard and very worth it. Need at least one teammate / leader who has used c++/java/c#/etc. extensively on large codebases to mentor others.
Teams of one, es6 is fine, typescript setup is probably overkill, especially for an mvp.
Dunno about you, but I do all of the things you mentioned, regularly, on a solo project. My test burden is greatly shrunken (getting rid of all those “did I pass sane args?” tests that one needs between modules) and I have much more confidence that I’m not shipping broken stuff.
I don’t think writing TypeScript actually takes longer once you’re practiced and it eliminates entire categories of error. YMMV, of course, but in 2019 it’s hard for me not to think of a new JavaScript project as somewhat unserious.
I agree, it doesn’t take me personally any longer to write typescript. In fact, it saves me tons of time and endless headaches. I _love_ typescript and use it at work in react and have used it in node for side projects. The benefits are incredible as you mentioned!
I guess it depends on what you’re doing. Setting up the tooling can sometimes be a bit of a pain in combination with other tools which are not designed with typescript in mind from the get go, such as react_on_rails.
If you’re doing a quick mvp in a weekend, I’m still not sure typescript is right. But it really depends on what other tools you are using and how well they integrate. If the mvp works, ya, definitely switch to typescript ASAP. That’s a fine line and really depends on the use case.
It's one and only useful feature compared to ES/TS is the syntax. Once you get used to it, which doesn't take long, you start to experience that in comparison to say ES6, you:
People say this is subjective, but my experience with other developers has shown otherwise. I once asked a team of developers to "just go along with CoffeeScript for 2 weeks" instead of arguing its syntactic decisions (they were developers who had only used C-style syntax languages in the past like Java/C++/JavaScript). All of them ended up loving CoffeeScript and staying with it for years.
Mind you, TypeScript was a very different language back then. Once it started adding features like disjoint unions and the tooling matured, I made the switch.
If you've learned to appreciate the elegance, expressive power, readability and overall speed of development of Coffeescript, tell me, are you going to drop that for some virtual type safety that doesn't even exist at runtime? There's no way you'll write a medium to large codebase in TS without the use of 'any' or 'undefined', otherwise you'll get completely stuck. Don't believe the hype.
When you are not writing critical code where lives or huge amounts of money depend on, then I'd say stick to Coffeescript. And when you find a type related bug in your code, fix it and write a test so the bug cannot occur again. Otherwise, first check out Elm, Dart and Livescript. TS is really the last on my list, I've had my share of pain there.
Any tips/thoughts??