Java just won’t manage Non-Primitive Numbers


I just stumbled over something really funny; something that would fit to the Watman lightning talk by Gary Bernhardt. As you may know, Java is jet another language that copied a really great programming language of the visionary Alan Kay, named Smalltalk. In Smalltalk everything is an Object (yes, really really everything! So even classes are objects, describes by meta-classes – even creating a subclass is done by sending the superclass a message, to which it replies with a subclass!) and all programming is done by objects sending and receiving messages, and answering to them. This is why in OOP, you don’t have functions but methods. A function can be called – it can be applied to values. So you actually define what to do. In OOP, an object decides on how to properly react on a message. It does so by looking up it’s methods on how to react on the received message. But how it will react is totally up to the object, it’s even possible that many different objects reply to the same message by using different methods; a function on the other hand is unique. But the key idea is that while in imperative programming you see and apply the function, in object-oriented programming this is a black-box to you (unless you programmed the method).

But I digress. Coming back to Java, when it was developed, it wanted to implement OOP, but on the other hand it also wanted to keep up with the speed popularity of C. So not only did the syntax change to be more C-like, but also a lot of things that work purely object-oriented in Smalltalk where implemented as they are in C. This also applies to numbers, they are primitives; values that lie in RAM, values on which functions are applied to. Now, this may sound totally normal to us – we don’t think of a number as an object, which we ask to do something, and then see if it does it, or not. But with Smalltalk, that’s exactly how it’s done:

1 class
=> SmallInteger

1 resondsTo: #+
=> true

Other pure object-oriented languages, such as Objective-C or Ruby (example below) behave in a similar way:

1.class
=> Fixnum

1.respond_to?(:+)
=> true

So how does it work? + is a method, same as any other method – with the exception that it is written in a special way, so that it can be used more human-readable, in an infix notation. #+ and :+ are symbols in Smalltalk/Ruby, which are used to identify the method. Say you have a method called println(), the symbol would be :println in Ruby or #println in Smalltalk. Ruby allows us to send a message to a object not only by naming the method, but also by using the send()-Method, that every object understands, and where the first argument is the the symbol of the method and the following arguments are arguments accepted by the method. So, here it should become obvious that + is actually a method and the second number (another object) an argument:

1.send(:+, 2)
=> 3

The Answer to the message is actually a new object. Not so in Java. Primitives are non-object values

System.out.println(1.getClass());

=> Unresolved compilation problem:
Cannot invoke getClass() on the primitive type int

Continue reading

Warum einfach…


… wenn es auch kompliziert geht?

Since the initial release of JDK 5.0, Java update releases have either been Limited Update releases that include new functionality and non-security fixes or Critical Patch Updates (CPUs) that only include fixes for security vulnerabilities. We will continue releasing Limited Update and CPU Java releases, however we are changing the frequency and way in which these releases are numbered:

  • Limited Update releases will be numbered in multiples of 20.
  • We intend for Critical Patch Updates to continue to use odd numbers. The numbers will be calculated by adding multiples of five to the prior Limited Update and when needed adding one to keep the resulting number odd.

This is best illustrated with an example:

The next Limited Update for JDK 7 will be numbered 7u40, and the next 3 CPUs after that will be numbered 7u45, 7u51, and 7u55. The next release will be a Limited Update 7u60, followed by CPUs 7u65, 7u71, and 7u75.

(Quelle)

Man muss sich das mal vor Augen halten – das sind Menschen, die beim Software-Riesen Oracle angestellt sind. Die werden für sowas auch noch bezahlt!

Der beste Satz ist aber folgender:

To avoid confusion caused by renumbering releases, we are adopting a new numbering scheme.

Der ganz reale Irrsinn, bei Oracle in der Java-Abteilung…

New way to organize (Java) Code?


Today morning I found this interesting article by neon in one of the internet boards that I am pretty active in. It’s about a new concept of designing IDEs and the way of coding. Instead of organizing your code via files, it is organized in bubbles. Each bubble is shown to you as demanded, i.e. if you need a certain code fragment, for instance a certain method of a class, you just display the code of that certain method (not the entire class, or entire sourcecode file that the class is stored in), in a bubble. You can even add notes to the bubbles or group them into categories, and much more – why don’t you watch the video on it, if you’re interested in the details.

Continue reading