Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java vs. C++

Name: VIPPER 2012-02-01 11:05

Hello /prog/, professional shitposterTM here. One of my Cisco classes for the second 8-week session of this semester was canceled due to low enrollment, and there aren't any other open Cisco classes for me to take, so I was thinking that I'd take a programming class. However, due to my schedule, and the fact that not all classes are open anymore, my only options are either a class on Java or one on C++. Which one would you suggest that I take?

I know regular expression, can make some simple bash scripts, and I mainly work with Cisco IOS and GNU/Linux in my networking classes, so although I don't know a whole lot about programming, I'm not exactly tech-illiterate either.

inb4 read SICP
no classes which fit into my schedule teach Lisp, so that's not an option

Name: Anonymous 2012-02-01 15:23

Don't bother asking /prog/ for advice. Nobody here actually knows C++ or Java, and you should hence ignore unsubstantiated claims such as "Java is slow" or "C++ is shit". The best path is to research the pros and cons for yourself, but here's a basic summary.

C++ and Java are two very different beasts, but it really only comes down to one thing: are you planning on getting a job as a programmer, or is this just a side-interest?

If you want to get a job writing code for a living, take the Java course. Java is the de-facto language that most large companies use. This is because Java offers a lot in the way of productivity and 3rd party tools, which allows their programmers to write less error-prone code in less time.
    Also, Java runs on what is called a VM (Virtual Machine). This means that your program will be (theoretically) portable across all platforms that the underlying VM is written for.
    Java utilizes a built-in GC (Garbage Collector) to clean up for you so it doesn't have to be done manually. This frees you up to concentrate on what really matters, which is the logic and structure of the program. Java is an Object-Oriented language, meaning that you will spend most of your time defining and manipulating data structures called objects in various ways.
    Java's portability and safety come at a price; any given Java program will be slower than an equivalent C++ program (although optimizations to the VM and the increasing power of computers serve to make this more or less a non-issue).

If you're just interested in learning programming, I'd suggest C++. Its syntax was the base for Java syntax, so the two don't look radically different. C++ is the same as Java in that it is Object-Oriented, but you have the ability to mix different programming paradigms within a single program. This means that you are not restricted to just using Object-Oriented Programming, unlike Java, which is strictly OO. there are also some aspects of Object-Oriented Programming that it does differently.
    The main advantage of C++ is its speed, and its vastly more powerful templates (though this facet can often be a double-edged sword). C++ does not use a VM like Java, and it is not garbage collected. This means that C++ programs are not portable across different systems (although its source code generally is; the distinction isn't really important for a beginner), but it is faster than Java; often quite a bit faster.
    C++'s speed also comes at a price, however. It is not as safe as Java's sandboxed environment. C++ allows you to manipulate pointers, which are dangerous and can crash your program if not used correctly.

(Anecdotal: I also find that, on average, Java code is much easier to debug. The C++ compiler will often give you very cryptic errors that are hard to track down. This is in part because of Java having a simplified syntax compared to C++. Whether this is a bad or good thing, is up to you).

TL;DR: Java will get you a job. It's safer than C++, and your programs will be write once, run anywhere. It forces you to only use Object-Oriented Programming, and is also somewhat slower.

C++ is fast and is more powerful, in some cases. It can also be Object-Oriented, but doesn't force you to use OOP exclusively. It is also more dangerous, and has a slightly more complex syntax.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List