DEV Community

loading...
Cover image for TypeScript vs JavaScript

TypeScript vs JavaScript

evilprince2009 profile image Ibne Nahian ・1 min read

Is is possible that in future browsers will recognize TypeScript ?

Please let me know your good reasons why it should happen or not.

Discussion (5)

pic
Editor guide
Collapse
rhymes profile image
rhymes

Nothing is certain but at this stage it seems a bit unlikely. Don't know about the far future :)

Browsers have virtual machines that are highly optimized towards JS and, increasingly, WebAssembly. TypeScript transcompiles to JS so there's no advantage in adding such tooling inside the browser.

If your target is JS you can keep using TS, if your target is WebAssembly then you can use tools like AssemblyScript, which is basically a reduced version of TS, or any other language that compiles to WASM.

Collapse
elmuerte profile image
Michiel Hendriks

There is little future in supporting another script language. There is more future in a compiled web environment (i.e. WASM). TypeScript would compile directly to WASM instead of the horrible unfixable mess of JavaScript.

Collapse
ecyrbe profile image
ecyrbe • Edited

Typescript being just a superset of JavaScript (JavaScript with type anotations) it could happen. You just need to remove two things from typescript for this to happen:

  • enums which is not in javascript
  • @ annotations who are also not in javascript

And to contradict other people that talked about wasm, transpiling typescript to wasm is an horrible Idea. See last video of the developpers at typescript conf why it is horrible.

Collapse
bcowley1220 profile image
Brendan Cowley

"OMG, I can now write (insert language here) for the client!"

shrugs

I'll probably be the dissenter here, but if the main browsers adopt it...meh. I don't really see a reason... with the caveat that just because you can do something doesn't mean that you should. You do you... just don't mess with JS ;-)

Collapse
willkenzie profile image
William

I am curious what the overall benefit of Typescript over JavaScript is though, however I would think there wouldn't be a major performance boost in browsers due to how the virtual machines inside them are configured.

I do know JavaScript is a pretty funky language (to be honest, if I knew I had to do like 10 different things just to make my code execute a specific way, otherwise I get a undefined hole - I would've learned C#) and a language other than JavaScript that is faster and less... quirky... then it could easily replace it. Not sure if that language is Typescript though...