Earlier quoted context omitted.
My point exactly. If people who liked type systems could stand to use the JS type system (and I only barely managed to write type system without scare quotes), we wouldn't have TypeScript. Or Cofeescript. Or Purescript. Or Elm. Or Fable. Or Flow. Or even ES6.
What's wrong with TypeScript?
So you want to write a type checker (2014)
41–50 of 103 posts
Re: So you want to write a type checker (2014)
#42Earlier quoted context omitted.
Don't underestimate Typescript. Sure, it's somewhat restricted by the "superset of JS" property, but you still get stuff like ADTs with exhaustiveness checking.
TS doesn’t have exhaustiveness checking
Re: So you want to write a type checker (2014)
#43Venn diagram of people who are interested in type theory, and people who like Javascript... OO
Re: So you want to write a type checker (2014)
#44Earlier quoted context omitted.
My point exactly. If people who liked type systems could stand to use the JS type system (and I only barely managed to write type system without scare quotes), we wouldn't have TypeScript. Or Cofeescript. Or Purescript. Or Elm. Or Fable. Or Flow. Or even ES6.
maybe because browsers and backwards compatibility exist and we cant just change the language as we please?
...at least that's when i'm planning to finally learn frontend development
Re: So you want to write a type checker (2014)
#45Earlier quoted context omitted.
You might want to give this a look: https://github.com/Microsoft/TypeScript
TypeScript, the language which only just this month added a flag to turn off their completely incorrect subtyping rules for functions! A flag! I remember reporting this bug years ago, and they said it was "by design, since JS programmers prefer to think of functions as covariant in their input". Well, I prefer to think of 2+2 as equalling 5.
Re: So you want to write a type checker (2014)
#46Earlier quoted context omitted.
TypeScript, the language which only just this month added a flag to turn off their completely incorrect subtyping rules for functions! A flag! I remember reporting this bug years ago, and they said it was "by design, since JS programmers prefer to think of functions as covariant in their input". Well, I prefer to think of 2+2 as equalling 5.
I don't know nearly enough about type systems to understand this. Can you explain what subtyping rules are, and how TypeScript's are wrong? And can you explain what "covariant in their input" means?
Re: So you want to write a type checker (2014)
#47Earlier quoted context omitted.
TypeScript, the language which only just this month added a flag to turn off their completely incorrect subtyping rules for functions! A flag! I remember reporting this bug years ago, and they said it was "by design, since JS programmers prefer to think of functions as covariant in their input". Well, I prefer to think of 2+2 as equalling 5.
I don't know nearly enough about type systems to understand this. Can you explain what subtyping rules are, and how TypeScript's are wrong? And can you explain what "covariant in their input" means?
Contravariant: A variable needs to have a function that accepts Animals. You can't put a function that accepts only Cats, or it will crash on other kinds of animal. But you can put a function that accepts all LivingThings.
So when something is covariant you can use a more specific type, and when it's contravariant you can use a more generic type.
When it comes to function parameters, typescript lets you use either. You can replace any type with any related type, even if you're going in the wrong direction. They did this to make certain use cases simpler, at the cost of weaker typing.
Re: So you want to write a type checker (2014)
#48Earlier quoted context omitted.
literally :) EDIT: Oh, the hard earned karma is leaving me. :) I apologize for the irony! In a nicer way: if you're interested in type theory then javascript is not the language to look at. I'm not even sure if typescript helps here, since the typing mechanism is fairly simple (and I don't mean it's not useful -- just not very advanced).
Well, it's kind of like "if you're interested in type theory then bash will not arouse your intellectual curiosity." Sure, but it's still a practical and kind of necessary part of the world, and if you take it for what it is, it's pretty nice.
I.e yes, bash is nice, but if it weren't the default shell in most systems I wouldn't ever think about switching to it voluntarily, nor be interested in learning it. It is useful because its so widely spread.
Re: So you want to write a type checker (2014)
#49Re: So you want to write a type checker (2014)
#50From (2014) people!