Podcast: Exploring Groovy, Grails3 and more with Ken Kousen

We’re joined with Ken Kousen to discuss the current state of Groovy, Grails3 and why those technologies are well worth exploring.

The time for Groovy is now. It makes your life easier and quicker. Anything you do in Java you can simplify by a good factor of five-maybe 10-and still have code that’s easy to write, easy to follow and easy to maintain.


Full Transcript:

[music]

Michael Carducci:

You’re listening to the "No Fluff, Just Stuff," podcast, a JVM conference series with dozens of dates around the country. There will be one near you. Check out our tour dates at nofluffjuststuff.com.

We’re here at the No Fluff event in Boston, and I’m joined with Ken Kousen. Ken, how are you doing?

Ken Kousen:

I’m great.

Michael:

One of the great things about Ken, a little-known fact. Ken actually has, this would be Dr. Kousen.

Ken:

Well, yeah.

Michael:

Not the useful kind.

Ken:

Right, exactly, Aerospace engineering.

Michael:

Your specialty is Groovy.

Ken:

I spend most of my time in the Groovy ecosystem, Groovy, Grails, Gradle, that sort of stuff, but I also do a lot of work with Android, and a few other topics as well and of course various Java topics — pretty much the whole ecosystem.

Michael:

Now, how did Groovy Doc as a moniker not stick? That’s what I’m most curious about. Not many people could be the Groovy Doc.

Ken:

I actually, once, out of pique of silliness, decided to create a YouTube account called Groovy PhD. That was as close as I get. I was going to pick Groovy Doc, and someone had already picked that.

Michael:

It was taken somehow?

Ken:

Paul King is a Groovy developer with a PhD, and he’s so far above what I do that I figure he’s really the Groovy Doc. There are a handful of others, we’re all Groovy Docs together, if you will. The way I think about it is that, with the resume stuff, I never had any trouble impressing my girlfriend’s parents. It’s impressing the girlfriends that was a whole different problem.

Michael:

I can relate.

Ken:

And of course, if my wife finds out about the girlfriends, then bomb shit.

Michael:

Groovy’s an interesting topic. Having started to explore a little bit myself, it’s actually a nice language, and it seems to have thrived, while Java, in my observation has kind of stagnated.

Ken:

Java 8 is really revitalizing the language. That’s great, but it only goes so far. It does add streams and lambdas, but Groovy has had closures from the beginning, but it also has the meta object protocol, the ability to make builders, and do meta programming.

Abstract syntax tree transformations, and all these fancy things that go beyond what Java can do, but it also dramatically simplifies Java in a wide range of various ways. I usually figure it this way. If you want to change paradigms, and adopt something like Scholar, like Closure with a J, then sure, be my guest, it makes perfect sense, but if you’re staying in Java, there really is no reason not to add Groovy.

Groovy is not designed to replace Java, it’s designed to work with it, and you can selectively use in a class at a time, or even a line at a time, in many cases, and thereby keep everything you’ve already learned, and then add more just to make your life easier.

Michael:

I was in a conversation, and a friend of mine decided that he was going to switch over to the dark side, if you will, and choose a JVM language. He asked me, he just solicited opinions. He’s a .NET developer.

Ken:

My condolences. [laughs]

Michael:

We all do things we’re not proud of to pay the bills, but I suggested Groovy, and he said, "Nah, that’s too niche for me." That surprised me a little bit, because for what he was doing, it would’ve been perfect.

Ken:

I think that’s the opposite, actually. I think that’s more of, most people who decide to change languages do something a bit more radical, go a little bit more into a different paradigm. If he was a .NET person, I would’ve been surprised if he hadn’t picked, say, F# to go as a functional paradigm mechanism there.

Of course, in the JVM world that would mean adopting Closure or possibly Scholar. The thing is Groovy has lots of functional capabilities, as well. It’s just not inherently a functional language. Groovy’s the language that you add to Java to make your life easier, it’s not the language you add to change the paradigm.

Of course, the Gradle build tool is winding up, showing up pretty much everywhere, and they have Spock testing and Jeepers for concurrency, and lots and lots of allied projects that make your life better, as well.

Michael:

I do think it’s a misnomer. I was really surprised when he said that it was too niche of a language, and he ended up going with Java, because I guess it’s not niche. It just seems like the Groovy community is booming, the technology is flourishing when Java, again, yes Java 8 is finally starting to catch up, but why is that such a widely held belief that Groovy is a niche language?

Ken:

Groovy, despite its name, or maybe because of its name, has never been the wildly popular meteor streaking across the sky. It’s never the hipster language that everybody decides to go to. I always think of Groovy as the tide coming in.

It gradually grows, and grows, and people adopt it, and they start using it for testing. They start using Gradle for their builds, and they add it here and there. It never just takes over and says, "Oh yeah, we are the totally cool new hotness that everybody needs to adopt."

But it’s not explosive in its growth, either. It’s gradual, like at 2GX, or at SpringOne 2GX I guess I’ll be nice, Guillaume Laforge, the head of the framework, pointed out that the number of downloads of Groovy this year in 2015 was seven and a half million and that was compared to about four and a half million from last year.

Again, significant growth, significant adoption, but not explosive. It’s not the 10 times type of thing that gets everybody’s attention, and makes people go to it. I think people don’t realize that anywhere you’re using Java, anywhere, you can add in Groovy and it will simplify your code, and I usually say that anything I code in Java, I can code in about a tenth of as many lines in Groovy, and they’ll be easier to read and follow.

Now, Java 8 has improved the situation dramatically, but the thing is I can use all the Java 8 stuff in Groovy as well. The syntax is slightly different, they haven’t adopted the syntax for lambdas or method references, but we do have closures, and we do have other ways of referring to methods as closures. There’s plenty of compatibility.

Michael:

Your Groovy compiler will compile Java, out of the box.

Ken:

Yeah, basically. Not delegates to the JVM, you do have to have a JDK installed. It’s working with it, but yes, in fact that solves a lot of cross-compilation issues. If you’re worried about separating your Groovy code from your Java code and applying them each, separately, like a Maven approach would do, you don’t really need to do that.

You tell your Groovy compiler, "Compile everything," and it’ll handle all the cross-compilation issues for you.

Michael:

I can really see this getting into one of those turf war type situations. If you’ve ever had a colleague where you got into line-ending wars, where you would check in with LFs, and then they would check in with CLIFs, and every time you did it different, every single line in the file had changed, I could see this.

You could tell who wrote what, because it might be written in Java or written in Groovy, so maybe it’s a good idea to have your team on board, or have some kind of idea if you’re going to start making some changes here or there.

Ken:

In practice, ultimately you’re going to wind up mixing these things, just because it’s such a natural thing to do. When you’re getting started, if that’s a concern, what a lot of people do is they start either with tests, which are not part of the production code, or they start with the Gradle build files.

Start adopting Gradle for their legion of people out there that just deeply loathe Maven. Not to say anything negative about Maven, necessarily, I’ll leave that for Neal or others. Gradle allows you to incorporate Groovy and Groovy capabilities into your project in a much easier way to accommodate than XML and writing plug-ins.

As for the testing, if you use Spock for the testing, Spock includes a JUnit runner in it, so that you can mix JUnit tests and Spock tests in the same project, and in fact, most people do that on a regular basis. Again, the benefit is, you don’t have to change anything. You just add, so all of your existing knowledge carries over.

Now, if you’re concerned that people will have the radically different opinions about code formatting and things like that, those are higher-order problems. But also, the Groovy…

Michael:

You can get those anyway.

Ken:

Exactly.

Michael:

Which surprises me because we all know that there is only one correct way to place your curly braces.

Ken:

You’ve got it right, don’t you?

Michael:

I do.

Ken:

The open brace that goes at the end of the method, not at the first line, or the first character of the next line. The open brace goes at the end of the method signature, the way God intended them to be.

Michael:

Ken, I thought we could be friends.

[laughter]

Michael:

You have to be able to look at the block, and then you can eyeball, you can see very clearly at the end of the block.

Ken:

I’m sorry to hear that. You are a magician, so I can always transform it the other way.

Michael:

Yes, and I also have ID plug-ins to do that for me.

Ken:

Yes, of course.

Michael:

To clean up heathen’s codes.

Ken:

The thing is, one of the nicest things about Groovy that doesn’t get as much press as I think it should is the community is very welcoming and friendly, which I think is amazing.

Michael:

Especially to newcomers.

Ken:

Yes. The Grail’s people have a Slack channel, which is very active, and the core team members monitor that. The Groovy people, now that they have moved to Apache, it’s an Apache project now. Currently in incubating project, but soon it will be a top level project at Apache.

The Groovy people have mailing lists, they monitor StackOverflow. It was an interesting discussion, actually, that happened at 2GX, during the Groovy boff was why didn’t they have a Slack channel? Paul King pointed out that they may, in fact, decide to have one, but the Apache people insist that any discussions that result in changes to the language need to happen on an area that has documentation.

For example, it has to be on an email list, because those emails will provide a trail to let you know what happened, and why. The problem with Slack, it’s not just that these things go away, it’s that you can edit a Slack post.

If somebody goes in and says, "Oh here, what about this stupid thing?" And somebody says, "No, that’s stupid," and then they go back and change it so it doesn’t look stupid anymore, then you’ve lost the thread of the conversation.

That’s the example Paul King used, and therefore while there’s no problem from Apache to maintain a channel, if they’re ever going to have discussions about the language itself, and about changes in the language, that has to happen on one of their Apache email lists.

That said, it’s a group of people, I’d say the top level people tend to be very humble, very friendly, very welcoming. There’s a lot of information available for that.

Michael:

I definitely got that vibe, being at the 2GX.

Ken:

You were there, at the Boff?

Michael:

I wasn’t in the Boff, but just being at the event and meeting a lot of the community.

Ken:

Graham LaShay, Guillaume Laforge, Paul King, I don’t think I’ve ever met people so bright who are so humble at the same time, other than the No Fluff speakers right at the backyard.

Michael:

Of course.

Ken:

Of course, present company except. At any rate, going on. [laughs]

Michael:

The other question I was going to ask you about.

Ken:

Sure.

Michael:

Grails 3, how do you feel about that? I, myself, have had some challenges with it.

Ken:

The thing about Grails 3, I think because of the whole Pivotal situation, them pulling out financial support for the Grails developers at the beginning of the year put them into a bind where they had to get this thing out the door before the documentation had caught up to it, and various other issues had been resolved.

They had to rush it to get Grails 3.0 out the door by March 31st, and we’re still paying for that little bit. Now that most of the Grails developers are now supported by OCI, Jeff Brown works there, Graham LaShay works there.

Michael:

Great guy.

Ken:

Oh, yeah, Jeff Brown being another No Fluff speaker. At any rate, they’ve also hired a few more, so they’re already, I know this is parenthetical, but OCI is already doing more to support Grails now than Pivotal was already.

At any rate, now that these guys are back to work and cranking things out, I expect those issues to go away and become much easier to deal with over time. Again, they’re very active on the Slack channels, answering questions.

The nice thing about Grails 3, of course, is that it’s built on top of Spring Boot, and a lot of the people who left Grails, Spring Boot is probably the hottest Java-based web framework around right now. Of course, that makes it easier to build restful web services and everything.

Grails is simply a set of Groovy DSLs on top of it that incorporates a persistence mechanism, and lots of convention over configuration, all of these nice motherhood and apple pie things that used to be on top of regular Spring MVC, are now layered on top of Spring Boot and get all of Spring Boot’s advantages.

All those metrics and everything you get out of Spring Boot, now you can get out of a Grails app. They’re working on these alternative profiles, so that there will be a micro profile where you can generate a restful web service very quickly and easily. These things are all coming.

The biggest drawback to Grails 3 right now is that the docs are not really there yet, and there are no books on it, but I do hope to do a video course in a couple of months. Even the IDE support isn’t quite there, but the biggest change in Grails 3 from Grails 2 is that now they use Gradle for the build tool.

In fact, you can open a Grails 3 project in IntelliJ as though it was a Gradle project. You just use the Gradle functionality, and all the Groovy editing functionality, and the same thing would work in Eclipse with the Groovy plug-in, if you will.

Michael:

If you still use Eclipse.

Ken:

Right, but unfortunately, in my experience, there’s a lot of people who are still sentenced to that as a free tool. I mean, I understand that, it is free, but the community edition of IntelliJ is also free, and that supports Groovy, if not Grails, and for Grails 3, that’s enough.

One should also mention NetBeans because they’re a small but very vocal community, you don’t want to leave them out. They have Groovy and Grails support since way back in 6.5 and I think they’re somewhere in the 7s now.

Michael:

NetBeans is still around?

Ken:

[laughs] Again, they are a quiet group, they will not object until you say it like you just did right there. "No, I use NetBeans all the time." I mean, it works.

Michael:

I did, five or six years ago, that was my PHP IDE.

Ken:

You’re admitting to being a PHP developer? Are you sure you want to go there? I had all this respect for you, now you put your braces in the wrong place. That’s probably where it came from, PHP and everything.

Michael:

There’s so many things I could say about PHP.

Ken:

Should I do the shameless self-promotion?

Michael:

I think it’s time.

Ken:

If you’re interested in Groovy, and you have a Safari subscription especially. Safari.oreilly.com, I have three video courses at Safari. One called, "Groovy Programming Fundamentals," one called, "Practical Groovy Programming," and one called, "Mastery Groovy Programming."

I also have Gradle fundamentals out there, and a Gradle for Android, as well as a couple of Android courses, as well. The Gradle for Android, I have to mention, because am very close to turning in the final version of a book that’ll be at O’Reilly called, "Gradle Recipes for Android."

Michael:

Cool.

Ken:

It’ll be an O’Reilly book, it’s basically done. Very short. It’s 150 pages, maybe something like that, and it goes through all of the different features of Gradle that are specifically designed for Android. It’s not a generic Gradle book, but it’s much more the one specifically designed for Android studio and Android development.

There’s all the video courses in the books, and there’s only so much self-promotion I could stomach, so that’s enough of that. What else did you want to talk about, anything there?

Michael:

No, that pretty much wraps it up. Do check those out.

Ken:

They’re all at shop.oreilly.com, but the video courses tend to be a bit pricey, so if you have a Safari account, you can just add them on. My older book, the one that’s been out a year or two now is, "Making Java Groovy." That’s the one from Manning.

That one is a book designed to show you how to add Groovy to Java, to make your life easier. Each chapter is more like, "OK, how do we do this in Java? How can we do this with mixing in some Groovy, and then by the way, does Groovy bring anything to the table?"

For example, the testing chapter, "Let’s talk about JUnit, and then let’s talk about doing JUnit in Groovy. Do they add anything? Oh yeah, there’s Spock as well."

Michael:

Now, this wasn’t the one that had, "50 Shades of Groovy," as a working title, was it?

Ken:

I really wanted to use that, I really did. [laughs] I thought that was my only hope at making the New York Times bestseller list, and sadly we did not go that way. The New York Times has not taken any notice of my books, so far.

Michael:

That’s probably a textual error.

Ken:

It’s more likely to happen in Vin Cad, anyway.

Michael:

Just by sheer volume of words.

Ken:

Exactly. This is my second book. It should be out in physical form by the end of the year. I expect it will be out early access form within a week of me finally getting my act together, finishing up the revisions. Which was going to happen today, but I had to do this podcast. Can I use that?

[laughter]

Michael:

Well, I’m honored to have you here. Just to wrap up, it sounds like if you’re looking for a breath of fresh air in your Java code, the time for Groovy is now. If you want to be more multi-lingual without having to learn a whole new paradigm, but you want to continue to grow, and maybe make coding a little bit more fun.

Ken:

It really does. It makes your life easier, and quicker. Don’t you want to go home on the weekends? Don’t you want to see your family again? Maybe, maybe not, but still, anything you do in Java, you can simplify in Groovy by a good factor of 5, maybe 10, and still have code that’s easy to follow, and easy to read, and easy to maintain.

It’s not about making the shrewdest code possible — that would be Perl, write-only code.

Michael:

If you were coding in Perl, you’d be home by now.

Ken:

Yeah, except if you had to read it again tomorrow, you’re in trouble. It’s about making code that simple, and easy to understand and follow. That’s what I like so much about it.

Michael:

One more big thank you to Ken Kousen. Thank you for being here.

Ken:

My pleasure. Glad to be here and I’m glad that you’re doing this. I mean, it’s long overdue that we’ve had something like this associated with the No Fluff, Just Stuff tour, and I’m glad that is now going to be around. I should quickly mention, also, we have a podcast in the Groovy community called the Groovy Podcast, which, by the way, will have a web page hosted by No Fluff, Just Stuff, as a matter of fact.

Michael:

I just saw Ben Ellington working on it.

Ken:

Exactly. Once we get our act together, that should be in the next couple of weeks or whatever, we’ll have that as well.

[background music]

Michael:

Wonderful, wonderful. we’ll see you on the road. Hope to see you at the show near you.

Ken:

Take care.

Michael:

At No Fluff, Just Stuff, we bring the best technologists to you on a road show format. Early bird discounts are available for the 2016 season. Check out the entire show lineup and tour dates at nofluffjuststuff.com. I’m your host, Michael Carducci. Thanks for listening, and stay subscribed.

Leave a Reply

Your email address will not be published. Required fields are marked *

*