News: Replacing If-then-else: Tom pattern matching extension for Java

  1. Nested if-then-else statements is the most common programming schema in applications that perform data transformation or data analysis. In most cases, these can be replaced by higher level pattern matching constructs, rendering the code more readable and easier to maintain. Tom is an extension for Java that adds support for algebraic data types and pattern matching. A Tom file is an alternation between Java code and Tom code. When compiling such a file, the Tom parts are transformed into Java code and the result is a plain Java source code file. This video shows how you can integrate Tom's pattern matching features into an existing Java application that uses the Java Persistence API (with Hibernate). It gives an idea of the ease of pattern matching instead of illegible if statement chains combined with loops and negations.
  2. I like the idea. We've found really useful to somehow 'externalize' some logic out of the pure java code. Users can modify the business logic without dealing with java and without the compile-deploy cycle. Now, I don't now anything about Tom. We've used Drools for jbilling. What kind of use cases are best done with Tom, rather that using Drools? Regards, Paul Brenoir Sr Developer jbilling.com The Enterprise Open Source Billing System
  3. From extensibility point of view a rule engine like JBRMS(earlier DROOLS) is better suited .
  4. Tom is best suited to perform data transformation and/or analysis, especially on trees. The example in the video is a simple use case, and is not showing all you can do with Tom. You can use Tom to externalize your business logic, but it is not it's main deign purpose. On the other hand, it is not always is a good thing to use a business engine for transforming data :) You can browse the web site or the documentation and the tutorial for further information.
  5. I'll try it as soon as possible[ Go to top ]

    It looks like exactly what I'm looking for. I need to do a lot of tree analysis and transformation in my work. I've even tried to use Haskell with Java, and then Jaskell, but it is not very stable. Having pattern matching in Java is my most desired feature. Thank you!
  6. The Scala programming language has a similar feature as Tom provides (and also runs on the JVM). I wonder how Scala compares to Tom in usability (tool support, etc).
  7. I'm not very familiar with Scala, but as far as I know the pattern matching capabilities of Scala are not as powerful as in Tom. If I am not wrong, it doesn't have list matching, and moreover the match that it provides can only be applied on the objects defined in Scala, and not on every Java object. Moreover, they don't have strategies, one of the strongest points of Tom.