3 ms·
Grammar ends up becoming a problem on a few fronts. I highly recommend Principles of Compiler Design [1]. One safe rule of thumb is, as grammar and rules expa
by anon3_ 11y ago
Grammar ends up becoming a problem on a few fronts. I highly recommend Principles of Compiler Design [1].
One safe rule of thumb is, as grammar and rules expand, the performance and simplicity of the compiler begin to deteriorate, particularly if features aren't added carefully.
The second is in practice, the additional grammar gives you far more ways to tackle the same problem. The is the conundrum that metaprogramming gives in languages like Ruby. Teams begin the phase of coding to the domain before letting other things fall into place.
Thinking ahead is good, but I think the issue is Scala's grammatical flexibility makes it too tempting to dig ourselves into a DSL before we're really ready. This is why we'd get so grumpy when PM's came to us asking for new features that'd require a refactor. We bought in to our own idioms, if we programmed things without the DSL, we'd be more nimble.
And we're not dumbasses. We're experienced programmers with experience programming in that domain before, but the target always ends up moving for reason's outside of engineering's control. From experience we know, DSL has no place until you're very secure in what the needs of the business is.
That said, no codebase is future proof to the rest of the team needing last minute changes - but I feel scala forces you into design decisions too early, and we thought that was an advantage.
Actually, I liked scala for not having Java's boilerplate. Then I began to miss those old things java forced you into.
It was painful, because the ego investment the team had in scala was huge. A lot was on the line. Crow had to be eaten.
[1] http://en.wikipedia.org/wiki/Principles_of_Compiler_Design http://en.wikipedia.org/wiki/Principles_of_Compiler_Design
- thescrewdriver 11y agoIt's worth pointing out that it's a case of YMMV. There are clearly those who haven't had success adopting Scala. I've seen Scala used successfully by multiple teams, but I suspect a strong culture of code reviews may have been a significant factor in our successful adoption of Scala. I would be disappointed if they tried to remove features from Scala, the extra features really do come in useful when used selectively.
- anon3_ 11y agoIf a good team nails the guidelines down before hand on which idioms they plan to use and stick to them, yeah. That is a rare qualifier to meet in my experience, many teams will be ecstatic about scala. Many times we'd be hiring java programmers who felt that scala would make them more relevant in the startup world. Next is the situation where it would be, "Just hold keep holding on..." until a. the language finally clicks b. the whole system is in scala. c. Both. Scala did just click. And there never was a best solution to solve a problem. Python programmers were canned, we had the floor - those "distractions" were eliminated. We just got in this vicious cycle while we burned away our runway. Now we look back, bitter, and make excuses. What hurts my pride to say is, Why didn't we just pick the safe bet - the Python or the Java. I upvoted you. If you got a smart team and can make scala work somehow, all the power to you. I think you should make a story about how you scaled your code so the rest of us can learn
- tormeh 11y agoI think this confirms the importance of a language restricting your choices, not only for type safety, but also for architectural soundness. Actually, it sounds like your team needed Go.
- zak_mc_kracken 11y ago> If a good team nails the guidelines down before hand on which idioms they plan to use and stick to them, yeah. So, like we used to do with C++? Anyone old enough to remember "C++ is fine as long as you define a well specified subset and stay away from certain features"? Even today, this is still what Google does about C++. Hopefully we learned that this is never a good sign about a language.
- thescrewdriver 11y agoIn our case it wasn't about enforcing the use of a subset of the language, but rather being selective about when to use more advanced features. Having the advanced features of Scala available has proven to be very useful for us, but we don't go to town looking for a place to use every feature we can at every opportunity. It's a lot like chrome on a car - selectively and tastefully used it looks good, but making the car doors and roof out of chrome isn't a good idea.
- tormeh 11y agoYeah, you're given enough architectural rope to hang yourself with. That said, why make a DSL? It's very very rarely a good idea, says I, an armchair architect. I use Scala like Java with pattern matching, immutables and map/fold/filter. Works well so far.
- yummyfajitas 11y agoI've found that DSLs which are well supported by theory tend to nearly always be a good idea. For example, Spire's mathematical data structures (group, ring, field, boolean algebra) tend to be useful, as are Scalaz's monad/monoid/applicative. One which I haven't seen out there in the world, but turned out to be a fantastically useful, is the Free Boolean algebra. It's a functor FreeBool[_] which is also a boolean algebra. It's Free because it has the property that for any function f: T => U, U a boolean algebra, there is a natural transformation nat(f): FreeBool[T] => U which is also a homomorphism (nat(f)(x & y) = nat(f)(x) & nat(f)(y), etc). Even though things were not actually pinned down (and still aren't), I'm confident this is a good choice - thousands of mathematicians are very rarely wrong.