Krista's Coding Corner


First touch to programming 1 (Hello World)

If you are reading this, I guess you wish to learn how to program. To do the actual code, you first need to decide which language you’re going to use. World is full of opinions on what is the best starting language. In my opinion, language is not so important, as when you learn more, you’ll see that most of the languages are almost like identical copies except on how the code looks like.

I’ll use mostly Python in my examples as it is an easy language that is quite similar to natural languages, it has fairly informative error-messages and to me it seems to have quite little of any irregularities. Python also runs on any operating system without a lot of hassle (okay, if you have something really weird going on there, I really won’t guarantee anything :P).

For starters you need an editor to write your code. There is a lot of choice for these ones. The simplest one is Notepad but I hardly recommend using it (I have use it in some situations and if you are not the most pedantic person with incredible perception, just forget this one, it is just waste of time). Best choice is to use an editor that has been created for the language you are using because they make the code more readable and so on. Try using Google :) I use Geany as it works for most of the languages but it has no extra abilities like having compiler in it.

Let’s start like everyone else, we create Hello World. This is a classic that is always the first thing to create with any new programming language as it is so simple. Any language you use, you will definitely find Hello World example on the Internet. It is an example where we “print” text to somewhere BUT it has absolutely nothing to do with your printer. Term print is just some ancient relic from the era of room sized computers. Mostly term print means that you will show the text somewhere in the screen.

With Python, write this to your editor (note that this is not a tutorial for using Python or any other language, so use this text along some tutorial to better understand what you are doing!).

print “Hello World!”

And then save you file as Python file (.py). Please, read my text of executing programs to know more about how to make this runnable. Then run your program. Your computer will show (== print) Hello World -text on your screen (in Windows it just flashes on the screen!).

If you're using *nix system (for example some Linux like Ubuntu), you might want to add #!/usr/bin/env python as the first line of the code. See more about that line in wikipedia.

blog comments powered by Disqus