Archive for July, 2007

My plea against C++

July 11th, 2007

My computer networking class requires us to write the project in C++. I don’t really know why, the project has nothing to do with C++, it is about implementing a network protocol. There is an option to use Java for a 10% penalty… but java?

I’m asking for something better, the following is excerpted from my email to the TA:

Can I *please* do project 3 in erlang? http://www.erlang.org/index.html From the FAQ: “Erlang is a general-purpose programming language and runtime environment. Erlang has built-in support for concurrency, distribution and fault tolerance. Erlang is used in several large telecommunication systems from Ericsson. The most popular implementation of Erlang is available as open source from the open source erlang site.” The entire language is centered around the idea of lots of independent lightweight processes– not threads, there is no shared memory. The processes communicate entirely through message passing.

I’m willing to take a 10% penalty similar to Java. Which having done the first two in C++ I think might be too small and my wrists don’t care anyways.

All the required protocol functionality for the project would be implemented in my code, but as this is a higher level language I can do it in symbols and pattern matching constructs not the tedious mucking about in string splicing and parsing (which I’ve done plenty of and am tired of re-implementing, and will still need to do somewhat for the user’s REPL). I will be dealing with the specifics of sockets and the old BSD interface less directly, but I already have that mostly factored out in my C++ code anyways.

The Rant (you can feel free to skip this, but here is the why):
http://www.slideshare.net/Arbow/comparing-cpp-and-erlang-for-motorola-telecoms-software/ Compares C++ with erlang for use in motorola telco. Found erlang programs are shorter, faster and more fault tolerant, but user more memory (5MB runtime, only really an issue for really small embedded devices).

I’ve been looking for an excuse of a project to learn erlang on for a little bit. I’d rather learn this new language to implement the project rather than Java, which I already know and have done similar projects in before. I was hoping to get some protocol design knowledge from this class, not bit twiddling and pointer chasing. In erlang I can focus on that (and have fun with the erasure codes).

Seriously, after the last project in C++, my forearms ached severely– the language is unnecessarily verbose and inconsistent.

I have been doing web programming professionally for 7 years now while at school and this has led to me doing networking code from time to time. I’ve implemented application layer protocols over ssl sockets for charging credit cards through at least 4 different merchant gateways in C#. My first Ruby program was an http client for an octet-stream of random numbers from random.org. I did network programming in Java all last semester for Nemo’s distributed OS class, and previous undergraduate classes.

One open source thing I’m somewhat proud of is hacking the UCW (Common Lisp web framework) multithreaded backend to use a pool of worker threads dealing out connections to them and having the threads return to the pool when done rather than assign connections in round robbin fashion that could lead to starvation and idling at the same time.

http://common-lisp.net/cgi-bin/darcsweb/darcsweb.cgi?r=ucw-ucw_dev;a=filediff;h=20051111160037-783f4-d10d54dac7e3b5560204e4a880239472b3d1f263.gz;f=src/backend/httpd.lisp
http://common-lisp.net/cgi-bin/darcsweb/darcsweb.cgi?r=ucw-ucw_dev;a=commit;h=20051111162051-783f4-8fb8c299cd4f4435f91578c0cc5b10984e1fc5a4.gz

I rejiggered someone else’s code to connect emacs to a javascript server embedded in a local firefox to help debug javascript live from the editor. https://trac.acceleration.net/JsShellServer Luckily didn’t have to do to much here– XPCOM nightmare… most of what I did was application and presentation layers.

Why do I say all of this (other than to toot my own horn just a little bit :-)? Of this work in implementing application layer protocols and dealing with sockets in different languages and interfaces; the network interfaces are familiar (boost::asio is nicer than some), but I’ve found nothing so difficult about it as everything else in C++ to get this done. The STL is just a shell of a library. Boost helps get it halfway to being useful. boost::shared_ptr is almost like having garbage collection except not. C++ is a world of special cases with little consistency. I’ve seen some absolutely abominable template error messages (ending with unnesting 7 layers deep completely unreadable and because i forgot to link in the proper libraries). This isn’t an “Enterprise language” it is a tarpit– I don’t care what Microsoft tells you. How do you think they got their reputation for OS and application security? I am a smug lisp weenie ;-) This was not my first application in C++ (although first in a while), but my opinion of the language has been cemented by this latest project. The feeling is “Should I be using punch cards as well?”

sorry for the length… C++ really gets to me. erlang?