in reply to C++, C# or Java

The answer is, it depends. What sort of software do you WANT to write? After all, if you are learning a language to stay employed and not because you want to use it and enjoy what you are writing, you are either using the wrong language or are in the wrong field.

If you want to move towards applications that get closer to the hardware, or even perhaps driver land, you must learn C. Learning C is a good bridge towards C++, but it is possible to learn C++ before C. C++ is essentially a superset of C, but it encourages some new idioms, some of which are good, some of which are not. In many ways, C++ trys to tack on OO in an ugly way (kinda like Perl but not really), and has some really braindead constructs like cout << setiosflags instead of fprintf. C libraries are plentiful and can bring you immense power, but it's not highly elegant. But what is... Java? Nah. Anyhow C++ OO is cludgy, but sometimes it's better than nothing.

Java, IMHO, gets too much press. Yes, it is multiplatform, it's painful to write GUI apps in Swing, but they are shiny and get the job done. It is a very bad language to use for writing services (daemons) in, but it has a lot of usage for JSP and Servlets (web stuff) in Industry. It's a mixed bag, I tend to dislike it because it feels like I am programming in handcuffs, and a lot of stuff is not doable without JNI (the XS equivalent) -- plus, not a good selection of modules as CPAN either. I recommend reading some nice Paul Graham Java Bashing.

Mono or no Mono, I would not consider C# unless you want to sell your soul to Microsoft. It copies Java (bad idea since Java ain't great anyway) and doesn't really do much but try to subvert it.

So some other non-mainstream languages were mentioned (Ruby), but are there many jobs in that? No. Personally I don't like ruby, but that's beside the point. If you want a language industry wants badly, Ruby ain't it.

Personally I am not officially a professional Perl developer, I use Perl whenever I can for build systems, command lines, etc -- often without asking management :) -- anyhow, keep Perl on your resume, as Perl is seldom the first language you are hired for, but it tends to be a huge plus. I wish I could find a mostly Perl (some C/C++) position myself, but there are hard to come by (especially in NC, USA). Most jobs on jobs.perl.org tend to be sysadmin related and/or in CA/WA/DC/NY. Or requiring massive LAMP experience.

So that's a long answer and not much good. I'll sumarize. If I were you, and I'm not, I'd learn C/C++. C is not dying. Learn C++ after C, and if you like it, there will be positions in that for a long long time. Someone said C++ is for GUI apps, and they were probably thinking VC++. Quite widely used. Not going anywhere, and not losing share. In the interest of full disclosure, in order of favorites, my languages are Perl, C, and C++. Java comes in about 8th.

My next language is going to be something like Haskell, Scheme (yeah, I know Lisp sort of), or Erlang -- something highly functional, borderline insane for industry usage, but screams 'this kid isn't a drone, we want him'. I'm also considering dropping a few languages from my resume just because. Yes, I know Python, but I don't want to look like I list every language I have ever used, and I don't want to land a job playing with it!

Replies are listed 'Best First'.
Re: Re: C++, C# or Java
by stvn (Monsignor) on Apr 02, 2004 at 23:13 UTC
    Mono or no Mono, I would not consider C# unless you want to sell your soul to Microsoft. It copies Java (bad idea since Java ain't great anyway) and doesn't really do much but try to subvert it.

    I have to disagree with this. C#, IMO, is a major improvement upon Java. Much of what I hated about Java is fixed in C#, and having read many of your gripes about Java in various posts, I actually think you might agree with me.

    I hate Java's primative types. IMO, it's a bad attempt by Java's designers to be "pure" about things. Its a pain to upcast primatives into objects, and then the OO syntax is overly tedious. To me its a waste of resources, both CPU and programmer. C#'s approach may not be as "pure", but its alot cleaner for the end-programmer. These 2 lines are basically equivalent:

    int i = 5; System.Int32 i = 5;
    No tedious new Integer(5) syntax like Java. The simplistic explaination is that int is an alias to System.Int32, but thats not the whole story. The CLR (Common Language Runtime) manages all your types, so int i = 5 is managed as a primative up until it is needed to be an object (System.Int32), at which point the CLR will "box" the (much smaller) primative type into the (really only slightly larger) object type. And because C# has operator overloading (unlike Java), it really makes no difference to your code what it is anyway. It all for free and behind the scences. Sure, this is not okay if we are writing a device driver, but you wouldnt use Java to write a device driver either, so that is of no consequence.

    Then there are delegates. I love my anonymous subroutines, I loved them in Javascript, and I love them in Perl (and of course, LISP, SCHEME, etc too). They are the much smarter and sexier evolution of C function pointers. C#, not to be left out in the cold, has delegates. They are basically a type-safe anonymous subroutine on crack! They are too detailed to get into here, but suffice to say, if you ever found your self writing an object in java where all you really needed was an anonymous method, you should check out delegates. (Yes, I know about the Pizza compiler, but thats not Java, thats Pizza).

    Casting in Java sucks, its unsafe and a serious source of headaches. And yes, you guessed it, C# is the Extra-Strength Tylenol for your Java headaches once again. Consider the all to common, fetching from a Collection casting idiom:

    MyType i = (MyType) c.get(5);
    If i is not a MyType derived object, you are in trouble and get an exception. But in C#, you can do this:
    MyType i = c.Get(5) as MyType;
    If i is not a MyType derived object, you get null in i. Which is much easier to test for than it is to handle exceptions.

    And what about foreach, another Perl favorite of mine. C# has it too:

    foreach (MyType i in c) { # do something with i }
    Thanks to an optimization in the C# compiler this handles all your type casting for you, and just as above, if its not a MyType derived object, its null.

    These are just a few things I liked about C#, there is plenty of other cool stuff, like properties and events that really IMO go way past what Java is trying to do in its all too restrictive "pure" OO box. Give it a look, you might like it.

    -stvn
      all good info, but to be fair to my much despised java, 1.5 is finally adding generics (and foreach loopage). My "copied Java" statement is true at face value. C++, Java, and C# all follow the same basic syntax and paradigm. I'm glad to see casting made cleaner, and exceptions paired down. Casting in java is painful. Yet, it is a rip off -- I was present at several early Microsoft C# dog-and-pony shows, and the similarities were very clear. The reps couldn't even break out a "why this is better than Java" line ONCE -- and when CLR came up, the best they had was "some group in Poland is trying to make C#" work. They don't care -- they just embrace and extend as usual. However my chief beef with them, and this still remains, is they have zero interest in anything but Windows, and the Mono folks are doing their best to clone something they really don't like (Windows Forms), so we're looking at what....GTK for Mono as alternatives? Microshaft isn't going to let that fly. I suppose if you are on a Windows platform, it's probably better than Java (no doubt, hard to be worse) and it may make due if it's still as powerful as C at lower levels, but you still...ultimately...have a language that should have been compiled down to exe (no runtime) and should not be MS specific.

      How is the API? You still bound to MSDN hell? That's another big issue with Microsoft. Inconsistant API's that actually make the inconsistancies (which are many) in Java look tame. Sometimes they take Unicode, sometimes they take UTF-8, always clashing on types... The Windows SDK and DDK are pure evil. How clean are sockets? memory mapped files? authentication? Have these been cleaned up at all from the DDK and SDK? Probably not.

      And our poster is still looking for a good employer language. C# ain't there yet, except in the early adopter type of shops (which, IMHO, are the suicidal shops).

        Bruce Eckel at least thinks that Java's generics may not be such a good idea. article 1, and article 2 give some specifics.

        java, 1.5 is finally adding generics
        Yes, I heard about that, FWIW C# 2.0 plans to have generics as well, along with (from what i have seen) true anonymous methods, iterators and partial classes (maybe like Eiffel's deffered classes, I am not 100% sure I still have stuff on my "to be read" list about this).
        However my chief beef with them, and this still remains, is they have zero interest in anything but Windows
        Well, can't argue with that, but are you aware of Rotor? It runs on BSD and Mac OS X, granted I tried it early on and opted instead for Mono, but it at least shows M$ cares ;-P
        and the Mono folks are doing their best to clone something they really don't like
        Not being a Mono folk, I cannot really speak for them, but I get the impression they actually do like it.
        I suppose if you are on a Windows platform, it's probably better than Java (no doubt, hard to be worse)
        I'm on Mac OS X,.. and I like it better than Java ;-) but i clearly have some issues, so dont take my word for it.
        How is the API?
        A lot better than the old Win SDK (although my experience with that is very limited), from what I understand though, alot of what was so bad about it before was that it was never really "designed", but instead just clobbered together over the years.

        The C# class libraries are very similar to Java, but being not so strict/purist about OO there are some places where it is alot cleaner. On some level they are very much the same since they provide alot of the same basic services.

        And our poster is still looking for a good employer language. C# ain't there yet, except in the early adopter type of shops (which, IMHO, are the suicidal shops).
        I disagree, my boss has been finding more and more demand for it out there, which was one of the reasons I learned it, so we can get some of that work. We are consultants, so we have to flow along with the trends a lot. It has actually been out for quite a while too, I have BETA release discs going back several years, so its not really early adopter territory.

        And again, no matter what you think about the evil that is M$, the C# and the CLR are pretty well designed and throught out concepts, really not too different that the Perl6/Parrot stuff if you really think about it. But anyway that discussion is for another node.

        -stvn
      Java is also trying to fix these things. In version 1.5, they have:

      a) boxing

      b) generic types (C++ STL)

      c) foreach

      d) bettern version of enum

      and several others