DEV Community

Discussion on: TypeScript vs JavaScript🤔

Collapse
 
peerreynders profile image
peerreynders
  1. The JavaScript engine is still V8 — so it "runs" JavaScript
  2. For performance reasons TS is only transformed, not type checked, when it is initially loaded.

In my book that doesn't qualify as "runtime usage" but out of the box loading support.

What type of looks would you expect if you suggested to a software engineer to support an environment where C-source is compiled and linked to binary every time you need to execute the code even though the source code hasn't changed?

Thread Thread
 
josunlp profile image
Jonas Pfalzgraf

Technically, you are right. Still, this is what makes Deno so great. It's a runtime that on the fly uses your Typescript code without you being in the need to compile it yourself.

Thread Thread
 
peerreynders profile image
peerreynders • Edited

Source code transformation shouldn't be a (production) runtime concern…

It's bad enough that JavaScript code has to make its way through Ignition, Sparkplug and Turbofan.

Thread Thread
 
josunlp profile image
Jonas Pfalzgraf

Typescript is a superset of JS. For an example C# code gets compiled into a inter language before then to bytecode. These two steps are necessary to ensure core features. Same goes for Typescript and JS. Since Javascript is the standard V8 can understand, Typescript gets compiled. This is why Runtimes like Bun and Deno with their build in Compile Support are great. They take the usual "watch and compile" Step away. Its just another step in the evolution of Code. If you want to use bytecode in the Browser, take a look at WebAssambly.

Thread Thread
 
peerreynders profile image
peerreynders • Edited

Typescript is a superset of JS.

"TypeScript is a Subset of JavaScript

I can't impress this one enough. Technically it is a superset from a feature support perspective. However, people use it so they have compile-time type checking so once that becomes a requirement for you there are just things you can't do with TypeScript."

[The Trouble with TypeScript]

I came to that same conclusion before the article was published.


They take the usual "watch and compile" Step away. Its just another step in the evolution of Code.

It confuses design time and runtime; yet another concession to developer convenience (by developers nonetheless).


If you want to use bytecode in the Browser, take a look at WebAssembly.