-
Replacing If-then-else: Tom pattern matching extension for Java (6 messages)
- Posted by: Asd Asd
- Posted on: October 22 2007 11:18 EDT
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.Threaded Messages (6)
- Re: Replacing If-then-else: Tom pattern matching extension for J by Paul Casal on October 22 2007 13:16 EDT
- Rule engine is better choice to replace if then else !! by Mohammad Tariq Yaqub on October 22 2007 13:24 EDT
-
Tom is not a replacement of business rules engines by Asd Asd on October 22 2007 01:33 EDT
- I'll try it as soon as possible by Sergey Edunov on October 23 2007 02:22 EDT
-
Tom is not a replacement of business rules engines by Asd Asd on October 22 2007 01:33 EDT
- Rule engine is better choice to replace if then else !! by Mohammad Tariq Yaqub on October 22 2007 13:24 EDT
- Re: Replacing If-then-else: Tom pattern matching extension for J by Erik van Oosten on October 23 2007 02:52 EDT
- Re: Replacing If-then-else: Tom pattern matching extension for J by Asd Asd on October 23 2007 10:21 EDT
-
Re: Replacing If-then-else: Tom pattern matching extension for J[ Go to top ]
- Posted by: Paul Casal
- Posted on: October 22 2007 13:16 EDT
- in response to Asd Asd
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 -
Rule engine is better choice to replace if then else !![ Go to top ]
- Posted by: Mohammad Tariq Yaqub
- Posted on: October 22 2007 13:24 EDT
- in response to Paul Casal
From extensibility point of view a rule engine like JBRMS(earlier DROOLS) is better suited . -
Tom is not a replacement of business rules engines[ Go to top ]
- Posted by: Asd Asd
- Posted on: October 22 2007 13:33 EDT
- in response to Mohammad Tariq Yaqub
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. -
I'll try it as soon as possible[ Go to top ]
- Posted by: Sergey Edunov
- Posted on: October 23 2007 02:22 EDT
- in response to Asd Asd
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! -
Re: Replacing If-then-else: Tom pattern matching extension for J[ Go to top ]
- Posted by: Erik van Oosten
- Posted on: October 23 2007 02:52 EDT
- in response to Asd Asd
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). -
Re: Replacing If-then-else: Tom pattern matching extension for J[ Go to top ]
- Posted by: Asd Asd
- Posted on: October 23 2007 10:21 EDT
- in response to Erik van Oosten
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.