Click here to Skip to main content
15,896,456 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,

There is an application i am developing. The customer wants me to code in java because he understands Java. I am very fluent in C++ and i know that C++ is very good with memory management. If i cant code in java, he said i can write the code in Python. My python is ok but, not as good as my C++. Python is not good with memory management, isn't?
I have only 2 months to develop the application. Do you think i will have time to develop a professional application in java and learn java at the same time in less than 2 months. Is java good with memory management?
Posted

In Java you don't get to manage memory yourself it has a garbage collector like c sharp as such you "Don't have to worry about memory leaks" as you do in c++, of course this means that you wont have the flexibility and power that C offers.

Java isn't a hard language to learn if you know c++ Java will come easy to you with a few adjustments since certain features are missing from Java like operator overloading , multiple inheritance and no header files (Java was created with c++ they use the nearly the exact same syntax)

also another consideration you should take is that will your application need to use OS dependent features? as java isn't very good at interacting with the OS. (this was done on purpose to make it platform independent)

Regards

K.D
 
Share this answer
 
v3
Comments
The_Real_Chubaka 11-Mar-11 8:08am    
Thank you for your answer.
I understand that java has garbage collectors. But, don't you think that not having the freedom that C++ offers make c++ better at memory management than java?
Albert Holguin 11-Mar-11 10:22am    
C++ is more conservative about memory usage but its all in the hands of the developer (to make or break), Java has the advantage of a garbage collector but that also means that memory sticks around longer than it really has to... and since its essentially an "interpreted" language, its going to run using more memory in the first place... but isn't the customer always right? :p
Kurt Degiorgio 11-Mar-11 8:12am    
well not exactly since the memory management in c++ depends on how good the developer is and developers tend to make mistakes. with a garbage collector you avoid that "human mistakes" variable again this comes at a cost of flexibility.
Emilio Garavaglia 11-Mar-11 15:55pm    
well ... the exact phrase should be "you replace all those individual human mistakes with the human mistakes of the guys who wrote the garbage collector".
;-) :-D
Kurt Degiorgio 14-Mar-11 3:46am    
true!! but at least you know that the guys that wrote the garbage collector knew what they where doing ^^ (gives you a sense of security, sort of)
With C++, you are the 'memory manager', not the language.
If you are fluent with C++, learning Java (and Python) shouldn't be a problem.
Why are you worried about how good is 'memory management'? Is this a critical issue?
If it isn't then you should look at the right tool to do (quickly) the job: it might be C++ since your good at it, but consider Java and Python could be help you a lot, relieving you from manual memory management.
:-)
 
Share this answer
 
Comments
The_Real_Chubaka 11-Mar-11 8:20am    
Thank you for your answer.

Yes memory management is more than a critical issue for this job. The customer however, wants me to write the application either in java or Python.

Since you don't have the freedom that C++ offers for memory management, doesn't mean that C++ is better than java and python when it comes to memory management?
CPallini 11-Mar-11 8:26am    
If the runtime performance is critical for your application, then you should 'fight for your rights' and persuade the customer that C++ is the right choice.
Sergey Alexandrovich Kryukov 11-Mar-11 13:39pm    
@CPallini: This is a part of our old discussion, but I should note that I faced with many problems in some of my colleagues because they are fixed on C++ knowledge along. Learning other languages are not the problem, but the problem is mental, C++ people tends to be loose flexibility and open mind. I think this is related to social problems and imprinting. So in practice, C++ experience does create mental blocks. The goal of the developer is to counter-act it and of course, getting wider experience.
--SA
CPallini 11-Mar-11 13:45pm    
Well I've to agree.
Anyway, here, we've possibly a performance issue too. A good C++ program would outperform the corrensponding good Java (and Python) one (on the other hand, if coding speed is involved, Java and Python are, for sure a better choice).
Sergey Alexandrovich Kryukov 11-Mar-11 22:06pm    
Performance yes, who would argue? but comparison based on language is not quite valid, as the platforms are different; and is you're talking about Python, it's usually interpreting (I know only one exclusion -- Iron Python).
More adequate comparison would be C++/CLI with other .NET languages; I read on DDJ C++/CLI outperforms, as is has internal optimizer while other languages use generic one. Interesting fact, isn't it?
--SA
Basically it depends on how you write your code. Though CLR is .Net has automatic memory management, it also has lot of memory leak potentialities. For example the garbage collector dispose the memory in chunks, if you create lot of small objects which are referenced by bigger objects for sometime and then go out of scope. These objects not collected in generation 0. But later generation it may get collected and those spaces remains as holes between larger object chunks. And that space is unusable.

So whatever the higher level programing platform offer, you can't simply dummy coding.
 
Share this answer
 
Comments
The_Real_Chubaka 11-Mar-11 8:40am    
Thank you for your answer.

But, java is not a .Net language. Is it? I know it has a garbage collector. Is what you explained valid for java too?
Kurt Degiorgio 11-Mar-11 8:53am    
no java isn't but that piece about garbage collection applies to every garbage collector out their.
Albin Abel 11-Mar-11 13:45pm    
The garbage collector stuff is about .Net. However each language has its own greatness and disadvantages. However all languages are written in C/ C++. What I said is it depends on how we understand about those higher level wrappers. If you understand java very well then Java is good for you else you know c# then it is good for you. Though c# has a garbage collector, but you don't know anything about its garbage collector, but you know java then ofcourse Java will help you more in memory management. That was the point I try to make. If you know how to manage memory then better c++

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900