TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Reservations about TypeScript

16 pointsby daviesgeekover 7 years ago

10 comments

barakmover 7 years ago
&gt; TypeScript compiles down to JavaScript, which doesn’t have types or type checking, it’s impossible to have actual type checking. The TypeScript compiler is great at checking at compile time, but at the end of the day, it’s impossible to actually check the types.<p>I&#x27;ll point out that C&#x2F;C++&#x2F;Haskell compiles down to Assembly, which doesn&#x27;t have types or type checking. GCC&#x2F;LLVM&#x2F;GHC is great at checking at compile time, but at the end of the day, it&#x27;s all just bits being modified...<p>Obviously you can find ways to break out of the type systems (void* cast?) but that&#x27;s on you, and even if Typescript has more escape holes, the existence of them isn&#x27;t an immediate fail
评论 #15056627 未加载
评论 #15056824 未加载
评论 #15056570 未加载
评论 #15056633 未加载
Harkinsover 7 years ago
First point: &quot;I found a bug but can&#x27;t give an example.&quot;<p>Second point: &quot;It adds a feature that&#x27;s different from a similar language.&quot;<p>These are not persuasive arguments. I&#x27;m not trying to be unkind, but the first point is totally unsupported and the second doesn&#x27;t elaborate on what&#x27;s bad about classes besides that another language also has classes.
评论 #15056729 未加载
评论 #15056505 未加载
azangruover 7 years ago
&gt; <i>TypeScript fundamentally changes the way JavaScript works. JavaScript does not have classes. Even ES6 classes are just syntactic sugar on top of the ES5 prototypical inheritance. I’ll repeat it again. JavaScript does not have classes. The class keyword may exist in ES6+, but under the hood, it’s still just prototypical inheritance. As long as this is understood, it’s perfectly fine, but the problem comes when ES6+ or TypeScript is marketed as having “classes” in the traditional OOP sense of the word.</i><p>It looks like the author started out as saying one thing (how Typescript is fundamentally different from JS) and ended up with another (how they are fundamentally the same) :-)<p>Which reminds me. Could you please explain to me what are the proper classes? I guess I have spent too much time with JavaScript to start thinking about classes just as about collocations of methods and properties spewed out by constructors. What is so improper about JavaScript&#x27;s prototype-based classes that is different in real classes?
评论 #15056725 未加载
stupidcarover 7 years ago
That is an appalling article, even by Hacker News standards.<p>I mean, his second &quot;reservation&quot; is that TypeScript &quot;fundamentally&quot; changes JavaScript. How does he demonstrate this? By complaining that classes, which are a <i>JavaScript</i> feature, work differently than in other OO languages. What the hell does that even have to do with TypeScript?
kxkciicoiciicover 7 years ago
Article lacks any actual, factual reservations, but rather complains about some code that didn&#x27;t work a year ago and the code of course has been lost. I don&#x27;t get the point of sharing this writeup. I guess author just posted some text he wrote up for a internal company discussion.<p>Opinions are like buttholes, everone has one.
评论 #15056345 未加载
评论 #15056362 未加载
forgotpw1123over 7 years ago
The authors main complaints seem to focus around &quot;but Typescript isn&#x27;t ES6&quot;. I don&#x27;t have a problem with this because Typescript compiles down to very clean vanilla JS. Unlike C++ to C, Clojure, and Babel the compilation down to JS is extremely good in comparison.<p>Good enough that I usually debug the Javascript output. Typescript has the cleanest transpilation I&#x27;ve ever seen so I don&#x27;t have any problems with using it. And if Typescript ever falls out of vogue I&#x27;m confident just compiling down to JS one last time and being done with it. Really the language is so easy to get rid of its harmless.
评论 #15056744 未加载
mixedCaseover 7 years ago
It&#x27;s gradual typing. Yes, it&#x27;s full of holes, that&#x27;s the whole point.<p>There are other languages with strong, powerful type systems that compile to efficient JavaScript, such as (in order of power) Elm, OCaml, PureScript and Idris. Those four are just arbitrary examples however, there are quite a few more.
nkohariover 7 years ago
Sorry, I don&#x27;t understand what this post is about, other than that you have some reservations about TypeScript. It&#x27;s not really clear <i>what</i> those reservations are.
评论 #15056803 未加载
guscostover 7 years ago
If you&#x27;re curious about or skeptical of TypeScript, do yourself a favor and check out the source code sometime: <a href="https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;typescript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;typescript</a><p>It&#x27;s a work of art, everything is so practical and (relatively) easy to understand. Even better, it&#x27;s written in TypeScript, so you can open it up in an editor with TS support and follow&#x2F;jump to any reference with confidence. I&#x27;ve only learned about compilers vaguely through osmosis, but I was able to extend its JSX syntax processing (admittedly that part does seem a bit bolted-on) to output JSON for my wonky framework side-project in a few hours: <a href="https:&#x2F;&#x2F;github.com&#x2F;guscost&#x2F;protozoa-tsx" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;guscost&#x2F;protozoa-tsx</a>
wwwighamover 7 years ago
Not to pry, but do you have a Java background? I see you&#x27;re using the global &#x27;Boolean&#x27; and &#x27;String&#x27; interfaces in your examples (which correspond to the equivalent JavaScript constructor objects), rather than the &#x27;boolean&#x27; and &#x27;string&#x27; primitive types. While it kinda works to use the interfaces instead of the primitives, the primitives, IMO have much more expected behavior in the type system, since, unlike the interfaces, they do not get compared structurally - TypeScript uses a structural type system for all objects, after all.