C++/Java/C#

This is a discussion on C++/Java/C# within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Java has huge, easily available libraries for server-side web programming. So many, in fact, that learning just a few for ...

Java has huge, easily available libraries for server-side web programming. So many, in fact, that learning just a few for comparison is quite a task. C++ has far fewer there, and of lower quality. So for the web, Java is the better choice.

For the desktop, C++ has the better libraries available, IMO.

Language capabilities are much more about available libraries than the language itself. The libraries tell you what you can do (with reasonable effort), while the language capabilities merely decide how you do it.

C++ has crap support for classes in libraries (dlls). Compile a dll in one compiler and u get face-slapped when trying to use it in another. And you're limited to the most basic types in library interfaces, you can't use std::string as an example.

That means there are no free functions - everything is inside objects.

Static functions

Numbers are not objects in C++

Neither in java, though they have wrapper classes that objectify them

Java does not support generic programming and templates to my knowledge.

Java has generics. Both templates and generics have their pros and cons.

That means there are no free functions - everything is inside objects.

Not 100% true. You can have static functions that don't require an object. You still need to put it in a class but you never need to make an instance of it.

Java has huge, easily available libraries for server-side web programming. So many, in fact, that learning just a few for comparison is quite a task. C++ has far fewer there, and of lower quality. So for the web, Java is the better choice.

For web I like PHP. Loosely typed works well for the web IMO.

You could learn something radically different from C, if you just want to broaden your horizons. You could learn Smalltalk. You could learn Lisp. You could learn Haskell.

Lisp was interesting but the overuse of parenthesis make it a bear at times. I would also recommend prolog for something different.

Not to open a different topic, but can someone tell me what are the BIG differences in Java and C++. Differences on what you can do easily and what you can't. Lets not consider the differences in performance, safety, etc etc

In addition to what I already said about Java above, Java does almost everything at runtime instead of compile time. So the "Generics" that Java has is crap... If you have a List<int> and List<String>, you only have 2 List's of objects after you compile it.

In addition to what I already said about Java above, Java does almost everything at runtime instead of compile time. So the "Generics" that Java has is crap... If you have a List<int> and List<String>, you only have 2 List's of objects after you compile it.

Type erasure is not crap. It's less powerful than substitution generics, but has the advantage of producing much leaner code.

Not to open a different topic, but can someone tell me what are the BIG differences in Java and C++. Differences on what you can do easily and what you can't. Lets not consider the differences in performance, safety, etc etc

In C++ you can very easily crash your computer. In Java it is a little harder.

In C++ you can very easily create unsafe applications. In Java it is a little harder.

In Java you can very easily find a job. In C++ it is a little harder.

In C++ it is very hard to find something you can't do with it. In java it is a little easier.

In C++ it is easy to interface with hardware devices. In java it is harder.

In C++ it is very easy imbue other languages or access application APIs. In java it is a little harder (not necessarily java fault in most cases, but because of a general lack of proper language specific APIs).

Really? That surprises me. I guess I'm looking for work as an engineer and not a programmer, but I know from experience that me and almost all of my friends were asked if we knew C++ (and/or Matlab) when applying for jobs. I don't know of anyone who was asked about Java.

In certain industries - like the trading industry here in Chicago and also in NY - C++ is the preferred language. In general IT, it's Java/J2EE and C#/.NET. Still some C++ there, but not nearly as much as the others.

That's why I ask what type of programming one is interested in when asked which language to choose.

Typically, either you control the compiler and options used to build the module and all its clients, and you can use any typeor you don't, and you can use only platform-provided types and C++ built-in types (even then, document the size and representation you expect for the latter). In particular, never mention standard library types in the interface of a module unless all other modules that use it will be compiled at the same time and with the same standard library source image.

Fortunately I control the compiler for all modules. But it was an interesting read, so thanks.

Fortunately I control the compiler for all modules. But it was an interesting read, so thanks.

I would still avoid using non-primitive types across modules though, because if you apply any compiler service packs, or even change some compile settings and then fix a bug in one of your DLL's and release a patch to customers, the ABI might not be compattible anymore.