TypeScript: Microsoft's Replacement For JavaScript
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.
Microsoft freely admits it, and when everyone jumps on the TypeScript bandwagon, the carpet will be pulled out from under you.
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!
Stick Men
Doesn't JavaScript have a better system altogether? Prototypical inheritance?
Classes feel awful in comparison.
And doesn't the next revision have support for classes? I keep forgetting the name of it, H s... oh Harmony?
I'm sure Harmony has a lot of things planned to extend the language massively to bring it up to standards even comparable to other languages.
Regardless, any and every attempt to expand on things is always good.
Yes, even if it is Microsoft. They gave you the website you are using now, remember. (unless you are in the 80s using some text browser)
Competition will hopefully lead to quicker implementations of a much better language overall.
This is another example of Microsoft trying to pollute open standard! Yes, I am aware that it's under Apache 2.0 License, but they're just going to introduce chaos and evil as usual like their Sharepoint piece of $h1t. DEFINITELY NO NO NO NO NO !!! NO NO NO NO NO !!! NO NO NO NO NO !!! NO NO NO NO NO !!! NO NO NO NO NO !!!
Dart, obviously. But what is the other one? Anyone know what the article writer was talking about?
Well.. maybe. Or Maybe not. But Definitely not sort of.
Sorry..
I am still busy with silverlight...
Oooppss. that did not work....
We have JavaScript and that's shit because no one wants to agree on anything. So what do we get instead? a dozen implementations or something that is in theory nicer but compiles to JavaScript. This is not a solution. It's a mess.
Fix JavaScript or give us something like Python minus the dangerous bits in the browser.
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.
Lol, how cute. You're trying to create FUD.
Stop trying to make JavaScript look like your favorite object-oriented language and accept it as is. It's a fantastic, flexible, un-bloated language that requires a different mind-set to master. Improve your JavaScript Engine performance and your DOM implementation, but leave the language alone. There is a reason why it's kicking so much ass. If you want strong, static typed and OO, go support ActionScript.
This is modus operandi for Microsoft, they were convicted for a reason.
Just remember, its either Open or it isn't, no half way house.
Nearly pregnant, nearly dead, nearly open, the Apache license.
Not to mention FRAND.
Once upon a time Slashdot used to stand for something.
...theirs seems like the right approach. It is certainly a better one than Dart. They've gone out of their way to be as compatible as possible, and really are making it practical for people to adopt the upcoming standards earlier. I really don't see what about this to get so up in arms about. Javascript does need improvements, and this is the best approach to that I've seen so far.
Please go ahead and try to change JavaScript into something new.
But realize that JavaScript is the internet programming language equivalent to Cobol.
It will survive everything you throw at it.
It will be here when you cant chew butter any more.
Yes you can make better compilers, perhaps support for hardware acceleration.
But its too late for making any fundamental changes to the language it self.
I'm going to leave this here as a placeholder for the inevitable...
Fifty watts per channel, baby cakes.
Obligatory: http://xkcd.com/927/
Note: please do not mod this post up.
Note: please do mod this post up
coding is life
We already have, what, a couple *hundred* languages to choose from at this point?
https://en.wikipedia.org/wiki/List_of_programming_languages
Can we knock it off with the new effing languages already? Don't these people have anything more useful to do?
It doesn't replace anything. Its simply a higher level language that compiles to cross-compatible JS. And its open standard to boot.
Not seeing any negatives about it. JS is a mess and MS is attempting to clean it up.
That you can run JavaScript in it does not help. Once you develop with it, some non-JavaScript stuff will creep in and make your programs MS only. I expect it will be impossible to restrict this thing to JavaScript only, as that would defeat its purpose: Attract people and then never, ever let them go again.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
go fix your damn O$.
So they converted a version of Scheme into a version of ML. Why? Because F#.
Did I get the gist of it?
to compile my C# algorithms to Javascript. See http://scriptsharp.com/. It's by a Microsoft guy so hopefully it gets official support some day.
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.
Be seeing you...
Considering how JScript turned out, do we want to go down this road again?
"Good, Fast, Cheap: Pick any two" -- RFC 1925
He's simply doing what the JavaScript developers should have done a long time ago -- add some kind of type-checking to the language.
It's about fucking time somebody did it, although I would have rather preferred that it was done within the JavaScript language itself.
What was that thing Microsoft used to do that was called? Something like Embrace, Extend and Extinguish?
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
heyJavaScript = (function (whatYouSay) {
var theFactIs = "You can't touch this! ";
return function (freeLesson) {
freeLesson = "I'm your global daddy!";
setTimeout(function(){
self.heyJavaScript = null;
delete self.heyJavaScript;
alert("So long sucker!");
}, 0);
alert(whatYouSay + theFactIs + freeLesson);
}
})("You talkin to me? ");
heyJavaScript("How about a makeover?");
heyJavaScript("Listen to me man!");
As a cocoa programmer tasked with implementing yet another embedded htmlfucking5 project thanks to Adobe Edge, I wish Javascript would die.
After looking at the myriad of patterns for my current project - a Javascript client REST API - I came to the swift conclusion that most of them are silly, namespace polluting, self initializing mindfucks. I gave up looking at patterns, found a preloader (lab.js - although require.js is looking good) and wrote my own module pattern objects to satisfy the clarity, structure and ease of maintenance requirements of a good API. Being verbose is not a sin in enterprise Javascript.
I have a lot of little helpers like this:
// actually gives you things
// handler
MyCompany.fetchSomething(function (things) {
});
Plus some event handlers
MyCompany.addEventHandler('scope', function (data) {
});
But by far the largest section of my code is the model fetching stuff - you know the really boring bits where copy by value doesn't cut it, I need functions and and objects.
My last trail by fire was a paginated e-book reader with support for embedded video and audio. That wasn't a lot of fun, but at least the CSS3 spec was helpful and the DOM readable. The Javascript in that project was limited to around 200 lines.
I recently discovered that REST libraries are pretty long winded - after 200 or so lines, Javascript becomes a horrible implementation specific mess of spaghettied anonymous function chains. I opted for the Module pattern and ran into lots of fun:
So with MS actually targeting 5 or more of the annoying problems I face, I find this library really useful. But naturally I'll get modded down because, a) I develop Apple software and b) I don't pick sides, I program (I like Windows 7 as my desktop, XCode as my IDE, and Slackware on my shell - go fish!).
Oh well, I can only dream of this being adopted!
We need a clean-slate approach to clientside embedded scripting. Something with
* strong typing
* CLR-like JIT compilation
* solid documentation
* robust cryptographic facilities with hardware acceleration
With everyone rolling out their half-assed attempts at creating something 'better' that's really just another layer on top of the old, bad JS, it's no wonder we're not getting anywhere.
The Green Brain
Playground doesn't work :-( Tested in Firefox and Chrome.
Perl Programmer for hire
I don't see that here at all.. it's basically declarative decorators on top of JS... it's far closer to JS than say CoffeeScript is. Though, I didn't like the way AS3/ES4 worked in practice, I think for some projects this can be useful... It also furthers the use of VS2012 as a tool of choice for Node.js dev.
Michael J. Ryan - tracker1.info
What's broken with JavaScript?
In a few years we've gone from scratching out code by hand to a wealth of JQuery libraries that make my web development easier. I've only used js as something to help the functionality of web pages at the client level / make AJAX calls. Whilst I realise it can be used for other things it seems to fit this need quite well.
So my question: It seems to produce the required outcome in its most prolific implementations so why the need to change it? Who benefits?
This looks really interesting.
JavaScript is, hands down, the most frustrating language I have ever worked with in my career, and despite working with it several times a week for 10 years now I still struggle to write clean and reliable code.
The basic syntax of TypeScript looks exactly the same as JavaScript, which is fine with me - JavaScript's syntax is really good. If they have fixed all the scope weirdness and bat-shit-crazy behaviour of things like the date class, then I'm behind them 100%.
Probably one of Go, Closure, Java (via GWT), or C (via NaCl), though I suppose one might see Python and (again) Java (this time, via AppEngine) as "replacements" for server-side JavaScript in the form of Node.js, though that's even a bigger stretch than the others. Dart is the only one that is actually an effort in the direction of a general JavaScript replacement, though.
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.
Assorted stuff I do sometimes: Lemuria.org
So, a very well respected and knowledgable langauge designer brings some concepts to Javascript to add in typing, but in a way that is easy to strip down to Javascript. He is writing a standards draft document and they have a Apache Licensed implementation of that standard. But, since Andres works at Microsoft, this must be yet another plot to fragment the web and make JavaScript Microsoft only, blah, blah, and this must be a stupid idea that nobody will actually use.
If Google has done the exact same thing (err, http://www.dartlang.org), nobody here would bat a eye, and a few would swoon. I know that some (perhaps many), think that Linux dodged a bullet with not supporting Mono, but in the end, all that was gained was a rejection of a useful programming language that is gaining a lot of traction because it does a serve a useful place, one that Java used to fill, but whose process is in complete gridlock, making even the most obvious of language features still unavailable.
This is a useful and well thought out addition to the discussion that needs to happen on how to make Javascript more useful for programmers. To dismiss this and to leave this to Google or any other one Company is not a good idea. To paraphrase Don Box (oh noes, another Microsoft guy): I like static typing. It catches the mistakes we all make, and let me concentrate on other things. I like how Typescript makes it easy to strip this information out, especially compared to Dart.
Javascript works well for what it was intended to do: adding dynamic functionality to webpages. It only has problems when it's used for something it was not intended to do like building web-based applications or the Flash-like animations of HTML5. These are very different use cases, and I don't think one language to cover them all is a good idea. Developing new languages for the new web technologies is the way to go.
What has always bugged me about the whole mess that javascript is, is why don't we ratify a standard instruction set/byte code format, an ABI and API for the browser, as well as HTML extensions ( e.g comes to mind ) and then the browser vendors only have to implement that ( as well as a javascript interpreter on that compiles to it for backwards compatbility ) and we can all write compilers that target that instruction set and get access two a whole lot of language without the baggage that is javascript.... why is this a bad idea ( i am really asking because i think i must be overlooking something )
So can we finally have a specification that is not bound to a specific implementation? Why in all what is good and holy, do we need the limitation of JavaScript? Just make a byte-language specification, just like the CLR or Java Byte-Code for the DOM stuff.
Then everyone are free to use Python, Ruby, Java or what else as a language, the browser needs only to interpret the Byte-Code that the language-compiler is producing (just like with Java and javac, where you can use any language you like to produce the Java byte-code).
If you are really worried about open source, then answer me this: What is the difference between this and byte-code? There is none, because both are not human-readable. So why not just to agree to a byte-code that interfaces the DOM and html5 and then we can use any language we like to generate the byte-code?
Wouldn't it be nice to fire up your favorite IDE or editor and just write Python or Ruby (or insert here your favorite language) for your web-page? But no, we just have to use JavaScript until the end of the universe.
PS: most browsers are compiling JavaScript to a byte-language anyway nowadays, because then they can optimize the byte-code so JS will run faster.
http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
You have to be kidding! This is like asking the fox to guard the hen house. Their only motive is profit and their top leadership is incompetent. For all of Javascripts problems, trusting Microsoft would be much worse. You might as well as developers to stab themselves in the eye.
Like the inimitable Groucho Marx, I would never join a club that would have me as a member.
"Embrace, Extend, Extinguish."
Exactly.
http://alternatives.rzero.com/
There is a LLVM backend that dumps to javascript here https://github.com/kripken/emscripten/wiki.
So, now you can probably run your python, lua, ruby, etc scripts on the client side, you just have to provide a LLVM front-end or a language that can be compiled with one of the pre-existing ones.
Opps, that should have read SDL.
Makes sense that the makers of the worst web browser create a replacement for Javascript, NOT!!!
Javascript along with it's creator needs to die a slow death...preferably in a fire.
Apache 2 license permits a patent trap, whereas GPL v3 doesn't.
Microsoft chose Apache 2 for that reason. Expect to see them announce they've been issued with patents that cover Typescript if ever it was adopted. Best avoided.
Google's Closure (https://developers.google.com/closure/) library does this same sort of thing: type checking, optimization, compilation (via obfuscation.) It uses comments instead of annotations; you just write comments about the type of objects you're passing around in your functions. It also supports inheritance, templates, dependencies, etc. When you're done you just run it through the Closure compiler (or don't, you're just using Javascript) to check everything and compress it down.
I'm so LPSTRDisAppOinTed!
I've wasted too much time porting VBscript to JavaScript already, just so that a site I had to maintain would work "cross-browser" (in this context meaning, "on anything other than IE") again.
Also, I've seen what happens with MS "cross platform"/"open" promises. That great platform dot net? Which was ported by the Mono project? I'm bloody impressed how far I got running that on Linux. Of course any of the MS-proprietary SharePoint components are only available as Windows DLLs anyway and won't work.
This is nothing more but another attempt to take over the web.
DO NOT WANT.
I wish the browser makers would replace that annoying JavaScript language with the elegant, nowadays rarely used (Object) Pascal. Then I'd love to work on AJAX web applications.
-Nahooda
Sigs suck!
Embrace
Extend --- You are here.
Extinguish
Is java an open-source language, that Microsoft could easily donate man hours to contributing to, or is it a closed thing that they are in competition with? Because if it's the latter, the company that owns Java is gonna have a tough run ahead of them.
Make sure you run 20 or 30 or more of these on every webpage and nest them 4 layers deep so that every browser in the world slowly chokes to death.
Why not leverage all C# features like in http://sharpkit.net/
Much like silverlight.
Right, exactly. Hence why it less free than licenses which are about that.
No, its not. Its the price for compelling other people to make their source free. The source of a permissively licensed work doesn't stop being free just because someone makes a non-free derivative work. The free codebase may become less readily available if the free codebase doesn't attract interst (which is just as true with the GPL as with permissive licenses, though.) The price of keeping the free code available is building a strong and successful community around the free software, which can be done just as well around a permissively-licensed code base as it can be around a GPL code base.
Wow! Crazy how much this looks like the Adobe/Mozilla actionscript/javascript3 that Microsoft flat out rejected in standards talks with the ECMA a few years back. I liked it when Adobe came up with it. I like it now that Microsoft is claiming to have come up with the idea. This kind of thing is needed badly by serious developers.
This signature intentionally left blank.
That is my understanding. When MS releases source under GPL, I will be a little more inclined to trust MS.
Actually, maybe not even then. There are always patents.
There are projects like Blade (https://github.com/vannatech/blade) that compile c# to JS, meaning you don't need to mess with yet another syntax and you get more interesting benefits such as sharing code files between client and server..
you can simply load JavaScript code and run it.
.. they don't really replace javascript. they just offer the usual new crap but make it compatible with javascript, maybe because they by now make the sound assumption that otherwise nobody would give a crap on their new crap.
well, i don't give a crap anyways, thanks.
What cracks me up about all these down-compiled versions is this: What other language can handle this well? JS is insanely flexible. It has some things that could do with an upgrade but if you actually bother to learn to write it well, you'll have no use for any of this down-compiled BS. And yes, it's BS. It does tie you to the original language. Writing/editing down-compiled code would be like trying to write/edit minified code only worse because of all the various ridiculous abstractions they'll be using to add classes where none were needed in the first place. JS is absurdly mutable. And yes it's dynamically typed. This has actually worked very well for web UI devs in part because of it's functional nature and in part because we really can't afford verbosity in order to deal with the sorts of BS a UI dev has to deal with.
And yes, it's perfectly scalable in spite of these things if you actually give a damn about architecture. It's the first massively popularly-used functional language. It's not going anywhere. Learn it well so you can avoid the crutches and training wheels that will ultimately alienate talent and that you'll regret implementing five years later.
Brendan Eich made a lot of excellent calls, making Scheme his inspiration in particular, but he's wrong about this rash of down-compiled languages, IMO. They're dead-ends.
I produced a free TypeScript eBook:
http://www.heronote.com/files/TypeScript.htm