I hate Scala


  • Banned

    I liked Scala two months ago. Then I've got a new job, which made me actually use Scala for the first time.

    My biggest annoyances, in random order:

    • sbt config and sbt shell have totally different syntax, both being completely undiscoverable. It took me a month to figure out how to compile tests without executing. I can't comprehend why test and testOnly are separate commands. Also, good luck figuring out what the latter does without looking it up.

    • Want to execute shell command and get exit code? No problem - just "command"!. Want to execute command and get output? No problem - "command"!!. Want to get exit code AND output? Sucks to be you!

    • Sum types, the most basic feature of functional languages, are implemented by this terrible hack of sealed inheritance hierarchy. They even added special syntax to make writing ad-hoc sealed inheritance hierarchies easier to write and use!

    • Most of the methods that make collections useful are defined on Seq trait. One of the most used methods ever, String.split(), returns Array. Array doesn't implement Seq. But it has the method toSeq() which turns it into Seq. It also has the method seq() that does the same thing, but doesn't work.

    • Of all languages with more than 100,000 users, Scala documentation is absolutely the worst.

    • The _ notation for lambdas is amazing, unless it doesn't work. And whether it works or not is seemingly random.

    • Organizing tests is absolute hell. The most basic thing imaginable, preparing environment before any tests are run, took me three daysof googling to set up. By doing so, I've probably lost the ability to run individual tests, although I haven't tested it yet. Also, I now have to remember to manually add every new testsuite to the list of testsuites that reauire environment preparation.

    I'll add more shit when I encounter it.


  • Considered Harmful

    @gąska Scala is a language designed for those who already know how to use it. Sometimes it seems like the documentation is too.



  • @gąska It reinforces my skepticism about tech lots of people claim is the greatest thing ever on the internet, yet it isn't popular. There is always a reason it isn't being adopted quickly.


  • Banned

    @sockpuppet7 I'm more wary of the "best techs ever" that DO become popular. Java, Python, JavaScript and its frameworks, C++, and - yes, Scala. It becomes increasingly popular, as a "better Java, but still Java".


  • Considered Harmful

    @gąska Kotlin is the 'better Java but still Java'. Scala is 'kitchen sink, and to accommodate those people who like having both knobs labeled C we've put three knobs on it.'



  • You sound like that guy ranting about PHP.

    Found it: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/



  • @sockpuppet7 said in I hate Scala:

    It reinforces my skepticism about tech lots of people claim is the greatest thing ever on the internet, yet it isn't popular. There is always a reason it isn't being adopted quickly.

    Scala's in the same bucket as the LISP people, but since it's built on the JVM it's slightly (slightly) more mainstream. But still way more hipster than mainstream.

    This point:

    Want to execute shell command and get exit code? No problem - just "command"!. Want to execute command and get output? No problem - "command"!!. Want to get exit code AND output? Sucks to be you!

    Amazes me.

    @gąska said in I hate Scala:

    It becomes increasingly popular, as a "better Java, but still Java".

    Right; but it's only "better" if you consider the LISP-y stuff better than traditional programming.


  • Banned

    @blakeyrat functional programming is better than traditional programming. And not just in feel-good sense - it has lots of very real, very practical benefits. There's a reason why every major language gets more and more functional features.



  • @gąska said in I hate Scala:

    Want to execute shell command and get exit code? No problem - just "command"!. Want to execute command and get output? No problem - "command"!!. Want to get exit code AND output? Sucks to be you!

    "command"⁉


  • Banned

    Did I mention that the !! only captures stdout? Also, if the process doesn't exit with status 0, the !! throws empty exception, leaving you with neither stdout, stderr nor exit code. Have fun figuring out the cause!

    And if you step in with debugger, you'll notice that the inner function indeed has access to all three - it just doesn't pass them to the outside world. And the inner inner function they used as a base for both ! and !! is private.



  • 11 years later, I'm still loving Haskell.

    filed under: I'm not smug, just right



  • @gąska said in I hate Scala:

    functional programming is better than traditional programming.

    Like everything, it's better at some things and worse than others. No silver bullet.


  • Banned

    @blakeyrat but it's a better default. A much better default.



  • @gąska said in I hate Scala:

    @blakeyrat but it's a better default. A much better default.

    We'll have to agree to disagree. I find it inpenetrable, with tons of terminology I don't know and am shaky on.

    I'll agree to this: perhaps, once you could expect the average software developer to have a good fundamental knowledge of it, functional programming is superior at solving most software problems.

    That's as far as I go. In the current world of 2018, where you can't expect any random developer off the street to know anything about functional programming, it's obviously inferior in a lot of basic ways.


  • Considered Harmful

    @gąska said in I hate Scala:

    @blakeyrat functional programming is better than traditional programming.

    :pendant: From a 21st century perspective the amount of "tradition" in FORTRAN and LISP looks rather equal.


  • Java Dev

    @gąska said in I hate Scala:

    @blakeyrat but it's a better default. A much better default.

    For, say, a GUI application?


  • Trolleybus Mechanic

    I've been using Scala the last couple years and like it a lot. Especially compared to Java. But then again almost any JVM language is better than Java. At work we have Clojure people but I can't just get myself to like LISP.

    For the shell exec problem, you can still use the standard Java way which would allow you to do both.

    Over time you learn which shiny Scala bits are good and which you should avoid. For instance, I don't think I've ever written my own code that cares about implicits (ie. magic) unless my code was feeding into other code that cared (ex. wrapper around json4s). Unless there was some reason that explicitly needed to use the feature, I'd probably consider using it in our code a "bug".

    I agree about the "_" implicit var in lambdas. I wouldn't mind it not working sometimes as long as I knew the rules. So far the rule seems to be "it won't work if the lambda isn't trivial...probably". For instance I've never had the same problem with the implicit "it" lambda var used by groovy and kotlin.

    One thing that really irritates me is Scala's lack of "break". There's a library you can pull in that mimics it by throwing exceptions. If your try/catch isn't quite right you can actually break the break. Sometimes I do only want to process the first X items after meeting some condition. I don't want to process all 1000 (or whatever) and then filter down to X.

    I like Scala's ability to mix OO and functional. The more I've done Scala, the more functional I've been writing my code as I learn new tricks.

    With some recent stuff I've been doing, I appreciate that they added the ClassTag/TypeTag (replacing Manifests) subsystem which allows reflection that gets around generics type erasure.


  • Trolleybus Mechanic

    At work we use gradle to build our scala since it's what we use to build our java and groovy code too. It has always seemed odd to me that many of the JVM languages seem to have their own build system written in their language. Why does scala have sbt? You could maybe argue gradle is the same for groovy except it's kind of the main build tool these days on the JVM for not just groovy. I've used it for kotlin which I think is where gradle is moving for scripting. Clojure has its own. I also don't know the relative ages of these build tools, which is probably a large part of the story.

    Maybe I'm the oddball, but I don't really want my build scripts to look like my application. I guess I want it to look like a build file. Gradle seems like a nice balance and has a nice set of plugins that give it broad language support. Maybe these other tools have it too.


  • Impossible Mission - B

    @mikehurley said in I hate Scala:

    Maybe I'm the oddball, but I don't really want my build scripts to look like my application. I guess I want it to look like a build file.

    I think you are the oddball in this case. Builds are a non-trivial process, and they frequently end up with enough complexity that you end up really wanting a scripting language, rather than a simple declarative "build file," to handle the edge cases.



  • @masonwheeler said in I hate Scala:

    I think you are the oddball in this case. Builds are a non-trivial process, and they frequently end up with enough complexity that you end up really wanting a scripting language, rather than a simple declarative "build file," to handle the edge cases.

    I'm perfectly happy with the XML-based format MSBuild uses. Sure it's verbose, but I've never need to do something it doesn't handle easily.


  • Trolleybus Mechanic

    @blakeyrat said in I hate Scala:

    @masonwheeler said in I hate Scala:

    I think you are the oddball in this case. Builds are a non-trivial process, and they frequently end up with enough complexity that you end up really wanting a scripting language, rather than a simple declarative "build file," to handle the edge cases.

    I'm perfectly happy with the XML-based format MSBuild uses. Sure it's verbose, but I've never need to do something it doesn't handle easily.

    I didn't say I didn't want scripting in my build file. Technically a gradle script is just a groovy script with some implicit variables being referenced (ex. a dependencies { } block is called against the Project object). I've written in-script groovy code and custom plugins. I understand the value of scripting in build files.

    I'm saying I don't understand why many JVM languages felt the need to make their own instead of just having an official plugin/module for gradle or for whatever existed before gradle. Also like I said, I'm sure part of the reason is timing of different languages and projects being created.

    I don't need/want my scala app's build file to be scala. And something else for java. Etc. I'd like all my build scripts to look the same across all codebases.


  • Trolleybus Mechanic

    @blakeyrat said in I hate Scala:

    @masonwheeler said in I hate Scala:

    I think you are the oddball in this case. Builds are a non-trivial process, and they frequently end up with enough complexity that you end up really wanting a scripting language, rather than a simple declarative "build file," to handle the edge cases.

    I'm perfectly happy with the XML-based format MSBuild uses. Sure it's verbose, but I've never need to do something it doesn't handle easily.

    I actually like this aspect of building on .NET. Like you said, it's verbose, but it's consistent across .NET languages.


  • Banned

    @blakeyrat said in I hate Scala:

    I'll agree to this: perhaps, once you could expect the average software developer to have a good fundamental knowledge of it, functional programming is superior at solving most software problems.

    Most software developers graduate universities. One of the courses that are always taught to CS majors in every college is functional programming in at least one language. We are literally doing what you say we should do, and have been doing it for years already!


  • Banned

    @pleegwat said in I hate Scala:

    @gąska said in I hate Scala:

    @blakeyrat but it's a better default. A much better default.

    For, say, a GUI application?

    GUI is special in that it doesn't depend on a language as much as on particular GUI framework. But a framework made in functional style would be much nicer than an equivalent stateful GUI. It would be even better with fully declarative language!


  • Trolleybus Mechanic

    @gąska said in I hate Scala:

    @blakeyrat said in I hate Scala:

    I'll agree to this: perhaps, once you could expect the average software developer to have a good fundamental knowledge of it, functional programming is superior at solving most software problems.

    Most software developers graduate universities. One of the courses that are always taught to CS majors in every college is functional programming in at least one language. We are literally doing what you say we should do, and have been doing it for years already!

    I'm sure it's changed since I graduated in 2005, but I only had a semester of functional languages in my school's "overview of programming languages" course. Most projects were done in ML (which I kind of liked) as well as a smattering of other stuff (prolog being the weirdo). Other than that, I had zero exposure to functional programming.

    Overall I hope our field moves more towards functional programming, but it's going to take a while.



  • @gąska said in I hate Scala:

    Most software developers graduate universities. One of the courses that are always taught to CS majors in every college is functional programming in at least one language. We are literally doing what you say we should do, and have been doing it for years already!

    Maybe but I am an old dog and also mostly self-taught. (I attended Computer Science courses at a university, but they were all utterly useless for actual day-to-day work at that time.)


  • Banned

    @mikehurley said in I hate Scala:

    I only had a semester of functional languages in my school's "overview of programming languages" course.

    That's enough to teach the basic principles.


  • Discourse touched me in a no-no place

    @blakeyrat said in I hate Scala:

    Scala's in the same bucket as the LISP people

    That's Clojure. Scala is the one with the crazy type rules.

    But still way more hipster than mainstream.

    QFT


  • BINNED

    @gąska said in I hate Scala:

    GUI is special in that it doesn't depend on a language as much as on particular GUI framework. But a framework made in functional style would be much nicer than an equivalent stateful GUI. It would be even better with fully declarative language!

    I've learned some ML back then in the CS101 course. Unlike Java, which felt utterly boring, it was conceptually completely new to me and I thought it was a quite exciting concept. But aside from the lecture exercises, I never got to use it in any real world programming.

    "It's all functional, free of side effects, that's awesome". At some point you start asking yourself how you'd actually use that, since side effects are the whole point of why you run a program. Years later, I hear the Haskell people's answer to that is "you do it in the IO monad". Um, what, come again? Now, of course, you'll tell me that it's a super simple concept, but it's funny that this guy termed that the "Monad tutorial fallacy".

    I'm sure I would understand it if I actually used it in practice and gained some experience, so far I haven't. I have used the functional programming concepts which are increasingly integrated into other languages, and they're generally really nice. Mixing paradigms is sweet, but a purely functional language still seems awkward. Isn't a GUI inherently stateful?!


  • Discourse touched me in a no-no place

    @mikehurley said in I hate Scala:

    I don't understand why many JVM languages felt the need to make their own

    Because they were bitten by an XML file and it scared them; that's why they don't use Maven (which continues to work really well even with obnoxiously complex builds). Also, nobody sane uses Java as a scripting language itself (I've used Beanshell, and it is not a sane environment) so those languages insist on using something else. Since Java is probably the only JVM language that JVM programmers all understand, they don't use each others' scripted build environments and instead reinvent the wheel. Again.

    I'm still happy with writing a Maven pom.xml. I've got really good tooling to help with that, including debugging inconsistent package versions and other annoyances that crop up once the dependency graph gets really large.


  • Considered Harmful

    @masonwheeler said in I hate Scala:

    @mikehurley said in I hate Scala:

    Maybe I'm the oddball, but I don't really want my build scripts to look like my application. I guess I want it to look like a build file.

    I think you are the oddball in this case. Builds are a non-trivial process, and they frequently end up with enough complexity that you end up really wanting a scripting language, rather than a simple declarative "build file," to handle the edge cases.

    That wasn't the question. It's not that the build file looks like a script, it's that the specific script language is the same as the language it's building. sbt builds Scala and uses Scala scripting, Leiningen builds Clojure and uses Clojure scripting, etc. I see no reason to use anything other than Gradle.


  • Discourse touched me in a no-no place

    @topspin said in I hate Scala:

    But aside from the lecture exercises, I never got to use [ML] in any real world programming.

    Once you get into real-world programming, you do a lot more opaque and partially-opaque types; it turns out that having very exact control over equality and what details are visible of a type are rather more important than you think when you're taking CS101. ML does have the tools to do this (it was actually a tool for solving practical problems before it became a teaching language) but they're not taught to beginners.


  • Trolleybus Mechanic

    @pie_flavor said in I hate Scala:

    @masonwheeler said in I hate Scala:

    @mikehurley said in I hate Scala:

    Maybe I'm the oddball, but I don't really want my build scripts to look like my application. I guess I want it to look like a build file.

    I think you are the oddball in this case. Builds are a non-trivial process, and they frequently end up with enough complexity that you end up really wanting a scripting language, rather than a simple declarative "build file," to handle the edge cases.

    That wasn't the question. It's not that the build file looks like a script, it's that the specific script language is the same as the language it's building. sbt builds Scala and uses Scala scripting, Leiningen builds Clojure and uses Clojure scripting, etc. I see no reason to use anything other than Gradle.

    You got it. Looks like you replied before finishing the thread :face_with_stuck-out_tongue: . I gave a similar summary a bit further down.


  • BINNED

    @dkf As I said, it's not that I've never used any tools from functional programming in other languages. They're quite useful. Just never used a purely functional language.


  • Trolleybus Mechanic

    @dkf said in I hate Scala:

    @mikehurley said in I hate Scala:

    I don't understand why many JVM languages felt the need to make their own

    Because they were bitten by an XML file and it scared them; that's why they don't use Maven (which continues to work really well even with obnoxiously complex builds). Also, nobody sane uses Java as a scripting language itself (I've used Beanshell, and it is not a sane environment) so those languages insist on using something else. Since Java is probably the only JVM language that JVM programmers all understand, they don't use each others' scripted build environments and instead reinvent the wheel. Again.

    I'm still happy with writing a Maven pom.xml. I've got really good tooling to help with that, including debugging inconsistent package versions and other annoyances that crop up once the dependency graph gets really large.

    I never used maven a lot but I didn't mind it. I do think having the ability to add script code to your build is useful and powerful. Maven doesn't feel bad to me, but it does seem limited in comparison to the modern build tools like gradle and I assume sbt and others.


  • Considered Harmful

    @mikehurley It's big, it's ugly, it's clunky, and it does exactly what you want. Some people would prefer this new streamlined thing that does it in fancier syntax but is less stable than XML. Others prefer the dependability and don't care about triple digit levels of XML nesting.


  • Banned

    @topspin said in I hate Scala:

    Just never used a purely functional language.

    Purely functional is impractical. But impure functional rocks.


  • Discourse touched me in a no-no place

    @topspin said in I hate Scala:

    Just never used a purely functional language.

    Ah, that's not ML either. It's got some quite reasonable imperative bits hidden inside.


  • Discourse touched me in a no-no place

    @mikehurley said in I hate Scala:

    it does seem limited in comparison to the modern build tools

    Hmm, I've never felt that. OTOH, I've seen a few builds done with other tools that were just awfully complex. It's not that you can't do complex things in builds, it's that they're virtually always a bad idea as they make the build harder to understand (and usually more fragile) without greatly improving anything at all. Purely declarative builds, for all that there's things they can't easily express, are the most comprehensible by other programmers; it's better to write slightly longer descriptions if those descriptions are significantly clearer.

    I've got an awful build at work. It's all makefiles (because this is building C for an embedded target) and those makefiles are full of inclusion of other makefiles in other projects that use complex macros to define non-trivial pattern rules that then do some serious compiler abuse. It's horrible and insanely tricky to debug or alter in any way, and almost anything you try just makes it worse. Part of the problem is that it's all written from the ground up to allow for insane code layouts Just In Case some idiot user decided to write something truly stupid. (A former employee of ours was someone who wrote all his code like that. Deleting that stuff with Extreme Prejudice has been one of my tasks over the past year, but the build system is still infected (or infested) with that sort of lunacy.) Anyway, I think that being boring and writing everything out properly is actually preferable; so what if it isn't exciting? If it doesn't make my brain want to go and hide under the desk in a gibbering heap, that's got to be an advantage…



  • @blakeyrat said in I hate Scala:

    where you can't expect any random developer off the street to know anything about functional programming

    I'd settle for "any random developer off the street" knowing anything about programming.


  • 🚽 Regular

    @mikehurley said in I hate Scala:

    Gradle

    Like automake but with all the bureaucracy of a major government nailed on.
    A bloody Android build takes about 10 minutes while the equivalent amount of C takes about 30 seconds to make. It's a build system, it only has to manage dependencies and config for the compiler/packager yet it has all the speed and grace of a snail on tranquilisers.



  • @gąska said in I hate Scala:

    @blakeyrat said in I hate Scala:

    I'll agree to this: perhaps, once you could expect the average software developer to have a good fundamental knowledge of it, functional programming is superior at solving most software problems.

    Most software developers graduate universities. One of the courses that are always taught to CS majors in every college is functional programming in at least one language. We are literally doing what you say we should do, and have been doing it for years already!

    Having taught people fresh out of uni to learn to program properly, I can say I have a rather dim view of what skill people fresh otu of uni have. Some people are fucking stellar freshly baked, most are not. Functional languages seem to be harder to grok, but once you get it they are really nice.
    that said, I am currently working with 5 developers that have explicitly said that stuff like lambdas and streams in java are too hard so they havent bothered learning it. Those kinds of developers will never be able to understand functional programming. I really don't think they even understand procedural programming, nor object oriented but rather mash codes together until it compiles and sorta does what the requirements say.


  • Banned

    @carnage said in I hate Scala:

    Having taught people fresh out of uni to learn to program properly, I can say I have a rather dim view of what skill people fresh otu of uni have.

    I know. I meant that if we expect them to code at all, we can totally expect them to code functional. It was in context of Blakey's statement that we as an industry shouldn't go full functional until we can expect average developer to code functional, and that as of 2018 an average developer can't be expected to code functional.


  • Banned

    @carnage said in I hate Scala:

    I am currently working with 5 developers that have explicitly said that stuff like lambdas and streams in java are too hard so they havent bothered learning it. Those kinds of developers will never be able to understand functional programming.

    Unless forced to. I assure you it's more about laziness and stubbornness than incomprehensibility. As long as we accomodate them, they won't accomodate us. I'm too young to remember specific events, but I'm sure our industry already had several "never will I ever" phases we got past through.


  • Banned

    What I hate Scala for today: variable is introduced in scope (and shadows other variables with the same name) before initialization. In other words, val x = foo(); val x = bar(x) doesn't work.


  • Banned

    What I hate Scala for today #2: Scala REPL doesn't have quit or exit command (or even help to tell you what you can do instead). As far as I know, the only way to terminate it is SIGINT (Ctrl+C). Of course Scala doesn't issue newline after it, so your shell prompt ends up on the same line as last line of output.



  • @gąska said in I hate Scala:

    @carnage said in I hate Scala:

    Having taught people fresh out of uni to learn to program properly, I can say I have a rather dim view of what skill people fresh otu of uni have.

    I know. I meant that if we expect them to code at all, we can totally expect them to code functional. It was in context of Blakey's statement that we as an industry shouldn't go full functional until we can expect average developer to code functional, and that as of 2018 an average developer can't be expected to code functional.

    Yeah, but if people can't learn simple stuff like lambdas, I doubt they can learn to do functional programming. Java is popular not because it's particularly good, but rather because it used to be overly simplistic (with the exception of the massive library that is) so it was easy to just derp away on a keyboard and stuff would work... ish...
    Not that I'd mind functional programming being a lot more pervasive, I like it. And if it would be a barrier for the worst crap devs, that's also a bonus in my opinion. :D But that does not seem to be what employers think.



  • @gąska said in I hate Scala:

    @carnage said in I hate Scala:

    I am currently working with 5 developers that have explicitly said that stuff like lambdas and streams in java are too hard so they havent bothered learning it. Those kinds of developers will never be able to understand functional programming.

    Unless forced to. I assure you it's more about laziness and stubbornness than incomprehensibility. As long as we accomodate them, they won't accomodate us. I'm too young to remember specific events, but I'm sure our industry already had several "never will I ever" phases we got past through.

    Yeah, we have. It's usually not clear cut, but rather a slow change from one thing to another so the ones that refuse to learn can cling to old code bases. There is still COBOL systems running for instance. The ones that fail to cling to old systems go to management and suck at that instead.



  • @gąska said in I hate Scala:

    What I hate Scala for today #2: Scala REPL doesn't have quit or exit command (or even help to tell you what you can do instead). As far as I know, the only way to terminate it is SIGINT (Ctrl+C). Of course Scala doesn't issue newline after it, so your shell prompt ends up on the same line as last line of output.

    It does have System.exit(0) but nobody tells you that


  • Fake News

    @gąska said in I hate Scala:

    What I hate Scala for today #2: Scala REPL doesn't have quit or exit command (or even help to tell you what you can do instead). As far as I know, the only way to terminate it is SIGINT (Ctrl+C). Of course Scala doesn't issue newline after it, so your shell prompt ends up on the same line as last line of output.

    From https://stackoverflow.com/a/23239004:

    :quit
    :q
    
    Ctrl + d // Unix
    Ctrl + z // Windows
    
    sys.exit
    

    How very intuitive! I guess Ctrl + c just kills the process and hence clutters your last line.

    Also, from https://stackoverflow.com/a/23232346:

    Additionally, exit was deprecated in 2.10.x with sys.exit suggested instead

    Because thinking about the end user's formed habbits is too much to ask?


Log in to reply