The Source for Java Technology Collaboration
User: Password:



Chet Haase

Chet Haase's Blog

Closures: Making Java a More Expressive Language?

Posted by chet on December 15, 2006 at 06:48 AM | Comments (8)

I went to a talk by Neal Gafter at JavaPolis on Neal's proposal for closures in Java and saw some happy code. The syntax that Neal is currently proposing can sometimes result in a ":)", which, as Sun's John Rose noted, is a smiley in the code.

Let's call this emoticode: the ability for code to express itself emotionally.

Completely ignoring any relevant discussion about syntax options, semantics, or even closures themselves, I just wanted to voice my support for emoticode. Far too long have we labored with languages which have no inherent emotion. The characters just sit there passively in our editor, staring dully back at us, having nothing more to say than what the compiler tells them they can. Now, through new language syntax, we can see whole new language patterns developing where code can be much more expressive. Code can smile at us, or frown, or wink, or laugh, or do any of the many, wonderful things that emoticons can do in the trite emails and IM messages that we receive from friends.

Finally, we can finally have a meaningful relationship with the code we write.

Perhaps we need more language features that specifically target emoticode. Maybe we can flag bug patterns through emoticode syntax. Or we can encourage good programming practice through happy expressions. Beginning programmers may fall into patterns that use emoticode that laughs at their developer; this gentle poking fun can help these students learn better coding practices while encouraging them to develop a long and meaningful relationship with the code they write.

Don't just write solid code; write happy code.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Enough with the jokes already! We want serious, boring technical blog entries dammit!

    Posted by: gfx on December 15, 2006 at 07:09 AM

  • hmm, this could be a revolutionary simplifier. What do you think about this:

    try{
    .....
    } catch( :( ){ :(.printStackTrace(); }


    The unhappy face becomes a sugar for all Exceptions.

    leouser

    Posted by: leouser on December 15, 2006 at 07:30 AM

  • > Enough with the jokes already! We want serious, boring technical blog entries dammit!

    Yeah, we want Laplace pimped timing frameworks with auto-beautifying compensations! ;)

    Cheers,
    Mikael

    Posted by: mikaelgrev on December 15, 2006 at 09:30 AM

  • Btw, can't we get closure about closures and close that RFC (Request For Confusion) down for good? We want a Pimped up APIs, not a Pimped up language spec.

    Posted by: mikaelgrev on December 15, 2006 at 09:34 AM

  • leouser:

    Excellent thought, although perhaps instead of having the syntax represent Exception, we could introduce a new class of throwables called "Expression". This way, the emoticode could express not only errors and Bad Things, but also happiness and Good Things. Maybe the user or developer would like to know when the code was having a good time, and could catch particular Expressions that applied.


    In fact, we could take this a step further and define subclasses of Expression to denote different types of expressions. One that I think would be useful would be Fit, which would be used for unhappy situations, such as:


    if (denominator == 0) {
    throw new Fit(:-(, "Divide by zero considered icky")
    }

    After all, if we can throw a fit, why can't our code?

    Posted by: chet on December 16, 2006 at 04:45 AM

  • i nnever know that

    Posted by: njo465p on December 16, 2006 at 05:14 AM

  • chet,

    this may be an excellent idea. We may want to add an additional method to Object to even allow the developer to query to see if the instance is feeling ok.

    Object o = new Thinger();
    o.areWe(FeelingOk.class);


    or maybe even have it be a keyword:

    if( o isFeeling Ok){
    o.playHappyMusic();
    }

    why hasn't anyone thought of this before? :(

    leouser

    Posted by: leouser on December 17, 2006 at 07:51 AM

  • <3!

    Posted by: robilad on December 17, 2006 at 01:43 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds