# C# or C++ - which one should the beginners choose



## S.T.A.R.S. (Jun 27, 2011)

Well hello there!
It has been some time since I have posted something last time.I have been so busy and I just couldn't find enough time.
-----------------------------------------------------------------------
This thread is dedicated to those who are planning to start learning computer programming,but do not know which language to choose between C# or C++.
-----------------------------------------------------------------------
Now before I start,I want to let the beginners to know that both languages C# and C++ are great and you can make anything you want in both of them.So my advice to you is to choose the one which is easier for you.I personally use C# because it is easier to make most of the things for the difference of the C++ where most of the things is so hard to make that you want to shoot yourself in the head after hours and hours spent in the front of the screen lol.

Ok now let's move on to the main part.For all of you who are planning to start learning computer programming,I am pretty sure that you have heard many good and many bad sides for C# and C++.Well that's true.Every programming language have it's good and bad sides.There is NO PERFECT programming language so do not lose too much time on which one to choose.In this case C# and C++.Because they are both great believe me.

Many of you who are planning to start learning computer programming soon,most of you probably have not seen any programming code yet.Unforcenately you will have to face with that sooner or later.Since you are now probably wondering which one to choose C# or C++ and which one is easier and which one you think it suits more to you,I have created 2 very simple computer programs.They are both exactly the same,only the first one is written in the C# and the second one is written in the C++ programming language.
Here is the image of the simple computer program written in C#:

http://img01.imagecanon.com/full_view.php?view=45682_C.jpg

Here is the image of that same computer program written in C++:

http://img01.imagecanon.com/full_view.php?view=45685_C-1.jpg


So as you can see on the both images,both programs look the same.They also both do completely the same things.The only difference is the title of the program.The first one is called "C# TEST" and the second one is called "C++ TEST" as you could have seen on the images and that's the ONLY difference.
Also as you can see,both of those programs have 3 buttons.All 3 buttons on BOTH programs do completely the same things.There is NO difference at all.The ONLY difference is that each one is written in a different programming language.First one is written in the C# programming language and the second one is written in the C++ programming language.

Ok now let's move on and explain what each of those 3 buttons do:

-The first button is called "Message".After the user clicks that button,a simple message (or so called MESSAGE BOX) will be displayed on the screen which will show the text "This is the C# message!" or "This is the C++ message!".That message box also has that familiar INFORMATION icon displayed on the left of the text.Also the title (blue area) of that message box contains the text "C#" or "C++".That message box will also have the "OK" button.After the user clicks that "OK" button,the message box will simply close...

-The second button is called "Minimize".After the user clicks that button,the program will simply minimize in the Windows taskbar.To restore the program up,simply click on it in the Windows taskbar as you usually do...

-The third button is called "Exit".After the user clicks that button,the program will simply close...


So as you see these 2 programs have 3 completely the same buttons which really do a very simple operations.
Here is the link to download the first program written in the C# programming language:

http://www.sendspace.com/file/bm9jmj

Here is the link to download the second program written in the C++ programming language:

http://www.sendspace.com/file/83yxoc


Now as a regular user,if you try both of these programs,you will NOT notice any difference because there is NO difference.But as a computer programmer,you will notice a LOT LOT LOT of difference.Now what difference is that?Well the difference is the PROGRAMMING CODE which is written in both of those "same" programs.
If you have downloaded both of those programs using the links I have provided you above,go ahead and take a loot at the size of both of them.You will notice that the size of the program written in the C# is 8 KB (kilobytes) and the size of the program written in the C++ is 116 KB (kilobytes).
Now the question is: "WHY IS THE SIZE OF THE SECOND PROGRAM WRITTEN IN THE C++ SO MUCH BIGGER THAN THE FIRST ONE WRITTEN IN THE C#???" Well the answer is simple.The second program written in the C++ contains a lot more PROGRAMMING CODE than the first program written in the C#,BUT THEN AGAIN THEY BOTH DO THE SAME THING.

So as you see,even now you slowly start to understand the differences between the C# and C++ programming languages.And the difference is simple.C# is easier than the C++.But does that mean that the C++ is better than the C#? Absolutely not.They are BOTH great.

Many people will tell you that the program written in the C++ works (executes) better and faster than the program written in the C#.However that is not true at all.The speed and the quality of the program does NOT completely depend on the programming language it was written in.It depends on the KNOWLEDGE which the programmer has and on the WAY HOW THE PROGRAMMING CODE is written.For example...if you write very good programming code in the C# program,but write the same code for the same thing in the C++ program much worse,it is obvious that the program written in the C# will work better and faster than the program written in the C++ EVEN THOUGH THEY BOTH DO THE SAME THINGS.Same thing of course applies for the opposite.If you write very good programming code in the C++ program,but write the same code for the same thing in the C# program much worse,it is obvious that the program written in the C++ will work better and faster than the program written in the C# EVEN THOUGH THEY BOTH DO THE SAME THINGS.

So as you see,it all depends on your knowledge,time you spent on the program and of course on the quality of the written programming code wether it is C# or C++...

Maybe you have heard that the C# sucks comparing to the C++.That is NOT true at all.They are both great and whoever told you that the C# sucks comparing to the C++ then that person probably never even tried any computer programming and probably do not know anything about it.

Ok now let's finally focus on the main part called PROGRAMMING CODE:

First of all it IS true that the C# is easier than the C++.But why is that?Well the answer is simple: In the C# you do not need to write so much code to accomplish something.In the C++ you MUST write MORE code which is even MORE complicated than the C# code to accomplish completely the same things.

So here comes the question which many beginners ask: "IF THE C# IS EASIER THAN THE C++ AND I CAN ACCOMPLISH EVERYTHING IN BOTH OF THEM,WHY WOULD THEN PEOPLE RECOMMEND ME C++ AND NOT THE C#??????"
Well the answer is simple: People mostly recommend C++ because they "think" it's a lot better.But keep in mind that most of those who recommend C++ probably never even tried any computer programming.They probably heard that the C++ is better and that's it.
Still it IS true that by time you will understand computer programming better if you use C++ than the C#,but believe me that the difference is not so big and you will realize that by time.
I am repeating again.You can make everything in the C# and in the C++.There are no limitations.The ONLY limitation is the KNOWLEDGE you have and NOT the programming language wether is is C# or C++.

Now before you decide which programming language you want to learn,let me show you the complete programming code of both of those programs about which we have talked before.Here is the complete programming code for the first program written in the C#:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace C_SHARP_TEST
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
// 
// button1
// 
this.button1.Location = new System.Drawing.Point(8, 8);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Message";
this.button1.Click += new System.EventHandler(this.button1_Click);
// 
// button2
// 
this.button2.Location = new System.Drawing.Point(88, 8);
this.button2.Name = "button2";
this.button2.TabIndex = 1;
this.button2.Text = "Minimize";
this.button2.Click += new System.EventHandler(this.button2_Click);
// 
// button3
// 
this.button3.Location = new System.Drawing.Point(168, 8);
this.button3.Name = "button3";
this.button3.TabIndex = 2;
this.button3.Text = "Exit";
this.button3.Click += new System.EventHandler(this.button3_Click);
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(248, 38);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button3,
this.button2,
this.button1});
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "C# TEST";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("This is the C# message!","C#",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private void button2_Click(object sender, System.EventArgs e)
{
this.WindowState=FormWindowState.Minimized;
}
private void button3_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}

-----------------------------------------------------------------------

Now here is the code of the second completely the same program written in the C++:

// This is the main project file for VC++ application project 
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <System.Data.dll>
using namespace System;
using namespace System:rawing;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;
using namespace System:ata;
namespace C_PLUS_PLUS_TEST
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public __gc class Form1 : public System::Windows::Forms::Form
{
private: System::Windows::Forms::Button* button1;
private: System::Windows::Forms::Button* button2;
private: System::Windows::Forms::Button* button3;
/// <summary>
/// Required designer variable.
/// </summary>
private: System::ComponentModel::Container* components;
public: Form1()
{
//
// Required for Windows Form Designer support
//
components=NULL;
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected: void Dispose( bool disposing )
{
if( disposing )
{
if (components != NULL) 
{
components->Dispose();
}
}
Form:ispose(disposing);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private: void InitializeComponent()
{
this->button1 = new System::Windows::Forms::Button();
this->button2 = new System::Windows::Forms::Button();
this->button3 = new System::Windows::Forms::Button();
this->SuspendLayout();
// 
// button1
// 
this->button1->Location = System:rawing:oint(8, 8);
this->button1->Name = "button1";
this->button1->TabIndex = 0;
this->button1->Text = "Message";
this->button1->Click += new System::EventHandler(this,&Form1::button1_Click);
// 
// button2
// 
this->button2->Location = System:rawing:oint(88, 8);
this->button2->Name = "button2";
this->button2->TabIndex = 1;
this->button2->Text = "Minimize";
this->button2->Click += new System::EventHandler(this,&Form1::button2_Click);
// 
// button3
// 
this->button3->Location = System:rawing:oint(168, 8);
this->button3->Name = "button3";
this->button3->TabIndex = 2;
this->button3->Text = "Exit";
this->button3->Click += new System::EventHandler(this,&Form1::button3_Click);
// 
// Form1
// 
this->AutoScaleBaseSize = System:rawing::Size(5, 13);
this->ClientSize = System:rawing::Size(248, 38);
this->Controls->Add(button1);
this->Controls->Add(button2);
this->Controls->Add(button3);
this->MaximizeBox = false;
this->Name = "Form1";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = "C++ TEST";
this->ResumeLayout(false);
}
private: void button1_Click(Object* sender, System::EventArgs* e)
{
MessageBox::Show("This is the C++ message!","C++",MessageBoxButtons::OK,MessageBoxIcon::Information);
}
private: void button2_Click(Object* sender, System::EventArgs* e)
{
this->WindowState=FormWindowState::Minimized;
}
private: void button3_Click(Object* sender, System::EventArgs* e)
{
Application::Exit();
}
};
}
int __stdcall WinMain()
{
Application::Run(new C_PLUS_PLUS_TEST::Form1());
return 0;
}

-----------------------------------------------------------------------

Now as you can see,there are many differences in the programming code between the program written in the C# and the program written in the C++,but then again THEY BOTH DO COMPLETELY THE SAME THINGS.On the first view you probably won't understand anything,but by time you will and you will realize that the C# is easier than the C++.

NOTE: I was using Visual C# 2002 and Visual C++ 2002 to write both programs.If you are using the newer versions of the C# or the C++,the programming code might look a little bit different.Also take note that in the Visual C# 2002 you have the visual designer which is a huge help when making programs.In the Visual C++ 2002 you do NOT have the visual designer so you must do everything through the programming code!Still if I am not mistaken,in the Visual C++ 2005 or newer versions you DO have the visual designer just like in the C#...

So phew!This was a lot of informations for the first time.I hope that this will help you to decide which language you want to learn now.

And remember...they are both great and both hard.It all depends on your will and time you spend studying it.

If you have any questions / advices,you can post them here and share with others or you can send me the private messages or send me the E-mail messages on one of my 2 E-mail addresses:

E-mail address 1: marin.j@hotmail.com
E-mail address 2: UAC-UserAccessCommands@hotmail.com

You can also contact me on Skype using my user name: "freeman.gordon4"


Enjoy and have a nice day folks!


----------



## NyxCharon (Jun 27, 2011)

Nice read, but where's java in all of this? 
Just kidding. I learned java before C/C++ and it was horrible. You develop a lot of bad habits in java, and they tend to carry over.


----------



## kobaj (Jun 27, 2011)

> So here comes the question which many beginners ask: "IF THE C# IS EASIER THAN THE C++ AND I CAN ACCOMPLISH EVERYTHING IN BOTH OF THEM,WHY WOULD THEN PEOPLE RECOMMEND ME C++ AND NOT THE C#??????"
> Well the answer is simple: People mostly recommend C++ because they "think" it's a lot better.But keep in mind that most of those who recommend C++ probably never even tried any computer programming.They probably heard that the C++ is better and that's it.
> Still it IS true that by time you will understand computer programming better if you use C++ than the C#,but believe me that the difference is not so big and you will realize that by time.
> I am repeating again.You can make everything in the C# and in the C++.There are no limitations.The ONLY limitation is the KNOWLEDGE you have and NOT the programming language wether is is C# or C++.



And you know, that other tiny little difference of C# being a managed code and c++ being unmanaged. But who needs little things like pointers anyway.

I'm not trying to rain on your parade, but it just seems like you're saying "if you want a language, C# and C++ are the same" when they are /very/ different and have different purposes.

I agree that C# is a lot easier, but with that respect, its also a bit limiting. You have almost no control over memory management and the garbage collector (ok, yes you can run C# as unmanaged, but then you're just being dumb and not taking advantage of the language). Where as C++ you are entirely responsible for memory management, no matter what.

Why are you using such old studios? Visual Studio Express is completely free and updated with the latest C++ and C# runtimes. 

If you put your code inside of [ code ] tags (without spaces) it formats it nicely.

```
public class Hi()
{
      private void Method(){}
}
```

Anyway, I digress, its a good tutorial and makes a lot of other good arguments (I really liked how you presented the fact that C# can be just as fast as C++ ). I love C# and grew up on it, please read this as a way to help you write better tutorials, not as being mean .


----------



## Cromewell (Jun 27, 2011)

kobaj said:


> And you know, that other tiny little difference of C# being a managed code and c++ being unmanaged. But who needs little things like pointers anyway.


There are packages available in which you can create managed C++ as well. I don't particularily like them, they feel clunky, but it's doable.


----------



## S.T.A.R.S. (Jun 29, 2011)

kobaj said:


> Why are you using such old studios? Visual Studio Express is completely free and updated with the latest C++ and C# runtimes.


 
Trust me you don't wanna know lol.


----------

