præclarum

Search:

Frank A. Krueger
Seattle, WA, United States

Recent Posts

Dear Windows Vista
Extension Methods Make Code... Different
Why Dictionary is Great - Dynamic List with Indice...
My 1 Minute Trial of VB 2008 Beta 2
Eben Moglen
Feynman my Hero
Mr. Gore acting as Philosopher
Assimilated by Win32
Times Reader makes reading on the web enjoyable ag...
A Naive Implementation of MapReduce in C#

Choosing C#/Java over C++ for a beginning programmer

Wednesday, September 05, 2007 Link

Christopher Diggins asked me present my view on whether beginning programmers should learn C++ as their first major language. Below is the response I wrote (slightly edited).

I think Christopher's original statement "you will find yourself to be much more productive in a shorter amount of time" just about sums up my feelings towards favoring C#/Java over C++. But you must understand that the debate is more complex than the conclusion.

Christopher presented the two pro lists for the languages, but the point about automatic garbage collection in C# should be emphasized even more. As Jamie Zawinski put it (http://www.jwz.org/doc/java.html):

That one point makes me able to forgive just about anything else, no matter how egregious. Given this one point, everything else in this document fades nearly to insignificance.


I am a decent enough programmer with enough experience that most of my C++ programs have only minor memory leaks. Sometimes I can even write one without any leaks, but such ones take some patience to design. My point is that C++ makes you think about memory ownership patterns. That's something you should think about, but C++ makes you think about it so much that you don't have much brain power left to tackle other problems (like getting your program to do what it needs to do).

With Java/C#, you are freed of this burden and you can focus on the problem domain.

His list for C# is pretty good, but I would add another feature that will soon be important: declarative style queries. When I find myself writing large data-backed applications, I end up performing a lot of queries. Doing this with just Sort, BinarySearch, and Hashtables is entertaining only for so long. The query syntax of C# 3.0 allows you to enter queries against object graphs similar to what's available in SQL.

In the debate between Java/C#, I have no opinion aside from the fact that they are nearly equivalent languages. Some syntactic differences, and C# is getting a bit of a power increase in then next version, but from a language standopint they are pertty similar. Both have fantastic libraries that will let you get things done fast. Both have good communities for support. Java's one benefit is that it is
applicable to businesses who do not drink Microsoft's juice.

---

My only reservation about favoring C#/Java over C++ stems from my own growth as a programmer. I began my programming career in BASIC but quickly moved on to learning Pascal/C/C++, the classic systems programming languages, so that I could do some classical systems programming. I believe that my abilities as a programmer have been
forever tainted, ahem, I mean influenced by that early work in low-level languages (by today's standards) writing low-level code.

Once you've written a fairly large programs in these languages, everything else seems easy and enjoyable to use no matter how screwed up it is (JavaScript).

Code and data become the same thing to you. You instinctively know the memory access patterns of your applications. You do not fear pointers or any other memory construct. You can read linux kernel code with ease. You will have a desire to perform meta-programming - code generation and the like - spawned by the greatness and simultaneous weakness of C++ templates.

But, frankly, it's like forcing professors to teach elementary school for 10 years before being allowed to teach students. Sure the lessons learned are valuable, but you will learn those lessons eventually anyway.

So my advice? Grab ahold of C#/Java and don't let go. Master the languages. Then learn a new language at least once a year. If you will be working with Cat, then you are already ahead in your studies. Learn C next, then C++ later on.

Reader Comments

Post a Comment