Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 2.36 KB

README.adoc

File metadata and controls

61 lines (41 loc) · 2.36 KB

Greenfoot with Groovy

This is an experiment that uses Groovy in stead of Java for teaching programming with Greenfoot

Why Groovy

Groovy is (more or less) a super-set of Java with a lot of extra features and a smart compiler that allows you to write code with less ceremony.

It is the last point that makes Groovy more suitable than Java for teaching:

//An Actor that wants to change the 'message' property of its world

//Java
HelloWorld helloWorld = (HelloWorld)getWorld();
helloWorld.setMessage("Hello " + helloWorld.getName() + "!");

//Groovy
world.message = "Hello ${world.name}!"

My 15 year old daughter had very little programming experience. When I tried to explain her the Java version, I lost her attention after 10 minutes. Explaining the Groovy version only took 5 minutes :)

Getting started

For the time being, this project is a quick hack and doesn’t come with an installer :(

The easiest way to get started is:

  • Install Intellij IDEA (the free community edition is sufficient)

  • Clone this repository (or unpack the zip download)

  • Start Intellij

    • Open the greenfoot project that you cloned or unpacked

    • Configure the JDK (you will need JDK 1.6 or newer): File → Project Structure → Project

    • If there is no JDK present:

      • download and install the latest JDK

      • add the JDK in Intellij: File → Project Structure → SDKs

    • Start greenfoot: Run → Run 'Greenfoot'

After that you can open the sample greenfoot project in scenarios/Groovy from within greenfoot.

Note
After editing code in Intellij, click the Compile button in greenfoot (you don’t have to save anything, Intellij does that automatically)

Why Intellij?

I noticed that aspirant programmers are eager to start programming without reading the docs and that they easily get frustrated by compilation errors.

Both issues can be solved by editing the code with Intellij i.s.o. the greenfoot editor:

  • Errors are highlighted while typing

  • Errors can often be auto-corrected with 'ALT+Enter'

  • Good code completion with 'CTRL+Space' makes it easy to explore API’s

Known issues

Generating/browsing documentation from within greenfoot is broken.