Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming News

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).
This discussion has been archived. No new comments can be posted.

TypeScript: Microsoft's Replacement For JavaScript

Comments Filter:
  • 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!

    • How exactly do you "extinguish" something that's free, open source and cross-platform from the get go?

      (yes, TypeScript is all three)

  • by Bill, Shooter of Bul ( 629286 ) on Monday October 01, 2012 @05:38PM (#41518565) Journal

    Dart, obviously. But what is the other one? Anyone know what the article writer was talking about?

  • by superflit ( 1193931 ) on Monday October 01, 2012 @05:41PM (#41518599) Homepage

    Sorry..
    I am still busy with silverlight...

    Oooppss. that did not work....

  • by thetoadwarrior ( 1268702 ) on Monday October 01, 2012 @05:42PM (#41518613) Homepage
    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.
    • Obligatory: http://xkcd.com/927/ [xkcd.com]

      Note: please do not mod this post up. Yes, it is completely relevant, and funny, but I can't take credit for it. :p (On the other hand, I request it not get modded down just because you don't like xkcd, either. Relatedly, why the frell don't you?)

    • Re: (Score:3, Insightful)

      by Anonymous Coward

      It makes me cry whenever I hear JavaScript being used as an 'assembler'.

      CPU performance, memory usage, and power consumption be damned!

    • by Anonymous Coward on Monday October 01, 2012 @06:11PM (#41518963)

      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:

      • - Implementable as a small and simple interpreter
      • - Implementable as an efficient JIT compiler
      • - The VM and the ECMAScript implementation should be able to share a JIT, e.g. by compiling scripts to VM, or a common immediate representation.
      • - Must share the DOM and APIs with ECMAScript
      • - A reasonably efficient ECMAScript implementation of the VM
      • - Programs specifiable as either text or binaries

      (LLVM bytecode is NOT suitable for this; it is first and foremost a compiler IR, and is not intended for cross-platform use.)

    • Well, CoffeeScript seems to be the prescription you are looking for... I don't think Dart will take hold so much... this seems a lot like the EcmaScript4/ActionScript3 direction taken as a pre-processor for JS, with some decent UI hinting to go with it... I do like that the *.d.ts files are pretty self documenting, and could be useful in defining object models for use with JSON based web services... the documentation I've been creating is very similar, as it's pretty straight forward, but may actually ref
    • by narcc ( 412956 )

      Something like Python? I thought you wanted something better?

    • "This is not a solution. It's a mess."

      Indeed. These companies are not creating JavaScript replacements because they just want it their way, there are real issues with using JavaScript for large developments. Why are we still waiting for basic features like optional static typing and classes to be added to JavaScript? Static typing is a very important feature. From it flows not just basic type checking, but also autocompletion (a major productivity booster), ease of re-factoring and useful code analysis (what functions use this particular type

    • by Hentes ( 2461350 ) on Monday October 01, 2012 @07:58PM (#41519991)

      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.

  • 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.

    • What's funny, is that was my first thought as well. It's not like Linus doesn't do anything beyond kernel dev... I mean, we have things Git.. oh noes.. Linus is looking elsewhere, Linux is teh d00med now!

      I do think CoffeeScript is pretty compelling, though I'm not sure how much I like it... a lot of what's in TypeScript is based on efforts with EcmaScript in the past/future, so it lines up a little better. I think there's room for CoffeeScript, Haxe and TypeScript. TS will probably get a bit more tra
  • by catbutt ( 469582 ) on Monday October 01, 2012 @05:55PM (#41518745)
    ...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.
    • by MHolmesIV ( 253236 ) on Monday October 01, 2012 @06:08PM (#41518951)

      Exactly, it's basically a preprocessor for javascript that allows your IDE to help you write better code.

  • by logicassasin ( 318009 ) on Monday October 01, 2012 @06:02PM (#41518867)

    I'm going to leave this here as a placeholder for the inevitable...

  • We already have, what, a couple *hundred* languages to choose from at this point?

    https://en.wikipedia.org/wiki/List_of_programming_languages [wikipedia.org]

    Can we knock it off with the new effing languages already? Don't these people have anything more useful to do?

    • by jo_ham ( 604554 )

      We already have, what, a couple *hundred* languages to choose from at this point?

      Almost as many as we have Linux distros!

    • Yeah people! Stop thinking about new ways of doing things! Get in line with the One True Way!

  • by Anonymous Coward

    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.

  • to compile my C# algorithms to Javascript. See http://scriptsharp.com/ [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.

  • 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, structu

  • Playground doesn't work :-( Tested in Firefox and Chrome.
  • by devent ( 1627873 ) on Monday October 01, 2012 @08:49PM (#41520413) Homepage

    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 [jquery.com] 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.

I have hardly ever known a mathematician who was capable of reasoning. -- Plato

Working...