

If you had a choice, which would it be: C++ or Java? - big_data

Hey Hackers, here is my quandary.  I have to make a choice between C++ and Java as the next language I learn at school.  If you were me, which would you select?  Why?<p>My career interests are mainly in data analysis, with perhaps some financial applications later on.  Which of these two languages would give me the most traction?
======
ecyrb
I happen to work for a company in the financial sector.

Our developers use Java (mostly).

Our research department uses whatever they are most comfortable with for
research, but the result of their research is coded up in C++. If we had to do
it over, we'd probably do everything in Java. Misc. notes:

Personally, I am WAY more productive in Java.

I supplement Java with Clojure.

I find the performance penalty for using Java is pretty-much negligible. It's
always _how_ you do it that matters more than _what language_ you do it in.
Don't use Java Generics for number crunching though... use a dedicated
primitives collection library like Colt.

Java and C++ are quite similar in _some_ respects. I would say though, that
it's easier to go from C++ to Java, than from Java to C++.

Best C++ books:

 _Accelerated C++_ by Andrew Koenig and Barbara E. Moo

 _Effective C++_ by Scott Meyers (make sure you get the 3rd edition)

Best Java books:

 _Effective Java_ by Joshua Bloch

 _Java Concurrency in Practice_ by Brian Goetz, Tim Peierls, Joshua Bloch, and
Joseph Bowbeer

If you have to use C++, start using the Boost C++ libraries early on. You can
learn a great deal just by _using_ the Boost libraries, and reading their
documentation.

~~~
big_data
Thanks for the book tips! These will help after I make my choice.

How about IDEs for each?

~~~
ecyrb
Oh man.... the tooling situation....

Eclipse for Java.

Visual Studio for C++ on Windows. Netbeans everywhere else?

I am constantly dissapointed with my tools.

(edit) ViEmu for Visual Studio is excellent. I'm not sure if it's Eclipse or
viPlugin for Eclipse, but one of them is laggy.

~~~
big_data
I was poking at Bloodshed Dev-C++ to test it out. Seems pretty good. Any
experience with it?

------
lambdom
I think Java will help you focus on more high level stuff than C++, which is a
good thing. For instance, you will spend less time debugging subtile C++
corner cases.

Also, a lot of C++ "good practice" are "built in" in Java. For instance, you
won't have to use #ifndef #endif or to declare your function in a header file.
So, again, I think Java is a better choice since, if you have to learn and use
C++, you will already know the good practices.

------
notaddicted
My POV (I don't have any special insight):

Big users of C++ are more tech-oriented. These are the people that would use
something better but they need the 2x speedup, because it's a major
competitive advantage in a mature pure tech firm.

example: google.com

Big users of Java are more enterprise-oriented. They use it because it is
proven, and they can hire programmers for it, and they can manage big projects
with it.

example: SAP.com

IMO: chase the $$$, learn Java. But if you work hard you can learn the basics
fast, and keep learning other languages. Once you know many languages and the
paradigms behind them, any given language is just a point in "language space"
and the details of the language are obvious, because they couldn't be any
other way.

~~~
kevinherron
Except Google is a HUGE Java user.

They've even release a large amount of libraries developed internally here:
<http://code.google.com/p/guava-libraries/>

------
pjharrin
If you want to do quant finance as a career. Learn C++. It is the industry
standard for quant work.

------
rbanffy
Between C++ and Java? I would open a restaurant!

Seriously: of those 2 choices, I would tend towards C (more than C++). I would
prefer more choice, of course. Current Lisp compilers are very efficient.

------
skennedy
In addition to the point about chasing the $$$ by learning Java, I would
definitely call your attention to C#. C# is based on C++, starting to pick up
speed (think Sharepoint), and developers are coveted right now for the small
but growing market.

~~~
ecyrb
How easy is it to use C# on a _(shudder)_ Oracle Solaris box?

(edit) In all honesty, skennedy makes a very good point. C# does seem to be
gaining popularity. (And yes I'm aware of the Mono project.) Frankly, I just
don't trust Microsoft. There have been compatibility issues with migrating
between early versions of the .NET framework, and the end of Visual Basic left
a bad taste in many mouths.

~~~
skennedy
If you are using C#, you are using a Windows box. But you can tie into Oracle
using the ODBC connection.

Maybe it depends on your specific needs, but I am not sure why you would want
any products you develop (regardless of the programming language) to share
server resources with the Oracle database. My teams always separate the
product load across servers and tiers. If you can afford the $20,000 per
processor for Oracle, hopefully, you have multiple tiers to put your code
elsewhere.

~~~
ecyrb
I simply meant that Solaris is now an Oracle property - not that they're
Oracle DB boxes.

~~~
skennedy
Ack. Still trying to get used to replacing all mentions of "Sun" with
"Oracle". Sorry for the misunderstanding.

------
makecheck
C++ is really an expert's language. It should be something you learn after
several other languages.

If you don't know Python, learn it. Then learn plain C, then perhaps Java, and
only C++ after at least those 3.

~~~
wanderr
I disagree. It was talk like this that convinced me to learn a couple of other
languages when I was a kid before jumping in to C++, and I regret not going
straight for it. C++ is not difficult to learn, but once you have it down
you'll have a better understanding and appreciation of all the higher level
languages that abstract the hard stuff away for you but sometimes perform like
crud.

------
big_data
I am seriously bummed by my lack of choices. As always though, I want to make
the best of it.

If I said that ultimately I wanted to use either language for distributed
computing applications, which then?

~~~
ecyrb
For distributed computing: Java.

~~~
big_data
Any examples come to mind?

~~~
ecyrb
Well, maybe I'm not the best person to ask, and my answer was a bit off-the-
cuff. The best answer is probably more like: _it depends on what you're
doing_.

But, I just find that Java makes life easier. For example, you don't have to
worry about endianess issues. You don't have to worry about portability (as
long as you can run a JVM). You can serialize objects across the network
easily, and if you want to do stuff like RPC, there's Cajo.

On the C++ side, you have stuff like LAPACK? Though I'm not too sure about
this stuff...

Also, Google's _Protocol Buffers_ project is quite helpful in passing data
around. (C++, Java, Python, in any combination)

------
freebsd_dude
Since you trying to learn something as apposed to just get something done, go
for C/C++.

C++ is closer to the machine. You'll have to worry about things like memory
management, pointers, sigfaults, etc - a great learning experience.

After this you should be able to pick up Java no problem. Although if you want
to be really productive or hate typing, Id pick Python.

