Which one is the better programming language in your opinion? I think C++ has better memory managment and better use of pointers, but java is definitely easier to learn and use, whats your opinion?
My main language is Java. Highly portable and a very clean language to work with. Also, you won't accidentally blow your foot off if you screw up. Massive downside is that Java is slow ... like really slow lol. C++ is great, but if performance isn't paramount, I would use Java over it any day. For performance sensitive applications like games, then duh, go with C++. Only game that I approve of that's written in Java is well, not surprisingly, Minecraft. deltatux
C++. You can simply do FAR more with it. Java is a great secondary language to learn, once you actually understand how things work under the hood, but given the choice, I'd take C# over Java. My preferred languages: C/C++ Ada C# Python VBA [when I'm forced to use a MS office program...]
It depends on the application you're building really but if you're just starting out and experimenting I'll say Java a thousand times over. It's just more modern and it shows in cleaner design. It's far easier to learn good programming practices, rigid type adherence and a good grasp of objects and inheritance in Java before moving on to C and derivatives. C allows you to do things that you couldn't do in Java but that's almost never a good thing. Edit: To answer your question, neither is inherently 'better'. If you're constructing a time- or resource-critical application that isn't running on a server then your only real choice is C, as it's basically portable assembler. Outside of that I'd say it's better to stick to Java but YMMV.
because java is so easy it gives you more time to spend on actual software development and improving the architecture rather than getting bogged down in core dumps etc. Also C++ is an excellent language and very powerful but its too easy to hack solutions so you can easily pickup bad habbits. Test driven development is a lot easier with java, splitting out unit and integration tests with junit and prevents an organic mess of an application where you keep adding things but breaking the previously working stuff. Java is also very good at teaching you design patterns( particularly The Gang Of Four Patterns ) because most of the API already uses patterns so when you learn that youre just missing the names of the patterns. C++ can be an absolute headwreck sometimes, especially coredumping with invalid pointer references.
But it's the pointers (memory management) which make it faster than any other language. It also does not need Virtual Machine to run it. Java is easy to port to other OS's and other devices because it runs on Java Virtual Machine. Thats what makes it slow. I also do not think that Net Beans is at the same level with Visual Studio. C# is awesome and you get loads of stuff done fast, but is it the best first language? At school I started with C, then went to C++, next was C#, Java, Java Mobile Edition, somewhere between that Python and QT for Symbian. Nothing wrong at learning to code with C ?
no, i think youre missing the point, Java is good to learn best practices in software development( without getting bogged down ) and afterwards if you want speed then go C or C++ or even go the whole hog and write assembly. If you come at software development from C++ angle you can pickup a lot of bad habbits which over time can result in an organic mess of coding. Java is crap if you want fast code, but thats not its purpose. C++ or C# all the way for gaming, but i wouldnt start out coding with the purpose of my first project being a CoD beater
Doesnt take that much to beat CoD But hey, what bad habbits, can you give some examples ? I dont think that I will understand your point without those... C#
I don't know, personally I still rather Java over C#. Probably that's just a personal preference. deltatux
lol, main ones being abusing multiple inheritence( although ive seen inheritence abused in java with 240 levels of inheritence, but you get my point that it would be a lot worse if that was multiplied ), also abuse of pure virtual functions, memory hacks( good for performance, usually difficult to understand if its someone elses code ) etc. etc. Most of it is only a problem if youre fixing up someone elses code, or you end up having a very large project that becomes difficult to maintain.
Oh, that. But thats why you //comment your code, right ? Like... int i = 0; // I use this to count how many times for loop has ran //Next we have 3 for loops inside each other and those count something and set values, not sure why it works though. But anyways, arent you supposed to document your code in companies and so on ? Also test that it works. But I might agree about that abuse of virtual functions, but might not be a problem if you start with basic C and then later go to C++ and start using and learn about that virtual stuff ? Thats what we did.
Ya but commenting still wouldn't help if the code is all spaghetti code. It'll just be a whole mess of text. deltatux
nah the commenting thing is useless in spagetti code. I mean my last project there was maybe 400,000 lines of code and a total POS lol( i inherited the junk ), you cant follow comments in code like that and you need UML diagrams( which i had to reverse engineer along with sequence diagrams for the use cases ) and the likes however because java is limited in what you can do you cant really break the UML( without affecting the model ) but you can with C++ and the virtual fuctions mess that up more( also making sequence diagrams far more complex ). With Java you can concentrate mostly on OO and developing your OO skills quicker rather than getting bogged down with core dumps and making a mess of code over time trying to get stuff working( i.e hacking in multiple inheritence/virtual functions etc. ). I think personally learning Java and OO well and then moving to C++ is a better route to take for good software design than direct to C++. The languages are just tool, learning how to design is more important as you can apply it to everything, i.e. once you know java it is quite easy to move to C++( ok, you just need to learn pointers and a few other things generally ), however going from e.g. C to C++ is an absolute nightmare( and thats worse because procedural programming in OO code is awful ). That 400,000 line project i worked on had the worst code ive ever seen( and no proper test cases ), everything in java was abused, procedural programming, hacks, methods 5000 lines long( arrrghhh ), 200+ levels of inheritence, if/else statements with several levels of embedded if/else statements( meaning in some cases there were 256 possible outcomes ). With that mess i can imagine if the idiots who wrote it in the first place were using C++, it wouldnt be possible to touch anything without breaking it.
HAHAHA, 5000 lines for one method?!?! HAHA. My java programming project was only 2000 lines, and it was a simple 2d game with the usual stuff (collision detection and things like that). One guy managed to make an isometric 2d game with mouse control and AI. And that fit into 4000 lines total.
Having obtained a degree in IT as well as having been additionally trained in Java software development myself I'll just write down a few facts. The most popular programming language for large scale projects today is the Java language. When a Java engineer talks about 'Java', the Java language itself is hardly ever discussed because the language is only a very tiny part of that which they commonly refer to as Java. Java is much more complicated than most people seem to think. Code written in Java has to be written in such way that it can be easily maintained afterwards but this not only suggests the importance of readability and documentation. The use of proven standards as well as design patterns is a must, and every aspect of the Java technology has to be used with the Java principles in mind. One of the most important goals is code reuse. A person who writes Java code often spends more time configuring stuff than anything else. You have to almost literally speak XML to keep Java Enterprise software up and running. Java is both web oriented (multi platform) and highly structured (scalable and manageable). It has always been evolving with security in mind. Since the Java language uses a syntax which has been derived from C++ it's also quite easy to provide optimizations based on specialized components. People who claim Java performs slow have got absolutely no clue whatsoever, because its performance mainly depends on how well people can program. A thorough understanding of hardware is the missing key.
^^ thats hard to read lol, ah man its not funny if youve to decipher it and try and fix the damn thing, personally if i had my own soft dev company i would sack someone on the spot for such crap
Not really; My seminar project back in college was a 2d game [think the first Zelda game on the NES]. About 6000 lines as of final alpha build, with fully functional dynamic sound engine, collision detection, remappable input, and an a very well designed player/enemy/projectile inheritence class setup. The above is why we chose C++: We used multiple inheritence on all projectiles, enemies, and player characters, as the only thing unique between them [from our perspective] was how they moved [user input, pseudo random, or set path]. As such, we treaded then each as their own unique sub-class, and spawned a new thread on the creation of each one. We actually created a fully dynamic, scalable, threaded program, that still scalles on modern processors. [1 player char + up to 10 enemies + up to 3 projetiles per enemy = 1 + 10 + [3*10] = 41 threads JUST for the player, enemies, and projectiles. Thats not even counting the user input thread, sound engine, and the various screen drawing algorithms we had]. And the code isn't obtuse at all; you can do a LOT in C++ if you know how. And in my experiance, I've seen more shoddy implementations in Java then I have in C++. Yes, C++ is a pain to learn, if for no other reason then its a strict superset of C, which itself was designed to repalce assembly languages. So if you mix and match, bad things can [and will] happen. But its better to learn the right way, learning WHY certain things are bad, learning HOW exactly storage is handled internally, then simply have the implementation do it for you. Because I've seen plenty of good Java programmers write shoddy code the minute their crutches [the Java language] is taken away from them. If anything, I'd teach new users in either Pascal or Ada [or even Basic if its a general language corese]. Then, I'd move in to "properly" teaching C++. Java should not be taught or used until the user understands what is going on under the hood. I also point out: Java usage in the past few years has declined a LOT; I think some of the scripting languages [Haskel, Pearl, Ruby, Python] have suppased Java at this point...Frankly, its bordering on "dead language" territory. EDIT As an appendum, I've used C++ for over 10 years, in various high performance environments, without ever having any of my code crash. Coincidentally, I've almost never had to use a pointer variable; thats the domain of C, not C++.
:3eyes: dunno where youre getting that from, maybe tell that to everyone with android phones, the developers and not to mention back end enterprise solutions Just for the sake of it, I have 5 years Basic + assembly( when i was a teenager ), 4 years C++ and just under 13 years Java( including some C++ and did the first Java->C++ OpenH323 stack bridge implementation - dead now but the precurser to SIP ), lots of Corba, RMI, SQL/ODBMS, Pearl, Unix script. Lauguages are just tool, learning to design well is what its about and that is more difficult with C++. If someone came to me using 41+ threads for a game just for the player, considering the stack overhead for each thread, synchronisation issues( cpu sitting idle while threads are waiting on each other ) and code complexity, i would tell him to completely scrap that and come up with a decent solution. A queueing mechanism is far far more effecient in such circumstances, splitting threads out to AI control, sound and gfx rendering( 1 thread each, gfx thread updated 60 times a second and the other queues executed faster obviously ).
A report that listed language by use over the past decade was released last week. Java has been declining in use every year since 2001. Several forms of low-level assembly JOVIAL J73 Various HP implementations of BASIC Visual Basic for Application [not by choice, mind you...] Python Pearl [In progress on this one] Pascal Ada Java C C++ Objective C C# and just for kicks: The A Programming Language Question: If a thread does not access any outside objects while any other thread is accessing that object, is synchronization needed? Answer: No. No synchronization was needed for the individual AI threads, period. We created a fully scalable, threaded AI in just over 25 SLOC's. [the threads themselves were quite simple: Enemies moved toward the player char, going AROUND obstacles [NOT THROUGH THE TREES!! ] and projectiles went stright until they hit something] So, if I have 6 cores with nothing to do, and have 6 AI threads that need to run, I should do them sequentally instead of at the same time? 0-O. Its that type of thinking which needs to go away. If I have 58 bullets in transit, 6 enemies, and the player character, I should have 65 threads, one for each unique object. Every bullet should be individually traced to its destination, every AI should act and react individual of the others, and the user should operate, obviously, as a stand alone thread.