Java or C++

Discussion in 'Mac Programming' started by NWAMacTech, Feb 15, 2006.

  1. macrumors member

    Joined:
    Jul 14, 2005
    #1
    I have been researching this question for quite some time and just to further that research I would like all of you experienced programmers opinion. I would like to make a career move, I have always enjoyed programming playing with VB, PHP, and the like but I am not a developer. Where should I start, in your opionion what languages will be most important to watch in the next few years. I want to make myself as marketable as possible however i know that may not be simple.
     
  2. Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #2
    If you're new to Object-Oriented Programming, then I would recommend to start with Java, and then when you feel you master that you're ready for C++, because Java is more educational/intuitive and not quite as messy/picky as C++. If you know Java then C++ should be fairly easy...

    On the other hand, if you're comfortable with the concept of OOP and like to fiddle with details then go for some straight C and on to C++. ;)
     
  3. thread starter macrumors member

    Joined:
    Jul 14, 2005
    #3
    I probably shoudl have asked in my orig. question. Can you recommend soem good books on java and or c++. I know there are lots out there and some i have looked at just suck.
     
  4. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #4
    Try Bruce Eckel's Thinking in Java and his Thinking in C++ books.

    Java is definitely a better language to learn because it's closer to a pure object-oriented language but C++ is a very popular language (for buffer overflows) on many platforms.
     
  5. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #5
    Ditto on Eckel.

    As far as which language: after about a decade with C++ and close to that with Java (very little overlap, so the C++ was a while ago), my personal preference is Java.

    However, I recommend that you look for open positions in your area to see who's hiring for each language. Around here, there's a stronger market for C++ than for Java.
     
  6. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #6
    how so?
     
  7. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #7
    I think the key word was "closer".

    Java isn't pure, yes, there are non-object data types, but almost everything you use is an object. C++, well, not as much.
     
  8. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #8
    You can pretty much avoid any primitive types in Java and use objects for everything, in contrast to C++ where you can write whole applications without using a single object.
     
  9. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #9
    interesting take, guys. i look at the "OO-ness" of a language based on how well it supports the core concepts (polymorphism, inheritance, etc.), rather than the extent to which it prevents the user from doing non-OO things.

    no worries, though, i was just curious about the thought process.
     
  10. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #10
    Well, I'd known people in the past to write a whole application with procedural code and try to convince other people that they were actually using C++, at least, until we made changes to the file extensions and compiled the same code using a C compiler.

    C++ is definitely a hybrid language. Borland went out of its way to make their Object Windows Library work more like a Smalltalk framework than C++. It's rather obvious from the way the wind blew that more than a few developers on DOS were more comfortable with the haphazard C/C++ approach of Microsoft Foundation Classes.
     
  11. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #11
    ahhh, the abuses. so, so many. like the guy i knew who "didn't trust" classes and kept using structs. or the guy who didn't quite understand inheritance and his baseclass ended up containing all the members of its derived classes.

    good times :)
     
  12. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #12
    back on topic...

    i see two big differences between c++ and java:

    1. c++ was designed and maintained, for a long time, as a core language that tried to avoid forcing implementation on its user base. a friend of mine was on the standards committee for years, and he told me this was the reason they chose not to define standards for things like a string class (this was a long time ago), which gave rise to companies like RogueWave. Sun, otoh, had no qualms about adding all sorts of packages to java from the get-go, plus defining standards for things such as inter-machine communcation and even development environments.

    2. java grew up in the internet age and focused to a high degree on portability and runtime environments. while the core of c++ (see #1) is portable, the things that developers code to make them run in an environment turned out to be very non-portable (an unfortunate fallout of the early committment to avoid forcing implemenation). to that end, i feel that learning java gives one a leg up on having skills that work on a variety of platforms as provided by the language, as opposed to, in c++, having to rely on 3rd-party vendors providing portability across platforms.
     
  13. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #13
    Considering the early days of C on the x86 systems, standard libraries were needed because even amongst functions with the same name, the functionality was sometimes widely different. GUI development is so (relatively) easy using Java because you don't have to learn multiple frameworks. I'm just surprised that the development of C++ shadowed that of C and generated a bit of chaos.
     
  14. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #14
    exactly. i know a bunch of guys who were experts in parcplace OI. and where did that get them? :)
     
  15. macrumors member

    irrªtiºnal

    Joined:
    Dec 15, 2005
    Location:
    Toronto
    #15
    i;m gonna take in your question my dear fellow, with a not so humble opinion of mine... i propose you the following readmap:

    i would 1000:1 beg you to start with Java. get involved to writing Java "applications" (i.e. bytecoded compilations to run on the JVM) that are some sort of translations of your favorite PHP scripts or Swing forms that do the same as your VB apps.

    use the latest JSDK (1.5.0, aka Tiger - coincidentally) and get your hands on a nifty code editor, one without a visual form designer: else you will start just dragging and dropping buttons and scrollbars like a maniac with no sense at all. i PERSONALLY RECOMMEND JCreator for the Win32 platform.

    most importantly. familiarize with the first 3 basic APIs of the framework, the Core (java.lang, java.io, java.util, etc), the AWT (all the java.awt.*) and the Foundation Classes (all the javax.swing.*)

    a good way to do programming by means of real life necessities: when i started i was really a newbie and i wanted to make a database of all my images. i knew that making software that would (1) do the JPEG compression/decompression, image analysis; (2) do the databasing in SQL or whatever and (3) be **EFFICIENT** would be a formidable task. (one that until now, i have not completed :D .) but i was decided to start somewhere and there i began: i could do a program that traversed a folder structure, dump the image metadata, and put it in a XML file. at that time what was a good achievement, because i got me seriously in the field.

    then start some multithreading, IO intensive, graphics programs; while at the same time you go for .NET in C#.

    the .NET platform is REALLY a damn copy cat of the Java platform. at it;s beginning it was more like a Microsoft optimized implemetation of the Java paradigm. now it is a very robust an promising technology. Vista will be mostly based on it, and consequently direct development for will be much easier/strcutured/well documented/consistent/scalable/bug-free/etc.

    not until you have mastered Java basics and C# (both of which will, almost by inertia give you an intuitive idea of what C is like - you would think it is like a primitive version of Java or C#) you can start C++

    seriously, it;s not that i want to be alarmist giving an impression that C++ is difficult/complicated. a (serious) problem (for newbies) with it is that it really is a literal (HUGE) extension of C, and as such it inherited all the compilation/linking/optimization hassle of its predecessor, altogether with the first real encounter with the ideal of OOP. the memory management is ONLY one of the many issues that you would struggle with for a while. i mean it. just to begin with, in C, people get in trouble getting a clear picture of the pointer/array and array of pointer/pointer to array/pointer to pointer question...

    in C++, the concepts of inlining, const-ness, (the infamous) references, copy/assigment/slicing, construction/destruction, dynamic binding, etc, etc, etc, etc, and more etc, will simply and utterly bloat the novice. and with this much hassle, chances are (s)he will end up not developing any **real** applications in any short time and will go frustrated :(

    try C++ all the time, until you get it. but in the meantime, get serious job done and apply a serious effort on Java, .NET and more PHP... or Perl/Python etc...
     
  16. macrumors G4

    Joined:
    May 10, 2004
    #16
    C++ is so bad I would even consider learning .NET if those were my only two options.

    Which they aren't. Just stay away.

    Forget about Perl, too. Best recipe for code nobody wants to look at.
     
  17. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #17
    what's "bad" about it? i think it's a fantastic language for large-scale development. if you know what you're doing.

    irrelevant to the discussion, but again: why? are you also going to have a go at sed and awk? if you want code that's nearly impossible to decipher, try lisp.
     
  18. macrumors G4

    Joined:
    May 10, 2004
    #18
    Lisp family languages are the only ones that get it right.
     
  19. macrumors G4

    Joined:
    May 10, 2004
    #19
    There's too many things to list them here. Just google for "c++ sucks".
    Just look at the crazyness people go about to do template metaprogramming. All that stuff is a piece of cake in Lisp, and way more powerful, as you can use the whole language for that, not a pathetic subset of types and operations.
     
  20. macrumors G4

    Joined:
    May 10, 2004
    #20
    It's not irrelevant, as somebody before mentioned Perl as something he might want to learn instead of C++.
    When I took a glance at awk, it didn't look so bad.
    I use a bit of sed sometimes, and I have some little scsh (Scheme shell) script to apply a sed script to sets of files. I wouldn't write anything complicated in sed.
    I do Perl-compatible regex in Java. One doesn't need to know the whole Perl language for that.
     
  21. macrumors 601

    zimv20

    Joined:
    Jul 18, 2002
    Location:
    chicago
    #21
    i dabbled in lisp some time ago (nearly 20 years ago, sheesh), so i'm probably quite out of date on the current state of the language. even so, i'm having a hard time imagining it being suited for the kinds of large-scale projects i've done in c++.

    no worries on the perl thing, i hadn't remembered it was mentioned. but again, not really suited for large-scale, imo. apples and oranges.
     
  22. macrumors G4

    Joined:
    May 10, 2004
    #22
    If you need fascism, none of the currently available Lisp languages is going to help you, AFAIK (unless maybe you implement your own dialect on top of it). In that case, the right alternative used to be Eiffel (when I looked at Ada 9X, it was broken for OO). As it is possible to do Design by Contract with third party tools now, Java is the current best alternative, because of all the libraries available. As there are generics with 1.5, there's no more excuse.

    BTW, aspect-oriented programming originated with Lisp. You don't need third-party tools for that there.
     
  23. macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #23
    I will be truthfull. The only programming I had done before I start C++ was HTML and Applescript, which were no way near the concept of C++. I started C++ and at the start, the concepts were easy to grasp but then... POINTERS APPEARED!

    My God, I don't remember being so frustrated in my entire life. There are problems that I encounter even now in C++, 10 months after I had my first encounter in C++.

    The other thing that frustrates me is C++ output to files.

    And the last and very important thing: C++ is a total CHAOS! Is very picky, and doesn't forgive mistakes. Is not only is a superset of C, is a HUGE implementation of new information! Not only that, but it has so many things to learn, so many libraries, and so many programming techniques, that it may take years to master the language and actually make a program that it would really get you any money at all. If you do a search for C++ in google, you will find that apart from the things that the books tell you, there is also a vast amount of information that you must read and study in order to get profficient in C++

    Do not make the same mistake as I did. Learn a simpler language first, like Java, which is cross-platform, then move on slowly to C++.

    One thing I must tell you though. What i do like about C++, is the fact that lets you not only do anything, but when you finally manage to write some decent programs, you will see that it will have forced you to write a very clean codebase. Programs that are written in C++ are very clean compared to other languages...

    Finally, I don't know if that matters to you, but I heard somewhere that Apple will not be continuing Java's implementation in OS X. It will leave it as is. Java was never meant to be implemented as one of OS X's native SDK's. They initially intended to provide support for Obj-C, C++, C. After that they only included Java to attact the Java developpers, but now, they want to drop support. I guess that explains why Java has always performed so badly on the Mac platform...

    BOOK RECOMMENDATION:
    After you have read a book that will teach you the basics in C++, you can download Bruce Eckel's "Thninking in C++" Vol1 and Vol2 for free on the internet. They are an excellent source of information and will teach you many things that will help you write some decent programs.
     
  24. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #24
    Given the original poster's intentions, I think we can forget about the "best" language. I don't think anyone will argue persuasively that Lisp is all that marketable a skill. C++ or Java are both good choices, and, around here, there are more C++ jobs than Java ones.

    Quality of language is unimportant - the OP wants marketability. God help him, but .NET isn't a bad idea either.
     
  25. macrumors 6502

    Joined:
    Feb 15, 2006
    #25
    If you're looking for one to start and stay with for your whole career, than you have to ask yourself what you want to be programming, since C++ is extremely popular with game design and desktop apps for Windows, while Java has a whole different set of applications.

    (the above could be wrong, I only know a little bit about both, but got the overall impression that C++ is the mainstay for programming actual apps)
     

Share This Page