Live data from Hacker News

Node.js adds experimental support for TypeScript

github.com

161–170 of 570 posts

Re: Node.js adds experimental support for TypeScript

#161

I really enjoy typescript and have been yearning for a typescript runtime but I can't help but laugh that I left java all those years ago to finally seek something a lot closer to java. I guess we all just wanted java with JIT, more feature rich type system and gradual typing. Also for all the shortcomings of npm ecosystem, it is a lot less daunting and more fun to be using libraries in this ecosystem. And surprising…

Typescript is way better than Java, in my experience. It's a lot less verbose. A lot more flexible.

Better for what? Quickly churning out short-lived code to get the next round of funding, definitely. Writing (and _supporting_) "serious" projects over the long term, which also require high performance and/or high scalability, and can rip through terabytes of data if needed, definitely not. (All IMHO from lots of personal experience.)

Re: Node.js adds experimental support for TypeScript

#162
post #159

Earlier quoted context omitted.

They are not comparable. If anything, Kotlin is the equivalent in the JVM universe.

Kotlin is much closer to Java than to TypeScript even in terms of flexibility.

To me "Flexibility" sounds a lot like "The programmer always knows what he does".

Re: Node.js adds experimental support for TypeScript

#163

Earlier quoted context omitted.

YES. It was such a joy to be able to ditch Jest completely and run tests natively.

i tried that but had to revert to vitest, the native test runner feels incomplete atm.

What is missing for your use case or workflow?

Re: Node.js adds experimental support for TypeScript

#164
post #46

Earlier quoted context omitted.

Yeah, my personal experience is that easily 95% of devs I work with/have met in person, if not closer to 99%, prefer statically typed languages. Maybe that’s a biased sample, but I do think the overall preference among devs is very strong. I also see JS slowly, more-or-less becoming TypeScript over time.

My days of being a real software developer are long behind me. So I'm totally willing to accept that I'm wrong here. But when I build a POC in particular, there's a LOT of power and flexibility granted by not giving a fuck about types. Suddenly I can accept non well defined data types (depending on my implementation) and can persist data that otherwise would have taken code changes and approval processes to accept. I…

Just use `any` or `unknown` when prototyping, then apply types once your happy paths start working for the first time to start catching the unhappy ones.

Re: Node.js adds experimental support for TypeScript

#165

I really enjoy typescript and have been yearning for a typescript runtime but I can't help but laugh that I left java all those years ago to finally seek something a lot closer to java. I guess we all just wanted java with JIT, more feature rich type system and gradual typing. Also for all the shortcomings of npm ecosystem, it is a lot less daunting and more fun to be using libraries in this ecosystem. And surprising…

The typesystem of Java was so laughably unpowerful that it severely constrained what you could write.

In Typescript you have far more freedom, and all the benefits of strong types.

Re: Node.js adds experimental support for TypeScript

#166

Earlier quoted context omitted.

Beyond ugly. They should just make TS official and be done with it. E: I thought it was JSDoc proposal. Ignore the comment.

I did only briefly look at the proposal. What did you find so ugly?

I misread the proposal. Thought it was for JSDoc.

Re: Node.js adds experimental support for TypeScript

#167

Earlier quoted context omitted.

Beyond ugly. They should just make TS official and be done with it. E: I thought it was JSDoc proposal. Ignore the comment.

What do you mean ugly? This basically is making Typescript official. They just can't have browsers doing the actual type checking because there isn't a specification for how to do that, and writing one would be extremely complicated, and I'm not sure what the point would be anyway.

I misread the proposal, tho it it was for JSDoc.

Re: Node.js adds experimental support for TypeScript

#168

Earlier quoted context omitted.

Native Java via GraalVM starts up in milliseconds.

And it has to go through slow compilation step. With Node you can have a cake and eat it too.

You're saying it like it's an absolutely good thing. Some (many?) users would rather pay the cost upfront in compilation time (doesn't really matter if it's AOT or JIT) than pay the same cost many times over through a significantly slower runtime. JVM also scales up to supercomputers (and everything in between) if you want it to, so depending on your requirements a single-threaded alternative might not even be an option.

Re: Node.js adds experimental support for TypeScript

#169

It would be nice for debugging if at least simple npms could just bundle their .ts files without any processing, so we could see the comments and types as they existed in the git repo. Apps can always minify them later. (I use Deno, but also use some npms.)

You can simply create npm packages which contain only the 'unprocessed' TS source files (or really any type of files - for instance I experimented with using npm as package for C/C++ projects in the past, it works just fine). Pre-bundling or compiling from TS to JS is just a convention. And in case of bundling not a good one IMHO, because bundling should only be a final step in the top-level project. One good reason…

The nice thing about this change to Node.js (when it’s no longer experimental) is that you could just distribute .ts files and JS projects could use them.

Re: Node.js adds experimental support for TypeScript

#170

Earlier quoted context omitted.

This is the first time I'm hearing such a claim. In C# you can't work with optional generics because an optional reference type is different from an optional value type. C#s poor type-inference often requires you to type out types thrice. You can't declare constants or class members with type-inferrence. The only way to define sum-types (A | B | C) is through intefaces and I'm pretty sure they can't be sealed. Defini…

C# has record (product) types now.

I'm not sure about the terminology here, but the & in TS is much more than a record. You can use it to smush types together e.g.

{name: string} & {birthday: Date}

becomes a single type with both properties.

Post reply on HN