James Williams
LinkedInMastodonGithub

Groovy as a first programming language

Tags: Groovy

Chrigel Uniter recently posted about the above question on his blog. He doesn't conclusively say yea or nay but does raise some interesting sub-questions, namely, Groovy vs. Java as a first language.

Groovy is better...

Low barrier to entry The lack of much scaffolding code would make the barrier to entry lower for students. However, this could descend into the current situation with ECMAScript. The low barrier to entry opens the door for some that shouldn't be there in the first place.

Syntactic sugar. Many of the functions that students I used to teach [in other languages] would think were provided are provided. For example, they were sometimes frustrated with the lack of consistency between finding the length of a static array and a dynamic array. Though it adds the convenience of calling size() on an int array, il ne cache pas the core-Java way. A prof could teach both while preferring consistency. It lets them code and not worry as much about semantics.

Groovy renaissance. I believe it will continue and we will see Groovy emerge as the preferred scripting language for Java applications and as a possible secondary scripting language for some Linux distros. Groovy is now in the Ubuntu repositories. I know Ubuntu != Linux, but it's my most favorite distro. Currently Python by far is the frequently used scripting language in Linux. As more move to Java 6, update 10, I think we'll see more Groovy.

Java is better....

Groovy teaches the easy way first. It makes me thing of a valuable lesson learned at my alma mater Baltimore Polytechnic Institute (it's a high school y'all). The teacher's name escapes me but I remember doing exercises for two weeks computing derivatives the long way in Calculus I class and then being shown the easy way. We asked the prof why didn't he just show us the easy way. He said something along the lines of "you would never appreciate the easy way if you didn't know the hard way." And that's the case somewhat with Groovy, much of its power comes from Java but unlike calculating derivatives, it isn't limited to the features of Java and can be a superset.

It might cause havoc to introduce CS 101 students to a language with weird parenthesis rules and as much syntactic sugar. (e.g. you can run a script without a class, unlike Java, but in actually it's being compiled to a class in the background)

It is the standard. Albeit verbose, Java has a defined structure. In the short term, there is a lot more reference material in Java than in Groovy....and a larger userbase [YMMV on that argument, it depends on if you believe that a Java dev is Groovy dev who doesn't know it yet].

I guess I don't actually answer the question either.