Originally posted by: xtknight
Originally posted by: kamper
That's a silly myth.
It's not a myth. It's the truth and unmanaged languages will always be faster because they don't have to catch exceptions on everything.
Exceptions only cost you when you throw them. Besides which, c++ has exceptions. Are you suggesting we stick with just c forever then?
The amount of speed difference may get down fairly low though. Isn't .NET basically a script that runs on a virtual machine, or is it actually compiled?
I don't know the internals of .NET (and I don't think it's actually a contractual part of the platform) but I'll give a little run down on how a java runtime might work. I suspect a .net implementation would operate similarly.
So first you compile your code to byte-code. This is is sort of like assembler for the virtual machine, but it's not necessarily optimized. At runtime, the virtual machine loads this code and can do a number of things with it. At the simplest, it will work like an interpreter, just reading the byte code and executing actions on behalf of your program. Of course, that's really slow because it requires re-interpretation every time something is executed.
The vm might start by interpreting all code and then noticing when stuff gets executed multiple times. That code it will then compile into native machine code and store it so that it can be run again at no cost next time. There might be several levels of compilation, each with more agressive optimization. More optimization takes more compilation time so only code that runs very frequently is given (and needs) the highest level.
A vm can perform much more agressive optimizations than a one time compiler because it knows certain things that won't change. It knows the cache size, it knows which methods are worth inlining (because it's observed them being run many times), it doesn't have to worry about portability at all and it can unroll as many loops as it likes because it'll only cost a little extra memory. Furthermore, if the data being processed changes over time and the current optimizations become no longer ideal, the vm can just toss what it's done and reoptimize.
I find Anandtech to be fine, but I've seen my share of yawn sites. Whether it's because of .NET or if the slow sites I'm talking about even use .NET I don't know, but I highly suspect it.
That's pretty weak. Seriously, a .NET or java written site, as a baseline, can return a page just as fast as anything else. If you notice a slow site, it's more likely the fault of the developer. Anyways, you can tell pretty easily what a site is running as .NET sites will almost always use the .aspx extension.
.NET doesn't seem as bad as some PHP/Postnuke sites. 90% of Postnuke sites are god-awful (relatively).
Point in case.
If you know what you're doing, C isn't dangerous. There are so many programs coded in C. I don't think you'll see Adobe converting Photoshop's image processing functions to .NET any time soon.
Of course c is dangerous. How many systems do you know that are really free from buffer overflow vulnerabilities or any of the other stuff that can be done when you have direct access to a processor. No offence, but you've obviously never worked on a team of paid programmers doing business applications.
Paid being the operative word there, because employers don't want to shell out for the extra time it takes you to get it right in C, plus the extra time you'll spend debugging mysterious errors. If the .net/java app happens to be a bit slower, it's far cheaper to pay for more beefed up hardware than for extra programming hours.
No photoshop probably won't be changed, but remember that adobe has a huge investment in that code and has little reason to change it. They also have to worry about portability to macs and they probably have linux in the back of their minds. But really, I wouldn't be surprised if they, or others, did start writing more in .net.
I'll tell you what, I'll write the same program in C (using VS2005 8.0 C compiler) as I do in VB.NET 2005 Express then report the results. I'll use ticks to measure time. This will just be a big loop increasing i. I'll see if it's worth my time to convert my program to C. Maybe this will change my mind, or maybe it will further prove my point.
I'll do it in a few...I'm off to Battlefield 2 on 64-bit for the moment. 😀
Even if performance was always a concern for managed languages, it's still where the world is going because development is way easier and way safer.