Valhalla Legends Forums Archive | General Programming | Speed? whats fastest?

AuthorMessageTime
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
August 10, 2004, 6:17 AM
hismajesty
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.
August 10, 2004, 11:33 AM
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
August 10, 2004, 1:16 PM
Kp
Some quick technical notes:

[quote author=FrOzeN link=board=5;threadid=8102;start=0#msg74851 date=1092118631]i want to start C++ now but want some background on it.
i'm looking for a low-level language for speed..[/quote]

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 author=FrOzeN link=board=5;threadid=8102;start=0#msg74851 date=1092118631]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..[/quote]

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. :)
August 10, 2004, 1:33 PM
Arta
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.
August 10, 2004, 2:15 PM
Kp
[quote author=Arta[vL] link=board=5;threadid=8102;start=0#msg74884 date=1092147301]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.[/quote]

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.
August 10, 2004, 2:32 PM
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.
August 10, 2004, 4:07 PM
St0rm.iD
If you want to make money, learn C#.
August 10, 2004, 4:25 PM
Myndfyr
[quote author=Clokr_ link=board=5;threadid=8102;start=0#msg74895 date=1092154058]
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.
[/quote]

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++
[code]
int i;
int j;
j = -1;
for (i = 0; i < 0x7fffffff; i++)
{
j = i;
}
[/code]

C#:
[code]
int i, j;
j = -1;
for (i = 0; i < 0x7fffffff; i++)
{
j = i;
}
[/code]
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.
August 11, 2004, 12:56 AM
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.
August 11, 2004, 3:10 AM
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 ;)
August 11, 2004, 5:14 AM
hismajesty
[quote author=FrOzeN link=board=5;threadid=8102;start=0#msg75013 date=1092201249]
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 ;)
[/quote]

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.
August 11, 2004, 3:27 PM
Skywing
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.
August 12, 2004, 2:26 AM
St0rm.iD
[quote author=Skywing link=board=5;threadid=8102;start=0#msg75140 date=1092277561]
$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.
[/quote]

Much easier to find a web job in a hip language than a C++ one, IMO.
August 12, 2004, 2:29 AM
Arta
[quote author=Skywing link=board=5;threadid=8102;start=0#msg75140 date=1092277561]
Windows 3.x and Win9x were written in assembler.
[/quote]

How much of them were? Writing an entire OS the size of windows in assembler doesn't sound very sensible!
August 12, 2004, 2:37 AM
Skywing
[quote author=$t0rm link=board=5;threadid=8102;start=0#msg75142 date=1092277742]
[quote author=Skywing link=board=5;threadid=8102;start=0#msg75140 date=1092277561]
$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.
[/quote]

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

I suppose. I'm not doing a 'web job', though, really.

[quote author=Arta[vL] link=board=5;threadid=8102;start=0#msg75148 date=1092278275]
[quote author=Skywing link=board=5;threadid=8102;start=0#msg75140 date=1092277561]
Windows 3.x and Win9x were written in assembler.
[/quote]

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

The vast majority, AFAIK. It was very sensible when your target machines had 4MB of RAM or less...

Proof of this can be found in that it was Win9x that really took off, and not NT (until relatively recently).

NT was written in C and not assembler, and far predated Win9x. Of course, you also had to have more hardware than the typical consumer desktop had to run it decently (compared to Win9x or Win3.1).
August 12, 2004, 2:42 AM
St0rm.iD
[quote author=Skywing link=board=5;threadid=8102;start=15#msg75151 date=1092278558]
[quote author=$t0rm link=board=5;threadid=8102;start=0#msg75142 date=1092277742]
[quote author=Skywing link=board=5;threadid=8102;start=0#msg75140 date=1092277561]
$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.
[/quote]

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

I suppose. I'm not doing a 'web job', though, really.
[/quote]

Whoops...looks like the lexer had an ambiguous match error.

Much easier to find (a web job in a hip language) than (a C++ one), IMO.
August 12, 2004, 2:52 AM
Skywing
[quote author=$t0rm link=board=5;threadid=8102;start=15#msg75153 date=1092279122]
[quote author=Skywing link=board=5;threadid=8102;start=15#msg75151 date=1092278558]
[quote author=$t0rm link=board=5;threadid=8102;start=0#msg75142 date=1092277742]
[quote author=Skywing link=board=5;threadid=8102;start=0#msg75140 date=1092277561]
$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.
[/quote]

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

I suppose. I'm not doing a 'web job', though, really.
[/quote]

Whoops...looks like the lexer had an ambiguous match error.

Much easier to find (a web job in a hip language) than (a C++ one), IMO.
[/quote]

Ah. Well, in my case it was easier to find a C++ job. Your experiences may vary, though.
August 12, 2004, 2:53 AM
FrOzeN
ok i'm just gonna start learning C/C# once i get the hang of them and start understanding socks i'll move into C++ as i eventually want to create my own game..

thanx for all the help ;D
August 12, 2004, 7:18 AM
St0rm.iD
not c/c#

it's java/C# and c/c++
August 12, 2004, 2:52 PM
hismajesty
[quote author=Skywing link=board=5;threadid=8102;start=0#msg75140 date=1092277561]
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...[/quote]

Windows 3.x/9x were written before .NET was even released, I meant in present time. And I got that information in an email Robert Scoble (developer at Microsoft) wrote me. I'll get the quote:

[quote]Yeah, in the past I'd assume most of the apps were done in C/C++. That's
changing very quickly to C#/.NET. Drivers and games and key things that
need high performance are the two big exceptions. Yeah, some
internal business apps (expense report kinds of things) were written in VB.[/quote]

[quote]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.
[/quote]

Nobody said that C/C++ was obsolete. I was speaking from where the world in general is moving, which is to .NET. Microsoft is developing in C# more and more. Which is where I mainly based that opinion, along with iago telling me the percentage of languages being requested in his area.
August 12, 2004, 4:01 PM
Grok
There is another way to look at this. What has industry done in the past when there were major language usage shifts? To answer that, you can look at COBOL and Visual Basic., as compared to C/Ada/C++.

There is always a large segment of industry, especially business applications, that will be using a low performance, easy-to-write-in language appropriate for those tasks. Business processes are dynamic, they change with the shifting requirements of business. They need a development shop that can rapidly, and I stress rapidly, design code and deploy new applications. That was never going to happen with C/Ada/C++ for the majority of uses. Those types of needs are what gave COBOL, and later Visual Basic, their market strength and fortitude.

Now along comes Java, which excelled at RAD, was great for mid-sized to large corporations, but not so much the smaller ones that had to scrape the barrel bottom for programming skills. Many mid to large companies went to Java, but equally as many programmers were doing VB now, and you still had legions of older guys (who are all 55+ now) supporting COBOL programs written in the 70s and early 80s.

By looking at the history, you can probably predict what will happen with .NET, mainly, pretty much the same things. It will find its niche. Nobody will be doing everything in .NET and .NET will not solve all problems. It will likely replace up to a third of Java installations, but might drive away businesses that were previously using VB6. Maybe those guys don't understand FCL or CLR and their whole little shops move to Java.
August 12, 2004, 4:54 PM
Myndfyr
Very interesting point, although -- if you can understand Java and the Java Class Library, then you can understand C# and the FCL. Programs that can be written in Java can be written generally in C# with just a few identifier changes, and then if you understand C#, they can often be made more robust rather quickly.

The first time I had to write a doubly-linked list in Java, I spent a few hours on it, couldn't get it to work correctly. Restarted in C#, had it working in 10 minutes, spent 5 minutes converting back to Java, and it worked fine.

How similar those two languages are is retarded, but... it's a fact of life I guess. :/
August 12, 2004, 6:34 PM
LW-Falcon
Yea I think Java is being used more now as they just switched from teaching C++ to Java in my Computer Science class this year.
August 13, 2004, 4:15 AM
hismajesty
[quote author=Falcon[anti-yL] link=board=5;threadid=8102;start=15#msg75314 date=1092370558]
Yea I think Java is being used more now as they just switched from teaching C++ to Java in my Computer Science class this year.
[/quote]

In most (all?) schools. It was a decision by the college board to switch the AP test from C++ to Java. However, my schools intro to programming class (who doesn't even get to use computers for a good part of the year...) is in C++. The curiculum is a joke though, the AP Comp Sci teacher gave me a sylabus for the class since I'm taking it this year. I covered the entire thing in 4 hours with one of my Java books. They don't get into Swing or anything like that, and spend 3 weeks on things such as if statements, but only one week on OOP.
August 13, 2004, 4:35 AM
Grok
[quote author=hismajesty[yL] link=board=5;threadid=8102;start=15#msg75320 date=1092371748]
The curiculum is a joke though, the AP Comp Sci teacher gave me a sylabus for the class since I'm taking it this year. I covered the entire thing in 4 hours with one of my Java books. They don't get into Swing or anything like that, and spend 3 weeks on things such as if statements, but only one week on OOP.
[/quote]

Most high school, and some college, compsci teachers either do not understand OOP, or do not understand it well enough to teach it. They struggle with ways to describe the concepts. Sometimes their problem is the students inability to conceptualize and abstract.
August 13, 2004, 2:29 PM
Maddox
We don't even have a CS class offered in our entire district.
August 13, 2004, 7:37 PM
St0rm.iD
we did flash last year for compsci.
i admit, i did learn it!
August 13, 2004, 10:21 PM
Maddox
I think I am going to take the AP CS test even though I am not taking the class. I bet I could get at least a 4 on it without studying.
August 14, 2004, 4:39 AM
Maddox
Anyways, getting back to speed.

[img]http://www.osnews.com/img/5602/results.jpg[/img]
August 14, 2004, 5:05 AM
Skywing
It would be interesting to see just what those benchmarks were, and if they are really just testing the speed of stock standard library implementations...
August 14, 2004, 5:56 AM
Adron
Sounds a bit strange to get such large differences on basic operations. Seems C++ kicks everything else though.
August 14, 2004, 10:54 AM
K
The comparison can be found here:
http://www.osnews.com/story.php?news_id=5602

I wouldn't put much stock in it. The author claims microsoft is wrong about equivalent code in different .NET languages compiling to the same MSIL, but if you look at his code you can see that he's using the legacy VB File IO functions in VB.NET and the stock .NET implementations in C#.

He also couldn't figure out how to make an "unmanaged C++.NET" project. ::)
August 14, 2004, 4:25 PM
Myndfyr
[quote author=K link=board=5;threadid=8102;start=30#msg75477 date=1092500706]
The comparison can be found here:
http://www.osnews.com/story.php?news_id=5602

I wouldn't put much stock in it. The author claims microsoft is wrong about equivalent code in different .NET languages compiling to the same MSIL, but if you look at his code you can see that he's using the legacy VB File IO functions in VB.NET and the stock .NET implementations in C#.

He also couldn't figure out how to make an "unmanaged C++.NET" project. ::)
[/quote]

Uh huh... an unmanaged C++ .NET project? Who ever heard of that?
August 18, 2004, 12:01 AM

Search