The name of the blog comes from a quote I heard many years ago: "Give me a wrench". "What size?" "It doesn't matter.I am using it as a hammer" This blog is a discussion of software development tools: how to use them, when to use them, how not to use them, when not to use them, the ones I like, the ones I don't like, etc.
Saturday, November 17, 2012
More about my incredible love-hate relationship with Scala.
I just finished a phenomenal course with Coursera on functional programming in Scala.
I found it excellently done, and generally very clear. This does not mean it was easy. Bringing a beginner's mind to my entire world of programming highlighted just how completely saturated my mind has become with the object-oriented paradigm.
But the video lectures were well done if algorithmically dense. It required me to wrap my mind about recursion as a typically good thing (as opposed to Java of where it is often a bad thing).
Each set of video lectures came with a set of unit tests, and some partially filled out code examples that you then completed and automatically submitted and they were auto magically graded.
But the main thing I wanted to blog about was not the course (though I would recommend the course), but rather the toolset that was provided as a bundled package. Rather than using these scala-IDE plug-in within an existing Eclipse environment, they package the entire thing as one download. The end result was a far more stable environment than what I had blogged about earlier. This does not mean that I am ecstatically happy with the toolset. It is far more stable than it was, and it still has some serious lapses.
In addition, I have noticed that there is a great deal of activity around the toolset and my hope is that this activity is an indicator that there will be drastic improvements in the overall coding experience.
Monday, September 3, 2012
More hints that will help with the ABCs of Scala
Add the ability to pull down source with the dependencies with SBT
If you add the EclipseKeys.withSource := true to the build.sbt file.
name := "canon"
version := "1.0"
scalaVersion := "2.9.2"
EclipseKeys.withSource := true
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Spray Repository" at "http://repo.spray.cc/"
Scala-IDE will automatically attach source to the dependency which will allow you to debug the cryptic error messages more easily
ABC's of Scala
ABC. Assume nothing. Believe nobody. Check everything.
- John Cockram - British Crime Scene Manager
I would love to say that I spent the last 2 months learning Scala . Instead, I have to say that it has been 2 months of wrestling with- Academic documentation unrelated to day-to-day development or learning.
- Documentation that is unconnected to the current implementation and not marked with what version it is connected to.
- Tools that are a decent alpha quality (and therefore better than the majority of the documentation).
- A language that is not just a moving target, but a dodging, weaving, actively evading target
- A large series of half completed build tools, testing tools, libraries and frameworks all driven by the NIH principle, many of whom reimplement the same concepts over and over and over and over.
- A separate ecosystem of artifact repositories
Some things I have discovered along the way that may help others
(WARNING: much of this information will be outdated in the next 5 minutes)
The best book for learning Scala
So far the best book I've found for learning Scala is O'Reilly and Associates' Programming Scala by Wampler and Payne. Simple explanations and definitions of the concepts combined with code examples that are related to the concepts being described.
General assumptions to save you time
Some of these may sound tongue-in-cheek or harsh.. They are intended to be neither. I consider these rules to be just a straightforward and logical as saying "don't stick your hand into dark crevices" in areas where there are black widow spiders.- Assume that the documentation is outdated. , You should not proceed until you have proven that the documentation is connected to the version of the language or the library that you are using.
- Assumed that the source for examples or tutorials does not build until you have confirmed that it can be built in a standalone manner unrelated to the project you're working on.
- Assume that the libraries in the Maven central repositories is out of date.
- Assume that the transitive dependencies will NOT be filled out.
- If the library you are using needs another library, you will probably need to specify it in the build.sbt file and you should not trust the documentation to tell you what version of that library is needed by the version of the code you are using. Instead, you should look at the dependencies listed in the source code of the library that you are using.
- For example, even though the Spray libraries say that they are built on top of Akka 2.0 you will probably not have those libraries automatically pulled in. You will have to go to the appropriate repository that they got pulled from and walks through their dependency information OR change logs, so that you can figure out what version of these other libraries are needed.
- Assume that whatever library you have pulled down is a partially implemented experiment. Until you have proven that others are using it in projects that are actually ongoingly developed by someone other than the author of the original library you pulled down, you should assume that the entire library is a false trail designed to deceive.
- So my recommendation is to test it always in isolation before
Specific assumptions to save you time
Scala-IDE
You can use the Scala IDE with either Indigo of Juno with the following caveats.
I would recommend using only the SBT based builder with ONLY a build.sbt file. Do not use IVYDE in combination with the Scala IDE or ivy.xml files. , I would not recommend mixed Java and Scala
projects unless you an extreme masochist.
projects unless you an extreme masochist.
- Assume that the Scala IDE error messages are unrelated to the code until
- You have closed and then reopened the source file
- Refreshed the project
- Executed a "Build Project" command.
- Assume that the Scala-IDE error messages are going to make no sense.
- If you are not able to find the error message in Google, you are better off rewriting the section of code than attempting to figure out what the error is.
- Make sure that the library versions that you are pulling down match the version of Scala listed in the build.sbt EXCEPT that even though the latest version of Scala IDE pulls down and uses 2.9.3 of Scala the version of scala used by SBT is 2.9.2. So you can have the following build.SBT file:
name := "canon"
version := "1.0"
scalaVersion := "2.9.2"
But not
name := "canon"
version := "1.0"
scalaVersion := "2.9.3"
SBT
- Do not use any of the SBT tutorials or documentation EXCEPT those found on the GitHub site for xsbt. All others are out of date and incorrect.
- Double check that the version of the XSBT documentation you are looking at is tagged for the same release that you are using.
- When attempting to find libraries look first at the Typesafe and Spray repositories before attempting to use any of the maven central repositories. They are more up to date in general.
Why am I still at it?
The functional programming paradigm and the Scala language offer a huge opportunity in productivity.
Unfortunately, it is necessary to wade through a phenomenal amount of un-workability in order to get there.
Still experimenting like crazy
Wednesday, July 4, 2012
The next Big Thing?
For a while now I have been very frustrated by the gyrations necessary to try and represent a complex, dynamic hierarchical model of relationships among domain objects using Java. I love what Java brings to the table compared to C and C++ for the kind of work that I do AND it is still insufficient for what I would like to get done.
In effect, I am up against the limits of Java's expressive power when dealing with complex, dynamic relationships. I am spending a great deal of time writing code to make tracking these relationships doable. Recently, I realized that I am writing more code to manage the dynamic relationships and properties of the domain model than any other code in the application. I have started getting many levels deep in indirection in order to try and model some complex relationships. Normally, when I am struggling to express the model in the language I am using, I would try and figure out how to simplify the model. But since the PIM (Personal Information Manager) I am working on is an attempt to express exactly those complex dynamic relationships I would be sacrificing the whole reason for the PIM to exist.
One of the new people at my current company is a Scala enthusiast (rhymes with addict). As a result, I have been looking at this language with some intensity. This is especially true since it appears that the language maps well to modeling the more complex relationships. In other words, it offers the hope of a programming model/paradigm that could drastically simplify what I am trying to do.
Scala combines brevity of expression with numerous and powerful new coding and programming constructs, all built on top of the JVM.
That is the good news.
The bad news is a mixture of a rapidly evolving language combined with old and new documentation intermixed along with a new paradigm (functional programming) to learn and a lack of well behaved, mature tools that costs productivity and time.
I will be writing more about the pros and cons and techniques I am learning in the next few weeks.
The biggest caveat I can give you is that almost all of the IDE integrations for Scala that I have worked with have been rudimentary at best. You should be prepared for a sometimes.
Frustrating user experience when using an IDE with Scala. The productivity gain is still worth the pain and I can't pretend that there isn't some pain involved.
The Eclipse IDE is installed as usual and then you want to install the Scala IDE. You will want to pick the specific plug-in you install very carefully. There are 2 different versions of Scala involved (2.9.2 or 2.10). 2.9.2 is the current stable release of the language and 2.10 is the current bleeding edge. You cannot install both plug-ins in the same eclipse installation. To pick which needs to be installed, go to this website:
Download the latest nightly builds
This page references the nightly builds for the latest version of the Eclipse plug-in (code-named Helium). Believe it or not this is much more stable than the previous versions of the IDE plugin., and the Helium version of the plug-in is available in several combinations:
- Eclipse 3.7 (Indigo) with Scala 2.9.2
- Eclipse 3.7 (Indigo) with Scala 2.10
- Eclipse 4.2 (Juno) with Scala 2.9.2
You will notice that the download page actually lists 4 possible update channels some of which are so messily documented and/or named it's unclear what they're referring to, so I have only listed the 3 that I can be sure of. This is actually a pretty typical situation when dealing with Scala and its tooling.
In order to start learning. I would recommend 1st reading the following to get an overview of how it all relates to Java (This is an invaluable starting point if you are already a Java programmer).
http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees
Then I would recommend the following books as a starting point:
Programming Scala: Tackle multi-core complexity on the Java Virtual Machine
Programming in Scala , 2nd edition
Subscribe to:
Posts (Atom)