Erlang logoBanner

Obfuscated Erlang Competition Results

In conjunction with the 13th International Erlang User Conference, an Erlang Obfuscated Programming Competition was held. The goal of this competition was to write the most obfuscated Erlang program, providing a safe forum for poor coding practices and programming styles. Through this competition, we hope to illustrate some of the subtleties of Erlang and how they can best be used and abused.

 


A report from the judges

This year's "Subject Matter Experts" were

Joe Armstrong,, Ericsson, Sweden
Jan Henry Nystrom, Erlang Training and Consulting, UK
Richard Carlsson, IAR, Sweden

A call for participation to the competition was made at the Erlang workshop in Freiburg. The rules of the competition are available here. That we got even fewer submissions than last year reflects well the feeling we have that the Erlang area is really hotting up to the point of being scorching. All were ingenious, making it very hard to pick a winner. The judges individually gave every entry a grade between 1 - 5 in the following categories:

  • Obfuscation
  • Style
  • Innovation
  • Functionality

The previous winning entries: 2005 and 2006.

Winners


First Prize:Mats Cronqvist


First prize goes to Mats for a program that uses macros to write one of the most unreadable identity functions possible. Here is the source code:

-module(xXx).
-author('mats cronqvist').
-export([x/1]).

-define(x,x(.
-define(Xx,X.
-define(X,X)

->. ?x?X?Xx.
	  

This is what happens when you run the program:


Second Prize: Per Gustafsson


Second prize goes to Urban Urban Boquist who wrote a small program that can testif a value is less than zero or if it is greater or equal to zero. Of course being one of the leading developers of the binaries and bit strings he has taken help of binaries for the task.

:

-module(obfuscated_per).

%% The program creates a message based on the sign of floats
%% stored in a binary. It does so in two different ways. 
%% One checks the sign bit of the float. The other actually 
%% checks if the float is greater or smaller than zero

-export([test/0]).

test1() ->
  TestData = <<0.0/float-native,
	      1.0/float-native,
	      -4.57352069251366153375e+233/float-native>>,
  io:format("Use sign bit:~p~nCompare to zero:~p~n",
	    [make_string1(TestData),make_string2(TestData)]),
  ok.

make_string1(Bin) ->
  case Bin of
    <<0:64,Rest/binary>> -> %%Float Representation of 0.0
      << <<"erlang ">>/binary, (make_string1(Rest))/binary >>;
    <<0:1,_:63,Rest/binary>> -> %%First bit is the sign bit
      << <<"is ">>/binary, (make_string1(Rest))/binary >>;
    <<1:1,_:63,Rest/binary>>  ->
      << <<"great">>/binary, (make_string1(Rest))/binary>>;
    Empty -> %we are done and return the empty binary
      Empty
    end.

make_string2(Bin) ->
  case Bin of
    <<0.0/float,Rest/binary>> -> 
      << <<"erlang ">>/binary, (make_string2(Rest))/binary >>;
    <<F/float,Rest/binary>> when F > 0 -> 
      << <<"is ">>/binary, (make_string2(Rest))/binary >>;
    <<F/float,Rest/binary>> when F < 0 ->
      << <<"great">>/binary, (make_string2(Rest))/binary>>;
    Empty -> %we are done and return the empty binary
      Empty
   end.


© 1999 - 2008 Erlang Training and Consulting Ltd.Erlang Web
Erlang Events
26 Aug 2008: Couch DB at 10,000 feet! (London User Group Talk)
26 Sep 2008: Commercial Users of Functional Programming Workshop, (Victoria, Canada)
27 Sep 2008: ACM SIGPLAN Erlang Workshop, (Victoria, BC)

Travel Costs to the US, Canada and Mexico are on Us!

In conjunction with the ACM Sigplan Erlang workshop in Victoria, Canada this September, travel costs and travel time for all our Erlang/OTP consulting and training services offered in the US, Mexico and Canada will be on us!!

If you are thinking of getting that code or architecture review, are uncertain if you are getting the most out of OTP, want a prototype to convince your manager or need that testing and debugging seminar, now is the time! Visit our Offer Page for more information.

Subscribe to our newsletter!

Sign up to receive the latest news about our Erlang/OTP scheduled training courses, new offerings and special offers.

 
Subscribe to our RSS feeds:


  Jobs feeds
  News feeds
  Events feeds