Hacker News new | ask | show | jobs
by kartickv 3404 days ago
Is TypeScript as annoying a language to code in as Javascript? Or is it comparable to other modern languages like Swift and Go? If it is, I'd say that pain of dealing with Javascript (for developer productivity and happiness) is already taken care of.
4 comments

Typescript is a type safe language that "compiles" into javascript. The Microsoft implementation compiles on save, so you work in your file.ts and a program running somewhere fires when the file is saved and converts it to file.js which you would distribute.

I haven't used it yet, but the demo from Anders looked good. It's an attempt to fix the "loosey goosey" nature of javascript. I would be great if browsers supported it as a built in language.

https://channel9.msdn.com/posts/Anders-Hejlsberg-Introducing...

If you watch the video, you'll notice the argument notation is name: type rather than type name. I think Anders is reminiscing about his Delphi days.

> If you watch the video, you'll notice the argument notation is name: type rather than type name. I think Anders is reminiscing about his Delphi days.

ActionScript and the proposed ECMAScript 4 also use the name:type notation, so there is definitely some prior art in the web sphere

Thats not really what he asked though. If in the end a developer can work 98% in TS, do they really care if it runs as JS or something else if it solves their problems with the language ? I have heard from people that love TS, but surprisingly many that also prefer pure ES6 JS.
The only concerns I would have is I believe you have to debug the javascript rather than the typescript.
You can make the sourcemaps refer to the TypeScript code. I set breakpoints in TypeScript files and step through it all the time.
You should think of typescript as javascript+ more than a different language. It looks more like what javascript would look like in 2-3 version if the governing body thought static types were important to add.
That doesn't answer my question of whether TypeScript solves the concern of JS being frustrating to work in.
TypeScript is a joy to program in. I was on a project where we had the opportunity to turn on all the strict checks (no use of any, no implicit nulls, etc.), and it was super enjoyable and efficient to program in.

You have algebraic types (well, 99%), union types, and concise ways of expressing tree types.

I would imagine it is more pleasant than Swift or Go, though I haven't used either of those very much.

But webassembly will allow for typescript or you language of choice, c/c++ and rust first, and as the OP suggests others too.
The question was whether the concern of JS being frustrating is already solved by TypeScript, in which case WebAssembly is less important than it would be otherwise.

(Which isn't to say that there aren't other questions like efficiency and already-existing codebases written in other languages.)