Programming from Scratch

Old 2 Comments on Programming from Scratch 61

“Everybody in this country should learn to program a computer, because it teaches you how to think”

-Steve Jobs

 

Enough with the Steve Jobs’ quotes for now, as it is your time to shine. A glory compiler road full of warning and errors. People often are shoved down after seeing the red exclamation mark, (“!”), but it happens to professionals several times a day! So when you start this exciting adventure, do not let the compiler fear you, but learn from it, as programming is easily learned from trial-and-error.

You may be asking “What the heck is this girl talking about,” aha, you are correct! Let me break down the key terms you may experience in this unforgettable journey you will be taking. A compiler is a piece of software to make machine code, binary, from human code. Human code can range from Java to C++; but a computer can’t understand “System.out.println(“Hello World”);” . Now how can you get a compiler you might ask, well that is easy. A compiler comes with most IDE’s which stands for integrated development environment. The IDE I use is Visual Studio, which is Microsoft’s premium IDE, but there are tons of free IDEs out there for you to use. There are also IDE’s which are opensource, such as MonoDevelop, which allows you to customize your IDE to your needs.
If you choose to also use Visual Studio, it may make a whole in your pocket at first, but you will make your money back if you make good software. I strongly recommend you DON’T buy Visual Studio IF you’re just starting. CodeBlocks or other IDEs will definitely be ‘good enough’ after a 90-day trial of Visual Studio. You can get a 90-day trial of Visual Studio at www.visualstudio.com. Navigate to the downloads and choose what fits your needs.
vs-1

For the purpose of the following posts, I suggest doing the ‘install now’ option of the latest professional build. And if you want to buy it, go to your MSDN’s subscriptions and buy it, but currently it is ridiculously expensive.
vs-buy

 

If you don’t know how to install Visual Studio, than this is not for you. But next we can open up Visual Studio, and start our very first project, FINALLY! Are you excited?
Okay, when you open up VS, you can create a new project or open one. Choose New, and navigate to C# and choose Console Application, Name the project something stupid, such as “KatyIsKEWL”, even though I am kewl, it’s a stupid name.

vs-new

 

 

After choosing OK, VS will build your new project. After a couple seconds, you should get the following.
vs-new-t

 

This is the default layout of Visual Studio. The Solution Explorer is where all your files in you project can be found. The default ‘home’ file name is Program.cs; but you can change it to anything and it will still work fine.

In the file viewer, where Program.cs is open, you can see the default code generated by VS. It gave us the namespace of the project as well as the class name. Typically the class name should match the file name without the extension. As you notice, both the namespace and class have curly brackets. These brackets tell the compiler that everything in-between them belongs to this, whether it be classes, namespaces, or functions.
“static void Main(string[] args)” is our main function. This is where the program starts. If you would to run it at the moment, you would get a black box, as we haven’t told the computer to do anything. So lets modify the function.

static void Main(string[] args)
{
Console.WriteLine(“Katy is KEWL!”);
}

Now if you run this, you get a black window which writes whatever you put in the quotation marks.

vs-run

 

Thank you for reading this article, and stay tuned for part 2 of beginning programming from scratch!

 

Author

Katy Pillman

Katy Pillman is the Lead Programmer for Tactician Studios LLC. She is young, but experienced in the technical field, and writes in her free-time. △ ◎ × □

Related Articles

2 Comments

  1. Jay November 18, 2014 at 7:13 pm

    Using visual studio is not really programming from “scratch”.

    Look how many lines of code were auto-generated for you upon starting a new console C# project…

  2. Anastasios Barianos November 19, 2014 at 7:28 am

    Could you tell us some reasons why you prefer visual studio? I personaly don’t see any reason for somebody to pay for a tool like this, when you can get software like dev c++, netbeans etc for free. Even notepad++ or gedit could be good enough, so I’m just wondering what it is you get out of visual studio.

Leave a comment

Back to Top