4 ms·
He says: "And it's really funny because JavaScript is essentially Java with the type declarations removed." That's pretty glib and I think not very informative.
by an1sotropy 5y ago
He says: "And it's really funny because JavaScript is essentially Java with the type declarations removed."
That's pretty glib and I think not very informative.
For more information you can read Sections 2 and 3 of this http://dx.doi.org/10.1145/3386327 http://dx.doi.org/10.1145/3386327
- capableweb 5y agoYeah, that seems like a strange sentence coming from a language designer who should know better. Just on the surface there is the differences of statically typed VS dynamic, class-based VS prototype-based, the implicit global state in JS, JS having first class functions and so on. Longer quote seems weird as well > To really get the performance improvements you see, it helps dramatically to have a statically-typed language. For dynamically-typed languages, like Python, it's really, really hard. And often, what people end up doing is adding annotations to the language so that you get languages like TypeScript, which is essentially JavaScript with type annotations. And it's really funny because JavaScript is essentially Java with the type declarations removed. So TypeScript is essentially Java with permuted syntax. He seems to be saying that TypeScript leads to faster code execution as TypeScript has types, but fails to understand that TypeScript still compiles to JS and the browsers run JS without types, so should have the same performance as just writing JS directly (probably less performance, as TSC adds bunch of wrappers and other unnecessary stuff you would avoid if writing vanilla JS)
- dmux 5y ago>He seems to be saying that TypeScript leads to faster code execution as TypeScript has types, but fails to understand that TypeScript still compiles to JS and the browsers run JS without types... I'm not saying this is the case, but isn't there a greater opportunity to optimize TypeScript code over JavaScript due to the presence of types? Isn't this the same thing as a statically typed program being compiled into assembly (untyped) ?
- darksaints 5y agoThere is a greater opportunity, but it hasn't happened in practice. And even with Typescript's types, I doubt that it would make much of a difference because the type system is deliberately not sound and the types can't really be relied on. Typescript is a great way of reasoning about a program, but it's not meant as a runtime execution type system.
- srtjstjsj 5y agoYes. Another common example is that in languages without pointers, the lack of aliasing enables optimizations that are impossible for languages with pointers. Also, C compilers generate efficient code by assuming undefined behavior cannot happen. (This sometimes corrupts buggy programs, because the type system can't guarantee undefined behavior isn't triggered.)
- x-shadowban 5y agoTS biases code to using objects of very consistent shapes, so the js runtime's assumption-based optimizations are deoptimized less frequently.
- elzbardico 5y agoother than curly braces, there's really no much similarity between Javascript and Java.