News: Exjali : EXpressiveness JAva LIbrary

  1. Exjali : EXpressiveness JAva LIbrary (2 messages)

    Inspired by the buzz around Java 7 and "new" JVM language (Groovy, JRuby, Scala, ...), Exjali is a small java library, hosted on sourceforge.net, which tries to provide features that are not part of the Java language (yet) with java classes, and allows more expressive and concise statements. For example, instead of writing a painful for loop like this one : for (int i = 1; i <= max; i++) You can write ; for (int i : range(1, max )) Here range is a static method provided by Exjali that builds an immutable collection containing all the integers in the (1, max) range. As it's a collection you also call contains : if (range(2, 45).contains(myInt)) In the same spirit Exjali provides two utility classes to iterate over the content of files with a Java5 foreach loop, one for text files (iterating on lines), the other for object files : for (String line : lines("test.txt")) { // do somthing for each line Exjali also support some kind of named parameters, (inspired by groovy) : you can use static methods to create objects while calling the method : createPerson(params(param("name", "michael"), param("age", 21))) The method createPerson must then verify the types of the given parameters : // Method declaration void createPerson(NamedParameters params) { // The client code should verify the parameters params.verify(paramVerify("name", String.class), paramVerify("age", Integer.class)); // Parameters retrieval String name = params.get("name", String.class); Integer age = params.get("age", Integer.class); // actual code ... } Exjali has more features. Visit http://exjali.sourceforge.net to learn more. If you have any idea or suggestion in the same spirit, feel free to share it !
  2. uh ... wow. I don't think i agree that for (int i : range(1, max )) is in any way more 'expressive' than the painful for loop for (int i = 1; i <= max; i++) nor that createPerson(params(param("name", "michael"), param("age", 21))); is either more concise or more 'expressive' than createPerson("michael", 21); even though it is inspired by Groovy ... especially since I now have to modify the class itself in other klunky ways. Although the file thing looks minimally useful, I think I will pass over this one.
  3. Here range is a static method provided by Exjali that builds an immutable collection containing all the integers in the (1, max) range.
    I wonder how this will hold against a good performancetest. Lets say I vary MAX from 1 to 100000 and do 100000 loop test with it. The good old way works with primitives but this new method works with collections and Integers I should guess. I will end up with alot of objects in this new way... NOT GOOD. But This is theoretically. I haven't done the tests. I wish people stop trying to transform Java into some kind of weird construct. The language is good and easy to understand and simple to code in. All those alleged improvements will reduce the readability, usability and maintainability of the code. If you cannot understand the basic simple constructs then you should not be programming in Java. Kind regards, Marc