Live data from Hacker News

TypeScript 0.9 – What’s Improved

flippinawesome.org

21–24 of 24 posts

Re: TypeScript 0.9 – What’s Improved

#21

Earlier quoted context omitted.

I like Typescript too, but this is a little over the top. Typescript's typing is nowhere near as expressive as Haskell's is (nor was it ever intended to be). I think of it more as a nicer way of doing Closure Compiler-like annotations plus you get a built in transpiler for many of the handier es6 features. edit: oh, and tooling, but I'm not normally on Windows for development so I haven't played much with the Visual…

Typing isn't just about catching type errors, but about semantic feedback useful for tooling. Unless you are using Haskell, then its just about catching type errors.

That's really unfair to Haskell. What are things like Hoogle if not tools, uniquely[1] enabled by Haskell's type system? All the basic IDE-like frills exist too, if you really want them. And now, with the advent of deferred type errors and holes, Haskell's type system is getting even more interactive. The process is quickly moving from writing code and running it through a compiler to having an ongoing conversation with the typechecker as you build up your program.

More importantly, types can go well beyond catching errors or tooling. Types can actually make your code more expressive and they can push your design forwards.

For the first, the simplest example is with Haskell's typeclasses: you can't easily write something like Show or have something like Haskell's flexible numeric literals without types. This allows you to grow[1] Haskell in ways that are even difficult in Lisp! For a more practical standpoint, I've found certain libraries to be much harder to reproduce without typeclasses, most crucially QuickCheck.

The second idea is slightly more abstract. As somebody else put it, types are like gravity sources: we place them strategically in our design space, and the rest of the code falls towards them. More concretely, coming up with the types to represent some domain often really helps in writing the code for it. Sometimes, once you've got the general framework of the types, the actual programming just feels like systematically filling in the blanks. More generally, the effect is nowhere near that pronounced, but the types do help shape everything else. In a sense, types help you constrain the set of possible programs at the outset, giving you fewer options to consider as you go along.

Oh, and I guess there's the performance thing. This includes both low-level optimizations (C++ or even C-style stuff) and high-level ones (like rewrite rules). Optional type systems seem to give up on these as a matter of principle. I don't believe static types are strictly necessary for good performance, but empirically they seem to help. Most languages with really good compilers are statically typed.

I think the idea that types just exist to catch type errors is one of the most unfortunate common misunderstandings about type systems. It really scares people away before they can learn about all the other benefits a good type system confers.

[1]: Okay, not really uniquely, but it's close. I've seen Hoogle-like tools for OCaml but not for Java or C++, much less something like Python. I'm not sure how useful or general they could be for other languages.

[2]: Easily my favorite CS talk: http://www.youtube.com/watch?v=_ahvzDzKdB0

Re: TypeScript 0.9 – What’s Improved

#22
post #21

Earlier quoted context omitted.

Typing isn't just about catching type errors, but about semantic feedback useful for tooling. Unless you are using Haskell, then its just about catching type errors.

That's really unfair to Haskell. What are things like Hoogle if not tools, uniquely[1] enabled by Haskell 's type system? All the basic IDE-like frills exist too, if you really want them. And now, with the advent of deferred type errors and holes, Haskell's type system is getting even more interactive. The process is quickly moving from writing code and running it through a compiler to having an ongoing conversation…

I saw Growing a Language in person in 1999 (he redid the talk during Utah's yearly Organick lecture). As for your arguments about Haskell, I find this very useful; thanks for the reply. I am quite interested in type systems for tool purposes, and grocking whether even code completion is possible for Haskell is quite a chore. Hoogle is exactly the tool I'm competing with :)

Re: TypeScript 0.9 – What’s Improved

#23
post #17
post #4

Regarding noImplicitAny, I find the choice of a compiler option rather than source code markup (like "user strict") rather odd. Granted there's no standard way to do that, but still...

why? compilers for other languages has compile time switches for various checks and/or optimizations, there it is assumed normal. Javascript's "use strict" is just a hack for lack such option. This has some benefits, i.e. you take some codebase that must compile with noImplicitAny and want to add some features, you start with less strict typing (implicit any allowed), when finished you compile with different flag. Be…

My understanding was that NoImplicitAny changes the rules of the language, so its use will make it harder to move code from projects that rely on it to projects that don't. Traditional compilers opt for a rich set of warnings and the ability to turn any warning into error. On closer inspection, it seems that code developed with NoImplicityAny should work 100% on projects without that, so my concern was unwarranted.
Post reply on HN