4 ms·
But if you're going to transpile, why not transpile from a real language, not a Turing tarpit?
by wtbob 10y ago
But if you're going to transpile, why not transpile from a real language, not a Turing tarpit?
- smegel 10y agoWell Google already did that with Java and GWT, but it never caught on. I guess TS being a superset of JS itself might be an advantage...otherwise it is still a new language designed for web browser programming unlike Java. I suppose it is a fair question why they didn't just use C#.
- aikah 10y ago> Well Google already did that with Java and GWT, but it never caught on. Actually it did catch on in the enterprise world, just like Typescript. Will Microsoft be as "dedicated" as Google regarding its language? wait and see.
- Cthulhu_ 10y agoThere's also Scala.js, which takes it even further than GWT. And of course Dart.
- _pmf_ 10y ago> Well Google already did that with Java and GWT, but it never caught on. ClojureScript uses the Closure(sic) compiler from GWT to compile Clojure/Java to JavaScript (not that I defend this technological train wreck). > I suppose it is a fair question why they didn't just use C#. This would have been superb, but I think Microsoft wanted to show that they "get" web developers; just mentioning C# causes the JS pundit get jittery because someone wants to limit the amount of write-only code he is able to spit out.
- PretzelFisch 10y agoThere were already open source projects that tried to do this some paid projects, but they never gained traction. Microsoft also had the hind sight of DART and GWT to help point them in the TypeScript direction.
- lennelpennel 10y ago>>Closure(sic) compiler from GWT false. Closure does not compile java to js and closjurescript does not use any tech from gwt. Clojurescript compiles to JS itself and then uses the Closure compiler (which is an incredible piece of tech) to compile js to js (not transpile, but actual compile).
- greendragon 10y agoWhat exactly don't you like about ClojureScript? The tooling may be kind of weird (and I believe you're out of date) but once you're set up with figwheel and something like om/reagent/re-frame you start approaching the bottom-up, truly dynamic, interactive approach to building things. Every time I hear stories of "we couldn't scale our JS until we switched to TS" it's always the case of they were developing their JS in IDEs and structured similarly to a Java application, but without having to declare types and having slightly nicer data literals...
- labrador 10y agoBecause you can paste in your favorite JavaScript code snippets and they work without modification. One can gradually add types to a JavaScript project at a pace of your choosing. I think a more interesting question is why add types when there is Facebook's flow. My answer: because flow doesn't help with the refactoring and other IDE tasks. Ask HN: If TypeScript is so great, how come all notable ReactJS projects use Babel? https://news.ycombinator.com/item?id=12537614 https://news.ycombinator.com/item?id=12537614
- DrJokepu 10y ago(1) The transpiled JavaScript closely resembles the source TS, making debugging easier (source maps allieviete this to a certain extent). (2) Transpiling from a whole different language means you have to port the standard runtime, otherwise you'd lose portability and familiarity, which are the two key advantages of transpiling from another, widely used language. Also, as JavaScript often runs in the browser this means downloading the runtime. (3) The more different the two languages are, the more likely you'll run into surprising situations where feature X in language Y cannot be implemented in its original form in JavaScript, causing subtle incompatibilities between Y code written for the "original" Y compiler / interpreter and Y code that was meant to be transpiled. (4) As someone else mentioned, TS is almost a superset of JS, which means mixing in JS code into TS code is much easier. (5) What is a real language anyway?
- wtbob 10y ago> The transpiled JavaScript closely resembles the source TS, making debugging easier (source maps allieviete this to a certain extent). High-level languages look nothing like machine code, but we still compile them to it. > Transpiling from a whole different language means you have to port the standard runtime That's true, but it's not a reason not to use a good language instead of a horrific one. > The more different the two languages are, the more likely you'll run into surprising situations where feature X in language Y cannot be implemented in its original form in JavaScript I contend that any feature of a Turing-complete language can be implemented in JavaScript. > As someone else mentioned, TS is almost a superset of JS, which means mixing in JS code into TS code is much easier. 'I still get to use JavaScript' doesn't sound very appealing. But, of course, many high-level languages offer an escape to assembler: a high-level language compiling to JavaScript can offer an escape to JavaScript. > What is a real language anyway? Haskell, CaML, Lisp, Python, Go — not JavaScript, though, which is an embarrassment to our profession.
- ridiculous_fish 10y agoOne answer is the strong compatibility story for existing JavaScript libraries. You can use d3 or three.js from TypeScript; that's a big advantage over something like Elm. Compatibility with JavaScript source (instead of libraries) is a disadvantage. The most dangerous parts of TypeScript are the JavaScript parts: arithmetic, bracket notation, etc.
- leshow 10y agoElm has ports to interop with javascript. it's really not that difficult