Monday, March 15, 2010

The Ups and the Downs of the Groovy Console

Like most scripting languages, Groovy has a programming editor -- the Groovy Console . Groovy's editor is home grown, (and not SciTE). There are, however,a few things you need to be aware of with the Groovy Console.
  1. It does not save when you run the program (so get used to saving before each run) 
  2. I've yet to get the interrupt button to work while its running, so I've had to kill the process (thus issue 1 above).
  3. If you are working on a program (and have not saved it recently) and go to open another program (file-->open) you're not prompted to save the first file before its replaced. So save often.
I'm willing to bet that as Groovy matures, that the these issues will get resolved.

Sunday, March 7, 2010

Groovy File One Liners

One of the nice things about Groovy if you are a Java programmer is the ease that you can manipulate files with just one like of code.

Create or replace a file  and write a line of text to it:

   new File("myfile.txt").write("Here is a line: \"whats a nice programmer like you doing at a blog like this\" \n");

Append to a file (creates the if it doesn't exist)

  new File("myfile.txt").append("\"Looking for a some code like this\"\n");

Read the second line (First line is line 0) of the file

  println new File("myfile.txt").readLines()[1] //what was the response

Saturday, March 6, 2010

Argh..Oracle has taken over the Java page

While I was adding links to this page I realized that sometime in the last month, Oracle took over the java.sun.com page. I can't find anything. Oh well, lets hope the change is good in the long run.

println("Hello World")

think that its about programming in Groovy. But It may just be groovy. (bad pun)

What is Groovy anyway?

Groovy is a programming language based on java. Its what happens when you take mix Perl and Java, and sprinkle on some Ruby.

Groovy is weakly typed, unlike java, but shares most of java's syntax (as well as the java virtual machine), but guess what -- you don't need semicolons at the end of the line. You can use pretty much any java class and syntax you want, and that means that any java programmer can learn it quite quickly. Once you get the hang of it you can pound out code pretty quick. (BTW, Groovy is the core language of the Grails web framework.) Groovy comes with a simple editor (the groovy console) , as well as a shell for scripting fun, but for heavy duty programming fun its supported by Eclipse, and NetBeans (which I use) .

You can find plenty more Groovy propaganda (and doc) at the Groovy Hompage

The current version of Groovy can be downloaded for Linux and Windows ( No current OSx support -- whats up with that? I use all three OS's)