Integrating It All
[ 310 ]
The club was teaching a Java class to the more senior students who had already
graduated from Scratch and HTML. The mentors were struggling with teaching
Java to youngsters. The amount of ceremony needed to set up even a simple
HelloWorld.java class was hard for the kids to grasp. The fact that you need a class
and a main method and all those semicolons caused a lot of puzzled faces and most
of the classes were occupied with helping the kids correct simple syntax errors.
My immediate reaction was, "Ouch! I don't want to be teaching Java", so I suggested
we try Groovy instead. In that way, all we needed to do for a Hello World script was:
println "Hello, World!"
Which is what we did. It has turned out to be a great decision. By losing all the
extraneous Java syntax we have been able to focus on introducing basic programming
concepts in a far more natural order. Starting with variables, conditionals and looping,
we then introduced methods and classes only when there was a natural need to do so.
As soon as we started using Groovy, we also started seeing opportunities to use the
DSL features of the language to improve the experience for the kids. By building our
own script launcher we were able to add built-in features to the coding environment
that made life easier, for example:
- While Groovy has println as an easily accessible shortcut, there is no easy
way to accept input on the command line so we added readln and variants. - We noticed that the stack traces and compile errors were confusing to the
kids so we captured those and simplified them. - We added other goodies like a built-in banner method which produces ASCII
text using JFiglet:
banner "Groovy"
http://www.ebook3000.com