Pages: [1] 2 3 ... 7
  Print  
Author Topic: The grand c++ vs everyone else debate  (Read 8239 times)
Offline (Unknown gender) luiscubal
Posted on: April 06, 2010, 08:19:47 AM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
I'm thinking that, if we're to discuss the whole C++ vs Java/C# issue, this might be a better place than the Announcements.
Does everyone else agree? (Or is that discussion over?)
Logged
Offline (Unknown gender) score_under
Reply #1 Posted on: April 06, 2010, 08:48:33 AM

Member
Joined: Aug 2008
Posts: 308

View Profile
The points are always the same.
C++:
You can treat any type as anything (for better or for worse).
Allows you to do almost anything (and you can include ASM, too, if this isn't enough).
Very fast compiled EXEs, especially compared to C#/Java.
C#/Java:
Interpreted; compiles faster and is easier to debug.
Cross-platform with little effort.
Consistent APIs.

Given these points, I prefer C++, mainly because it equates much more closely to the actual code being executed by the processor and is therefore more predictable.
« Last Edit: April 06, 2010, 08:51:25 AM by score_under » Logged
Offline (Unknown gender) Micah
Reply #2 Posted on: April 06, 2010, 08:48:53 AM

Resident Troll
Joined: May 2008
Posts: 129

View Profile
That discussion is stupid. The only argument was between "use the right tool for the job" and "use C++ for everything."

EDIT: score_under, you extremely exaggerated the difference in speed and interpretedness between the two. C# and Java are pretty much compiled and almost as fast, although you can't tinker with as much low-level stuff and thus can't do as many manual optimizations.
« Last Edit: April 06, 2010, 08:56:36 AM by miky » Logged
Offline (Unknown gender) luiscubal
Reply #3 Posted on: April 06, 2010, 08:59:31 AM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
C#/Java: Rarely interpreted. Usually compiled. This is a huge point. It's the same for JavaScript. Almost nobody runs interpreted JS(IE9 has JIT too). Modern browsers COMPILE the code into native code. Which is why JS is recently having such huge performance boosts.

C++ is much LESS predictable than Java/C#. Undefined behavior is EVERYWHERE. Weird interactions occur. Stuff like buffer overflows make code pretty much impossible to predict.
Java pretty much FORCES code to be predictable.
Therefore, your "predictable" argument is bogus. Java and C# are predictable unless there is a bug in the VM/JITer. And, guess what, C compilers can have bugs too.

My main point is being closer to the processor(also known as "low level") is better if you want to solve a problem that's close to the processor(kernels are a typical example).
As the tasks you need to do become more complex(and, therefore, require abstractions to be possible to solve), having "high level" languages becomes more useful.
This is why C++ has some popularity over C - you can do ANYHING with C and, in fact, C code equates much more closely to the actual code being executed by the processor than C++.
And this also why C# and Java become more popular as the task becomes more complex.

In other words, C++ is a low-level language, where everything is possible but nothing is simple. C/C++ are BRILLIANT languages for low-level programming.
Java is a high-level language, where low-level things are more complex(and therefore hardly worth the effort to replace C), but things that were insane in C are very easy to handle in Java.

Low-level tasks -> Low-level language(C)
High-level tasks -> High-level language(Java/C#)
Logged
Offline (Unknown gender) Micah
Reply #4 Posted on: April 06, 2010, 09:15:14 AM

Resident Troll
Joined: May 2008
Posts: 129

View Profile
Low-level tasks -> Low-level language(C)
High-level tasks -> High-level language(Java/C#)
Exactly. Except that Java and C# are not nearly high-level enough when you're doing something high-level, so only use them when there's something on the JVM or CLR that you want--and then there's JRuby/Jython/Scala/Clojure/etc. and IronRuby/IronPython/F#/etc. for most cases.
Logged
Offline (Unknown gender) Game_boy
Reply #5 Posted on: April 06, 2010, 09:18:23 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
Commercial game development today is almost entirely done in C/C++ (Possibly that is complete rubbish. Please tell me if so). Even when they build new engines.

C++ must be offering some advantage there.

Logged
Offline (Male) retep998
Reply #6 Posted on: April 06, 2010, 09:33:34 AM

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Because all the major api's such as OpenGL and c++ and a whole bunch other stuff are also made in c++.
And because when you make a game, you want to have control over memory yourself, so you can optimize loading of textures and other resources as needed.
However many major game engines that use c++, also include a scripting language to actually make stuff happen.
The programmers had so much hard work making the engine, that they don't want to go crazy scripting everything that happens, so they make a scripting language and let the rest of the team take it from there.
Logged
Offline (Unknown gender) score_under
Reply #7 Posted on: April 06, 2010, 09:38:17 AM

Member
Joined: Aug 2008
Posts: 308

View Profile
C#/Java: Rarely interpreted. Usually compiled.
Excuse me for being a little ignorant on the subject, but every time I've seen something written in Java, it's been a ".class" file, and every time I see something written in C#, it has a CLR header (containing the CIL bytecode to the entire program) and a dependency on the .NET-interpreting DLLs.

C++ is much LESS predictable than Java/C#. Undefined behavior is EVERYWHERE. Weird interactions occur. Stuff like buffer overflows make code pretty much impossible to predict.
Java pretty much FORCES code to be predictable.
C is predictable to me.
Your idea of predictable is "do what I mean", and mine is "do what I say". If I want a program to be able to write 500 bytes to a 400-byte-long buffer, then I will do that. If I don't, I'll put the necessary checks in place.
(Saying that, MSVC++ usually puts a check in place to make sure that a program will "abnormally terminate" instead of returning from a function if it sees the the return address has been smashed - it pads the return address with a few encrypted values to verify that nothing has overwritten it).

Also, nobody [in their right mind] uses gets(). At all. They might as well rename it crashme().

In other words, C++ is a low-level language, where everything is possible but nothing is simple. C/C++ are BRILLIANT languages for low-level programming.
I do have rather a thing for low-level programming.
Java is a high-level language, where low-level things are more complex(and therefore hardly worth the effort to replace C), but things that were insane in C are very easy to handle in Java.

Low-level tasks -> Low-level language(C)
High-level tasks -> High-level language(Java/C#)
Actually, low-level tasks are completely impossible in Java, but high-level tasks are just difficult in C. Tried writing an OS kernel in Java? Not possible. In C, it's just difficult.
« Last Edit: April 06, 2010, 09:39:59 AM by score_under » Logged
Offline (Unknown gender) Game_boy
Reply #8 Posted on: April 06, 2010, 09:45:22 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
Quote from: score_under
Tried writing an OS kernel in Java? Not possible. In C, it's just difficult.

Singularity? JNode?
Logged
Offline (Unknown gender) luiscubal
Reply #9 Posted on: April 06, 2010, 09:50:27 AM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
There was a time where people said C was too slow that it was unusable.(asm programmers)
Turns out C is now "fast enough for most purposes, sometimes faster".

http://unity3d.com/gallery/game-list/
http://docs.google.com/viewer?a=v&q=cache:6aTCMeFMbfUJ:simcitysocieties.ea.com/help/readme/readme_en.pdf+Simcity+societies+.NET&hl=en&pid=bl&srcid=ADGEESjMcZl10XCwCQyoSjd83qROSAmuCKMshtYYzWKrU5o6pjTEmIOTfq1-tHdBVxcHMU5NaSfKUQ_gCfAFvYJAdnXrOMc8SeJkl2xezMkeFQ_0VKjDiHbrVIyYKAEoRWy27k390Gr7&sig=AHIEtbTeUtbE081MKORjFEzLRZej-lub-g
Quote
SimCity Societies requires .NET 2.0. This will be installed along with SimCity Societies if
necessary. Visit www.microsoft.com for .Net.

With frameworks like Unity3D and XNA, along with Mono's iXXX efforts, I think the trend is going to be reversed.

Java and C# are *COMPILED*. Get used to it. The JVM takes those class files and, depending on how much they are used, compiles and optimizes them(some classes are more worth optimizing than others).
Those ".NET-interpreting DLLs" are the API, which can also be compiled.
That's why it's called "Just-in-tme" compilation instead of "Ahead-of-time" compilation(JIT vs AOT)

Java and C# do what I say too. So they are predictable(by your own definition of "predictable").
Sure, there can be errors on bound checking, but they are perfectly clear on the language standard, and therefore predictable.

Yes, it is possible for kernels. Cosmos is a C# kernel. Not sure about Java, but I'm pretty sure they are possible.
And, technically, it is possible to do *ANYTHING* in BRAINFUCK too. Which means your argument just puts C along with turing tarpits.
Logged
Offline (Male) retep998
Reply #10 Posted on: April 06, 2010, 09:51:42 AM

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Quote from: score_under
Tried writing an OS kernel in Java? Not possible. In C, it's just difficult.

Singularity? JNode?
Quote
JNode is a free, open source Java technology based operating system implemented in the Java language with a very small assembler nano-kernel.
Note that the kernel was NOT made in java, but rather in assembly.
Logged
Offline (Unknown gender) Game_boy
Reply #11 Posted on: April 06, 2010, 10:07:40 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
Ah, OK.
Logged
Offline (Unknown gender) luiscubal
Reply #12 Posted on: April 06, 2010, 10:11:41 AM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
No kernel is done in C then.
It is IMPOSSIBLE to write a kernel in C.
You need always a very small assembly component.
Most modern C-based kernels use the linker to mix it with Assembly(inline assembly is also used in some cases, but might not be enough)
Because, somehow, C is *too* high-level for some kernel tasks.
Logged
Offline (Male) retep998
Reply #13 Posted on: April 06, 2010, 10:18:24 AM

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Pretty much any critical kernel code such as the thread manager, the initial loader, or whatever, is generally done in assembly.
The rest of the kernel is then usually coded in c or something similar.
In this kernel is included stuff to run processes, whether they be in windows .exe format or as java programs.
You can't write a kernel in a high-level language because you need something low-level to execute it.
Logged
Offline (Unknown gender) luiscubal
Reply #14 Posted on: April 06, 2010, 10:20:24 AM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
There are AOTs for C#.
Logged
Pages: [1] 2 3 ... 7
  Print