Showing posts with label scala. Show all posts
Showing posts with label scala. Show all posts

Saturday, January 16, 2010

Programming in Scala

I am currently looking into the programming language Scala which compiles to Java byte code and can be run everywhere a Java JRE is installed. This alone makes it an interesting language.

For my studies I bought Programming in Scala, a book by the creator of Scala, Martin Odersky, and by Lex Spoon and Bill Venners publisched by Artima. Information on the book at the Programming in Scala can be found at the Artima book site.

IntelliJ Scala Plugin Compile Errors

Are you trying your first steps with Scala like I do, using IntelliJ with its Scala plug-in?
Do you see something like the following while trying to compile you Scala source code?

Information:Compilation completed with 3 errors and 0 warnings
Information:3 errors
Information:0 warnings
Error: error while loading Predef, Scala signature Predef has wrong version
Error:expected: 5.0
Error:found: 4.1 in C:\Users\\.m2\repository\org\scala-lang\scala-library\2.7.7\scala-library-2.7.7.jar(scala/Predef.class)

Well, if you are clueless like I was it might interest you that this problem is most likely coming from a lack of backwards compatibility in compiler version and that the IntelliJ plug-in for Scala that I use seems to use a newer compiler (Scala 2.8 -> internal 5.0) than what most libraries like for example scalatest 1.0 are compiled against (2.7.7 -> internal 4.1).

The remedy is to point your IntelliJ plug-in to the libraries downloaded with the Scala 2.7.7 final installation. As far as I know as of now you have to do this under Project Structure by either clicking on the Project Structure icon or by using Ctrl+Alt+Shift+S and then under Project Settings you select Facets. This should give you a dialog window where you can set the Scala compiler library and the Scala SDK library.

Make sure you did not install on a path with spaces because that would be interpreted as separate paths constructs.

Sunday, January 10, 2010

Scala for Notepad++

The Scala distribution comes with a Notepad++ syntax highlight configuration file. You will find the file under SCALA_HOME/misc/scala-tool-support/notepad-plus. As stated in the README file copy the xml file to %APPDATA%\Notepad++. There is a typo in the installation file and it says Nodepad instead of Notepad.

However, do not copy it in your Notepad++ installation folder as I first did not reading carefully enough the installation description.