14 ms·
TypeScript: a language for application-scale JavaScript development
TypeScript is a language for application-scale JavaScript development.
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
Any browser. Any host. Any OS. Open Source.
From Microsoft.
- ww520 14y agoThis looks very good enhancement on top of Javascript. Hope browsers start bundling the TypeScript compiler natively.
- anuraj 14y agoWholeheartedly support this thinking softie has no daggers hidden. The changes do make the language more readable and maintaninable compared to the mess called JavaScript. If the IDE is support is also there, this will be a no-brainer.
- nnq 14y agoThe only thing that I find "exciting" in the land of compiled-to-javascript languages is LiveScript (http://gkz.github.com/LiveScript/ http://gkz.github.com/LiveScript/)...
- oinksoft 14y agoIt seems to me that the type checking in TypeScript is extremely limited compared to what the Closure Compiler supports. The examples only show simple `fooInstance : Foo` examples, whereas Closure supports function prototype validation and such, a la C. I will need to see more elaborate examples. Granted, there is no documentation that I could find on the website. I understand that this is a "preview," but I disagree with this way of presenting a tool. When the Closure Library was released, for instance, it was absolutely chock full of API documentation. This is because it was used for real-world projects and extensive docs mattered, even internal to Google. There is a language specification (PDF, in the source tree) which is encouraging, but where's the manual? <http://www.floopsy.com/post/32453280184/w-t-f-m-write-the-freaking-manual> http://www.floopsy.com/post/32453280184/w-t-f-m-write-the-fr.... The specification is largely a rewording of the ES5 spec with insertions where the typing additions are important. It will take a good bit for the reader to separate the wheat from the chaff, as they say. I have more than a sneaking suspicion that this project is essentially a proof-of-concept, and that it is not heavily used at Microsoft. Do you remember "Microsoft Atlas" in 2006, at the height of the JS DOM Library Wars? In the end, they just pushed their developers to use jQuery with some code generation helpers. Microsoft's open-source track record for JavaScript is not impressive, and I think you'd be a damned fool to invest in this technology for any serious project.
- JimmaDaRustla 14y agoIt's an open-source iniative - great ideas like this are best seeded and grown through a great community effort. You sound like you want to be given the whole tree.
- wingspan 14y agoI have more than a sneaking suspicion that this project is essentially a proof-of-concept, and that it is not heavily used at Microsoft. My team has been dogfooding TypeScript for several months now, providing lots of feedback and writing > 30,000 lines of code (in many cases the new TypeScript code is shorter than the original Javascript).
- oinksoft 14y agoIn this case, I must infer that the culture of documentation is not the same at Microsoft as it is at Google. Further, how can you have a tool like this and nothing for generating type-aware documentation from your source code? Google uses jsdoc-toolkit, so this is a moot point for them. Either you guys are using this in an informal fashion, or documentation isn't that important at Microsoft, or you just haven't released the doc generation tool(s), which would be a really odd choice!
- bnr 14y agoThe Language Specification looks pretty extensive[1]. And TypeScript is just the language, so there's no API to document besides what your browser exposes in JS. [1] http://www.typescriptlang.org/Content/TypeScript%20Language%20Specification.pdf http://www.typescriptlang.org/Content/TypeScript%20Language%...
- epidemian 14y agoIt looks really good for a first release. The focus on tooling is IMO the most refreshing thing about the project; the playground is great! I haven't dug much into it yet, but there are a couple of annoyances that i noticed in the playground that i wish will be corrected/alleviated somehow: - The language is not expression-oriented. Once i got used to the "everything is an expression" mindset in languages like CoffeeScript or Ruby (or every functional language that i can think of) it feels quite tedious to "go back" and remember that, no, now the "if" is not an expression any more, you can't return it, or pass it to a function, or assign it to something. You can use the special syntax of the "?:" operator for an if-expression, but there is no equivalent for "switch", or "try", or "for". - The type system doesn't seem to support parametric polymorphism. For example, the type of string[]::map is ((string, number, string[]) => any, any) => any[] instead of ((string, number, string[]) => T, any) => T[]. So the value ["hello", "world"].map((s) => s + '!') is of type any[] instead of string[], which would be preferable IMO.
- wingspan 14y agoTypeScript will eventually support generics, as per the spec [1]: NOTE: TypeScript currently doesn’t support Generics, but we expect to include them in the final language. Since TypeScript’s static type system has no run-time manifestation, Generics will be based on “type erasure” and intended purely as a conduit for expressing parametric type relationships in interfaces, classes, and function signatures. [1] http://go.microsoft.com/fwlink/?LinkId=267121 http://go.microsoft.com/fwlink/?LinkId=267121
- epidemian 14y agoCool. It is quite expectable too, at least considering the capabilities of the C# type system :)
- euroclydon 14y agoThe compiler's written in... TypeScript!
- euroclydon 14y agoWhat unit test framework are they using in the source? It looks like Jasmine ('describe', 'it') but then it has 'assert' and I can't find an include for it.
- dotborg 14y agoReminds me about Turbo Pascal, I love it!
- zoowar 14y agolol: application-scale
- stuaxo 14y agoHm.. classes, interfaces... reminds me of AS3; which of course MS stopped becoming the next javascript. Still - looks useful.
- lukeholder 14y agoCan I write my TypeScript in coffeescript?
- gfosco 14y agoOne can never be too careful, apparently.
- streptomycin 14y agoThis seems similar to the type checking and optimization done by Google Closure Compiler?
- polarix 14y agoThe main difference is that the Closure compiler compiles JS->JS, keeping all the type info in jsdoc comments. Typescript makes the typing a first class language entity, which reduces code portability (and toolchain flexibility) in favor of (I assume) readability and maintainabilty. Another huge advantage is that the typescript parser & compiler is written in Javascript. Closure's jscomp is Java, which decreases backend portability somewhat.
- deleted 14y ago[deleted]
- cek 14y agoSay what you want about whether this is a good idea or not, it is clear at least part of MS is really serious about open source. * TypeScript is under the Apache 2.0 license [1] * Source is available via git on Codeplex [2] * Installation is as easy as npm install -g typescript [3] Extra bonus coolness: They've provided an online playground like jsfiddle! [4]. [1]http://typescript.codeplex.com/license http://typescript.codeplex.com/license [2]http://typescript.codeplex.com/SourceControl/changeset/view/d397c54a55db http://typescript.codeplex.com/SourceControl/changeset/view/... [3]http://www.typescriptlang.org/#Download http://www.typescriptlang.org/#Download [4]http://www.typescriptlang.org/Playground/ http://www.typescriptlang.org/Playground/
- OriginalSyn 14y agoI don't know when it happened but CodePlex got a makeover as well, it looks good.
- JimmaDaRustla 14y agoMicrosoft also has Github a account/accounts - I thought they were going use it for all their open-source projects, but they seem undecided now.
- nigelsampson 14y agoI believe a lot of the teams were jumping on Git for source control before Codeplex had Git support. A little awkward in that stuff is split, but still awesome to seem more stuff like this.
- Rhino55 14y agoThis is an absurd and outrageous statement. Akin to the full pay glossy ads for oil companies in Vanity Fair with messages like "We care about people and nature". M$ is serious about embrace, extend, extinguish. M$ is not serious about supporting the computing community, is not serious about creating powerful platforms, and has gone out of its way to serious damage the knowledge economy. Microsoft will destroy this technology just like it destroys everything it touches. Microsoft is the Chuck Bass of computing. If you get that reference, you are probably looking at someone else's computer right now. The thing you see in front of you is, perhaps 10% Microsoft and 90% the work of a small number of dedicated individuals. Microsoft has shown a track record of destroying good technology and ignoring the community standards process. I sincerely hope that someone rips this idea off and liberates it from Microsoft. Typed JavaScript is not patentable or copyright-able, and Google beat the daylights out of Oracle over Java, so I think this is fair game. tl;dr I give this project 18 months before the M$ business machine starts using TypeScript as a weapon.
- kombine 14y agoNow I want to take an advantage of strict typing at runtime, which is obviously not possible, because instead of standardizing a VM all vendors are doing stupid things like this.
- cek 14y agoI'm willing to bet MS has built runtime type support into the Chakra VM. The question is whether they will do it in a propitiatory way or push it as an extension of ECMAScript and try to get other VMs to implement it.
- kombine 14y agoThe worst thing is that they already have the runtime that is language-agnostic, performant, has a great standard library and so on. When they tried making it available on the Web, the so-called "open stadards" won. Which are in fact a bag of shit.
- freehunter 14y agoOn the Techcrunch article also posted to HN recently, the designer said they would not be baking TypeScript into Chakra, but rather letting it compile to JS and running it the same way everywhere.
- untog 14y agoThe TechCrunch[1] article states otherwise: "Asked whether Microsoft might do something to prioritize TypecSript in Internet Explorer, Lucco, the chief architect of IE’s JavaScript rendering engine Chakra, says no." [1] http://techcrunch.com/2012/10/01/microsoft-previews-new-javascript-like-programming-language-typescript/ http://techcrunch.com/2012/10/01/microsoft-previews-new-java...
- swannodette 14y agoThey've added type annotations to all of jQuery it seems? http://typescript.codeplex.com/SourceControl/changeset/view/d397c54a55db#typings%2fjquery.d.ts http://typescript.codeplex.com/SourceControl/changeset/view/...
- iambot 14y agoI worked on a joke/conversion project a little while ago that achieves the same ends without having to compile to JavaScript. The only reason I wrote it was to prove to a co-worker who was "hating" on JavaScript that it IS possible to have a type system in JavaScript - if that's what you want. Its not the same end result but similar enough to warrant a mention. Here's the repo: https://github.com/christopherdebeer/TypedFunc https://github.com/christopherdebeer/TypedFunc
- MicroAndMacro 14y agoSublime Text, Vi, Emacs: TypeScript enabled http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx http://blogs.msdn.com/b/interoperability/archive/2012/10/01/...
- tlack 14y agoWeird that I didn't spot a friendly list of features.. seems to have some cool ones, like a shortened function expression (from the doc PDF): (x) => { return Math.sin(x); } and modules, which are implemented using the immediately invoked function expression pattern: module M { var s = "hello"; export function f() { return s; } } Syntax seems more clear than CoffeeScript and tool chain will probably shape up better. Looking forward to seeing this get some traction.
- untog 14y agoI like the shortened function form. I played around with CS for a while before going back to JS, but I do miss being able to do something like: var names = people.map((p) -> return p.name); (or something along those lines). Funnily enough, it reminds me of C#'s LINQ: var names = people.Select(p => p.name);
- tlack 14y agoApparently ECMAScript 6 is considering some other forms of function literals as well: http://www.2ality.com/2012/04/arrow-functions.html http://www.2ality.com/2012/04/arrow-functions.html
- untog 14y agoInteresting. As the TC article stated, it seems like a lot of this is based on ECMA proposals.
- wingspan 14y agoI've written a LINQ style library for TypeScript that allows you to write something like this: from([1,2,3]).select(n => n * n).where(n >=2).toArray() which outputs [4, 9] Hoping to open source it soon. Edit: typo, n * 2 should have been n * n, sorry for the confusion
- Kafka 14y agoCould you please explain why it would output that?
- koops 14y agoI've written a lot of JavaScript, including large-scale projects, and never once have thought, "Gee, I wish I had type checking." Haven't we come to a consensus that types are more trouble than they're worth? They hurt clarity and catch few bugs.
- masklinn 14y ago> Haven't we come to a consensus that types are more trouble than they're worth? Pretty sure we haven't. That shitty languages with shitty type systems are mor trouble than they're worth yes, but types?
- ovidiu 14y agoNo, we have not. Read John Carmack's posts on static code analysis to understand why.
- erichocean 14y agoI've been writing large-scale JS applications with SproutCore since 2007, and not once have I been bitten by a bug that would have been caught by static typing. Same with Objective-C and my iOS and Cocoa development (since the OpenStep days). I do use Scala on the server side though, and it helps there. But application development is, IMO, hindered by static typing. It's a lot more work to set up, and provides essentially zero benefit. And I love static type analysis (I use it with C stuff all the time). +1
- samspot 14y agoI noticed you mentioned scala on the server side. Does your comment about static typing being a hindrance apply to scala? I would also argue that static typing provides a self-documenting benefit that is easy to forget, making it easier for someone unfamiliar with the codebase to understand what is going on. When I'm doing maintenance work I often start at the point of failure and work backwards, and it is very helpful when I can immediately identify what a variable is supposed to be representing.
- drcode 14y agoBack in the day, Microsoft would use a strategy called "embrace, extend, extinguish." http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish Recently, Microsoft has been pushing Javascript very hard (embrace) and now it looks like they've started the "extend" phase. Luckily, no one really worries about them being able to pull off the "extinguish" part anymore... they just don't have enough market power these days. EDIT: Yes, I conceede the fact that TypeScript is OS probably addresses most of these objections.
- zokier 14y agoTypeScript is as likely to extinguish JS as ASP is to extinguish HTML.
- MatthewPhillips 14y agoYou're wrong "extend" is when you add features to a standard that are not part of the standard. Since this only compiles to JavaScript and isn't being built into IE, it doesn't qualify. Dart does, though.
- untog 14y agoExcept that this is fully open source, which makes it a little difficult for MS to retain control over it, no? Re-reading late 90s M$ memes gets old after a time.
- jakejake 14y agoThis would still be the "embrase" phase. Extending is when they add a new feature that doesn't exist and isn't supported by the competitors. As soon as you see it compile to a flavor of JavaScript that only IE understands - then will the "extend" phase have begun.
- wingspan 14y agoAwesome, great to see this finally released. I'm a dev in FUSE Labs (http://fuse.microsoft.com http://fuse.microsoft.com) and we've been dogfooding TypeScript for a while now. I'd be happy to answer any questions about using TypeScript vs vanilla JS, converting a large codebase, etc.
- lstroud 14y agoHow does it compare to Dart & Harmony (even coffeescript)? I know that is a long answer, but I'd love a bullet point list of how if compares to the other javascript++ languages that have been coming out over the last couple of years.
- wingspan 14y agoI'd have to defer this one to the language designers, I'm sure they've done such a comparison. Per the spec [1]: TypeScript syntax includes several proposed features of Ecmascript 6 (ES6), including classes and modules. [1] http://go.microsoft.com/fwlink/?LinkId=267121 http://go.microsoft.com/fwlink/?LinkId=267121
- ovidiu 14y agoI'm wondering how to make use of an existing object system. We already have a JS framework that simulates classes and inheritance in the Java-style OOP.
- wingspan 14y agoIf you have a small sample, you could try it out in the playground (http://www.typescriptlang.org/Playground/ http://www.typescriptlang.org/Playground/) and see what TypeScript can recognize. Generally, I've seen TypeScript plays well with other OO forms and gives you intellisense on quite a lot.
- platonichvn 14y agoThis is great to hear. I have only just started reading up on TypeScript. But I would love to know if there will be support for a decimal type. I have been following Google's work on Dart and it doesn't look like they will be implementing it last I checked. Such a feature would be a great differentiator.
- zachrose 14y agoWould it not be just as reasonable to put type information in JSDoc, and build a preprocessor that does the complaining?
- ericcholis 14y agoFavorite part about this, I didn't know it was Microsoft until I scrolled down!
- lowboy 14y agoI had suspicions from their choice of styling and typeface.
- init0 14y agohttp://i.imgur.com/XB3ib.png http://i.imgur.com/XB3ib.png Oh M$ Oh...
- thedeuce 14y agowhat are you 5?
- untog 14y agoYou lost me at "M$". I'd like to think that HN's level of discussion is above that.
- cbaleanu 14y agoNonetheless, interesting disclaimer text spotted there. Raises a good question... would that text be there because somebody in the industry analyzes your code?
- lazugod 14y agoAre we reading the same thing? Code is not sent to Microsoft.
- cbaleanu 14y agoExactly. But if one clearly states that, perhaps there are others in the industry that do the oposite, iaw analyzing / scraping / calling home some code. Having that disclaimer makes them safe in case someone might notice that insert IDE / online editor here does that and rings the bell.
- untog 14y agoI think it just means that Microsoft has overzealous lawyers.
- init0 14y agohttp://i.imgur.com/XB3ib.png http://i.imgur.com/XB3ib.png Oh M$ Oh...
- spicyj 14y agoThis looks nice. I love the fact that there's no runtime that needs to be included or any overhead when the compiled JS runs. It'd be 100% more useful if it was more aware of nullable types -- as it is, it appears that null * 7 compiles without any error messages. If they add a "nullable number" type distinct from "number", I'll be a lot more likely to use it. It also appears that some other things compile that perhaps shouldn't, such as 7[2] and 7["a"] even though (7).a is equivalent and (correctly) fails to compile.
- wingspan 14y ago`7[2]` is valid Javascript, so it is also valid TypeScript (fetching the '2' member of the `7` object). Detecting null expressions at compile time might help. There are "nullable" types, but afaik only in signatures: foo(x?) { alert(x); } If `x` is not passed in, it will be `undefined`.
- spicyj 14y ago"wingspan" * 7 is also gramatically correct JavaScript, but evaluates to NaN and almost certainly isn't what you want in your JS program, which is why TypeScript prints a type error (well, warning) if you try to compile it. Having optional variables is similar, but not the same as nullable types, especially when the compiler can't enforce non-nullable-ness. All JS devs are familiar with the annoying error "'null' is not an object" (and anyone who's programmed in a language like Haskell, OCaml, or F# knows the value of sophisticated compile-type type checking).
- wingspan 14y agoYes I see what you mean, it'd be interesting to see what the exact rules around type checking are; especially when dealing with []. The string type for example, always give you a string when indexed, even when incorrect: var s = 'foo'; var l = s['length']; // type of l is `string` I also agree about non-nullable types, and I've found even with TypeScript, having to make sure your vars are defined and not-null is still a pain.
- wicknicks 14y agoLooks really good. The IDE support looks like a big bonus. Wish this had been released on a Friday -- have to wait a bit before I can dig deeper!
- tlrobinson 14y agoThis looks great, but the IDE seems to be one of the key features, so we're going to need something other than Visual Studio. EDIT: they've got syntax highlighting for some other editors, but full completion and error reporting is still needed http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx http://blogs.msdn.com/b/interoperability/archive/2012/10/01/...
- jopamer 14y agoOur language service APIs are all open source, so feel free to hack together support for your favorite IDE and let us know! (Check out the code under src\services, and let us know if you have questions.)
- Permit 14y agoI can't imagine it'll be too tough for other IDEs to support. There's a pretty impressive demo here: http://www.typescriptlang.org/Playground/ http://www.typescriptlang.org/Playground/ It even has auto-complete if you press "Ctr-Space" while typing a word. Considering the source for all this stuff is freely available, I don't think it'll be too long before other IDEs support it.
- wingspan 14y agoThe language support in VS is really great, and getting better with each release. Go to definition, code outlining, folding, type information on hover, intellisense; all these make writing code much less easier and error prone, especially if you are used to writing in a language like C# or Java in a good IDE.
- tlrobinson 14y agoBut does VS run on Mac OS X or Linux? Didn't think so.
- wingspan 14y agoAh right, misread your post. I was just commenting in general on the VS support, you are right that it would not be as nice on other platforms.
- wensheng 14y agoNo list comprehension? No, Thanks.
- wingspan 14y agoWould be a good thing to suggest to the team, it is the first release of the language, after all. In the interim, a simple library like underscore is quite succinct: _.map([1,2,3], n => n * n) With more library support you could even do infinite lists with something like this: _.generate(index => 1.0 / index);
- mykolasmith 14y agoCodeplex/samples/simple (http://bit.ly/Svcc4Y http://bit.ly/Svcc4Y) is the same as the CoffeeScript constructors doc section (http://bitly.com/PnLtGy http://bitly.com/PnLtGy)... Wonder what other stuff they borrowed from CoffeeScript?
- nagnatron 14y agoMaybe that's a good idea because it makes it easy to compare the two?
- jonny_eh 14y agoI was reading the synopsis on the page then it faded out and replaced it with sample code. Geez, let me read and then scroll down. WTF is with the carousel non-sense?
- scanr 14y agoVery interesting. The Apache 2.0 Licence is comforting, makes it worth having a look. The docs are here for anyone interested in the spec: http://typescript.codeplex.com/documentation http://typescript.codeplex.com/documentation I like what they've done. Nothing too revolutionary, mostly adding static typing to Javascript without straying to far from the existing (or future) language or increasing the noise significantly. Here's some highlights: * Type inference function f() { return "Hello World!"; } Will do the right thing * Explicit Typing function f(s: string) { return s; } * 'Ambient Types' To facilitate integration into existing JS libraries or the DOM, TypeScript lets you specify 'placeholders' for variables / classes that the runtime would expect to see e.g. declare var document; Almost a kind of dependency injection but also a neat way to manage talking to existing code. * Structural Typing * Classes and Interfaces interface BankAccount { balance: number; deposit(credit: number): number; } class CheckingAccount extends BankAccount { constructor(balance: number) { super(balance); } writeCheck(debit: number) { this.balance -= debit; } } * Modules module M { var s = "hello"; export function f() { return s; } } * Arrow function expressions (x) => { return Math.sin(x); }
- euroclydon 14y agoAre you actually implying with the above example code that you can call a undefined "super" constructor on an interface and pass it the "balance" variable, which the interface's non-existent constructor would presumably match by name?
- scanr 14y agoNope. I probably should have used a different example for the interface. The examples are from the full spec where they progress a little more gradually from a BankAccount interface to a BankAccount class to a CheckingAccount subclass.
- zokier 14y agoI haven't read the docs so I may be completely off. But that "super" syntax could be similar to "brace initialization" in C.
- camus 14y agoFunny how Microsoft refused ES4 because it came from Macromedia/Adobe ,yet now it pushes a language that looks like its own JScript/AS3
- petegrif 14y agoMS answer to DART?
- arturadib 14y agoAll of these compile-to-JS efforts are great, and as much as I love things like CoffeeScript I have to say I definitely worry about language fragmentation. JavaScript is full of flaws, but its monopoly in the browser space has brought about one intriguing and welcome side-effect: a VERY efficient market for both employers and employees. It's easy to overlook how important this common denominator has been for everyone involved. Employees have a tremendous amount of mobility within the industry: don't like your current JavaScript job? No problem - just about every dot-com needs a JavaScripter. Similarly, companies can today tap into a tremendous pool of JavaScript developers. In today's fast-paced development environment, the ability to hit the ground running is key, and I worry that fragmentation will introduce unnecessary friction in the industry.
- zem 14y ago> In today's fast-paced development environment, the ability to hit the ground running is key actually, i think one of the major flaws in the current programming job market is overrating the ability to hit the ground running. that leads to a dangerous level of short-term optimisation, where, say, you'd choose an employee who has experience with your current stack over someone with a better track record but requiring a month or so to learn their way around the specific languages and ecosystems involved.
- latchkey 14y agoThis same fear of fragmentation is what kept Java from progressing for so many years and look what happened there. Things 'fragmented' by people just switching to other languages. I say roll the dice and see what happens.
- camus 14y agoJavascript is dreadfull , and its flaws are counter productive and intolerable. It has good things like closures and first class functions , and that's it. Most of js developpers hate javascript , but are forced to work with it. So they dont care what they use as client language provided it gets the job done. few people cares about Javascript. most of the devs hate it. But the browser as dev plateform is a fact.
- libria 14y agoIt's good to see sharp developers like Anders Hejlsberg spearheading this. I really hope this means we'll get LINQ sometime in the future; good to hear generics are on the way.
- devongovett 14y agoMy thoughts on Badass JS here: http://badassjs.com/post/32674515997/typescript-microsofts-new-typed-javascript-dialect http://badassjs.com/post/32674515997/typescript-microsofts-n...
- alexanderh 14y agoWhat about debugging? Thats my biggest problem with coffeescript How do they map errors thrown in the browser, to TypeScript code? If this has things like classes and such, the relationship isnt always going to be 1:1 and debugging can become a nightmare. Part of what makes javascript so great is how easy it is to debug. All these "superset" languages that compile to javascript fail hard @ debug support usually
- wingspan 14y agoDebugging would be helped greatly if they supported source maps (http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ http://www.html5rocks.com/en/tutorials/developertools/source...).
- munificent 14y agoSource maps[1] should help with this. [1]: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/ http://www.html5rocks.com/en/tutorials/developertools/source...
- alexanderh 14y agoThis is cool and I keep hearing its coming to coffeescript soon, but just the fact that the TypeScript website doesnt mention "debugging" or "source maps" anywhere on the front page is disheartening. Its more important than anything to me, yet its still just a "we'll get there eventually" priority for all these alternative javascript languages. I would think microsoft wouldnt want to release this until source maps were tested, working and included as part of the language as a major bullet point feature. These languages are nothing but a novelty to use in prototyping until that happens. I'll never use any of these languages in my production development workflow until proper debugging is available.
- cnp 14y agoLanguage output is more important than SourceMaps. Coffeescript output is substantially harder to read than TypeScript, and personally I've never had an issue tracking down issues. I'm looking forward to it, sourcemaps or not.
- andrewla 14y agoOn a tangent, does anyone know anything about the in-browser editor they are using for the playground? It seems really slick. The javascript references something called "monaco" and the directories are all prefixed with "vs". The code is hosted on their demo site; /Script/vs/editor/editor.main.js appears to be the main js file and has this notice: /*! © Microsoft. All rights reserved. This library is supported for use in Windows Store apps only. Build: 1.0.8514.0.win8_rtm.120711-1900 Version: Microsoft.WinJS.1.0 */
- wingspan 14y agoI believe the monaco editor is already being used in Azure Websites and possibly the TFS preview. I wouldn't be surprised if more information about it would be released soon, they are also a major dogfooder of TypeScript.
- jon6 14y ago$ t command not found clearly they could have named the compiler just 't' instead of the overly verbose 'tsc'. all those extra characters!!
- spicyj 14y agoThe compilers for C# and F# are named csc and fsc, respectively. I think we can handle two extra characters. ;)
- lowboy 14y agoIf I develop an RSI and a doctor tells me it was by a matter of a hundred keystrokes, I'm coming for Ballmer's pelt.
- ndabas 14y ago$ curl http://news.ycombinator.com/user?id=j No such user. Clearly you could have named yourself just 'j' instead of the overly verbose 'jon6'. All those extra characters!!
- jon6 14y agoClearly you can't perceive sarcasm.
- eddieplan9 14y agoThis is quite impressive technically, and I think the type-checking feature alone can make it appeal to those making large-scale application in collaborative development environment. I hope this inspires other similar efforts. A quick run-down of features: - It's a superset of JavaScript. So there is no porting effort needed. (With CoffeeScript, you do not need to port if you don't want to.) - compile-time type checking, like type erasure in Java's generics. - module support at the language level. It's very thin. It does not give your AMD or CommonJS module, but you can easily hack around it. - class and inheritance support at the language level. The implementation is very similar to CoffeeScript's.
- wingspan 14y agoWith reference to AMD and CommonJS modules, the spec has more info [1]: TypeScript implements modules that are closely aligned with those proposed for ECMAScript 6 and supports code generation targeting CommonJS and AMD module systems. It also looks like you can consume CommonJS and AMD modules using familiar constructs. [1] http://go.microsoft.com/fwlink/?LinkId=267121 http://go.microsoft.com/fwlink/?LinkId=267121
- mbq 14y agoLooks like all the bad features of Java and JS combined.
- colin_jack 14y agoIn case anyones interested, dart JS interop: https://github.com/dart-lang/js-interop/ https://github.com/dart-lang/js-interop/
- stalled 14y ago(for posterity, stray duplicate discussion with exactly the same url: http://news.ycombinator.com/item?id=4597724 http://news.ycombinator.com/item?id=4597724)
- colin_jack 14y agoIn case anyones interested, dart JS interop: https://github.com/dart-lang/js-interop/ https://github.com/dart-lang/js-interop/
- iamleppert 14y agoWhy does everyone want to take all the nice features of javascript, it being so loose and freeform and turn it into Java? I don't need interfaces and classes built into the language. That's why it's so powerful and lightweight. Prototypical! People keep making the same mistakes, if you let them. No thanks.
- kami8845 14y agoBecause writing big apps in dynamic languages sucks (I say this writing primarily Python & JS)
- tlrobinson 14y agoThe static typing is optional. You can be all "loose and freeform" when hacking stuff out, and later add types in to solidify your code and check for errors. It's the best of both worlds, IMHO.
- winteriscomming 14y agoBecause these "loose and freeform" attributes make your life hell building large applications with large teams.
- SeanLuke 14y ago> The scope of a parameter, local variable, or local function declared within a function declaration (including a constructor, member function, or member accessor declaration) or function expression is the body of that function declaration or function expression. This thing claims to be meant for "application-scale" JavaScript, and yet doesn't repair even JavaScript's most notorious error? A suggestion to the authors. Purchase this book: http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742 http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockfor... ... then go through the book with a fine-tooth comb, and every time it describes something as a "bad part" or an "awful part", delete or fix that misfeature in TypeScript.
- AdamTReineke 14y agoExcept then you would likely lose the attribute of being a superset of JavaScript.
- clockwork_189 14y agoSeems pretty cool, but how does it compare to DART or does it even compare?
- aaronblohowiak 14y agoThey added static typing to javascript, except you can still pass a number to a function that takes a string. In their example http://www.typescriptlang.org/Playground/ http://www.typescriptlang.org/Playground/ replace the new Greeter("World"); with new Greeter(5); and it still works. What good is adding types to functions if they are ignored?
- bilalq 14y agoAm I the only one experiencing sluggish scrolling on that site? Rather ironic for a site boasting about application-scale development.
- bilalq 14y agoAm I the only one experiencing sluggish scrolling on that site? Rather ironic for a site boasting about application-scale development.
- Zelphyr 14y agoThe Google guys called. They want Microsoft to stop being jealous of the JS-influenced turd that is Dart.
- buremba 14y agoI think javascript is awesome enough so it doesn't need any language improvements. The only improvement over javascript is coffeescript and it's just because its syntax nothing more else. take a look at this video from google i/o: http://goo.gl/BGvAS http://goo.gl/BGvAS
- FreshCode 14y agoCould TypeScript be combined with the CoffeeScript syntax to save keystrokes?
- malandrew 14y agoLike someone else commented in the TC article about Typescript, this Resig quote, changing "Google" for "Microsoft" is relevant: "Why is [Microsoft] putting time and effort into changing JavaScript when the DOM is what needs fixing?" https://twitter.com/jeresig/status/124114331616026624 https://twitter.com/jeresig/status/124114331616026624
- munificent 14y agoIronically, improving the DOM is actually something we're trying to do with Dart: http://www.dartlang.org/articles/improving-the-dom/ http://www.dartlang.org/articles/improving-the-dom/.
- malandrew 14y agoThose "improvements" really don't address what is wrong with the DOM. The problem with the DOM isn't that it could use a more consistent API with better interface naming. The DOM simply is a poor abstraction for applications. For example, it doesn't have a concurrency model and many modifications to the styling of individual elements or changes to the DOM structure can cause repaints and reflows.
- antidoh 14y agoI wish they had named it something else. typescript is the default output file name for script(1). http://www.unix.com/man-page/Linux/1/script/ http://www.unix.com/man-page/Linux/1/script/
- DigitalSea 14y agoI will admit MS have impressed me here. The fact they've released TypeScript under an Apache 2.0 licence and put the code up on CodePlex goes to show Microsoft are making strides in the open source community. A big change considering the mentality of MS used to be open source was unsafe and a threat to their dominance in the software industry. The world must be ending: Apple is starting to falter and Microsoft is climbing back to the top.
- Floopsy 14y ago(Wikipedia) “Some examples, like Dart, portend that JavaScript has fundamental flaws and to support these scenarios requires a ‘clean break’ from JavaScript in both syntax and runtime. We disagree with this point of view.” - Microsoft’s JavaScript team If Google comes out with Dart, well, then there's no need for that. But it's ok for Microsoft to be secretly working on their own Javascript 2.0. Just sayin' - Why criticize Dart when you've just come with almost the same thing? :) But snark aside, good job Microsoft. Well done.
- josephcooney 14y agoTreating Microsoft as a single, whole, coherent, consistent, and logical entity is the first mistake you make when trying to understand their actions and motivations.
- BrendanEich 14y agoAlso, no "JS will be replaced" threat, no proprietary native VM in IE-prototype to advantage it over other browsers running TypeScript compiled to JS. But I agree it is another case of two-faced behavior, not in the way you suggest. The IE blog post against Dart rejects a "clean break" and TypeScript builds on ES6. That's consistent. What is not consistent is how similar parts (but not all) of TypeScript are to ES4, which MS opposed vigorously. Time has passed and ES4 had its own problems, so bygones.
- luke_s 14y agoIt seems the analyser to infer the types of your vars is fairly easily fooled. The following code compiles, but prints out "Hello undefined": interface person{ firstname; lastname; } interface apple{ colour; } function hello(p : person){ alert("hello " + p.firstname); } var aPerson = {firstname: "joe", lastname : "blogs"}; var anApple = {color: "red"}; var foo; if(true){ foo = anApple; } hello(foo);
- wingspan 14y agoWhen you paste this into the Playground, and hover over the `var
- ilaksh 14y agoNot having to deal with types is one of the advantages of JavaScript. This actually makes it worse.
- dreamdu5t 14y agoThe lack of strong typing in JavaScript is a feature not a bug.
- pootch 14y agoMS has no credibility in this space. If you think slapping an OSS license on their code gives them cred you must be some kind of fanboy. As for Javascript - well, browsers still sucks, webapps still suck, and web development still sucks. Javascript is a big part of that. 30%
- charlieok 14y agoSo they've set up a site for TypeScript but as far as I can tell, that site hasn't got a blog. With so many projects vying for attention, subscribing to a project's blog is my default way of keeping it in mind for later. If they post interesting updates, I'll be reminded later to come back and give it a closer look.
- dmorgan 14y agoOpen Source? Node.js? Github? Javascript cross-compiler? ES6 based? Type annotations? This is the first sign that they are "getting" 2012 developers and are back in the game with a vengeance. Hope it works. Dart is mid-nineties MS by comparison.
- drhowarddrfine 14y agoFrom the company that brought you Silverlight, JScript, VBScript, ActiveX.... Don't do this. Microsoft doesn't matter anymore.
- dogada 14y agoOne of the key TypeScript features is not only the fact that JavaScript program is TypeScript programs but also ability to add type annotations to existing javascript libraries without changing of their source code. For example, see port of Backbone's TodoMVC: http://typescript.codeplex.com/SourceControl/changeset/view/d397c54a55db#samples%2ftodomvc%2fjs%2ftodos.ts http://typescript.codeplex.com/SourceControl/changeset/view/...
- dogada 14y agoIMO Microsoft looks for web-developer loyalty because recent stupid policy of big monopoly drive them to zero share on web-browser market. The only remaining question: will IE10 support TypeScript or it will be added in IE11 only?
- deleted 14y ago[deleted]
- bbayer 14y agoyet another language compiled to javascript. What is the deal with the adding type system without doing runtime checks? Does it solve DOM manipulation complexity or it just solve code readability problem? Does it worth to learn new language constructs when you decide to begin low or middle scale projects?
- emillon 14y agoVery good idea. But note that these annotations are just hints : they are enforced only in simple cases : var x = "lol" - error found : http://pastebin.com/R1wqp0CS http://pastebin.com/R1wqp0CS var x; x = "lol" - accepted : http://pastebin.com/0vc68RbY http://pastebin.com/0vc68RbY
- Andi 14y agoFor stuff like this, you use schema.js.