Yan Pritzker photographer, entrepreneur, software engineer, musician, skier

Blog :: Git Workflows Book :: Dotfiles :: Photography :: About Me

TwitterCounter for @skwp

Get the news feed
Get updates by email
Follow me on twitter

hello, i'm yan

I am a photographer, entrepreneur, software engineer, guitarist, climber, and telemark skier

This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.

Enterprise intelligence with prediction markets

Find out what your team, colleagues and partners really know about the future — and leverage their knowledge to improve business decisions.

I'm the founder of Planypus, the place to share your plans!

Archives

Contact

Reach me at yan at pritzker.ws

Syntactic sugar: why Iterators have no place in code. (i.e. Java needs to learn from Ruby)

Posted 7 August 2006 @ 6pm | Tagged software, thoughts


Submit to HN

So here we are in Java 5, some ten years later, we finally have a sugar coated syntax for for loops.

for (var : Collection) ...

Now the embarassing thing is, even Visual Basic had a For Each construct like 8 years ago. Java seems like A Tale of Two Cities, a book for which Dickens was paid by the word. Are Java designers being paid by the byte to write monstrosities like:

for(Iterator iter; iter = collection.iterator(); iter.hasNext()){ ... }

There is a primary reason that syntactic sugar matters: we write code not for the self gratifying purpose of putting words on a page, but for solving real world problems. The closer you get to the language of the customer domain, the faster and more accurately you can write code. If a customer tells me that for each order we need to email the manager, I want to write code that says
orders.each {|o| email o.manager}. I don’t want to write something that starts with “Iterator…”.

Syntactic sugar matters. Beautiful code matters. Domain specific languages matter. The Java community needs to start realizing this sooner rather than later or face obsolescence. Iterators have no place in the real world. Abstract them out.


No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment