It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

Programming Lessons: Getting Started

page: 1
0

log in

join
share:

posted on Sep, 3 2008 @ 04:01 PM
link   
Getting Started -- Before the Basics
Okay, even before the "before the basics" here, I want to throw out a disclaimer. I program for a living, I've studied it for a while, and I did a bit of college work with it. I like to think I know what I'm talking about, but sadly enough I'm only human. I make mistakes, typos, grammatical errors, so on and so forth. I might even tell you something that's blatantly wrong -- or not so blatantly. I still make mistakes pretty regularly, but I think the day I'm perfect is the day I'm probably not writing code for a living


Think of this as a really big "caveat emptor" sign before progressing; I'll do my best to take care of you here, but you're proceeding at you're own risk. I take no responsibility for damage to computers, monitors, walls, the cost of removing shards of LCD screen from your knuckles when it just ain't going right, etc.

Capiche? Great, let's continue.

To start with, you'll need a "build environment." We're going to stay with the cheap and easy route here, and get Microsoft's Visual C# Express Edition. It's free, and fairly simple to use. If you have an older computer, it might be a stretch to use, but hopefully you can work it out. You can get the 2008 Express Edition at www.microsoft.com... For what it's worth, I'll be using Visual Studio Standard 2005; as far as I'm aware, everything I'll be doing in that for these lessons, you'll be able to do with 2008. If you dig around on the MSDN site a bit, you might be able to find the 2005 Express Edition -- should be a little easier on older computers. Let me know if you have any problems with that.

I'm afraid I can't help too much with the installation of the software. Just be aware that it's a fairly large download, but if you're seriously interested in getting started with programming (not even just for these articles, but in general) it's worth it -- it's a lot easier (in my opinion) than a lot of tools out there that are easier on the bandwidth.

Once you've got it downloaded and installed (or, while you're waiting for it), I want to introduce you to a few key terms I'll throw around a lot: the first three are "source"/"source code", "project" and "solution". "Source" is, basically, your program. When we get started, we'll be writing source code. The source code is the set of instructions you give the computer -- what to do, when to do it, and how to do it. You write these as plain text files, feed them into a program, and the program spits out your program for you to play with.

A "project" is essentially a collection of source files. There's other stuff thrown into it also -- libraries, resources, and other things you don't need to worry about. For now, just consider a project to be a bunch of text files.

A "solution" is the next level up -- it's a collection of projects. For most of this, we'll just be dealing with a single project, so there's no need to really worry about it. I just wanted to make sure you're aware of it.

There's two other important terms we need to go over, and that's "compiling" and "building". I'll use these terms pretty much interchangeably, though when you get into hardcore programming they really have two different meanings. For our purposes though, they both mean the same thing -- it's the act of taking your source code and turning it into something the computer can execute. In other languages, like C/C++, the difference is a much bigger deal; for us, it's almost irrelevant at this point in time. So if I say something like "Go ahead and build," and then, two paragraphs later, I say "Now compile your project," I'm saying the same thing -- if I ever stray from that, I'll let you know. You may also want to know the term "compiler", which is the program that "compiles" your source code into an executable program. As an added trivia detail, we're using Microsoft's C# compiler for our purposes. Anyways...

Hello ATS
If you've ever tried to learn how to program before, you know that every. single. programming. tutorial starts off with the ubiquitous "Hello world" example. Why break such a well-loved tradition, eh?

Create a new project by going to the File Menu and selecting "New Project..." (you can also do it by pressing Ctrl+Shift+N). Select "Console Application" from the templates list, and give it a name -- "Hello World" or "Hey there" or "I hate moldy cheese", what ever you like.

Now, I wish I could post what you should see, but the formatting isn't handling it quite right and it looks pretty crummy. However, for right now, you can ignore most of it -- just look for one part:

static void Main(string[] args) [
]

Just as an FYI, this is called a "method", and it's something that I'll go into more detail on later. Specifically, this is the "main" method, where everything that your program is going to do is put. For now, though, just think of this as your program -- everything between the '[' and ']'. Well, the "nothing" between them for now, but that's what we're going to change.... Put your cursor after the '[', hit the "Enter" key to move to the next line, and type (or Copy/Paste; I won't tell anyone) the following:

Console.WriteLine("Hello ATS!");

Now for the fun part -- compile and run it. In Visual Studio, you can do this with one button press -- the F5 key. Push that, and watch your new creation.

Note: Odds are you had a console window popup and disappear really fast. If that happened, add the following line after what you just wrote:

Console.ReadLine();

You'll be able to read the window now when it pops up; just hit the "Enter" key when you're done admiring your work.

Okay, this should be good for a start. Trust me, there's lots more to come, but you're already one-up on a lot of people when it comes to coding. Next time we'll cover variables, math, and some basic logic, and that's when you start getting something that's a bit more like a useful program, instead of something that looks like an overkill for a notepad (yes, I have tried to leave people messages using programs like this, thank you very much
).




posted on Sep, 10 2008 @ 08:56 AM
link   
You have forgotten the most important thing for the program, you didnt mention the consoles and namespaces I meant the Using System global namespace and the user defined namespace.



posted on Sep, 10 2008 @ 10:01 AM
link   
Those weren't forgotten; they were purposefully ignored
I'm trying to focus on general details of programming right now, and while namespaces are definitely important, they're not very useful at the moment, while we're just dealing with the basics.

Later on they'll come be much handier, when we start dealing with classes and stuff like that.



new topics
 
0

log in

join