3 ms·
So now two popular dynamic languages have type hinting of a kind: Python (unenforced annotations) and PHP (declarations). Great!
by TazeTSchnitzel 11y ago
So now two popular dynamic languages have type hinting of a kind: Python (unenforced annotations) and PHP (declarations). Great!
- gaius 11y agoI encourage all use of the type system to ensure program correctness, but once you've had Hindley-Milner inference, it's hard to muddle along with something like this.
- TazeTSchnitzel 11y agoIt really is. Since using Haskell, the type systems in the mainstream languages I've used have seemed sorely lacking.
- Dewie3 11y agoThough make the type system sufficiently more expressive than Haskell's and you have to give up on type inference again... Though maybe you could restrict how expressive the type system is on something like a module (Haskell module) level, so that you can have type inference if you give up on some power? I don't know.
- Kutta 11y agoType inference doesn't somehow fail if we go beyond Haskell's type system. The inferable subset of the language remains inferable. Haskell already has inferable (Hindley-Milner) and uninferable (higher-rank polymorphism, GADTs) parts. If we go beyond Haskell's type system, it actually becomes crucial for productivity to have powerful type (and term) inference. Agda and Coq both have much more powerful inference than Haskell; it's just that don't bother with using it to realize Hindley-Milner-style annotation-free bindings, because there's little use for it in proof assistants.
- gamegoblin 11y agoHaving used Haskell a lot, I still feel pretty fine about C++ or C# type systems. It's Java's that drives me absolutely insane. Type erasure makes me want to pull my hair out.
- the_af 11y agoI agree that Java is painful to use, but why is type erasure the annoyance that you need to single out? Haskell does type erasure as well.
- gamegoblin 11y agoSomething I find myself wanting to do occasionally, that you can do in C#, is instantiate a generic type with a default constructor. Like if I have a generic type T, I'd like to be able to do `new T()`.
- codygman 11y agoI feel like that comment is a little disingenous or at least needs a caveat after reading this[0]. I know that casts are almost never needed in Haskell code whereas I needed them in my last Android application (correct me if there's another way). 0: http://stackoverflow.com/questions/12468722/does-haskell-erase-types http://stackoverflow.com/questions/12468722/does-haskell-era...
- the_af 11y agoThat stackoverflow answer explains Haskell does type erasure. No, it doesn't work exactly the same as in Java, but nobody claimed it did. The OP claimed Java's type erasure annoyed him, while also claiming he had used Haskell a lot. I merely pointed out Haskell also erases types. I cannot advise you on your Android application without knowing what you're trying to accomplish.
- seanmcdirmid 11y agoYou can use both, actually. Type systems here days are more about type feedback (code completion, yeh!) than correctness (important, just not the central focus).
- chimeracoder 11y ago> So now two popular dynamic languages have type hinting of a kind: Python (unenforced annotations) and PHP (declarations). Great! Don't forget Javascript, via Typescript (which predates both Python and PHP's typechecking): http://www.typescriptlang.org/ http://www.typescriptlang.org/ Typescript is a strict superset of Javascript that compiles very transparently to the equivalent Javascript, so I think it's close enough to what Python3 does to be included here. The annotations are stripped out before runtime, but they are checked at compile-time for any errors that are possible to detect statically.
- wstrange 11y agoAnd Dart - which had optional types from the start.
- TazeTSchnitzel 11y agoTypeScript is a JS superset, though. It's not part of JS itself.