Hacker News new | ask | show | jobs
by nailer 4743 days ago
I saw the original announcement of Typescript at JSconf EU last year. It was an interesting moment: everyone was expecting another Dart, or less (there's a sea of Macs and most professional JS devs experience of Microsoft is IE) but stayed to listen to the presentation out of respect for the creator, who also made Delphi and C#.

Pretty much everyone came out impressed. Typescript is just JS with type hints, and neat warnings if you send a function something which its signature doesn't expect.

You can make a JS project a Typescript one immediately, adding type hints as you go, which for large projects is damn useful. The output, however, is pure regular old JS.

It's just like a CSS preprocessor, but for JS - transparently adding some optional awesomeness.

It works on Linux/Mac and SublimeText (albeit you don't get all the VS Intellisense stuff IIRC) too. I'm looking forward to trying it on a new project.

5 comments

Typescript is in my peripheral vision so far but that really makes me want to look into it properly.

How do you think does it fit in with ES6? I feel like we're coming to a point in time where there should be a major shift in how we write javascript in a modern way -- so far my thought process has been that Coffescript is a nice stopgap before ES6 and the dust has almost settled enough to write ES6 first sorta..

Bit of a ramble. Interesting times.

TypeScript is far better suited than CoffeeScript if your goal is ES6. TypeScript currently outputs as ES3 or ES5 depending on a flag. ES6 to follow. It's very much up in the air with CoffeeScript.
ES6 is very important for them. For example, classes and modules in Typescript are essentially lifted directly from ES6, and they aim to remain compatible with ES6 as it evolves.
They are aiming to bring ES6 into today development so they looks into ES6 specs very often.
Yes, when the team is interviewed they consistently say that, where there is overlap, Typescript will adapt to follow ES6 standards once agreed upon.
I had no idea this was the baby of the Delphi/C# guy. I am super excited now.
There's a plugin for Adobe Brackets too.

https://github.com/tomsdev/brackets-typescript-code-intel

Still early

It seems to be very close to CoffeeScript, but without this ugly Ruby syntax (for me).
It's completely unrelated to CoffeeScript, as CS does practically no static analysis and generally CS does almost nothing more than pure JS. What it does is it translates some keywords to a chunks of JavaScript code. If JS had macros - sweet.js! - Coffee would be completely unneeded.

TypeScript is entirely different thing. It adds a layer of static analysis to the language, which does not end in the code that actually runs. Generally everything you type in Coffee has an equivalent in compiled JS; it is not so with TypeScript, where you can write pages of code which won't be visible in the compiled JS.

CS and TS have different goals and are different things, and the only thing they have in common is that they both "transpile"/compile some language to another. Hardly a similarity that makes them very close.

Actually I would appreciate TypeScript implementation on top of Coffee (or the other way around, whichever would be simpler). There is a dialect of CS that supports contracts (you really, really should start using contracts anyway), but that's yet another thing that cannot hope to replace static verification of certain things in programs.

You're absolutely right. I'm an C# dev who switched to JavaScript stack and using TypeScript already for 5-6 months. It was just a first-look description for the TypeScript.

Btw, TypeScript also aiming to fix context problem so in callbacks 'this' keyword is always related to parent class.

`this` being dynamically bound is a feature, it's broken as intended. You can always `bind` a function to remedy this if it's a problem for you.
Why would it be a feature? It is almost never the desired outcome, thus a terrible default.
I disagree. 1. Coffeescript is far from ugly, and also not particularly similar to Ruby :p 2. Typescript includes types and brackets. Coffeescript does not. 3. Icedcoffescript includes async/defer keywords. I include this last point only as a result of a personal perspective that if you're going to use coffeescript, you might as well use icedcoffeescript.
I'm sorry, I'm not a Ruby developer and hope never would :) From my prospect - all languages, which has no brackets are ugly and simular to ruby.

Btw, based on typescript discussions, they are going to implement async/await functionality too.

It's all what you're used to reading. If all you've been staring at are various curly-brace languages then of course you're going to prefer that.

I was primarily a curly-brace developer for 10 years, but changed my mind after a few years of Python, Ruby and Lua. Now I actually think these languages look better than the curly-brace family.

For me, the stereotypical CoffeeScript experience applies: Easy to write, hard to read.
async/await is on their roadmap, though I'd estimate about a year before it'll be in a stable version (I wouldn't be surprised if it'll be available on a feature branch much sooner, but with lower expectation of stability).
> It works on Linux/Mac and SublimeText

A programming language works with a text editor? Wow!

Nope.

It is running on Linux/Mac/Windows (node.js module).

And already has support in all major IDE (Visual Studio, IntelliJ) and text editors (Sublime, Emacs, ..)

FWIW, I've only tested emacs support. It's definitely sub-par. Barely indentation and syntax highlighting, we're still in need of a real typescript-mode for emacs.

I appreciate the effort, (I can't say the same for other Microsoft projects), but it's still not fun to play with typescript in emacs (as opposed to more mature projects like Python, C or, of course, Lisp).

Is there more than just syntax support in Sublime? I was pretty psyched when TypeScript was first announced but quickly bummed that the Sublime plugin didn't have any of the fancy autocomplete features.