4 ms·
Scala was my first serious use of a JVM language and I kept hitting little rough patches that people were assumed to understand from a prior Java background. On
by philipkglass 10y ago
Scala was my first serious use of a JVM language and I kept hitting little rough patches that people were assumed to understand from a prior Java background. One example: a month or so into my use I started getting a puzzling failure when sbt was trying to download a dependency. Everybody already knows about Java's security certificate handling, Ivy, and Maven, right? I didn't. I kept on Googling the wrong terms because I was searching for Scala and sbt. The problem turned out (IIRC) to be a dependency download attempt that started from a URL whose certificate was trusted and then got 302 redirected to a mirror whose certificate was not yet trusted by Java. The error messages that actually showed up in my console were not at all helpful and I ended up using tcpflow and a Java-savvy colleague to figure out what was actually happening. Would it be so hard for (e.g.) sbt to provide an interactive security prompt for if you want to trust a remote source's security cert, rather than expecting you to figure out the error message and solve it the Java way with plain Java tools? (Maybe it would be hard. Maybe that's why it doesn't do that. I don't know because I didn't use Java before Scala.)
I don't have concrete examples to hand for the other rough spots but I recall hitting other areas of knowledge that are explained via Java instead of standing on their own. "The Scala Bar is like Java's Foo, but with these improvements..." I never learned the Java Foo and I don't really want to have to acquire a working Java developer's knowledge to use Scala. I'm using Scala and not Java. If you're writing docs for Scala and the reader needs to know something important about either Java-the-ecosystem or Java-the-language, please inline that knowledge.
- lmm 10y agoI wouldn't recommend SBT, especially for beginners (Maven is much better documented), but no, it can't give you a prompt because programs don't have access to modify the keystore by design. The JVM is one of the few platforms that actually has a decent go at security, which sometimes means usability suffers.
- jackcviers3 10y agoTo use scala effectively, you must use SBT. Almost every scala library and framework is built using it. There are tons of productivity enhancing tools wrapped in plug-ins for it. It is java, scala and scalajs aware, and incrementally compiles large projects if you use it. The documentation for it is good from version 0.12 on. You can learn 90% of what you need to do scala builds in SBT in 4 hours by reading the documentation and the walk-through tutorial. Eventually you may need to write your own tasks, but 90% of those tasks are covered by the existing plug-ins available, and you can easily modify or create a new task by writing some simple scala function on your first day using the tool without having to publish a plug-in to some repo for it to work. I absolutely would reccommend SBT for beginner scala users. It's a must to use and understand it, as much a part of understanding scala as understanding for comprehensions, case classes, and if/else expressions.
- denis1 10y agoUsing SBT with Scala is certainly encouraged, but you can use other build tools. At work we're successfully using gradle without too many problems. The only things that are slightly weird are the not-so-perfect plugins for gradle, but that is understandable considering they are mostly community driven (sometimes only a one person even).
- vorg 10y ago> the not-so-perfect plugins for gradle Could be because Gradle up to version 2.x provided only Groovy for writing plugins and build scripts. Gradle 3.0 was released a few months ago, and provides both Kotlin and Groovy for plugins and builds, and even prefers Kotlin for writing plugins. Perhaps the "not-so-perfect" situation will change as plugin providers switch over. I recently looked into Groovy's apparent popularity at #17 on the TIOBE ranking and found Baidu was giving a result 12 times too high and Yahoo a result 20 times too high, both of which would skew the ranking. Groovy's real ranking is somewhere below that of #50 ranked Clojure. These results are being used to promote Groovy as successful to the Apache Software Foundation directorship. I can understand Gradleware wanting to switch to a language with a seemingly more honest approach to promotion.
- lmm 10y agoLibraries and frameworks use SBT because they need to cross-build for multiple scala versions - that isn't something you normally need to do as a "regular" developer. Even post-0.12 the documentation is a lot lot worse than maven's. You can absolutely use Scala effectively without it.
- philipkglass 10y agoI was hired to work on an existing codebase that used sbt. I had domain knowledge and plenty of general development experience but I hadn't used Java, the JVM, or Scala for production code before. My previous background was C, Fortran, Python, and JavaScript (scientific computing and web dev).
- Scarbutt 10y agoI hope you don't try Clojure then, is much worse there ;) Joking aside, in Clojure this a feature, one of Clojure's theme is "embrace the host"(leverage java apis). I don't know Scala but in Clojure you definitely need to become familiar(if you aren't) with Java if you are serious about writing productions apps in it. Also, abstractions leak.
- cutler 10y agoI've been using Clojure happily for years without needing to dip into Java for anything other than something like parseInt(). Leiningen is a joy to use compared with anything Scala has to offer and Clojure also has its own library repository. When I asked on IRC where to find Scala libraries I was advised to go scavening on Maven Central. Jeez.
- amelius 10y ago> I've been using Clojure happily for years without needing to dip into Java for anything other than something like parseInt() You needed to dive into Java to figure out something as basic as parseInt?
- cutler 10y agoI said "dip into", not "dive into" and by dip into I meant discovering I needed Java rather than a Clojure function.
- amelius 10y agoI didn't mean to offend you. I don't know Clojure or Java, and was just wondering why you need to look into the internals of Clojure for something as basic as parseInt.
- jakebasile 10y agoClojure.core doesn't have a parse integer function. You use Java interop to get one. It's as simple as '(Integer/parseInt "42")'
- hocuspocus 10y agoTo be fair, package managers and SSL certificate issues are a PITA in pretty much all ecosystems. On the JVM, even if you stick to pure Java, you still need to figure out where and how the dependency resolver is launched before you can override its settings, which can depend on things like your build tool and IDE. But at least, adding your own certificates to the keystore/truststore is fairly straight-forward.