TypeScript: Microsoft's Replacement For JavaScript 488
mikejuk writes "Everyone seems to have a replacement for JavaScript — Google even has two. Now Microsoft has revealed that Anders Hejlsberg, the father of C# among other languages, has been working on a replacement and it has released a preview of TypeScript. The good news is that it is compatible with JavaScript — you can simply load JavaScript code and run it. JavaScript programs are TypeScript programs. To improve on JavaScript, TypeScript lets you include annotations that allow the compiler to understand what objects and functions support. The annotations are removed by the compiler, making it a zero overhead facility. It also adds a full class construct to make it more like traditional object oriented languages. Not every JavaScript programmer will be pleased about the shift in emphasis, but the way it compiles to a JavaScript constructor is fairly transparent. At this early stage it is difficult to see the development as good. It isn't particularly good for JavaScript developers who already have alternatives, and it isn't good for C# developers who now have confirmation that Ander Hejlsberg is looking elsewhere for his future."
Update: 10/01 20:34 GMT by U L : It's also freely available under under the Apache 2.0 license, and there's a language specification available. It looks pretty interesting: it even has ML-style type inference (including e.g. deducing the types of higher order functions).
Embrace, Extend, Extinguish (Score:2, Insightful)
JavaScript programs are TypeScript programs.
'Nuff said.
and it isn't good for C# developers who now have confirmation that Ander Hejlsberg is looking elsewhere for his future.
It's C++ all the way down!
CoffeeScript, Dart and this - screw it all (Score:5, Insightful)
Fix JavaScript or give us something like Python minus the dangerous bits in the browser.
Re:DEFINITELY No!!! (Score:2, Insightful)
Bullshit. Look at other languages that compile to JavaScript that also don't pollute the standard:
https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS
The summary is just wrong. JavaScript isn't being replaced. It's being enhanced in an entirely compatible and most importanly voluntary way.
Re:CoffeeScript, Dart and this - screw it all (Score:3, Insightful)
It makes me cry whenever I hear JavaScript being used as an 'assembler'.
CPU performance, memory usage, and power consumption be damned!
Re:Remember the old addage (Score:5, Insightful)
Rubbish. Not a good view of the technology. You might want to watch the channel 9 video and see how the language works before sounding the war horns. Essentially it's an overlay on javascript code that allows the developer to infer useful information about their code. The output from the "compiler" is bog standard javascript, no microsoft extensions at all.
So if the "carpet" ever got pulled out from under you, all you would do is go back to editing the standard .js directly.
Re:And this suprises you? (Score:3, Insightful)
Um, the Apache License is significantly more free than the GPL. Just sayin'.
Re:CoffeeScript, Dart and this - screw it all (Score:4, Insightful)
Fix JavaScript or give us something like Python minus the dangerous bits in the browser.
Full Python is a relatively heavy language (compared to, say, Lua), and I would be less than thrilled if all browsers had to implement a Python interpreter in addition to the Javascript interpreter they would still require for compatibility.
Besides, Python is all dangerous bits.
I think a lightweight virtual machine would be a natural successor. If they had done it in the 90s it would be a considerably worse legacy than Javascript was, but I think we're ready for it now.
Some desirable properties would be:
(LLVM bytecode is NOT suitable for this; it is first and foremost a compiler IR, and is not intended for cross-platform use.)
all these languages what am I to do? (Score:2, Insightful)
Sticking with C.
How many computer languages do we need? Really?
It's bad enough that you don't trust javascript from webpages, now i have a new type not to trust?
Microsoft, i don't trust you, never have. fuck typescript, fuck Windows 8, and well, fuck you.
Re:Remember the old addage (Score:5, Insightful)
Embrace, Extend, Extinguish.
Microsoft freely admits it, and when everyone jumps on the TypeScript bandwagon, the carpet will be pulled out from under you.
How is this shit modded 'Insightful'? Karma whoring at its best, capitalizing on the nerd rage of geeks frothing at the mouth whenever Microsoft does anything. The fact is it is under an Apache 2.0 license, the spec is available and there are already 5 forks, so unless you have a fundamental misunderstanding of what EEE means you're just trolling.
Re:Remember the old addage (Score:4, Insightful)
I think you are missing the point. While it is good the output is 'bog standard' Javascript what really matters is that the source is not 'bog standard Javascript'. Once you start writing in TypeScript you are forever bound to Microsoft. Now there may be compatible implementations but you may get a situation like C# where Microsoft's implementation is not only the foremost, but also the only complete one.
They did a similar trick in years past with C++, where they had so many extensions that you pretty much needed for Windows development that once you started down their C++ path, forever would it dominate your project's destiny. These days their compiler will accept 'bog standard' C++, however to get real stuff done you still have to start using Windows constructs and interfaces (due to Microsoft producing APIs that look like like 'plain vanilla' C++; as many other APIs try to do).
As others have pointed out, "All the roads lead to Microsoft, but none lead out".
Now Microsofties could complain that the open source proponents are whining unfairly about this and it is resticting their, "Freedom to innovate". To that I say simply this, "How about you instead spend the effort on making your browser work like everyone else's?". The amount of workarounds and hacks required to compensate for the borked and agonizingly slow way that Internet Explorer handles (what should be) cross-platform Javascript is 'criminal'. The wastage in businesses and the entire IT industry caused by handling Internet Explorer's brokenness should make them blush. Sure, innovate and make the Javascript experience the best on Microsoft tools and platforms, but don't do it by creating more 'islands' than you have already.
As others have pointed out, TypeScript may be tech flavor-du-jour for Microsoft at the moment (since they're trying to push their mobile solutions), but just like all their other tech it will have a limited shelf-life. You are better choosing truly cross-platform and long lasting tech for building solutions on. Historical examples: C#.NET (still used widely but not getting the Microsoft focus it once did), Visual Basic, COM/DCOM, OLE, C/C++ Win32 etc etc Yes you can still develop with these, but once upon-a-time they were the shizzle promoted by Microsoft and now people have to spend their time maintaining them with old and outdated tools. Meanwhile solutions developed with Standard C/C++, Java, etc get better tools and there are code changes required to maintain them are far more minor.
Bet your solution on the long-lived tech stacks (and increase your long-term profits!).
Re:DEFINITELY No!!! (Score:5, Insightful)
The probem isn't so much with C# the language/toolset. The problem is that in order for Microsoft to sell you new tools and tech it has to periodically change them just enough so you feel enough pain to shell out for new stuff. The other problem is that while C# is good for development it is clear that it is no longer an object of adoration in Microsoft's strategy. C# will always be around but it won't get the resources that the 'new hotness' team gets (eg. TypeScript). Meanwhile, those that use other tools (standard C++, Java etc) will keep plodding along, continuously evolving.
If you know Aesop's Tortoise versus the Hare fable then this is what is happening now. Those who always watch the speed of the hare miss the fact that a new hare is entered into the race every few years. Meanwhile, those not distracted by the hare are watching the tortoise and see how it is less flashy but progresses continuously. If you built your tech on the tortoise you still have good solutions. If you build your tech with the hare then every few years you either have to rebuild your tech for the new hare (expensive! this is what CTOs worry about and code-monkeys don't), drop your existing investment and start building again for the new hare (expensive and wasteful), or stay with old tech (painful, and now surpassed by the tortoise).
Re:Remember the old addage (Score:2, Insightful)
Exactly this. Another attempt by microsoft to comandeer a standard and lock people in as they manipulate it to be incompatible.
Re:Remember the old addage (Score:4, Insightful)
While it is good the output is 'bog standard' Javascript what really matters is that the source is not 'bog standard Javascript'.
Most of it is actually bog standard ES6 (for example, classes). The only proprietary bit here are type annotations. Which you can ignore altogether if you want, and then you just get a free, open-source implementation of a convenient subset of ES6 that spits out ES5.
Anyway, this is open source (Apache license), and the implementation is itself written in TS, and runs on Node.js. In other words, it is in no way locked into any existing Microsoft technologies, completely self-sufficient, and you can fork and mod it to your heart's content, on any platform. There is no way to "extinguish" it for Microsoft from this point on, nor control you should you choose to use it, now or in the future.
never (Score:2, Insightful)
Never touch anything coming from Microsoft unless you plan to sell out wholesale.
If you're an MS shop anyways, then do whatever you want. But if you are not, you should've learnt by now that everything they make is lock-in, bait-and-switch or some other trickery.
Name a counterexample. Pick one that has been around for a while, because they do have a long breath and sometimes give you several years to really bet the farm on their technology before springing the trap.
Re:Remember the old addage (Score:5, Insightful)
Is it just me or are the MS shills getting even more stupid?
When Apache 2.0-licensed, publicly available (on Git), already forked code is somehow getting you "locked in" and "manipulated to be incompatible" i think it's safe to say the stupidity lies with all the anti MS morons with their senseless EEE rhetoric. Although given you think pointing out that this is about as open as it can get which makes it the exact opposite of "locking people in" is being a "shill" you're probably not much different.
Re:Remember the old addage (Score:4, Insightful)
research.microsoft.com has been advancing lots of open source functional languages that use type inference and no one has been getting burned. The research group lets them do cutting edge research and then another research group builds an implementation for more mainstream languages and then it gets pulled in by product management.
So I'd say in the open source language arena the public has learned the opposite.
I'll agree it is different with products as opposed to technologies.
Re:Remember the old addage (Score:2, Insightful)
Microsoft ALWAYS has a plan to manipulate things or outright control things. It is not unreasonable at all to be suspicious of this too, even if there is no currently visible way that anything underhanded could be done. Act offended if you want but not very many people will care.
Re:Remember the old addage (Score:2, Insightful)
Re:Remember the old addage (Score:4, Insightful)
He means in the 'dictating policy and direction' way.
But that wouldn't make sense because the beauty of open source is that if you don't like the direction that the project steward is taking it in you can just fork it, simple.
Re:Remember the old addage (Score:4, Insightful)
He means in the 'dictating policy and direction' way.
People here forget the concept of Opportunity Cost. Everything costs you some resource: Time, money, brain nurons, carbohydrate energy in your blood, at least something.
I use a simple text editor because I don't want to learn Emacs. I don't decry the tyranny of Emacs, of the evilness that is Stallman locking me into a particular set of key sequences. Oh my deity! Stallman is dictating policy and direction for my text editor!! I just say "I don't want to spend my energy there".
Everything pushes you to a direction. Microsoft does. JavaScript does. ECMAscript does. C does. C++ does. Scheme does. If you're worried that the direction Microsoft pushes you leads to a bad path, fine. But don't kid yourself that by choosing something else that you're no longer being pushed.