07.11.07
My plea against C++
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?
Tony said,
July 11, 2007 at 1:18 pm
There’s an option for Java with 10% penalty? What exactly are they testing you on?
Good luck with getting Erlang approved.
David Mercer said,
July 11, 2007 at 1:18 pm
Brilliant! I hope you succeed.
Why the 10% penalty for Java?
UnwashedMeme said,
July 11, 2007 at 1:24 pm
The TA feels that Java makes it too easy which is why he attaches the 10% penalty. I suspect this means he won’t be amenable to Erlang either, but I had to try. After fighting with C++ for the first two projects I don’t really care about that penalty either.
Ryan said,
July 11, 2007 at 1:27 pm
Punch cards are essential to modern network protocol design.
Joseph Huang said,
July 11, 2007 at 1:30 pm
Just use Felix, it compiles to C++.
______ said,
July 11, 2007 at 1:56 pm
I like your web design aesthetics.
As for the topic at hand:
This is good preparation for the real world.
It teaches you that when you do work for someone else, there are nonsensical requirements that drive you insane.
The sooner you realize this, the sooner you can stop asking permission. Leave school and start a start-up. Work only for yourself.
http://news.ycombinator.com
Andy said,
July 11, 2007 at 2:16 pm
Being a good programmer is not about bending a problem to meet your requirements, it’s about doing the best you can with the tools you have available.
I hope your TA says no, you’ll learn more from it!
Walter Bright said,
July 11, 2007 at 2:41 pm
You might be interested in the D programming language, which is a reengineering of C++.
UnwashedMeme said,
July 11, 2007 at 2:44 pm
Joseph: I might take a look at that, I was also thinking of Gambit-C scheme(http://www.iro.umontreal.ca/~gambit/) for the same reason.
_____: The blog skin is one of the many great freely available wordpress ones, it claims to be written by http://beccary.com/
Andy (and others): I agree that being a good programmer does involve working with what you’ve got, but there is also the aphorism of “use the best tool for the job”, I think we have better available.
I don’t think I will learn much more from doing this project in C++. I will get a little bit more facile in it maybe, but if he does say no I will most likely ditch all the code I have and use Java anyways, it will be faster. All the details that C++ makes you focus on I have done before they are tedious, not informative.
I want to use erlang precisely to learn more. It is a language I don’t know in a paradigm that I’ve not used much of. The higher level would allow me to focus on a more complex/interesting protocol design, which is why I took the class in the first place. Implementing Erasure Codes(http://en.wikipedia.org/wiki/Erasure_code) for recovery is optional, something I would like to work on, but will be much less likely to do if I have to spend all my time tracing down spurious segfaults or spending to much time just trying to get the linker to work.
Total Loser said,
July 11, 2007 at 2:51 pm
Erlang is the hottest language that has gotten lots of internet buzz around it in the last few months.
Learn it, but not for this school project (I don’t think the instructor will understand anything about your code - and erlang - it’s so different)
Just do it in C++. Why suffer a penalty? Sometimes you have no choice and need to adapt.
(P.S. I do C, C++, VB6, VB.NET, C#, Java, Perl, PHP, Pascal/Delphi, Shell scripting … and more.. whenever required)
some guy said,
July 11, 2007 at 3:42 pm
“I hope your TA says no, you’ll learn more from it”
you don’t want to use the most powerful tools you can get your hands on; you want to use the LEAST powerful?!
that’s the fucking stupidest thing i’ve ever heard. why doesn’t he do it in assembly language, that’ll be even harder. fuck that, why not just toggle this shit on a front panel in octal using machine language? that makes doing “hello world” hard, he’ll learn a lot from that.
go get outsourced and die, you luddite retard.
Tony Morris said,
July 11, 2007 at 3:57 pm
“Erlang is the hottest language that has gotten lots of internet buzz around it in the last few months.”
I think the Haskellers would disagree.
cunningjames said,
July 11, 2007 at 4:44 pm
Hope your teacher lets you.
It reminds me of a time when my networking teacher gave a particularly tricky assignment. He said we could use any programming language we’d like — referring, of course, to the Java and C that he’d been using to teach.
Well, screw that, says I; I’d been looking for a reason to try Ruby. It’s easier to ask for permission than forgiveness.
cunningjames said,
July 11, 2007 at 4:45 pm
Er, forgiveness than permission. Ignore me.
Phil Rand said,
July 11, 2007 at 5:29 pm
It’s supposed to be a learning exercise? Then write it in both C++ and Erlang, carefully recording how much time you spend, how many bugs you have to swat in each, and how fast they run. Submit both, plus a well-written report on the comparison. And please post it to your blog, too.
___ said,
July 11, 2007 at 6:05 pm
When you get hired for your first job, are you going to whine and complain because you’re told to do a job in THEIR preferred programming langauge? Give me a break!
Aaron said,
July 11, 2007 at 6:54 pm
Dont be a pussy, you are in college to learn the hard stuff so suck it up and do it in C++. Really understanding C and C++ will really help you understand computers, which is very valuable and will really help you be a better programmer. And to really get C and C++ you have to do large projects in it.
serious said,
July 11, 2007 at 7:20 pm
Yes, this seems awfully stupid.
Why should the language matter if it isn’t the subject of the assignment?
Ideally, there should be a series of tests which the students assignment should be able to pass if it is implemented according to the spec.
All that matters is input and output.
UnwashedMeme said,
July 11, 2007 at 7:47 pm
Phil Rand: If he denies my request I might very well do both, attempting to use the erlang one as a protoype to solve all the interesting problems to minimize how much I then have to do in C++.
___: As I said above, I’ve been working professionally for 7 years. I use all kinds of languages at my work, some I like, some I don’t. If in starting something, I felt the wrong course was being taken and didn’t say anything, I think I would be remiss in my job. I may argue against it, but if the decision is made then I do it; if I really don’t like it, then I quit and go work somewhere else. That is certainly not an option to be exercised lightly but it is there.
Aaron: One thing I really like about the college degree I’ve gotten is that I’ve worked at every level from the transistors up. I think I do have a pretty good grasp on most of them. I’ve done my share of pointer chasing, and as that is not the stated purpose of this class I am hoping to avoid doing more. And as serious also echos, the feeling is “Should I be doing this on punch cards?” I have in fact had professors argue in favor of this, I still disagree.
kirindave said,
July 11, 2007 at 8:52 pm
For the love of xose, don’t listen to the defeated and spineless people giving you advice to “suck it up and code in C++”. They’re the kind of people who never get anywhere in the field, and wonder why their careers stagnate.
Erlang is among some of the many languages used by software companies focused on delivering a quality product as opposed to an adequate one. I myself had to fight to use Objective-C in college, so I wish you luck.
If you want someone to email your TA or professor with reassurances that these languages are used in the domain I question, email me and I’ll gladly send one for you.
Albino said,
July 11, 2007 at 11:59 pm
This kid seems to have a good grasp of the world to me. Unless he is outright lying about his 7 years experience with other B&D languages, I would give in on this one. Of course the TA has to be smart enough to understand that freeing someone like this is more important than forcing them to stay with the rest of the class. Thats damn near impossible in this world where the 80% is eating Java like its a cream filled jelly doughnut and the other 20% is experiencing freedoms like lisp, haskell, and erlang.
If I’m the TA/Professor and I’m educated on the cutting edge of what’s going on in the language world, I have this kid write me something fairly advanced dealing with C++ code to prove he knows how and then I’m turn him loose. His learning a whole new language to accomplish one programming assignment ought to show his commitment to learning.
UnwashedMeme: You do have one solace. They _must_ grade your code. One of the Python Twisted guys was bragging in IRC a few years back how in the beginning Java course he wrote one of his assignments without using any loops. The entire purpose of the assignment was to teach the student how to write loops. The point was not forgotten by the grader nor the professor.
JJ said,
July 12, 2007 at 12:19 am
Please stop whining. Yes, whining. Clearly typing doesn’t make your arms sore, so why complain about it in your email? Clearly neither C nor C++ lead to bad software, as there is a lot of great software written in both (Linux, for example).
There are many people who are quite happy coding in C++, and many of them are quite comfortable using whatever the current fad language is too.
Anyone who gets confused by compiler error messages is clearly inexperienced in the given language. How about you spend some time learning C++ properly rather than whining?
maht said,
July 12, 2007 at 1:38 am
Perhaps it is because he can;t mark it because he only knows Java and C++. Perhaps you should try a C looking language.
Limbo is the one I would choose. It has CSP and GC and other stuff that takes you away from all that C++/Java crap and it’s readable by C programmers.
*AND* if Nemo is the guy I think he is, he’ll be v. pleased :)
http://www.vitanuova.com/inferno/limbo.html
Masklinn said,
July 12, 2007 at 1:55 am
> Being a good programmer is not about bending a problem to meet your requirements, it’s about doing the best you can with the tools you have available.
Funny, I was told that being a good programmer means carefully studying the *real* requirement and using the right tools for the right job, which C++ definitely isn’t in this case.
> Just do it in C++. Why suffer a penalty?
Because using C++ for that is stupid, and sometime convenience is better than gimmicky points.
Plus implementing a correct solution in half the time and getting 90% of the maximum grade beats failing to implement a correct solution and getting 10% out of the potential 100% of the maximum grade.
> Dont be a pussy, you are in college to learn the hard stuff so suck it up and do it in C++.
no.
> Really understanding C and C++ will really help you understand computers
Lol.
Well, no, really.
> which is very valuable and will really help you be a better programmer
That’s the most stupid and delusional thing ever.
C++ doesn’t make you a better programmer, and for C to make you a better programmer you need to hack on systems stuff such as OS or drivers code.
Languages like Erlang, Lisp or Haskell, on the other hand, do make you a better programmer by broadening your solution-research space and offering you alternative methodologies and programming paradigms to work with.
OU said,
July 12, 2007 at 2:19 am
It might be nice to GPLv3 an erlang version of the problem task, and the offending C++ code. Just for a comparison.
Wayne Khan said,
July 12, 2007 at 2:49 am
I was once asked to write a .NET webapp for a school project when .NET was still pretty new. The frontend was, of course, ASP.NET. The entire course provided code fragments in VB.NET. I hated the wordiness but I did the work nevertheless.
Then midway through I figured that C#.NET provided the C-style syntax and curly braces I loved. I wrote the entire code-behind in C# and received a D grade as a result.
Jordan Wilberding said,
July 12, 2007 at 4:43 am
“I hope your TA says no, you’ll learn more from it”
As I have TA’d classes myself I can say this is the farthest from the truth. How do you learn more by having a required language that is used for almost every CS class taught?
For all the classes where I have designed the materials they are structured in a way that a student can choose any language they want. This gives students a chance to try different languages and compare how elegant their code is compared to other kids who chose different languages.
Fortunately, most of the classes at the university I attend are like this. I can tell you, writing programs in Erlang allowed me to take 1/5th of the time it took other people to use C++ and Java.
Aaron said,
July 12, 2007 at 6:23 am
It sounds like you have a good college then. If you really do have a good enough grasp of it maybe you dont need to do it, but I am not saying you should do it just because its hard (ala punch cards). I have worked with a lot of people in the industry who have no clue how computers work and thats a bad, bad thing. They are barely able to patch together snippets of code they found on the web, chant some voodoo incantation, and then close their eyes click Run and hope something not too bad happens. People like that could really benefit from some C++ experience.
Not everyone can grok memory and pointers and templates and the stl and how to architect non-gc programs, but I think everyone should at least try. If you really already understand that maybe you dont need anymore experience. That said though, if you do, then maybe it shouldnt be such a big deal to this project in C++ rather than Erlang, right? Actually having to write the code that does some of what Erlang gives you out of the box will probably help you understand Erlang better as well.
And maybe thats one of the things your teacher is trying to teach your class. Not just how to write a protocol, but how to make it work without invoking “magic” constructs in a concurrent language like Erlang that students dont really understand. Its like how you probably had to write a linked list implementation even though almost every language known to man has a library linked list. There is something to be said for writing basic stuff instead of just using what has already been written for you. It gives you some good experience.
kirindave, there is a difference between being spineless and understanding that doing hard things can make you a better person. Also, for what its worth, if you consider games and real applications that people use everyday, C++ is far more prevalent for those than higher level and niche languages like Erlang. Obviously its not the same for web applications, but in my experience it is the people who can ONLY do web apps or can ONLY do hard C++ apps that really stagnate.
Joseph Huang said,
July 13, 2007 at 3:31 pm
Gambit-C compiles to C, not C++, so that mite be an issue. If compiling to C is fine, there are many languages that you could use. I recommend Mercury, which has a high-level C backend.
http://www.cs.mu.oz.au/research/mercury/