Live data from Hacker News

How we failed, then succeeded, at migrating to TypeScript

heap.io

21–30 of 60 posts

Re: How we failed, then succeeded, at migrating to TypeScript

#21
post #15

Typescript seems to be approaching C++ levels of syntax and expressiveness. The main difference seems to be the existing tooling, tutorials, libraries, etc for node.js and others. But if compiled languages like C++ or Go had as many dedicated libraries for webserver management as JavaScript, would there really be a benefit to using Typescript?

Yes, build times of a few seconds instead of minutes. Easier and more robust "write once, run everywhere". Integrating third party libraries in a matter of minutes instead of hours, sometimes days. Generally much faster prototyping capabilities. And so on.

Re: How we failed, then succeeded, at migrating to TypeScript

#23

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... Any tips/thoughts??

Why do you say "But coffeescript is seeing a bit of a revival"? Many metrics (such as https://github.com/jashkenas/coffeescript/graphs/contributor...) suggest otherwise...

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.

Re: How we failed, then succeeded, at migrating to TypeScript

#24

Earlier quoted context omitted.

For me the scale tips heavily towards type safety and tooling of TypeScript. Then again, I wish we didn't have to choose.

What would you say are the most useful features of coffeescript?

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:

- Write/edit code faster - Read/understand code easier

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.

Re: How we failed, then succeeded, at migrating to TypeScript

#25
post #3

Earlier quoted context omitted.

You just gave me an idea.. because we've shared a similar experience. I really miss the elegance of Coffeescript. ES6 is great, Typescript is great, but sometimes I feel like I have to visually parse a lot of static cruft to read the essence of the program. What if one's editor had a toggle hotkey to hide typescript typings. Maybe you could turn it off to visually parse the program real quick, before turning it back…

You're getting in the realm of "projectional editing." It's a fascinating idea: https://news.ycombinator.com/item?id=15534555

I love reading about stuff like this, thanks for sharing. Developer UX still has a lot of room to grow.

Re: How we failed, then succeeded, at migrating to TypeScript

#26
> Yes, we were adding TypeScript code, but we were adding CoffeeScript at a faster rate.

Unsurprisingly.

> how do we get our coworkers to buy in to this new paradigm?

By forcing them?

> and we’re all happy to spend hours figuring out exactly how we’ll set up our TypeScript config.

Oh yes what a joy!

> our data access layer (“ORM”) is ubiquitous, and most files use it in some way.

Use SQL instead, it's better.

> We also made tooling and configuration a priority.

Of course, there's no way to go down the TS rabbit hole without it!

> Finally, we converged on a set of agreed upon linting rules

The code soup that's generated with the 'airbnb' setting, I know it's a terrible read.

> When we began analyzing TypeScript adoption patterns, it became clear that using TypeScript wasn’t a seamless process for our engineers, who would often need to import special utilities (ts-node/register) or create intermediate CoffeeScript files that did nothing but import their TypeScript equivalents.

How productive!

> We avoided using any in this phase, instead opting for the stricter unknown.

Yes, the dream of type safety ends with using 'any' or 'unknown'. But are you sure only in this phase? I've never seen a TS codebase without it!

> Tackling a migration like this means asking your teammates to give up a way of doing their jobs that they’re comfortable and effective with

So tell me, no one left because they didn't like to have the joy sucked out of their lives?

> To do this we created a #typescript channel in Slack, and made sure developers getting stuck could get unblocked.

Another great addition to the workflow. But you mean 'stuck' like you cannot continue building because of TS? I only hear from TS proponents that it improves productivity?

> From the beginning, we knew that bulk, overnight migration was not a possibility, and that it would likely take a year or more to complete the process.

Ok, so more than a year with the entire team to kill a few type related bugs? How did you have to lie to get this agreed upon by the CEO?

> As we continue with this migration, we hope to keep learning, and to use this knowledge to make the next big project even easier.

Yes, keep learning because soon TS will be exit with the upcoming WebAssembly and you can start all over again in another hyped language or framework.

But for the record, instead of fixing a few type errors a once in a while and create proper tests for it, you went rewriting the entire app and fucking up your entire dev team that were happy with Coffeescript? I'm also really curious how much this entire operation has cost the company, and what the actual benefits are? Is it that the dev now can hover with his mouse over a variable see the related type? Or is the app really looking and working much better now? Always when I worked on a TS project the benefits were mostly imaginary and the pain real. Unfortunately there are way too many inexperienced web developers that think they look incredibly smart doing TS.. Vanity is a thing. Doing a dynamically typed language is for the poor minds that don't understand type safety, not? You are all way smarter than Brendan Eich I guess.

Re: How we failed, then succeeded, at migrating to TypeScript

#27
post #6

I was looking at some of my old repos today. Enjoyed the nostalgia. Lots of CoffeeScript there. I had to switch to ES and then TypeScript because CoffeeScript was abandoned at the time and I was stretched over other projects to be able to help maintain it. Reading my old code, I was surprised by how clean it looks. How easy it is to digest. There is a certain sense of calm when your brain doesn't have to process all…

> How easy it is to digest I’ve not had this experience. I’ve found the ambiguity in coffeescript a maddening adventure in syntax confusion. - function call syntax doesn’t need parens except if a 0 parameter method - commas are largely optional both in arrays and function parameters. How do you parse: [f, f(), f a b c] - implicit returns are a terrible idea. - the @ syntax refers to either a ‘static’ method or an ins…

I was very excited about CS when I learned about it, and in my initial tests found it really pleasant to write. However, before committing to using it more, I went and read some other projects written in it. At that point I decided that the reading experience was confusing, and the lack of "visible" syntax elements to guide me drove me nuts.

Re: How we failed, then succeeded, at migrating to TypeScript

#28
post #7

I was looking at some of my old repos today. Enjoyed the nostalgia. Lots of CoffeeScript there. I had to switch to ES and then TypeScript because CoffeeScript was abandoned at the time and I was stretched over other projects to be able to help maintain it. Reading my old code, I was surprised by how clean it looks. How easy it is to digest. There is a certain sense of calm when your brain doesn't have to process all…

If you want the quiet syntax of CoffeeScript and even better type safety than TypeScript, you might be interested in Elm. https://guide.elm-lang.org/

Elm is not compatible with js library or at least it's not seamless.

Re: How we failed, then succeeded, at migrating to TypeScript

#29
post #6

I was looking at some of my old repos today. Enjoyed the nostalgia. Lots of CoffeeScript there. I had to switch to ES and then TypeScript because CoffeeScript was abandoned at the time and I was stretched over other projects to be able to help maintain it. Reading my old code, I was surprised by how clean it looks. How easy it is to digest. There is a certain sense of calm when your brain doesn't have to process all…

> How easy it is to digest I’ve not had this experience. I’ve found the ambiguity in coffeescript a maddening adventure in syntax confusion. - function call syntax doesn’t need parens except if a 0 parameter method - commas are largely optional both in arrays and function parameters. How do you parse: [f, f(), f a b c] - implicit returns are a terrible idea. - the @ syntax refers to either a ‘static’ method or an ins…

My experience was that I always found my CoffeeScript really easy to read since I was always internally consistent with which opinional bits I used and which bits I ignored.

Reading other people's CoffeeScript on the other hand...

Re: How we failed, then succeeded, at migrating to TypeScript

#30
post #9

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... Any tips/thoughts??

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, albei…

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.
Post reply on HN