Skip to content

rma93/greenfoot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 91.0%
  • HTML 7.9%
  • C++ 0.5%
  • CSS 0.3%
  • Groovy 0.1%
  • Inno Setup 0.1%
  • Other 0.1%