Tuesday, June 14, 2011

Seven Languages In Seven Weeks

I'm stuck trying to put my thoughts on estimation, conferences and switching jobs into writing. So many unfinished drafts, oh my!

So instead I'm now trying to write the odd post about my experience working through Seven Languages In Seven Weeks.

aimee daniells had the great idea to start an online study group for said book (not gonna type that title again, nu-uh). And since it helps distracting me from worrying about finding a new place to live within the next 3 weeks I gladly took the opportunity to join. (Sidenote: if you're looking for a flatmate in Hamburg please do get in touch.)

The book is very interesting to me because I don't know all that much about any of the languages but have been meaning to take a closer look at Clojure, Ruby and Erlang for some time. It's nice to have something concrete that gets me doing that.

The first language is Ruby. I've worked through days 1 and 2 now and here's a quick summary of what I took away from it.

Ruby has a lot of syntactic sugar. Enough to almost certainly give you diabetes. Parts of me (the old, elitist parts) feel somewhat uncomfortable with that. Other parts of me (the ones trying to get work done in Java) just feel jealous.

There were some more notes I took that I'll just list here without trying to add context (or sense)

  • The kindle version of the book doesn't wrap the code examples correctly with larger text sizes. That's pretty annoying. Does no one test these things?
  • When googling for the api docs one should be careful that one reads the docs for the correct version of ruby one is using. I spent 10 minutes wondering why str.match(regexp) { block } never executed the block until I figured out that that feature just didn't exist
  • String and exec expansion seem to behave pretty much like in bash. Single quote string get left alone, double quote strings get processed and backticks execute native programs. (I hope I'm not misremembering my bash there)
  • if and while have counterparts in unless and until. Sugar++
  • Sugar++ would not actually work. Sugar += 1 does, however. And I think I like why that is the case
  • Numeric zero and empty strings evaluate to true, which i find pretty disgusting
  • Running in a windows shell I successfully ran into encoding issues for Umlauts. Probably Windows' fault. I hate character encoding
  • Cygwin can install ruby and Umlauts look ok there. Calling the windows ruby executables from inside cygwin, which I tried first, had some really weird issues
  • On that note: mintty still rocks
  • Enumerable has all the nice sugar you can only get via Google's guava in Java. And with blocks it's a lot better readable
  • And you can mix all that into your own classes, with just a bit of duck typing. Very nice
  • All that duck typing really makes me long for some grapes
  • If I understand it correctly, Hashes can lazily evaluate values from keys which reminded me of the guava MapMaker. Also very nice. 
  • Hash.invert seems almost too sugary but could be useful
  • Same goes for String.next. Instant tooth decay!
  • A File API with permissions and methods to create symlinks? I never dared dream of that (although, wasn't there something in that regard in the works with Java, too? About time anyway)
  • IO.readlines/foreach is really handy. Convenient enough to never look at perl again. 
  • The automatic closing of files when using blocks is also nice. Kinda like using() in C#, implicitly. (Wasn't there also something like that coming to Java? I can't remember all the things that may or may not go into the language)
  • I felt pretty clever doing Array.new(16) {|x| x+1} until I saw (1..16).to_a
Code is here.

All good fun so far.

No comments:

Post a Comment