• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why C++ when Java!

 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you want to go back to C++ when there are other free and equally powerful languages like Java. I work with machines and manufacturing and still I can take the performance hit of Java and make it work.

Why do people still code in C++ and esp C++ in .NET which is a commercial license? There are so many tools/plugins/IDEs/components available in other languages to get up and started with.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally, any of the questions of the form, "Why program in X when Y does Z" can be answered by any of the following:

a) It's what the individuals are used to.
b) The language, for the task given, may be just as suitable for the purpose.
c) Too lazy to be aware of anything else.

Now, given that - C++ (and I'm speaking from Unix C++ / not .Net as I haven't looked at it) does have some advantages over Java in a couple of areas:

- Bit Handling
- Interfacing with lower-level protocols
- Device and OS drivers / management
- Embedded work

In short, the answer is the same reason as your answer to the question - Why do you like flavor of tea you like?
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Craig - interesting perspective!

I develop in Unix C++ and Java and we have successfully implemented Bit Handling, Interfacing with lower-level protocols, device and OS drivers/management. There are so many libraries available in Java to interface. I do not deal with embedded work so I cannot comment.

But I want to specifically know why does one use C++ 2008 (.NET)

In short, I doubt A and C but B needs research. The answer is not as simple as your tea example - I make tea at home cause it costs less :-)
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vyas Sanzgiri wrote:In short, I doubt A and C but B needs research. The answer is not as simple as your tea example - I make tea at home cause it costs less :-)



You doubt that some people use a language because it is the only one they know? And it can be as simple as the tea example. It costs less for me to use Java than C++ because I know java better and it is more suited to what I primarily do, which is web development. Folks use managed C++ (C++ in the .NET environment) for a lot of reasons.

To me, your questions are bordering on insulting. I perceive a bit judgment in them.

[I edited one part of my post because I didn't realize this was probably targeted towards the book promo.]
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry I never meant insult and insult to whom? I am talking to the general public. Sorry again Gregg, Craig and ranchers

We are updating our repository from C++ to Java since we have better ways to handle and enhance code. We have successfully achieved the tasks listed above as well.

Also, we get more and more developers well-versed with Java as compared to their C++ skills I would love not to waste time updating our legacy code but I do not see any C++ training sessions or skills distributed around us. So maintenance is a big issue.

I am just trying to understand why one would use Unix C++ or C++ 2008 (which I just learnt about last week!)
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A few years ago, I had to make a call to .NET from java. With JNI, it was possible to get from Java to C/C++, but that isn't enough. Unmanaged C/C++ can't use .NET services in most cases. The only thing that it can do is call static methods.

So, I had two options...

1. Make another wrapper to get to Managed C++ -- meaning Java to C/C++ to managed C++.

2. Make another wrapper to get to C# -- meaning Java to C/C++ to C#.

In the end, I chose the first case. Why? My reasoning was that unmanaged C++ and managed C++ can be in the same file. There was no need to have a separate file to compile. A stronger (and probably better) reason was probably that three languages at the same time (although I do that often today) tend to get really confusing.

Henry
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vyas Sanzgiri wrote:
I am just trying to understand why one would use Unix C++ or C++ 2008 (which I just learnt about last week!)



Well, one big reason is... not everyone has the luxury of choosing between either Java and C++. For many, it is not a choice. For many, it could even be both. You have to code based on the underlying libraries, frameworks, managerial decisions. etc.

Good programmers must work within the restrictions of the project. And in my opinion, someone that quits or refuse to join a project, because it isn't pure java, is someone that I don't want on a project. The last thing that I need is someone whose understanding of other languages is whether it is legacy or not.

Henry
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Well, one big reason is... not everyone has the luxury of choosing between either Java and C++. For many, it is not a choice. For many, it could even be both. You have to code based on the underlying libraries, frameworks, managerial decisions. etc.

Good programmers must work within the restrictions of the project. And in my opinion, someone that quits or refuse to join a project, because it isn't pure java, is someone that I don't want on a project. The last thing that I need is someone whose understanding of other languages is whether it is legacy or not.

Henry



Absolutely true as one of the reasons
 
Author
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings, Vyas --

One unique factor offered by C++ 2008 is its backward compatibility to native (unmanaged) C++ and legacy C. This offers the programmer the ability of using proven and tested code written more than 30 years ago. The world's first Hello World program illustrated in the 1978 first edition of The C Programming Language (called Hello, Earth on page 527) still runs without change, as does the same program in The C++ Programming Language (called Hello, Mars on page 529).

Cheers,
Pren

Vyas Sanzgiri wrote:Why would you want to go back to C++ when there are other free and equally powerful languages like Java. I work with machines and manufacturing and still I can take the performance hit of Java and make it work.

Why do people still code in C++ and esp C++ in .NET which is a commercial license? There are so many tools/plugins/IDEs/components available in other languages to get up and started with.

 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very interested. I have to try it out.
 
blacksmith
Posts: 979
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...it is interesting but, depending on the company you are working in and the architectural
decisions that have been taken, it might need some arm twisting before you can indeed
try out C++ and then use for real development.

I've worked for companies that were open for suggestions and others that were more
conservative, both have their advantages.

 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gian, I am looking beyond management decisions, resistance to change, "I know c++language" kind of statements. I am more towards what is the technical reason behind C++ still being used as the author and a few other ppl have commented before.

In our company we are finding it very difficult to support C++ since we do not get good quality C++ programmers. Our message bus and core infrastructure is still in C++ ! - very stable and reliable
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vyas,
Actually choice of language is influenced by factors like:
1. Language that all your team members are comfortable with.
2. Existing technology that the company is using.
3. Easy for developing prototypes
4. Mandatory language for the targeted platform
(this is all that came to my mind while writing this reply)

I work in a mobile gaming company where we develop mobile games for numerous platforms. To be honest I simply love Java and C++. My choice of language depends upon the targeted mobile phone. But whenever I need to test out an algorithm or need to make some prototype, I use Java. For server side programming I again use Java because I love Servlets/JSP. It takes care of most the headaches.
Still there are some parts of the code which needs to be written in C,C++ when every single CPU cycle and every single byte becomes important .
 
Greenhorn
Posts: 18
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Pradip Bhattacharya wrote:Hi Vyas,
Actually choice of language is influenced by factors like:
1. Language that all your team members are comfortable with.
2. Existing technology that the company is using.
3. Easy for developing prototypes
4. Mandatory language for the targeted platform
(this is all that came to my mind while writing this reply)



Don't forget the maintenance issues, although it can be seen as related with the existing technology that the company is using. You know, the main cost of every software development project resides in its maintenance, so besides the documentation, a well ordered and structured programming, etc., the availability of good programmers in a specific programming language far beyond the end of the project "development", it should also be a key for choosing the right language. Some examples regarding the difficulty in the availability of C++ programmers has been mentioned here. And concerning the easy for developing prototypes you also mentioned, yes, this could be a reason if your project and or development methodology is mainly based on prototyping.

And answering the thread question, Why C++ when Java!, humans are lazy by nature and if their needs can be accomplished by one language, don't expect they learn another (there are always exceptions), thus the answer should bypass this natural human behaviour and then respond that C++ may be used when Java doesn't fit well enough to our purposes, and viceversa. For instance, C++ best fits in programming embedded devices, but Java in web development.
 
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm...interesting topic. I think it all depends on nature of the Project and decisions made by Enterprise architects because a lot of factors involved including compatibility to existing systems, company culture on introducing new language etc.. One key point is money being spent on new project. I know it is easier to find good and cost effective Java programmer than C++ guy. So, maintenance would be much cheaper if you go by a popular and widely used language, which is Java

But again it all depends on nature of the project and we can't have a rule of thumb
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most of the commercial Java Runtime Environments (JRE) are written in C++.

So, when you think you are using only Java, you are also using C++ in most cases
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. I am marking this topic as resolved since I got the essence of the argument.

Thanks for all your expert contribution.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vyas Sanzgiri wrote:Why would you want to go back to C++ when there are other free and equally powerful languages like Java. I work with machines and manufacturing and still I can take the performance hit of Java and make it work.

Why do people still code in C++ and esp C++ in .NET which is a commercial license? There are so many tools/plugins/IDEs/components available in other languages to get up and started with.



I'm not going back to C++. I prefer C++ over Java. I learned C then Java and then C++. In my view C++ is superior to Java.

I like the portability of Java. That's the only reason to use it really. But as soon as you need to do something just a little out of the ordinary Java becomes a hassle. For example forget using OpenGL with Java. And try to easily use other non-mainstream technologies with Java such as CUDA. It's a pain in the ass.

Besides all the problems with using Java in extraordinary situations, C++ actually is a much better language. And to boot, C++ is not proprietory.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my current job, I use both C/C++ and Java (actually, use C++ a bit more than Java at the moment, but it changes week to week). And seriously, don't really prefer one over the other. Maybe it is because I am very comfortable with both. Maybe it is because I care less about the language, the API, or framework, and more about the task at hand.


Anyway... I could see the last post fueling a bit of a religious debate -- it definitely "pushed" it a bit more than other posts. Please be careful. This topic is interesting. Or it can get to the point where it will be deleted.

Henry
 
Sha Jar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:Anyway... I could see the last post fueling a bit of a religious debate -- it definitely "pushed" it a bit more than other posts. Please be careful. This topic is interesting. Or it can get to the point where it will be deleted.



It's my post you mean right.

Well I thought the OP asked for personal experience so I gave mine.

I'm not trying to impose my view on anybody else though. Everybody thinks and does what they want.
 
Pradip Bhattacharya
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not trying to hijack the thread. Just want to give my opinion on what Natasha wrote

Natasha Jar wrote:For example forget using OpenGL with Java.


Its just a matter of writing appropriate java bindings. I have used JOGL and Android Java OpenglES interface, they are pretty good. And currently I am not aware of any CUDA binding. But it should be relatively easy once you know CUDA.
I think its inappropriate to draw comparisons between two languages based on the availability of OpenGL/CUDA support.






 
reply
    Bookmark Topic Watch Topic
  • New Topic