C++ or java

Discussion in 'Programming/Html' started by Shadowsoldier, Jan 26, 2011.

  1. naike

    naike Ancient Guru

    Messages:
    2,020
    Likes Received:
    0
    GPU:
    Asus EAH5870
    I asked this question, and the answer I got was, go Java if you don't need C++ features like better memory management and pointers, but if you plan to develop games and such then definitely C++.
     
  2. Xendance

    Xendance Guest

    Messages:
    5,555
    Likes Received:
    12
    GPU:
    Nvidia Geforce 570
    I wouldn't necessarily say that C++ has "better" memory management. From a programming standpoint it's more like a chore that you have to do sometimes. But from performance standpoint it's pretty obvious why you sometimes need to do it.

    Pitfalls? Also == in java only checks for reference equality, not if the actual object is equal, for which you need to implement your own equals() method.
    Also all languages I've tried use = for assignment and == for equality. Though I have only programmed with Java, Scala, C, C++ and done some python scripting.

    And you probably mean C++0x, not "Cx0x". It's a new standard for C++, not C. At least I couldn't find anything related to "Cx0x" on google.
     
    Last edited: Feb 9, 2011
  3. gamerk2

    gamerk2 Ancient Guru

    Messages:
    2,108
    Likes Received:
    1
    GPU:
    NVIDIA 570 GTX 1.2 GB
    ^^ Yeah, I meant C++0x; was thinking of the C99 standard at the time, and got the two mixed up [never a good practice! :D]

    And most languages that do not follow the C syntax use either := for equality [as has been done for over 1000 years in mathematics], or use = for both assignment and equality. == was, and still is, just a bad synatical choice, as the number of times you would set a variable inside an if statement is extraordinarilly small...

    As for manual versus automatic memory management, its a classic argument that exists in other languages as well [DirectX and OpenGL, for instance...]: Who handles resources: The developer, or the implementation?

    And to note: Java is NOT immune to memory leaks; I have a debugger for another language written in Java at work with a MASSIVE memory leak, so it crashes after running from the 20th breakpoint. I *think* what is happening is the garbage collector is so low priority, our high-priority threads keep pre-empting it [remember, in Windows, the highest priority thread ALWAYS runs], and thus, garbage collection never occurs. Farther, its worth noting the C++ standard includes a provision for automatic memory management, though its almost never implemented in practice.
     
  4. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,541
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    @Karie777 I guess the question is not relevant anymore (seeing no activity since 2011).

    Btw, I have never seen desktop application written in Java.

    As a developer I am doped and addicted to .Net and C# for last 6 years (and don`t want to deal with C++ anymore).
     

  5. sverek

    sverek Guest

    Messages:
    6,069
    Likes Received:
    2,975
    GPU:
    NOVIDIA -0.5GB
    Nobody want to mess with memory.

    C# is aimed for windows, so if you want your application to be cross platform, you gonna have a hard time.
    I use Golang now, still getting used to it, but I really like how easy you can compile code across platforms without major issues.

    Comparing languages to building a house:

    Python/PHP/JS is like asking company to build house for you. You may not like the result, but you didn't consume much time.

    Golang/C#/JAVA is buying parts / tools and building house by yourself. Bought parts might not be the best, but you can design your house better.

    C/C++ is like making tools from raw material, growing trees -> cutting them down, prepare parts and then build a house.
     
  6. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,541
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    @sverek
    Windows is the only platform I worked for (except for DOS).

    C# feels so much more comfortable and friendly comparing to C and even to C++. .Net framework with its huge library is definitely for lazy guys. And generic types in .Net is so much more usable than templates in C++. Plus huge benefit of .Net assemblies with types info incorporated within (comparing with binary + header files combo in C/C++). The list can go long...
     
    HK-1 and sverek like this.
  7. Alessio1989

    Alessio1989 Ancient Guru

    Messages:
    2,941
    Likes Received:
    1,239
    GPU:
    .
    I barely use "new/alloc/malloc/calloc" on C++, and usually only on rapid prototyping for binary parsing... After defined the needed custom allocator ( here platform syscalls and intrinsics may be needed, though you can still obtain good performance without them, at least compared to the naive heap allocation..), everything can be automatized (which means no manual memory allocation and deallocation at all).
    Unfortunately C++ needs a longer learning curve compared to other languages to obtain what you can best achieve with the language... Especially if there are tons of crap books written by monkeys coming from other banana languages...
    Yes modern C++ (C++11/14/17) made the language a lot better compared with the 98/03 "C with classes and some template mess", but most of the learning materials cover mostly the first standard. And yes, the "compatibility" feature means "we are going to kill a things or two in a decade" - not because they are simply "horrible" but - "since we need to recycle a keyword and some syntax" (this is the reason there are like 6 or more way to initialize an integer .-.).
     
    Last edited: Apr 11, 2018
  8. Stickynote

    Stickynote Guest

    Messages:
    15
    Likes Received:
    2
    GPU:
    Iris Pro/128Mb
    I started with Java and still use it for most of my programming projects. I think it's more popular.
     
  9. sverek

    sverek Guest

    Messages:
    6,069
    Likes Received:
    2,975
    GPU:
    NOVIDIA -0.5GB
    3 Billion Devices Run Java.
    OMG, 3 Billion Devices Run Java...

    I never wrote Java, but had to deal with servers that run on Java servlet. Getting those to run can be tricky. I once ended up debugging java server platform for 2 days, only to realize it takes 30 minutes for java application to start up. So stupid.
     
  10. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,541
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    You mean smartphones?
     

  11. RealNC

    RealNC Ancient Guru

    Messages:
    4,953
    Likes Received:
    3,230
    GPU:
    4070 Ti Super
    If you want your UI application to work on multiple platforms and look nice and integrate well, your only choice is using a language that offers bindings for the Qt toolkit. C++ and Python are the main ones. If you want to target Android and iOS too, then it's just C++. (Yes, you can use C++ on Android and iOS just fine.) Using Java for this will result in applications that look and behave like abominations on many platforms.

    If you're only interested in Windows, you can use C#. If you later want to port to a non-Windows OS though, you're gonna have a bad day.

    Java is pretty much for legacy Android apps right now. For new apps, Java is being replaced by Kotlin, Google's "next gen" Android language.

    Knowing Java is still useful. However, this is true for pretty much any language.

    Edit:
    If you need to develop performance critical code, then obviously you should be using C++.
     
  12. JoshuaPortman

    JoshuaPortman Guest

    Messages:
    2
    Likes Received:
    1
    GPU:
    memory size
    I was gonna ask the same question but I learnt both just in case.
     
    mbk1969 likes this.
  13. Mechwarrior419

    Mechwarrior419 Active Member

    Messages:
    56
    Likes Received:
    10
    GPU:
    Gigabyte 3080
    Hello, everyone .

    As an college educated programmer. I would posit that in a situation where you are actually writing production code ( i.e. working for a software development company or just a personal project ) then pick which ever language suits the project best.
    As has been several times already If your application is performance critical then C/C++ are your only real options.

    But I would like to address this issue from an academic standpoint. It is my belief that if you are new to programming and are serious about becoming a good software engineer, then it would be much more beneficial to start out with C or C++ ( I would recommend C++). The reason I would recommend this ( and just as an aside, at my university we started with C++ ) is because since C/C++ are much lower level non memory managed languages so the aspiring programmer is forced to learn how memory management really works. You are also given a good introduction to the fundamental of OO programming.

    I found in my personal experience learning to code. I was very happy to have learned C++ first, because when I later started picking up languages like C# and Java, I had a much greater appreciation and understanding for everything that's going on under the hood.

    Also in my experience Visual Studio is miles ahead of the competition when it comes to developing GUI driven applications for windows. Although eclipse and net beans are starting to add this ability slowly.

    The only downside to C++ is that it relies on OS and SYS calls for threading. This is due to change shortly though with the introduction of the latest version of C++.
     
    Last edited: Nov 1, 2021
  14. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,541
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    @Mechwarrior419

    In book "CLR via C#" Jeffrey Richter (if I am not mistaken) states that .NET CLR has a bit of benefit compiling the code (from IL) on the fly on the actual machine (HW + platform) because it can optimize a bit deeper than static optimizations made by C/C++ compiler (even made on the same rig).
    Sure IL code to binary code compilation takes time, but only on first account.
     
  15. anticupidon

    anticupidon Ancient Guru

    Messages:
    7,878
    Likes Received:
    4,123
    GPU:
    Polaris/Vega/Navi
    So, learning Python is not so cool ?
    I am new to this, barely started with Python.
    I need Python because I want to simply automate some network stuff and such.
    Being a higher level programming language makes it easier to read and remember the syntax.
     

  16. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,541
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Python is good. You will feel cool when you achieve your automation tasks with it.
     
    anticupidon likes this.
  17. anticupidon

    anticupidon Ancient Guru

    Messages:
    7,878
    Likes Received:
    4,123
    GPU:
    Polaris/Vega/Navi
    @mbk1969 Also learn Powershell gives a administrator some leverage.
     
  18. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,541
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Powershell is my crush since it is pure .Net and I am .Net developer.
     
  19. anticupidon

    anticupidon Ancient Guru

    Messages:
    7,878
    Likes Received:
    4,123
    GPU:
    Polaris/Vega/Navi
    Then I will have some questions, I will need to do some automatisation, or some form or scripts to do certain things at a certain time/conditions met.
    Thanks in advance, good to know who to ask.
    Cheers!
     
  20. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,541
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Will be happy to assist.
     

Share This Page