News for hackers. Stuff that matters.
Re:Why if TYPE_CHECKING? by remram on Wednesday December 20, 2023 @06:59AM (#38707671)
TypeScript is also interpreted, and does type checking without running code. Their argument is very weird.
Re:Why if TYPE_CHECKING? by kaoD on Wednesday December 20, 2023 @07:58AM (#38708113)
TS is not interpreted. It compiles to JS, which is interpreted, but TS itself is not. There are no TS interpreters, they all compile to JS behind the scenes.

Or does Deno run TS natively? At a glance it looks like even its runtime is written in JS[0].

EDIT: looks like they have bindings for V8[1] so yeah, just a JS interpreter behind the scenes.

[0] https://github.com/denoland/deno/tree/main/runtime/js

[1] https://github.com/denoland/rusty_v8

Re:Why if TYPE_CHECKING? by SlimTim10 on Wednesday December 20, 2023 @07:23AM (#38707837)
That's an odd thing to say. The distinction between compiled and interpreted languages is very fuzzy, but TypeScript is clearly on the compiled side.
Re:Why if TYPE_CHECKING? by gpderetta on Wednesday December 20, 2023 @09:33AM (#38709085)
It is not so much that it is fuzzy, it is that the two definitions are not exclusive.

A compilation translates a language to another, whether it is native code, internal bytecode, portable bytecode, or another source language. Compilation might also type check and optimize depending on the language. Interpretation executes a language; normally bytecode is executed, but pure source level interpreters exist. Native code is "interpreted" by the cpu itself of course.

For example JAVA is certainly a compiled language, but it is typically compiled to bytecode and then interpreted or JITed (which is a combined interpreter/compiler).

Re:Why if TYPE_CHECKING? by remram on Wednesday December 20, 2023 @12:56PM (#38711509)
Likewise, the Python typing annotation language could very well be on the compiled side...

Someone took the interpreted JavaScript language, added typing syntax on top, and typing can be checked statically.

The Python team took the interpreted Python language, added typing syntax on top, and here we are reading a claim that it can't be checked statically because it's interpreted. You understand my puzzlement.