3 ms·
Mh, I have to say, this is far less impressive if you think in interfaces everywhere (or haskells type classes everywhere)... This is just something like: inte
by tetha 17y ago
Mh, I have to say, this is far less impressive if you think in interfaces everywhere (or haskells type classes everywhere)... This is just something like:
interface TypeConstructor<T,V> {
T buildType(V value);
}
List<TypeConstructor<T,V>>;
or something like this.
- natrius 17y agoIs this a joke? That's nowhere near as simple.
- silentbicycle 17y agoHaskell is making explicit (and inferring - you don't need to type it!) what Python implicitly assumes will probably work, but checking whether it's actually correct. The terminology is math-y to the point of exclusiveness because of Haskell's close association with academia* , but there's a point after which it's simpler to make the compiler check than to rewrite the same kinds of tests over and over and over. Type systems are for expressing your requirements in a way that the compiler can do the tests once, at compile time. Computers are good at automating tedious and repetitive work, y'know? It's too bad most of the people discussing how these things work seem hell-bent on using Greek letters and other insular terminology for everything. Static typing is kind of a wash for smaller projects (I'd just use Lua or Python for something that will only be a few pages of code), but once you start worrying about maintenance or testing changing interfaces between modules, the immediate feedback from a good static type system really comes in handy. OCaml is a pretty great language, but has some major usability warts and not that much written about it in English. (And Haskell's "avoid success at all costs" motto is...telling.)
- natrius 17y agoYeah, I understand that, but the examples were supposed to be impressive in their simplicity. You can mix types in an array even in C, but the code you'd need to write to do so makes it unattractive. If the comment was "But you don't get any type checking" instead of "My language can do this too", then it'd make perfect sense.
- tetha 17y agoMy point was: Yes, you can cram differently typed values into the same array, but this won't make sense unless all elements in the array share a common interface to access them. If this is not the case, all the dynamicness is useless, because you cannot do anything with the elements inside the array. And once I arrived at this important realization, all the discussion of 'yay, I am SO dynamic' kind of fell over, because a lot of things reverted to the same principle of interfaces and programming to interfaces.