• Welcome to Valhalla Legends Archive.
 

Speed? whats fastest?

Started by FrOzeN, August 10, 2004, 01:17 AM

Previous topic - Next topic

FrOzeN

i want to start C++ now but want some background on it.
i'm looking for a low-level language for speed..
so far i know a fair bit of VB6 but i want to move into C++

whats faster..

Visual C++ v6.0?
C++ .Net?
other?(name plz)

because i want to find out whats best to learn so i dont waste time learning a slower one..

btw: i learnt VB6 as its good background knowledge for VBScripting and things
~ FrOzeN

hismajesty

#1
VC6

The way the .NET framework functions results in a 10%+ slowdown. You see, it operates a bit differently than other languages of the past. Instead of compiling into native machine code, it relies on the .NET framework. However, in turn, it's safer and more portable.

1. Your Application
2. Runtime enivroment (VM)
3. Operating System
4. Hardware

However C++.NET has access to the entire FxCL, which is very nice.

Edit: Personally, unless you're planning on making drivers and games professionally, you should probably learn Java and C#. At Microsoft they use C# for almost everything, with the exception of C++ for drivers and games, and VB.NET for internal finance applications. Also, I was talking to iago yesterday, and he said only 1% of jobs in his area are for C++, the rest are for Java/Web programming.

iGotPropz

Yes C# is the newest and fastet growing langauge. It really ins't that hard to learn either, just goto the MSN scripting reference. It'll give references on how to code something in VB, then how it looks in C#. IT gives details about each little thing involved in C# ;D

Kp

Some quick technical notes:

Quote from: FrOzeN on August 10, 2004, 01:17 AMi want to start C++ now but want some background on it.
i'm looking for a low-level language for speed..

Assembly.  I doubt you want to learn machine code, but it and assembly are about the only options if you really meant "low level language."  C/C++ are considered high level languages because they handle variable management, structures, etc. for you.  VB* is a sandbox language.

Quote from: FrOzeN on August 10, 2004, 01:17 AMwhats faster..
Visual C++ v6.0?
C++ .Net?
other?(name plz)
because i want to find out whats best to learn so i dont waste time learning a slower one..

Speed will depend lots on your optimization level, and how well/poorly you write code.  Also, distinguishing between VC6 and VC++.Net shows a lack of understanding, and you should stop doing it.  They aren't different languages, just different compilers for the same language.  I suspect you mean C#, not C++.Net.  C#, which the other posts referred to, is the MS rip-off of the Java concept ("The programmer is stupid, let's put him in a sandbox so he can't hurt himself."); afaik, Visual Studio 7 (aka VS.Net) allows C# or C++ coding (though you have to do some stupid things to get them to mix properly).  From personal experience, I've never seen VC6 generate code that could outperform a g++ compile of the same source.  I've heard good things about the VC7 optimizer, but I don't use it personally, because it had some really funny bugs, like modifying your assembly to always crash on exit from certain routines.  This is a nasty bug, since it is difficult to diagnose without assembly knowledge.  Also, the Visual Studio family requires absurdly expensive licenses, while g++ is free under the GPL. :)

As the yeti lover pointed out, C# will run slower than equivalent C++ code by the very nature of the sandbox language.  Exactly how much slower will depend again on the quality of your code (i.e. if you make a stupid loop that takes twice as long as it should to complete, that can hurt more in C# where cost of one iteration is higher, so you'd pay double of a higher price).

One other note, regarding portability.  Java > C#, since there already exist relatively complete and stable Java libraries on platforms that aren't made by Microsoft, so Java has more of a claim to portability than the .NET framework does.  Of course, Java's also a sandbox language, so you'll still suffer for using it.  Note to $t0rm: don't bother pointing out Mono, since I said relatively complete. :)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Arta

#4
Kp: Your propensity for finding bugs in Microsoft products is quite remarkable :)

I personally have never encountered a bug in the VC7 compiler. I don't have any data to back this up, but I would assume also that VC7 > VC6. I expect VC7 incorporates new optimisations for modern processors that weren't around when VC6 was standard.

Kp

Quote from: Arta[vL] on August 10, 2004, 09:15 AMKp: Your propensity for finding bugs in Microsoft products is quite remarkable :)

I personally have never encountered a bug in the VC7 compiler. I don't have any data to back this up, but I would assume also that VC7 > VC6. I expect VC7 incorporates new optimisations for modern processors that weren't around when VC6 was standard.

It's quite easy, really.  Just listen when Skywing tries to build BC and catalog the things that the compiler does wrong. :)  Re VC7 optimizations: I've heard (though not tried/seen) that it will also do other aggressive optimizations, like breaking calling convention.  That is, it'll recognize that a particular register is not used in the caller, so it will clobber it even though it's normally a "stable" register.  iirc, this was the cause of the crash-on-exit bug I hinted at: it could sometimes become confused and wrongly believe it was acceptable to clobber ebp.

Although gcc won't break calling convention, I've been overall very impressed with its optimization abilities - it's well worth learning on if you don't have a VS license.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Clokr_

Just stick with what Kp said. C# is easier, but slower. Also C# is another unexportable language that microsoft made, instead C++ is exportable to other platforms.

Banana fanna fo fanna

If you want to make money, learn C#.

MyndFyre

Quote from: Clokr_ on August 10, 2004, 11:07 AM
Just stick with what Kp said. C# is easier, but slower. Also C# is another unexportable language that microsoft made, instead C++ is exportable to other platforms.

Uhhh no -- C# is not unexportable.  Go Mono.  Learn what you're talking about.

With regards to the Visual C++ compiler, with Visual Studio 8, they are doing some wonderful things.  The current PDB (debug database) format is going to be extended into a profiler system, which will allow a process to log what methods, loops, et. al. will be used most frequently and to see what changes during those critical areas.  Each subsequent compile will use profiling data to aggressively optimize code, which *may* result in some errors -- I haven't used it, but what I've read about it seems quite promising.

Additionally, if you have these code snippets:

C++

int i;
int j;
j = -1;
for (i = 0; i < 0x7fffffff; i++)
{
 j = i;
}


C#:

int i, j;
j = -1;
for (i = 0; i < 0x7fffffff; i++)
{
j = i;
}

The first time, the C++ code will run slower.  The second time, they will run at identical speeds.

If you run ngen.exe on the C# output, they will run at identical speeds both times.

What it seems I need to keep reminding everyone is that .NET Framework functions are only JIT-ted once -- the first time they are run -- and the resultant native code is stored in a cache on the machine.  The JIT compiler is being upgraded continually for more aggressive optimization.

So quit downing it!

Also -- Kp, all of mscorlib.dll *had* to have been written in MC++.  As you so astutely pointed out to me today in Op [vL], without it, there would have been no native types for the .NET languages.  :P  Also, if you use MC++, you'll find a lot of operations on System-namespace-types that you don't see in the other languages -- I can't think of any offhand, but it's interesting.  However, using MC++ will sometimes cause a slowdown, if you use the .NET Framework extensively.

Personally, I wouldn't use C++ .NET unless you were going to upgrade existing code.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Kp

First, I already said to ignore Mono. :)  The site is unreachable atm, but iirc, it's not made by Microsoft.  It's some third-party project by people who thought .NET was a good idea but couldn't bring themselves to actually use a Windows OS to run it, so they set off making a CLR clone for other systems.  Regarding profiling: gcc has had this for quite a while. :)

I'm not quite sure what you're getting at with your example loops, since they're exactly the same and any decent C++ compiler ought to recognize that the loop is garbage and just do the assignment once.  I don't have any experience with whether the C# JIT is that smart.

Regarding mscorlib.dll: it'd make more sense to write it as true C++ code, not Managed C++.  As I understand it, making it "managed" causes it to suffer from some of the same performance stupidities as Java, such as always checking array indices every single time, which is generally rather excessive.  As to your comment that it must be written in MC++: think about these forums.  How many "Brood War" and "Warcraft III" connections does Blizzard get from clients that weren't even implemented in Win32/C++ / Mac/C++?  My point is that it'd at least be possible (don't know about easy) to write mscorlib and friends in any DLL-capable compilable language, as long as the designers were careful to export it in a way that looked compatible to the .NET framework.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

FrOzeN

k from what i've heard i take it C# would be best alternative to use?
and VC7 is that Visual C# v7.0?

finally just wondering in example what would games like Battlefield//Counter-Strike be made in? (or did the company develop there own private code/complier?)

Thanx for the help  ;)
~ FrOzeN

hismajesty

Quote from: FrOzeN on August 11, 2004, 12:14 AM
k from what i've heard i take it C# would be best alternative to use?
and VC7 is that Visual C# v7.0?

finally just wondering in example what would games like Battlefield//Counter-Strike be made in? (or did the company develop there own private code/complier?)

Thanx for the help  ;)

C# would probably be the best route if you're going to try to make a living programming.

VC7 was probably referring to C++.NET, but I dunno. :P

As I said in my original post, high end games are still written in C++, so yes, Battlefield 1942/CS were written in it.

Skywing

#12
I'm not sure where you get that most of the things Microsoft writes are in C#.

NT, Office, VS/CL (for the most part, excepting some of the IDE -- the compiler/linker is the important part anyway), etc are C or C++.

Windows 3.x and Win9x were written in assembler.

I think that covers enough things not C# or VB.NET...

MindFyre-

VC6 had a profiler too.  It seems that VC7/7.1 just got left out and didn't come with one.

$t0rm/hismajesty-

I'm getting paid to write C and C++ right now, actually.  Dunno where this myth that nobody gets paid for writing stuff other than Java/C# started from, but it doesn't seem to really hold true.

Banana fanna fo fanna

Quote from: Skywing on August 11, 2004, 09:26 PM
$t0rm/hismajesty-

I'm getting paid to write C and C++ right now, actually.  Dunno where this myth that nobody gets paid for writing stuff other than Java/C# started from, but it doesn't seem to really hold true.

Much easier to find a web job in a hip language than a C++ one, IMO.

Arta

Quote from: Skywing on August 11, 2004, 09:26 PM
Windows 3.x and Win9x were written in assembler.

How much of them were? Writing an entire OS the size of windows in assembler doesn't sound very sensible!