2014-10-13 Tweets

2014-09-22 Tweets

When I Say “Groovy” or “Clojure”, I Mean “Groovy” or “Clojure”

Two languages that I am looking at these days (and would eventually like to work in) are Groovy and Clojure.

There is a site called Find Grails Jobs. Most of them are for jobs for which you would code in Groovy and/or in Grails.

But there are a few that are really Java jobs. They will mention a lot of Java technologies, and Groovy is mentioned as a “nice to have” way at the bottom. Are some firms hoping you will sneak Groovy into a Java shop? Or are they trying to pull a bit of a bait and switch? I think it might be the latter. I like Java, but I would prefer doing Groovy. If I want a Java job, I will look on a site about Java jobs.

There is no site devoted to Clojure jobs, but there is one called Functional Jobs. They have jobs for a lot of functional languages. So much for purity.

One ad said (and this is a direct quote): If you’re interested in functional languages like Scala, Swift, Erlang, Clojure, F#, Lisp, Haskell, and OCaml, then you’ll enjoy learning Flow.

First off: I tried googling a few combinations of “Flow”, “programming”, “language” and “software”. I could not find a page that appeared to be a home page for a language called “Flow”. I did find a few pages about “flow-based programming“, which I guess is like Dataflows in GPars.

But more to the point: If I am interested in Clojure, don’t tell me that I am interested in some other language that only exists at your company. If you feel that some obscure language is the best way to deliver your products, fine. But don’t tell me what I want. You decided to jump down the rabbit hole. You deal with it.

You’re welcome.

2014-09-15 Tweets

Groovy Validator: Better Than Cowbell

There are more updates to the Groovy Validator project.

I got regular expressions working for StringAnnotation in POGOs and immutable objects.

IntAnnotation and LongAnnotation now have an optional argument called “divisorSet”. If you want your number to be even, you can add the set [2]. If you want it to be divisible by 3 or 7, you add [3, 7].

I also changed the exception messages and did some refactoring. There was some repetition I moved into methods. Handling doubles and floats was pretty much the same, and integers and longs were almost the same.

I think the README and groovydocs explain things pretty well.

You’re welcome.

2014-09-08 Tweets

Regular Expressions in Groovy Validator

There is another update to the Groovy Validator project. I added regular expressions to the StringAnnotation class. I have not added it to the class that performs validation for immutable objects.

Before, all you could do is validate a String by length. Now you can also use regular expressions:

import info.shelfunit.properties.annotations.ImmutableValidator
import info.shelfunit.properties.annotations.StringAnnotation

@ImmutableValidator
class ImmutableRegEx {
   
    @StringAnnotation( minLength = 10, regEx = /^.*?[Gg]roovy.*$/ ) 
    String groovyString
    @StringAnnotation( regEx = /\d{4}?-\d\d-\d\d/  ) 
    String yearWithDay
    @StringAnnotation( minLength = 6, maxLength = 10, regEx = /^(?=.*[0-9].*[0-9])[0-9a-zA-Z]{8,12}$/ )
    String password
}

The default is the catch-all “.*”, so the annotation will still work with no regular expression provided by the user. This can be used with POGOs and processed by AnnotationProcessor.process, and it can be used with ImmutableValidator. If you are going to use regular expressions with ImmutableValidator, you must delimit the regex string with slashes. If you are using regular expressions with AnnotationProcessor, you can delimit the regex string with slashes or quotes. But, as always, if you use quotes, you have to do a lot of escaping yourself.

The regular expression has to be unbroken on one line. This means you cannot use comments to document them.

I also beefed up the annotation AST transformer for immutable objects. I put annotations on every field in the immutable objects I was testing, and it was only now that I realized that it choked on a field in an immutable object that did not have any validation annotation. I think I fixed that.

I keep thinking I am done, but I have one more change I think I can make.

You’re welcome.

Update On Grails Constraints and Clojure

I am still going through the Grails constraints and seeing if any of them are put into a database schema out of the box, or how to do them with triggers.

I have not spent as much time on it lately. It is also a bit more tedious than I thought.

I am also looking more at Clojure. I think that functional programming will become more prevalent. Plus it also handles concurrency pretty well.

I would like to use Groovy or Clojure full-time at some point. Until that happens, I can only look at one. So I am thinking about going more with Clojure for a while.

On one hand, I think the Clojure community is stronger here in Austin than the Groovy/Grails community. The Clojure meetup happens every month. Sometimes the Groovy/Grails meetup skips a month, as it did in August. The organizers don’t want to be the only ones presenting. I have presented a few times, but I don’t think I am the town favorite.

The irony is that in general I think the Groovy/Grails community overall goes about things better. They are largely copying Ruby and Rails. Sometimes when you ask some Clojure people about web frameworks, you get this answer that they don’t like frameworks, they like to pick and choose amongst different libraries. “That’s the Lisp way.” Given that Lisp has spent several decades going nowhere, maybe “the Lisp way” is not the way to go.

That said, I keep getting the feeling that is where things are going. Here is something I posted last year:

When Ken Kousen was here for the Groovy meetup, he said that he had a boss who kept saying, “Oh, we could do that in Lisp 20 years ago.” He thought it was really annoying. He said it was more annoying when he realized his boss was right.

It seems to me that over time languages are becoming more like Lisp or Smalltalk, and less like C.

I still have a few small changes to add to Groovy Validators, and I want to look a bit more at the Grails constraints. But I might get more into Clojure soon. I am on the fence about this. I have spent a lot of time on Groovy and Grails (and money going to GR8Conf), but I don’t want to commit the sunk cost fallacy.