practical-groovy-public
practical-groovy-public copied to clipboard
Some possible subedits and stuff
"Before I explain how to install and set up Groovy, consider this: w" → W
Java platform → Java Platform
Re Java runtime, Groovy required JDK, JRE is not sufficient.
Re getting JDK, all platforms with package management can install OpenJDK via package management, much easier than downloading and installing OracleJDK.
Emphasize scripting a bit more in the need for a JDK/Groovy installation: Groovy can be used like Python, Ruby or Perl.
Groovy installation: on Debian "aptitude install groovy2", on Fedora "yum install groovy".
I am a strong advocate of using groovyConsole as the initial teaching tool for people who do not already use IntelliJ IDEA, NetBeans, Eclipse,... I would probably not even mention http://groovyconsole.appspot.com/
"Let’s now try out the Pythagorean Theorem. You do remember that from school, don’t you?" I'd lose that second sentence, potentially a bit condescending, and indeed makes many assumptions that may not be true for the reader.
The code delivers 5.0 not 5, why? (I know, but the reader may be surprised.)
I would use final rather than def: introduce people to creating bindings rather than variables. With Groovy 2.5 this is now checked (finally). Alternatively do things with a declaration using the Script binding, make it more Pythonic. No need to mention why it works at this stage.
10.getClass() → 10.class Use the property syntax initially, then do the method call form later?
am a great fan of showing people broken code and the errors produced, but some of Groovy's error messages are a real turn off, especially for people new to Groovy. Maybe say that the print1n() is gratuitously horrible so as to deal with this by siding with the reader?
"Ignore the for loop and println() statements for the moment and just focus on the results of executing the script." → "We'll look at the loop and print statements shortly, for now let us focus on the results of executing the script."
[[Have to go now, more later.]]
Thanks for the feedback.
- Man, the grammar around the colon is tough!
- Does Groovy really need a JDK? If so, why? The JRE seems fine for Groovy scripts and the console/shell.
- I like the web console because it allows people to try the language without installing Groovy. It can be used in internet cafes and the like too.
- I keep thinking of incorporating
final
but it sometimes feels too early to introduce/explain it. Worth revisiting this though. - I almost always use
.getClass()
anyway and it avoids having to explain properties at this stage.
Rest all looks good, thanks!
Although I really like the idea of getting people to use final
, introducing it before Groovy properly supports it is just going to confuse users and possibly put them off the language. If Groovy 2.5 is out by the time the book is ready, then I'll switch to final
as suggested, because then I can at least show what happens if you try to change a final variable's value.