Monday, July 6, 2009

Keith Myers & DJ Pompey Headlined ToorCamp 2009

Riding back from ToorCamp 2009 at the Titan-1 Missile Silo! Very fun time. I'll let the other bloggers tell you all about it.



Those of you who know me personally are aware that in addition to programming, I've also been DJing as "DJ Pompey" for 8+ years. On Saturday night (July 4th, 2009) I did my biggest gig yet. I headlined ToorCamp with Keith Myers: 12:30am-4am. Something like 600 people were in attendance.


Photo credits Matt Westervelt.

Just listen to these satisfied customers on Twitter:

dmertl Great Toorcamp even though it got off to a rocky start. @KeithMyers rocked it for 8hrs Fri and 4hrs Sat, holy shit.
dakami Holy crap. @KeithMyers 's DJ powers are apparently now over 9000. #toorcamp epic status confirmed.

skout23 @KeithMyers (DJ keith) is killing it here at toorcamp the last 2 hours, and he's got another hour to go. Awesome!
pinguino My rave muscles all hurt. Aaghhh.


The footage of us together hasn't surfaced yet, so just imagine a fusion of these two videos!





We got a noise complaint from over 7 miles away.

Monday, January 12, 2009

Beyond web.xml

Another day paying the bills in Eclipse...
public class HelloWorldServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.getWriter().println("Hello World!");
}
}

So you've just written yourself a spiffy little servlet and you want to test it out. That's when it hits you... there is a long and arduous road ahead. You've got to remember how to deploy a War (how does that Ant script go again?). You need to configure Tomcat (Or wait 20 minutes for Weblogic to start). Then you need to write that dreaded web.xml file. This is a barren wasteland, riddled with fire and ash and dust. The very air you breathe is a poisonous fume. Not with ten thousand men could you do this. Tis folly!

Dag-nabbit! You aren't writing a big fancy industrial strength web app. All you want to do is run your little servlet in a local web browser and get on with your life! Jiminy Cricket, it's times like this that can turn a developer to Rails.

So what are you going to do? Bite the bullet and muddle through it all for the umpteenth time? Give up and write a command line app? Recall that the three chief virtues of a programmer are: Laziness, Impatience, and Hubris. Where there is a will, there is a way.

Grab yourself a Jetty jar and throw one of these in your app:
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;

public class EmbeddedServletRunner {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
Context root = new Context(server,"/",Context.SESSIONS);
root.addServlet(new ServletHolder(new HelloWorldServlet()), "/hello");
server.start();
}
}
Run it. Point your browser to http://localhost:8080/hello and you're good to go.

Sunday, October 26, 2008

Ladies and Gentlemen, The Editor War

Scene opens. The Lakota coffee shop in Columbia, MO.

Jane: ... and the other has been really interesting. It's Anthropology, with Jim Metcher.

Ray: (lights up) Yes! I actually got to take one of Metcher's classes during my brief stint in the evening program.

Jane: Are a Mizzou student?

Ray: Close. I graduated from MST in '06. I'm workin' now.

Jane: What do you do?

Ray: I help machines think. I'm a programmer.

Jane: Spiffy! So what's new in the fast-paced world of "programming"?

Ray: Well, lot's of things I guess. Let's see... new languages coming out as usual. PHP making some controversial design decisions regarding namespace. 50th anniversary of Lisp was just celebrated at OOPSLA; I bet there were some great talks at that. Oh yeah, and I just read about a new development in The Editor War.

Jane: ... The editor what?

Ray: War. The Editor War... it's this infamous feud. (waves hand dismissively)

Jane: Feud? (interest grows at the scent of scandal) Over what?

Ray: Which text editor to use.

Jane: (Smirk) No, really. What is it about? I'm actually interested this time, you don't have to make things up to amuse me.

Ray: No... (Slowly raises hand to forehead), that's actually what it's about.

Jane: (Confused) That doesn't sound like a very political decision. Is there some, like, protocol or something that has to... (pauses) I thought text was all sort of... compatible. (glances downward) I guess I don't much about this stuff.

Ray: Actually, you've got a decent grasp of it. While there have been a few new standards in recent years to accommodate different languages, text is overall very compatible from one editor to the next.

Jane: In that case, I don't get it. What other technical hurdle would force all programmers to use the same editor?

Ray: Ahh! I see the source of your confusion. That's not the issue. We're not debating the adoption of an official industry-wide standard editor. Nothing along those lines. It's a matter of personal preference.

Jane: (Disappointed) So it's just different people choosing a different tool? Aren't you exaggerating a bit by calling it a feud?

Ray: I see where you might think that, but believe it or not, I've been to parties where shouting matches broke out spontaneously at the mention of either of these editors.

Jane: Really?

Ray: Really.

Jane: Wow. So this has been going on for what, weeks now?

Ray: A bit longer than that.

Jane: Months?

Ray: It has been going on for over 25 years.

Wednesday, July 16, 2008

Clone Wizards of Time and Space

The talk, Code Generation: The Safety Scissors Of Metaprogramming by Giles Bowkett.

The quote, "This is how Lisp guys think of Lisp and the Lisp community: intergalactic voluntarily bald clone wizards of time and space who the womens are be lusting fors."

He literally said that. I'm not paraphrasing. One more time in case you missed it.



Intergalactic Voluntarily Bald Clone Wizards of Time and Space Who The Womens Are Be Lusting Fors.


I for one am quite offended! I resent the continuing perception that Lispers are smug and arrogant. Nothing could be further from the truth! We do not see ourselves as some sort of secret society with magic powers beyond the comprehension of you mere mortals.

Signed,
Ray, Squire of the Grand Recursive Order of the Knights of the Lambda Calculus

Saturday, July 12, 2008

Learn Recursion

Todays message is short and sweet.

I was just reading chapter seven of Beautiful Code, "Beautiful Testing". As the chapter begins, the reader is challenged to attempt writing a binary search. Here's mine.
int search(int[] arr, int target) {
return arr.length == 0 ? -1 : search(arr, target, 0, arr.length-1);
}

int search(int[] arr, int target, int min, int max) {
if (min >= max) return target == arr[min] ? min : -1;
int middle = (max + min) >>> 1;
if (arr[middle] > target) return search(arr, target, min, middle-1);
if (arr[middle] < target) return search(arr, target, middle+1, max);
return middle;
}
Yes, it's in Java. I'm not going to rewrite it in eight other languages because that's not the point, for once.

Here's the point: If you call yourself a programmer and don't grok this recursion business, fix it. Now.

This has been a public service announcement brought to you by the "People Who Will Not Take You Seriously If You Don't Understand Recursion" Foundation.

Tuesday, July 1, 2008

The arrogance of demanding evidence

"No one has the right to destroy another person's belief by
demanding empirical evidence." — Ann Landers

This is widely quoted but I haven't found a full citation of the original source. Thus, it's remotely possible that this is a misquote, out of context, etc...

Still, I'm not too worried about misquoting a shared pen name. My main concern is that in 2008, it is still possible to read a quote like this without flinching. One might even agree!

The statement implies two things. The first is that the freedom of speech should be abolished. (We'll look past that one for now.) The second is that it is unreasonable, inhumane, and simply impolite to expect people to base their worldviews on ... the world. In intellectual discourse, once someone says the magic words "I believe," it is inappropriate for other parties to continue further.

In fact, a more honest phrasing of the Ann Landers quote might be:

"Don't speak up; you might inadvertently cause someone to change their mind."

I've had my beliefs turned upside-down by empirical evidence dozens of times in my life, and I'm probably not done. I used to believe that aliens crashed in Roswell, New Mexico in 1947. I used to believe that Uri Geller was psychic. I used to believe that homeopathic preparations had medicinal properties. I used to believe that computers couldn't think — and would never think.

I am a better person for being able to change my mind.

"It is far better to grasp the universe as it really is than to persist in delusion, however satisfying and reassuring." — Carl Sagan

"Isn't it enough to see that a garden is beautiful without having to believe that there are fairies at the bottom of it too?" — Douglas Adams

Thursday, April 10, 2008

Subsequences With BGGA Closures

Just a quick followup on Returning '(()) Considered Difficult. I just rewrote the "subsequences of length n" exercise yet again (surprise, surprise), this time using the Java BGGA prototype by Neal Gafter et al. I really like being able to abstract away the accumulation loop.
import static com.cadrlife.ListUtils.*;
...
private static <T> List<List<T>> subn(int n, List<T> list) {
if (n == 0) {
return Collections.<List<T>>singletonList(new ArrayList<T>());
}
if (list.isEmpty()) {
return new ArrayList<List<T>>();
}
T first = list.get(0);
List<T> rest = list.subList(1, list.size());
return addAll(collect(subn(n-1, rest), {List<T> sub => push(first, sub)}),
subn(n, rest));
}

A word on syntax: Some people have come down on the {=>} closure syntax but I wonder if they have actually used it. This was my first time using BGGA; everything compiled and worked on the first try. I can't say the same about trying to simulate closures with anonymous Transformer classes using the Apache Commons CollectionUtils version of collect.

Just in case you don't have com.cadrlife.ListUtils in your classpath, here are the obvious definitions of collect, addAll, and push.
package com.cadrlife.ListUtils;
...
public static <A,B> List<B> collect(List<A> list, {A => B} function) {
List<B> result = new ArrayList<B>();
for (A element : list) {
result.add(function.invoke(element));
}
return result;
}
public static <T> List<T> push(T el, List<T> list) {
list.add(0, el);
return list;
}

public static <T> List<T> addAll(List<T> a, List<T> b) {
a.addAll(b);
return a;
}

FunctionalJ: Steve points out that the last bit could be done this way, using the Java library FunctionalJ.
DynReflect reflect = new JdkDynReflect();
Function1 pushFirstElem = reflect.staticFunction(
AnnotatedSequencer.class, "push").f2().bind(first(list));
return addAll(map(pushFirstElem, subn(n - 1, tail(list))),
subn(n, tail(list)));
Be forewarned that using reflection to simulate first-order functions in this way will sacrifice compile-time verification.