3 ms·
Joe talked about this in Strange Loop 2014, and it seems to me that the idea is far less crazy than it seems. The more functional programming I do, the more sen
by hibikir 11y ago
Joe talked about this in Strange Loop 2014, and it seems to me that the idea is far less crazy than it seems. The more functional programming I do, the more sense it makes.
A major reason for modules in OO languages is to manage mutability: There's some hidden state, and some conventions surrounding that state, that the module tries to abstract away from us. But the price is very high: We have to make sure our executables are built with the right versions of modules, and avoid incompatibilities: What we know as dependency hell.
But why do we need dependency hell at all? For instance, in Scala, why do I have to do gymnastics to use a modern version of Shapeless along with spray-routing? Because the JVM is not happy with multiple, incompatible versions of shapeless in the same classloader.
Under Joe's plan, all of that disappears. It's just a question of how much we lose in exchange for sidestepping a problem like this. Given that any libraries I write nowadays tend to have just a few hundred lines of production code, I am very tempted.
- oleks 11y ago> Joe talked about this in Strange Loop 2014, and it seems to me that the idea is far less crazy than it seems. The more functional programming I do, the more sense it makes. Someone (sorry, don't remember who) also mentioned this at ICFP in 2012 wrt. Hackage, the Haskell community's package archive - that the better method of delivery is a function, not a library. This makes sense in the Haskell community where you have Hoogle (https://www.haskell.org/hoogle/ https://www.haskell.org/hoogle/) by your side.
- chriswarbo 11y agoModules serve a useful purpose in Haskell too, since they can hide "dangerous" functions, ie. ones which violate invariants (which can't/aren't enforced by types, for whatever reason) when called in particular ways. This is similar to private methods of a class. Personally, I dislike hiding such functions completely, and usually expose them via a ".Inner" module (similar to Python exposing "private" things with _underscores)
- moron4hire 11y ago>> A major reason for modules in OO languages is to manage mutability... Where did you get that idea from? That's pretty out there, even for OO.
- brownegg 11y agoDoes it not resonate? That line hit me like a ton of bricks. I'm almost an OO fanboy, but that is a _very_ good point.
- moron4hire 11y agoI'm not trying to be dense here, but I'm not really sure if you guys aren't trying to be dense, either. I don't know what assumptions we both lack in common. Are you guys just mixing up modules and classes?
- danarmak 11y agoThat problem exists because the JVM doesn't have a module system. If it did, then you could load two different versions of Shapeless and use them from different parts of the code without interference. Which some people simulate by using per-library classloaders.