Evil Code Challenge
As an exercise in absurdity, I think it would be a fun experiment to try using only the “worst” features of a language to accomplish some programming task. The definition of “worst” is certainly subjective, but get a few developers in a room and I’m sure they can all agree on a few common peeves.
For example, most Java devs I know would gag at the idea of writing an entire program using only constructors and checked exceptions. No conditional logic, no methods, no
return statements, just checked exceptions thrown from constructor methods. It’s disgusting.
But it’s also kind of an interesting challenge. In a backward kind of way, checked exceptions provide a multiple-return control flow mechanism that is completely different from the way we normally think about our code. And if you squint hard enough, using only constructor calls is almost like using pure functions, because it would be pretty much impossible to maintain any meaningful state. Maybe?
Implement a sample code exercise (e.g. something like FizzBuzz) using only constructor calls and checked exceptions. Sort of like object calisthenics taken to an extreme, be sure to avoid
return, and maybe even
System.out. Remember, it’s not enough just to use the worst language features—you have to use only the evil features. We’re looking for 100% Grade-A Evil.
Post the code to GitHub and share your hellspawn with the world. I’m eager to see how terribly awesome this could be.
Extra credit if you can find a way to mix in even more features we love to hate, like named
break statements (
break foo; otherwise known as Java’s
goto) or putting real code in a
finalize() method to be executed at some random point when GC occurs. Muwahhaha.