4 ms·
There is nothing wrong with using Scala as a better Java. Indeed that's what I recommend to Scala beginners with a background in OO. That's the beauty of multi-
by mafribe 11y ago
There is nothing wrong with using Scala as a better Java. Indeed that's what I recommend to Scala beginners with a background in OO. That's the beauty of multi-paradigm languages: pick and choose the language subset that works for you.
Indeed I often program in a way that could be called "locally stateful, globally pure-functional". It's a good approach!
- krisajenkins 11y ago"locally stateful, globally pure-functional" Can you expand on that, please? Because it seems to me that state fulness propagates up through the system. I can't imagine a system that was pure in the large but side-effecting in the small. I'd be interested to hear how that works...
- dragonwriter 11y agoOne way is to use local mutable state within functions that are implemented so as to be not rely on external state, which are then indistinguishable to calling code from pure functions.
- mafribe 11y agoYes, that's what I had in mind. If only there was an effect system that could guarantee purity and at the same time not be in the way (i.e. allow full or Scala-like type inference). Then purity would be guaranteed by types, like it is in Haskell. (N.B. I'm not asking for Haskell's purity by default. I advocate impure as default, with a type guarantting purity.)