Tuesday, November 9, 2010

Scala 2.8.1 is out!

After a far shorter development cycle than for 2.8.0, Scala 2.8.1 reach us today.

More than 100 bugs were corrected, some of them really old (#36 !).

The great thing with that release is that for the first time ever, it is fully binary compatible with the previous one, Scala 2.8.0. With that and the creation of Scala Solution company, it seems to be really good insights toward Scala industrialization in the coming years.

Tuesday, July 27, 2010

Set-up Eclipse workspace in RAM

I just published an article about how to set-up your Eclipse workspace in RAM to make I/O (almost) instantaneous. It was promised in the "Eclipse perfomance optimisation article", and now it's here: http://blog.normation.com/2010/07/27/set-up-eclipse-workspace-in-ram/

And like last time, any information about Eclipse optimization is much appreciated !

Sunday, July 18, 2010

Java LDAP SDK for SyncRepl replication showcase

I just published a post on my company blog about how to implement a SyncRepl client using two different Java LDAP SDK, Apache DS and UnboundID: 


http://blog.normation.com/2010/07/18/java-ldap-sdk-for-syncrepl-replication-showcase/

SyncRepl is a replication protocol for LDAP, normalized in RFC 4533.  

The demonstration is done with a showcase web application that display in real time modification done in an LDAP server. 
The application, named Syweno, was developed in Scala, thanks to Liftweb and it's amazing Comet. It looks like:



Of course, update are synchronized thank to SyncRepl, and are propagated to the web page in real time thanks to Comet updates. 

The code source is available on github here: http://github.com/fanf/syweno

Enjoy !

Wednesday, July 14, 2010

Scala 2.8.0 is out

The most awaited Scala version of all time (ok, it's easy for now...) is out, at last !

Congratulation to every body who contributed to make it happens, and long life to Scala post-2.8.0. After a brilliant childhood, perhaps it is time for the unruly teenager to quieten down a little and conquer the industrial world !

The official link:
http://www.scala-lang.org/node/7009


Thursday, July 1, 2010

Scala dreaded underscore @ PSUG

(orignal content from http://blog.normation.com/2010/07/01/scala-dreaded-underscore-psug  )

On the evening of June 30th 2010, the Paris Scala User Group organized its second event.
This time, there were two presentations:

  • in the first one, Alexis Agahi, our kind user group leader, made a feedback after one year of scala experience. It’s available here.
  • the second one was given by your servitor, and deals with each and every use case of underscores in the Scala language – I hope I didn’t miss any.
    It’s available here.
See you next time on PSUG!

Monday, May 24, 2010

Optimizing Eclipse performances

I just published an article about Eclipse perfomance optimisation, especially with the Scala IDE plugin, here : http://blog.normation.com/2010/05/24/optimizing-eclipse-performances/

This article mostly talk about generalities and gives some reference links about JVM tunning. It also contains some eclipse.ini examples, and point to reference topic on that subject.

A second, more involved article in which I will explain how to put your workspace into ram (and keep it synchronizes to disk, of course) will follow in a couple of days (ok, perhaps packed in weeks, depending of my work...).

Of course, any information about Eclipse optimization is much appreciated !

Tuesday, May 18, 2010

Maven2 bootstrap pom.xml for Scala with SLF4J and no-commons-logging

Following an older post, this is the pom I use as a starting point for Scala project which uses maven.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>org.test</groupId>
 <artifactId>test</artifactId>
 <packaging>jar</packaging>
 
 <version>0.1-SNAPSHOT</version>

 <properties>
  <!-- UTF-8 for everyone -->
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  <!-- Other general properties -->
  <slf4j-version>1.6.0</slf4j-version>
  <logback-version>0.9.20</logback-version>
  <scala-version>2.8.0.RC2</scala-version>
  <scala-maven-plugin-version>2.13.1</scala-maven-plugin-version>
  </properties>

 <description>
  Starting pom
 </description>

 <repositories>
  <repository>
   <id>scala-tools.org</id>
   <name>Scala-tools Maven2 Repository</name>
   <url>http://scala-tools.org/repo-releases</url>
  </repository>
  <repository>
   <id>scala-snapshots.org</id>
   <name>Scala-tools Maven2 Repository snapshots</name>
   <url>http://scala-tools.org/repo-snapshots</url>
  </repository>

  <repository>
   <id>no-commons-logging</id>
   <name>No-commons-logging Maven Repository</name>
   <layout>default</layout>
   <url>http://no-commons-logging.zapto.org/mvn2</url>
   <snapshots><enabled>false</enabled></snapshots>
  </repository>

 </repositories>

 <pluginRepositories>
  <pluginRepository>
   <id>scala-tools.org</id>
   <name>Scala-tools Maven2 Repository</name>
   <url>http://scala-tools.org/repo-releases</url>
   <snapshots><enabled>false</enabled></snapshots>
  </pluginRepository>
  <pluginRepository>
   <id>scala-snapshots.org</id>
   <name>Scala-tools Maven2 Repository snapshots</name>
   <url>http://scala-tools.org/repo-snapshots</url>
  </pluginRepository>
 </pluginRepositories>

 <build>
  <sourceDirectory>src/main/scala</sourceDirectory>
  <testSourceDirectory>src/test/scala</testSourceDirectory>
  <plugins>
   <plugin>
    <groupId>org.scala-tools</groupId>
    <artifactId>maven-scala-plugin</artifactId>
    <version>${scala-maven-plugin-version}</version> 
    <executions>
     <execution>
      <goals>
       <goal>compile</goal>
       <goal>testCompile</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <args>
      <arg>-target:jvm-1.5</arg>
      <arg>-make:transitivenocp</arg>
      <arg>-dependencyfile</arg>
      <arg>${project.build.directory}/.scala_dependencies</arg>
     </args>
     <jvmArgs>
      <jvmArg>-client</jvmArg>
      <jvmArg>-Xmx1G</jvmArg>
     </jvmArgs>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.1</version>
    <configuration>
    <source>1.6</source>
    </configuration>
   </plugin>
   
  </plugins>
 </build>

 <dependencies>
  <dependency>
   <groupId>org.scala-lang</groupId>
   <artifactId>scala-library</artifactId>
   <version>${scala-version}</version>
  </dependency>
  <dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time</artifactId>
   <version>1.6</version>
  </dependency>
  <!--  test -->
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.7</version>
   <scope>test</scope>
  </dependency>

  
  <!--
   All the following is related to our will to NOT use Commong-logging
  -->
  <!-- use no-commons-logging -->
  <dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging</artifactId>
   <version>99.0-does-not-exist</version>
  </dependency>
  <!-- no-commons-logging-api, if you need it -->
  <dependency>
   <groupId>commons-logging</groupId>
   <artifactId>commons-logging-api</artifactId>
   <version>99.0-does-not-exist</version>
  </dependency>
  <!-- the slf4j commons-logging replacement -->
  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>jcl-over-slf4j</artifactId>
   <version>${slf4j-version}</version>
  </dependency>
  <!-- the other slf4j jars -->
  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-api</artifactId>
   <version>${slf4j-version}</version>
  </dependency>
  <!-- using slf4j native backend -->
  <dependency>
   <groupId>ch.qos.logback</groupId>
   <artifactId>logback-core</artifactId>
   <version>${logback-version}</version>
  </dependency>
  <dependency>
   <groupId>ch.qos.logback</groupId>
   <artifactId>logback-classic</artifactId>
   <version>${logback-version}</version>
  </dependency>
 </dependencies>
</project>




Monday, April 19, 2010

Summary of my Scala Days 2010

A great reception...

I had the immense luck to go to the First ScalaDays event organized by EPFL in Lausanne on 15/16 of April 2010.

It was an immense luck, because the event was simply fabulous. And so, to begin, I really want to thanks the Scala team, and especially Antonio Cunei for their amazing work of organization: the welcome with the little kit with the little goodies and T-Shirt was a nice introduction, the food was really good, the boat trip and dinner on first day evening a really top-level dinner.
Safe for a volcanic eruption in Iceland which disrupted flights all around Europe and so impacted a lot of attendees, it could have been near perfection.

... with great talks ...

And that is just for the organization: presentations were at the same level. Most of them were really good, and the choice between two sessions not always easy. Fortunately, presentation were recorded, and so should soon become available in line (I listed presentation I went to at the end). One little reproach: some of them would have deserve more time than allowed here, but that is near to nothing.

Akka presentation was somehow special. Jonas Boner and the Akka team did an amazing work in no more than a year, from “just an other actor implementation” to a full feature actor framework à la Erlang OTP, with actor supervision and management, persistent data structures, distribution, Software Transactional Memory (STM) integration, and all of that under the common umbrella of actor paradigm. 
To me, Akka is more and more looking like the Killer App for Scala, a middle layer framework which will be more or less in all Scala applications in a near future, a little like Spring is for the Java world. It brings so much power with so little boilerplate... So, if you don't know Akka, just go looking for it right now.

... and a bright future in sight for Scala

All along the event, there was a felling of “taking part of the starting point of something great”, perhaps a little like what were firsts Java one. Perhaps it was partly du to the fact that meeting about 155 Scala enthusiasts from Europe, US, Japan, Australia and so on was a great moment - it was really good to finally put faces on mailing lists and IRC names (hello Miles, Josh, Timothy and all the others !).
But I believe that it was more than just that. Today, I'm pretty confident that Scala is here to stay and growth.

The most "symptomatic" announcement of that evolution of the language organization from the research sphere to a broader audience is the announcement that a Scala Foundation will be created to manage it. 


So, that was a really wonderful event, and long life to Scala !

Ho – and I get my “Programming in Scala” dedicated by Martin, it's the little thing that is making that event even more special to me :)


Presentations seen

So, that's the list of presentations I attended, with a (really) brief description of them. Video of talks should me made available in a near future.

April, 15

15 morning - opening talk
A cool Opening Talk by Martin Odersky, focused on all the goodness brought by Scala 2.8, how it evolves from "just a little refactoring of Collection API" to a "3.0 without the name". Great.


15, morning


PEGEX by Kota Mizushima
or how to have combinator parser which looks like regexp. Interesting project, but a I think a little young for now... Keep an eye on it.

Scala Parallel collections by Aleksander Prokopec
Presentation of parallel collections arriving in Scala 2.8.1... It seems that it will be really great stuff, with good integration in existing collection API.


Developing the Scala bindings to the Fly Object Space by Channing Walton, Nigel Warren, Simon Kent
I miss a part of the beginning, but for what I saw,  Fly Object Space seems to be a powerful framework for distributed computing. 


15, afternoon, part 1

CCSTM: A library based STM for Scala by Nathan Bronson, Hasaan Chafi, Kunle Olukotun
A talk about what  Software Transactional Memory (STM) implementation can be achieve with Scala from an ideal STM, really nice stuff – STM seems to be a hot topic, it is cool that what is one of the most interesting feature of Clojure is winning interest in Scala.

Lightweight language support for type-based, concurrent event processing by Phillip Hadler
Really nice technical presentation about how type information can leads to massive performance optimization in pattern matching.

Named and default argument in Scala by Luka Rytz
To me, this feature is one of the best of Scala 2.8. It was nice to see how the implementation was done.


15, afternoon, part 2

Specialization in Scala by Iulian Dragos
Specialization finally comes to Scala 2.8 ! For the first time, Scala has the opportunity to be able to do things faster than Java, namely automatically specializing method to native JVM type to remove unnecessary boxing/unboxing logic. Great stuff, even if it's just a beginning.

Leaky Monads – an experiment with automatic resources management by Josh Suereth
Or how to cleanly manage resources in Scala with a little bit of monad, but only when we need them.
Great presentation by Josh, with a lot of “déjà vu” feeling for me – most of the problem he talk about and the solution he found was alike whose I encountered when I did my monadic resource management of LDAP connections.

Type-safe SQL embedded in Scala by Christoph Wulfz
Cool stuff to make SQL a first class citizen in Scala, as XML is.

April, 16

The next day seems to have again raise the level of the event. For me, it was a fabulous set of presentations. All were really top level one, and all subjects were great - well, or at least, I was the perfect target for them :)

16, morning keynotes

A really interesting keynote by Kunle Olukotun, the man behind the heavily-multi-core Niagara processor. He shows how to deeply embed polymorphic DSL in Scala, and it was kind of amazing. The Parallel and concurrent future seems to be bright in Scala world.

16, morning

Scala @ Linkedin : distributed computed with Norbert by Chris Conrad
Really cool to see what Linkedin did with Scala, and their scaling and distribution problem are really nice ones (in the way a hard maths theorem is nice to prove ;).

Akka: Simpler scalabitity, fault-tolerance, concurrency & remoting throught actors by Jonas Boner, Victor Klang
As I already said, Akka is more and more looking like the killer app on Scala. Kudo to Jonas ans Akka team.

Scala IDE for Eclipse : retrospect and prospect for 2.8 by Miles Sabin
After years of purgatory (for users ;), Scala Eclipse IDE seems to finally be interesting again, thanks to Miles and all the hard work. A really bad point for Eclipse foundation and its autism regarding JDT evolution.

16, afternoon, part 1

sbt: design and implementation by Mark Harrah
SBT, the build system that will save all of us from Maven – thanks Mark, and congrats for the work

Scala Modules: a Scala DSL to ease OSGi development by Heiko Seeberger
A “small” library to make OSGi use more user-friendly, and a lot of interest toward it. Sometime, syntax and cleanness IS important (subliminal message to all Java coders who don't see the problems with Java boilerplate)

Sneaking Scala into your organization by David Copeland
Even if I don't have that problem – in my company of four people, all the two developers are Scala experts ;), the talk was really interesting and well thought. Hope that a lot of people will follow these advices :)

16, afternoon, part 2


Their was no presentation in the last afternoon, but a workshop in which attendees were able to summarize their thought about Scala - what is missing, what has to be done, etc. Unfortunately, I had to leave before than the restitution was done, and missed it. So, for that, I'm like all of you: waiting for blog/video to know what happened !

And that's all, until next year (in U.S ?) !

Wednesday, April 14, 2010

Scala Days tomorrow !

In a few hours, I'm going to take the TGV for Lausanne, to attend first Scala Days !

There seems to be a lots of really good conferences, and it will be the opportunity to finally met a lot of irc/mailing list names !


Saturday, April 10, 2010

Embed OpenDS in your application

I just created a github project that shows what one has to do to configure and start OpenDS LDAP directory from a Java application, for example to run unit tests.

Most of the code is a direct transcription of information found on OpenDS wiki[1].

Along the commits, I tried to remove most of the unused configuration for the proposed goal, and I ended to replace the Berkeley DB backend by a memory one.

The source code is here: http://github.com/fanf/opends-simple-config

Feel free to remove even more unused configuration, or propose things to make OpenDS start time even faster.

Enjoy !


[1] https://www.opends.org/wiki/page/CreatingAnOpenDSInstanceForEmbeddedUse
https://www.opends.org/wiki/page/ControllingOpenDSFromAnotherApplication

Wednesday, March 17, 2010

Scala Unix file permissions DSL

Scala native DSL capabilities are astonishing. I just created some Scala object to mimic Unix file permission representation and "chmod" interaction, and I'm rather pleased of the result

Only user", "group" and "other" permission are managed - so no setuid, setgid or sticky bit.

Perm objects

They are simple immutable permission objects with a nice toString and an octal representation:
scala> val p:Perm = wx
scala> w.toString // "-wx"
scala> w.octal // 3
You can combine permission to obtain new permissions:
scala> w+r  // rw-
scala> rwx-w // r-w

FilePerms objects

They keep a group of three mutable permissions. You can create a new File permission object from octal values:
scala> val perms = FilePerms(777)

Or from Perm object:
scala> val perms = FilePerms(rw,rw,r)
Like Perm, they have nice string and octal representation:
scala> val perms = FilePerms(777)
scala> perms.toString //rwxrwxrwx
scala> perms.octal // 777

Missing values are initialized to "no permission":
scala> val perms = FilePerms(77) //rwxrwx---
scala> val perms = FilePerms(rw) //rw-------

And of course, you can change permissions:
scala> val perms = FilePerms(77) //rwxrwx---
scala> perms.g-wx  // rwxr----
scala> perms.ugo+x // rwxr-x--x
scala> perms.a-wx  // r--r-----
The binding of theses objects with Java IO with the goal to actually set file permissions is let as an exercise for the reader ;)
It's available on gist here: http://gist.github.com/335791. To test it, simply copy the file content, fire a Scala REPL, start an object declaration, past the content of the file, close you object, import its content, and play:
scala> object p { [enter]
  | [here, past the content of the file]
  .....
  | }
defined module p

scala> import p._
import p._

scala> FilePerms(644)
res0: Option[p.FilePerms] = Some(rw-r--r--)

Enjoy !


PS: if you have an idea about how to mimic chown, I would appreciate. For now, all I get is:
chmod( ug(_)+rw, filePerms)
Not really nice.

Wednesday, January 27, 2010

Scala 2.8 Beta 1 is out !

Today, the first official "Scala 2.8 Beta" was released. It was awaited, and for really good reasons !
Just look at the announcement summary to see all the goodness available: http://www.scala-lang.org/node/4587

I would like to thanks all the people at EPFL and all other contributors around the world to provide us with such a good language and awesome libraries/tools for our daily work - both production ready thanks to Java existing ecosystem and Start-up friendly (ok, no argument here, I just like that language :)

Downloads are available here: http://www.scala-lang.org/downloads

Wednesday, January 20, 2010

Scala and Spring 3 JavaConfig

Scala, Spring 3, Actor, REST, IoC configuration by code...
... and well, I should be able to put some other buzz words in that title, perhaps agile and Scrum ?

I wanted to test Spring 3 "configuration via code" new feature, and especially how well it works with Scala.

As a Tapestry 5 (former) user, I'm a great fan of IoC configuration done in Java (or Scala). From a developer point of view, it's so much more easy and robust (especially refactoring prone) to have access to a real, type safe language in place of an ersatz like XML... and most of the time, it's also much less verbose.

The application
I needed a pretext and decided to build a trivial web application that allows to upload files to some URL, and post-process them - a rather usual need in a web-application. That will allow to test Spring 3 new "REST" features, a bit of Expression Language, and put in a little Scala Actor to let the (long) processing be done asynchronously.
I also used maven, and Slf4j with NoCommonsLogging to be able to use Slf4j with Spring.

What exactly does the application:
- wait uploads on a REST endpoint URL;
- when an upload comes, save it into a temporary file;
- signal the file's availability to a "file processor". That processing may take a looooooong time to process (for example, it's a big XML report, with a lot of parsing, input validation, graphs generation, etc), and so, the processing should be done in a side process.

Results
Everything comes along really well, and the result is available on github.

To test it, you will need a JVM and Maven (if you haven't done it yet and are not limited by production constrains, just go download the last 1.6 JVM (1.6.0_18), the performances improvements with the last two releases are impressive)

% git clone git://github.com/fanf/scala-spring3-upload.git
% cd scala-spring3-upload
% mvn jetty:run
You should have a Jetty server up and running on localhost.
Now, you can upload a file to http://localhost:8080/upload, and see that the upload is processed and HTTP code returned, and then an asynchronous process is launched to process the file - well, actually it just waits 10 seconds and delete it.
On Linux, you can use Curl to post files:

% curl -F FileToUploadName=@/path/to/the/file/to/upload http://localhost:8080/upload/


Details about the project
Here comes the different files and their purpose:

src/main/webapp/WEB-INF/

It contains usual servlet configuration files, in XML :
- web.xml : standard Java servlet config file, nothing to see here. with a reference to the annotation based context loader and the AppConfig.scala file.

- upload-servlet.xml : Spring servlet config file. It's this one that is Spring default enter point, and it contains an entry point to the Scala file used for bean configuration, and to the prope


I just don't understand why this last file is needed. It's where you feel that JavaConfig was an afterthought in Spring... Couldn't have we a convention in place of that ? Something like "put your master configuration code in that package" ? All in all, it's small pain to have to write that file, but it also bring really little information. 


UPDATE: as Chris Beams shows me, I should have RTFM more carefully. It's now possible (I do believed it wasn't in first RCs), and I updated the sources to have a full ScalaBased configuration.

src/main/scala/org/test/upload

That package contains the code to receive file (UploadEndpoint.scala) and process them (FileProcessor.scala).
As you can see, there is very little code, and most of it is self-explanatory.

src/main/scala/org/test/upload/config

That last package only contains the AppConfig.scala file, the place where Spring IoC configuration is done.
I really like the cleaness of that file, compared to what may have been the equivalent XML one.
The default sleepTime value is especially cool, typically a things hard to do when you only have XML

Conclusion
This little project could be a good starting-point if you want to use Spring 3 with Scala, or Slf4j with Spring.
I'm also rather impressed by how much little code is needed with Spring 3 to configured the REST endpoint.
And building little asynchronous services thanks to actor is just too simple (OK, here it's a toy, but if you want serious business with actor, look at AKKA).

Saturday, January 9, 2010

Happy new year 2010

For me, year 2010 will be a big switch in my life... hopefully for the best !
So, I wish you all the best things for this last year of the first third millennium's decade !

Happy new year !

  © Blogger template 'Minimalist G' by Ourblogtemplates.com 2008

Back to TOP