Project 1999

Go Back   Project 1999 > General Community > Rants and Flames

View Poll Results: Which do you like?
C 4 17.39%
C++ 15 65.22%
C# 9 39.13%
Multiple Choice Poll. Voters: 23. You may not vote on this poll

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 06-22-2012, 09:48 PM
Lucky Lucky is offline
Sarnak

Lucky's Avatar

Join Date: May 2012
Location: I don't give a h00t
Posts: 253
Smile C vs. C++ vs. C#

Hi. I am a computer scientist. This is a comparison of memory usage for a simple hello world application between C, C++, and C#. Compiled VS2010 32-bit x86 Release.

PHP Code:
// C#
// 1,968k
using System;

namespace 
hellonet
{
    class 
Program
    
{
        static 
void Main(string[] args)
        {
            
System.Console.Write("hello world");
            
System.Console.ReadKey();
        }
    }

PHP Code:
// C++
// 640k
#include <iostream>

int main(int argccharargv[])
{
    
std::cout << "hello world";
    
std::cin.get();
    return 
0;

PHP Code:
// C
// 484k
#include <stdio.h>

int main(int argccharargv[])
{
    
printf("hello world");
    
getchar();
    return 
0;

As you can see, C# uses 5x as much memory as C and 3x more than C++ just for a simple hello world application. And M$ is writing Windows.Next kernel in this managed language.

Rogean you can thank me for the adsense money from the future googlers that will find this site (as applies to all of my insights made here).
__________________

In your unfailing love, silence my enemies; destroy all my foes, for I am your servant.
Blessed be the LORD my strength, who teaches my hands for war, and my fingers to fight.
(Psalms 143:12-144:1)
Quote:
Originally Posted by Harrison View Post
To be fair he is making $$, which I can't fault him for. If cheating gets you real money, go for it. Real money > pixels.
[10:53] <@Amelinda> he grabbed my ass and then i broke his nose.
  #2  
Old 06-22-2012, 09:59 PM
Lucky Lucky is offline
Sarnak

Lucky's Avatar

Join Date: May 2012
Location: I don't give a h00t
Posts: 253
Default

Note: I was using the MS C compiler for the C code. Bjarne Strassoup (creator of C++) said that hello world should generate literally same code. So I copied the C code and compiled with MS C++ compiler and it was 488k.

interdasting
__________________

In your unfailing love, silence my enemies; destroy all my foes, for I am your servant.
Blessed be the LORD my strength, who teaches my hands for war, and my fingers to fight.
(Psalms 143:12-144:1)
Quote:
Originally Posted by Harrison View Post
To be fair he is making $$, which I can't fault him for. If cheating gets you real money, go for it. Real money > pixels.
[10:53] <@Amelinda> he grabbed my ass and then i broke his nose.
  #3  
Old 06-22-2012, 10:09 PM
Razdeline Razdeline is offline
Fire Giant


Join Date: Jan 2011
Posts: 757
Default

c++ for obv~ reasons
  #4  
Old 06-22-2012, 11:39 PM
Lubian Lubian is offline
Orc


Join Date: Mar 2011
Posts: 30
Default

I'm kind of wondering why you're comparing the memory usage of each of these Hello World programs in the different languages; is that supposed to be a way to determine which language is better? God, I hope not.

Furthermore, what also saddens me is your leap from this into the Windows 8 Kernel and managed, but I have a feeling you don't know what managed means.

Also, since you used "using System;" so you don't have to write the namespace System before Console. ReadKey() probably doesn't do what you think it does; I think your intention would be Read().

Lastly, you don't have to wonder if they generate the same code, since you can view the disassembly very easily in VS2010, but ensure you're viewing the release build when you do so.
  #5  
Old 06-22-2012, 11:50 PM
Lucky Lucky is offline
Sarnak

Lucky's Avatar

Join Date: May 2012
Location: I don't give a h00t
Posts: 253
Default

Of course I knew there would be criticism of comparing hello world applications, but I sincerely doubt C# will perform any better when dealing with generic containers compared to C++ STL which inlines to C.

Perhaps it is unfair as .NET is a framework, so I will compare it to Qt.

PHP Code:
// Qt C++
// 960k
#include <QtCore/QCoreApplication>

int main(int argcchar *argv[])
{
    
QCoreApplication a(argcargv);

    
std::cout << "hello world";
    
std::cin.get();
    
    return 
a.exec();

I didn't say anything about Windows 8.

Quote:
Originally Posted by Wiki
Midori is the code name for a managed code operating system being developed by Microsoft Research. It has been reported[1][2] to be a possible commercial implementation of the Singularity operating system, a research project started in 2003 to build a highly-dependable operating system in which the kernel, device drivers, and applications are all written in managed code. Microsoft has mapped out several possible migration paths from Windows to Midori (referred to as "Windows.Next").[5][6][7]
The namespace was unnecessary I'll agree, but not something which would have effected the compiler. From my understanding, ReadKey() is more-o'er-less similar to a single getchar() and std.cin() beyond the fact that return doesn't need to be pressed.
__________________

In your unfailing love, silence my enemies; destroy all my foes, for I am your servant.
Blessed be the LORD my strength, who teaches my hands for war, and my fingers to fight.
(Psalms 143:12-144:1)
Quote:
Originally Posted by Harrison View Post
To be fair he is making $$, which I can't fault him for. If cheating gets you real money, go for it. Real money > pixels.
[10:53] <@Amelinda> he grabbed my ass and then i broke his nose.
  #6  
Old 06-23-2012, 12:32 AM
Lubian Lubian is offline
Orc


Join Date: Mar 2011
Posts: 30
Default

Quote:
Originally Posted by Lucky [You must be logged in to view images. Log in or Register.]
Of course I knew there would be criticism of comparing hello world applications, but I sincerely doubt C# will perform any better when dealing with generic containers compared to C++ STL which inlines to C.
Performance wise, probably every developer knows that the lower level C languages are going to be faster than C#. It's also pretty widely known that the simple C# programs use more memory, because they purposely didn't design for an empty exe; since if you needed something with a low memory footprint or something time critical you would use a lower level language. This should be of no surprise for anyone who knows what a high level or low level programming language is and the advantages and disadvantages between the two.

Quote:
Originally Posted by Lucky [You must be logged in to view images. Log in or Register.]
The namespace was unnecessary I'll agree, but not something which would have effected the compiler. From my understanding, ReadKey() is more-o'er-less similar to a single getchar() and std.cin() beyond the fact that return doesn't need to be pressed.
I'm starting to think it's a waste of time even responding to you. You can clearly see the return type of ReadKey() from the IDE (it's a struct). I don't know why you would continue spewing misinformation after someone told you it might have been wrong, and the fact that it takes 1 second to validate.

I'll stop wasting my time here. Good luck with your thread and checking how much memory Hello World programs use in different languages.
  #7  
Old 06-23-2012, 01:01 AM
Spectre Spectre is offline
Banned


Join Date: Dec 2009
Posts: 34
Default

I could write a C++ program that could kill your whole family.
  #8  
Old 06-23-2012, 01:55 AM
Lucky Lucky is offline
Sarnak

Lucky's Avatar

Join Date: May 2012
Location: I don't give a h00t
Posts: 253
Default

As far as ReadKey() goes, it is the accepted practice of preventing a console application of immediately closing. I tried Read(), and of course there wasn't any significant difference in the memory footprint. Maybe they load similar buffers, or don't load any until the key is actually pressed and the method returns, that I do not know.

What inspired this in the 1st place was reading this statement on stackoverflow: The .Net framework takes anywhere from 5-15 megabytes of RAM just to load up enough code to execute "Hello World".

Obviously C# was going to fail in this. It's JIT'ed, which means that it's an inefficient waste of crap language designed solely for the purpose of treating ignorant software programmers as fodder for applications developed on a Microsoft platform. I don't care how easy it is to program in; there's no way in hell I'll use a language which doesn't put forth the idea of "flexibility" and "control" as important. C# was designed to make Microsoft money, and to provide businesses the ability to write generic, lame, CRUD applications.

But after seeing all of this I'm reaffirmed and glad I switched to Qt years ago and never looked back.
__________________

In your unfailing love, silence my enemies; destroy all my foes, for I am your servant.
Blessed be the LORD my strength, who teaches my hands for war, and my fingers to fight.
(Psalms 143:12-144:1)
Quote:
Originally Posted by Harrison View Post
To be fair he is making $$, which I can't fault him for. If cheating gets you real money, go for it. Real money > pixels.
[10:53] <@Amelinda> he grabbed my ass and then i broke his nose.
  #9  
Old 06-23-2012, 03:09 AM
somnia somnia is offline
Kobold

somnia's Avatar

Join Date: Apr 2012
Location: The Clouds
Posts: 165
Default

Hi. I am a developer. This is the reality check.

Taken from http://www.ecma-international.org/pu...T/Ecma-334.pdf referenced by http://en.wikipedia.org/wiki/C_Sharp...ote-ECMA-334-6.

As the definition of C# evolved, the goals used in its design were as follows:

• C# is intended to be a simple, modern, general-purpose, object-oriented programming language.
• The language, and implementations thereof, should provide support for software engineering principles
such as strong type checking, array bounds checking, detection of attempts to use uninitialized variables,
and automatic garbage collection. Software robustness, durability, and programmer productivity are
important.
• The language is intended for use in developing software components suitable for deployment in
distributed environments.
• Source code portability is very important, as is programmer portability, especially for those
programmers already familiar with C and C++.
• Support for internationalization is very important.
• C# is intended to be suitable for writing applications for both hosted and embedded systems, ranging
from the very large that use sophisticated operating systems, down to the very small having dedicated
functions.
Although C# applications are intended to be economical with regard to memory and processing power
requirements, the language was not intended to compete directly on performance and size with C or
assembly language.


I've bolded the most important bullet point for your reference. I understand many of you machine-hybrid basement dwellers enjoy ultra efficiency as I employ a number of you for highly specialized tasks in my company but keep in mind that it is important to use the right tool for the job.
  #10  
Old 06-23-2012, 03:17 AM
Lucky Lucky is offline
Sarnak

Lucky's Avatar

Join Date: May 2012
Location: I don't give a h00t
Posts: 253
Default

hence why it sux
__________________

In your unfailing love, silence my enemies; destroy all my foes, for I am your servant.
Blessed be the LORD my strength, who teaches my hands for war, and my fingers to fight.
(Psalms 143:12-144:1)
Quote:
Originally Posted by Harrison View Post
To be fair he is making $$, which I can't fault him for. If cheating gets you real money, go for it. Real money > pixels.
[10:53] <@Amelinda> he grabbed my ass and then i broke his nose.
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:42 PM.


Everquest is a registered trademark of Daybreak Game Company LLC.
Project 1999 is not associated or affiliated in any way with Daybreak Game Company LLC.
Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.