Declarative programming: a Range type for Java

Scala got it and of course all the other hip languages these days like Ruby and Groovy got it, too. Talking about a build-in type for Ranges, some praise for its easy to apply and readable Declarations, a demonstration of a sound declarative Style.

For example, if we want to print all even numbers in a Range between 11 and 22 in Ruby, we simply could apply a literal form like this:

for number in 11..22
 puts "#{number} is even" if number%2 == 0
end

Read the rest of this entry »

Advertisements
Posted in java. 12 Comments »

Building your own literals in Java – Tuples and Maps

As hinted in my last post about literals in Java, we’ve only scratched the surface on that issue.
In this entry it get’s even weirder, since i will show you a very unconventional way of how to declare Maps in a more literal form. Maps are surely and undisputed one of the most used examples when it comes to show how verbose Java is, comparing to such hip languages like Ruby or Scala. Read the rest of this entry »

Posted in fun, java. 14 Comments »

Building your own literals in Java – Lists, and Arrays

The rise of some ‘new’ languages like Ruby, Groovy and Scala is (among other things) accompanied with discussions about the verbosity of some established languages, especially Java.
For example there are not few voices, complaining about the boilerplate code that you have to write (and read) when it comes to the declaration and instantiation of collection types in Java. Read the rest of this entry »

Posted in java. 22 Comments »