Jun
29
2008
From Citizen Astronomy, ScienceNews:
From a scientific standpoint, Galaxy Zoo started paying dividends almost from day one. “This is not something we expected,” notes Chris Lintott, an Oxford University scientist and “zookeeper.” The hope was that hundreds of people would log on. To date, almost 150,000 have.
And the idea that many of the images might one day be categorized illustrates how low the zookeepers’ expectations had been. On average, each of the images on the site has already been seen and characterized by 50 people. Those 50 million photo evaluations “is simply fantastic,” Lintott says, “and illustrates for us one of the huge advantages of getting the public involved. It gives us an error bar on the classifications.”
(Also, there’s Sacre Bleu Wine.)
Popularity: 2% [?]
Jun
26
2008
Those Groovy adepts who want to skip to the punchline can check out my best-seller JIRA ticket: “ExpandoMetaClass sometimes, but sometimes MetaClassImpl“.
For the rest of us, check out some odd behavior in Groovy.
class A {}
def a = new A()
a.metaClass.greet << { println "Hello, World!" }
a.greet()
Looks great. Looks like a classic “Metaprogramming in Groovy” example, right down to including “Hello, World!”. So, I’m off to run it…
Exception thrown: groovy.lang.MissingPropertyException:
No such property: greet for class: groovy.lang.MetaClassImpl
groovy.lang.MissingPropertyException:
No such property: greet for class: groovy.lang.MetaClassImpl
at Script0.run(Script0:4)
WTF? Weird…where’s that “MetaClassImpl” come from? Where’d my ExpandoMetaClass go?
So, right after executing the first line, and I check out the metaClass attached to the class.
class A {}
println A.metaClass.class.simpleName
// prints "ExpandoMetaClass"
Okay, good, so I’ve got it. The awesome part is what comes next.
def a = new A()
a.metaClass.greet << { println "Hello, World!" }
a.greet()
// prints "Hello, World!"
Hey, whaddyaknow? Now it works out great.
Turns out that you only get the ExpandoMetaClass if your class statically calls “.metaClass” before the variable is instantiated. Either that, or you need to call ExpandoMetaClass.enableGlobally().
Popularity: 5% [?]
Jun
25
2008
Edit: BTW, the title of this post is a reference to “Music to Make Love to Your Old Lady By“.
Almost every developer I know puts on their headphones when they’re really getting into coding. Now, I’m assuming that everyone is listening to
something, and I’m curious to know what it is.
Here’s my list. Continue Reading »
Popularity: 3% [?]
Jun
24
2008
After I learned OCaml, my coding mindset was totally distorted. I started writing Java code that looked like this:
public Collection<Foo> getCertainFoos() {
return
CollectionUtils.select(getFoos(), new Predicate() {
public boolean evaluate(Object o) {
return SOME_CONSTANT.equals(((Foo)o).getProperty());
}
});
}
This is kinda ugly in Java, but it’s simply what comes out when I was thinking this in OCaml:
List.find_all (fun i -> SOME_CONSTANT = i#getProperty()) #getFoos()
I also started slapping final everywhere — see Yet Another Reason final Is Your Friend. A ubiquitous use of final actually gave some nice patterns (in the “macro” sense of patterns), but raised all kinds of eyebrows and made my code unmistakable. This lead up to a unique coding style which you can see in my most involved open source project, JConch. Meanwhile, my co-blogger was talking about “The Hole in the Middle” Pattern, which is also a lay-up within FP circles but required some backflips to implement in Java (functional interfaces) and C# (delegates).
It wasn’t until the advent of Ruby and Groovy, though, that functional programming skills really became easier to use. Basically, because of the inline closure’s succinct syntax (and ability to access non-final variables), I could suddenly do all kinds of really fun stuff. This “fun stuff” was exactly the kind of stunts I was pulling in Perl back in the day (see the BEGIN block in my Text::Shift code for a reasonably accessible example), and it was part of the reason I loved Perl so much at the time.
So, I thought I’d share some more of these cute stunts with you.
Continue Reading »
Popularity: 7% [?]
Jun
20
2008
Are you ready to celebrate? Well, get ready: We have ICE!!!!! Yes, ICE, *WATER ICE* on Mars! w00t!!! Best day ever!!
— Mars Phoenix Rover (cite)
Wired article is here.
University of Arizona’s page on the Mars Lander has a press release here which includes some pictures.
NY Times just got into the mix here.
Popularity: 1% [?]