Donnerstag, 16. April 2009
Java type system anomally
In the last days I was hacking a small system integration application in Scala. It was really a pleasure to work with a reasonable type system. During that I remembered several of the “well known” Java Type anomalies especially following code fragment:

Integer ints[]=new Integer[1];
Object objs[]=ints;
objs[0]="Hallo Arno";

A really nice one, which I really like. It compiles without any warnings, but it is completely broken. For inexperienced ( Java) developers maybe a little hard to spot why. It would be easy and nice to create a nice Java Puzzle out of this theme. The java-generics documentation states,


“Because the program compiles without warnings, we can state with certainty that it will not throw a ClassCastException at run time.”


This is right, because the code throws a java.lang.ArrayStoreException. So the statement is formally correct, but in practice, there is no difference. In any case the method terminates with a runtime exception. On the other hand I understand the initial design forces for the java team. They wanted a simple typed language and they wanted to be able to write some array handling library code.

I haven´t made up my mind jet, which solution to this dilemma I would prefer. These are:

  1. The highly sophisticated inheritance model of the latest languages like scala
  2. the dynamic duc typing of languages with a pure dynamic type system like J/Python, J/Ruby,
But for one think I am sure, I prefer both solutions over the pure old fashioned Java type system. What do you think?

... link (1 Kommentar)   ... comment


Dienstag, 17. März 2009
Manifesto for Software Craftsmen
I personally prefer to call myself a software craftsman and not a software engineer.
(Please note: I have received the academic grades for calling me a software engineer from one of the best Universities in Germany.)

So I was more than happy to see and sign the manifesto of softwarecraftsmanship

... link (0 Kommentare)   ... comment


Samstag, 16. August 2008
Ant task for ProtocolBuffers
ProtocolBuffers (pb)are an interesting new protocol. Till recently it was a proprietary protocol. So it was no surprise, that there were only limited support for usual development tools available. I wrote recently an eclipse plugin for syntax highlighting. I am using pb for a messaging project and I needed therefore some ant-build support. If you have read some of my previous blogs, you know that a reliable build is as important as a reliable configuration management process. So I decided to write an ant-task for pb.
If you are interested you can now download it here and the source here. This version is released under Apache License, Version 2.0

You can use it with an ant target like:

<target name="compile_proto" >
<taskdef name="pb" classname= "org.schmidmeier.protocolbuffer.ant.PbTask" 
    classpath="lib/PbTask.jar"/>

<pb ProtoFile="Sample.proto" ipath="/prj/pbuffer/include" 
   java="${java_output}" 
   python="${python_output}"  
   cpp="${cpp_output}">
   <protopathentry ipath="proto_includes "/>
   <protopathentry ipath="protolibs "/> 
<pb/>
</target>
At first you have to define the task. You do it with the taskdef statement. From here on you can use the pb task. ipath defines the includefiles. java, cpp, and python define for which languages code should be generated. (and where it should be dropped)

Here are the possible attributes for the task.

Attributes



Attribute Description Required
java if set, output will be generated for java. The value must be the java output directory at least on of java, python, cpp
cpp if set, output will be generated for C++. The value must be the C++ output directory at least on of java, python, cpp
python if set, output will be generated for python. The value must be the python output directory at least on of java, python, cpp
ipath The directory which may contain include files No, default unset
failonerror if set, the compilation aborts in case of errors No, Default, true
protopathentry The possibility to add multiple include file to the command line No, Required unset

Current open issues:

  1. The ant-job was currently only tested on windows. If you find some issues on other platform, please notify me
  2. The pb-compiler which is invoked from the ant-job has some problems with Windows drive names, when it should generate C++ or python code.
If you have some comments, have found some bugs, etc. please feel free to contact me on pb at Schmidmeier dot org

... link (0 Kommentare)   ... comment