Live data from Hacker News

So you want to write a type checker (2014)

languagengine.co

51–60 of 103 posts

Re: So you want to write a type checker (2014)

#51
post #48
post #26

Earlier quoted context omitted.

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 can't really agree with you. Yes, javascript is "good for what it is", but this kind of positive evaluation is only the result of that it (the language) pretty much can't be avoided when doing web development. Many things appear in a more positive light if they have been around you long enough, and you've gotten use to the experience. I.e yes, bash is nice, but if it weren't the default shell in most systems I woul…

The reasons why people accuse JavaScript of being a terrible hack just never really resonated with me.

The "wat" video is funny, but that stuff just isn't a problem in my experience. Sure, I've been confused by "array.map(parseInt)" and other oddities, but overall, I think weird semantic edge cases are mostly an easy thing to nitpick about.

So as I see it, JavaScript is a nice little language with good syntax for literals (JSON, which conquered the world), a familiar brace notation, first class functions, high quality implementations, etc.

Bash's oddities are weirder, but it's also a fun and extremely useful language, and I like it a lot. Many of my coding and administration tasks involve calling programs, running background processes, piping streams around, making temporary files, globbing, etc etc, and shell scripting is still unsurpassed in convenience for these things.

Re: So you want to write a type checker (2014)

#52

Earlier quoted context omitted.

It was a bit tounge in cheek. Considering that half the languages and typecheckers invented in the last decade were invented simply because the JS type system isn't what it should. Coffeescript, TypeScript, Fable, PureScript (And countless others).

These languages exist because: - people want to target browsers - everyone’s idea of a perfect language is different - javascript is the only viable compilation/transpilation target Even if Javascript had the combined typing capabilities of Haskell, Agda, and Coq, there would still be people inventing/porting other languages to support client-side web development

There would exist some languages that compile to javascript. But look at typescript specifically. Its compilation stage is mostly "remove the type annotations, so the browser doesn't get confused". The lack of typing is so bad that notable languages get made just to tackle that single issue.

Re: So you want to write a type checker (2014)

#53
post #4

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

Design decisions like this are part of what makes TypeScript much more enjoyable to work in than other JS type systems (e.g. Closure, Flow).

TS tends to make pragmatic tradeoffs between sound typing, and the way JS developers tend to architect code. I'm glad they do.

Re: So you want to write a type checker (2014)

#54

Earlier quoted context omitted.

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?

Covariant: A variable needs to have an Animal. You can put a Cat in the variable. 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 gen…

That helps, thanks.

Can you explain the naming? What sort of variance is the second case contra?

Re: So you want to write a type checker (2014)

#56
post #33

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.

Why is everyone forgetting Scala.js?

They always do. I think people want to complain about things and still not actually try nicer alternatives.

Re: So you want to write a type checker (2014)

#57
post #33

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.

Why is everyone forgetting Scala.js?

Or Kotlin: https://kotlinlang.org/docs/reference/js-overview.html

Re: So you want to write a type checker (2014)

#58

Earlier quoted context omitted.

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?

Covariant: A variable needs to have an Animal. You can put a Cat in the variable. 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 gen…

Which use cases are those?? Are any of them actually real life, practical use cases?

Re: So you want to write a type checker (2014)

#59
post #51
post #48

Earlier quoted context omitted.

I can't really agree with you. Yes, javascript is "good for what it is", but this kind of positive evaluation is only the result of that it (the language) pretty much can't be avoided when doing web development. Many things appear in a more positive light if they have been around you long enough, and you've gotten use to the experience. I.e yes, bash is nice, but if it weren't the default shell in most systems I woul…

The reasons why people accuse JavaScript of being a terrible hack just never really resonated with me. The "wat" video is funny, but that stuff just isn't a problem in my experience. Sure, I've been confused by "array.map(parseInt)" and other oddities, but overall, I think weird semantic edge cases are mostly an easy thing to nitpick about. So as I see it, JavaScript is a nice little language with good syntax for lit…

I don't think js it's a hack. Yes, in the beginning there were some strange things, like objects based on prototype, referring to this, and probably more. Much of this has been worked on, and fixed (unfortunately-but-understandably keeping the old behaviors as well).

But nowdays there are many who want more-- they want types --and not only simple types, but some advanced type system. This is where it's hard to see the intersection of js "likers" and type theory "likers" -- they must have really different reasons for liking these things.

As for where the criticism towards js probably stems from is the lack of freedom -- it's the only language that runs in browser. On the server people are free to choose what to use. And yes, you can now compile other languages to js too, but reaching an agreement to use such a setup can be challenging in many workplaces.

Re: So you want to write a type checker (2014)

#60

Earlier quoted context omitted.

I understand your point, it's simply wrong. If those people didn't want to use javascript, they could have migrated to something else altogether. Clojurescript, Elm, Dart, RustJs, ... Instead they kept Javascript with a type system on the top (typescript, purescript, flow, ...).

Some are supersets of JS, some are not. Elm, Fable, etc are examples of languages not just extensions. The reason for using an extension/superset is usually not because JS is terrific but because gradual/partial migration and interop are more important than a better language.

Before anyone points it out: Fable isn't a lanugage, it's an F#->JS compiler. It's "programming JS without programming in JS" though, so it's another language used in that sense.
Post reply on HN