How to start programming in Linux

Programming in linux is a vast topic – I have to say that Linux platform is made of different parts; some that control hardware and make it work, some for compatibility of the applications and hardware between each other, some for user interface etc… But that is exactly what Windows and Mac OSX do… Why should we switch to Linux? Well, because Linux has it’s own and unique way of doing all those things in it’s own way that just fits some people perfectly. I will assume you are running Linux on your system right now, no matter if it’s USB boot or Live CD or installed besides Windows… Here are some terminal basics.

When you want help while programming on Linux, there are really just two ways to go: Either on forums (there are many Linux forums out there, just search for what you need) or IRC (Internet Relay Chat) – system with chat rooms so you are able to chat with people through your browser. Now, when you know how to get help, it’s time to pop up a terminal window. Press Ctrl + Alt + T or just search for it in your programs. When the terminal window pops up, that’s where all the magic happens. You can run any program just by typing it’s name for example chromium. If you want to open a browser at a certain website you can put chromium google.com or a text document gedit my_text.txt.

When it comes to installing software, in the beginning linux might seem a bit confusing to you – Most of the job is done with the terminal. If you have a repository that contains your file, just type in sudo apt-get install NAMEOFAPP. I’ll mention here just a few directory commands and then we’ll jump to other fun stuff. To manipulate between directories, there are a few commands; cd – for opening up a certain folder (ex. cd Downloads), ls – lists all directories and files in a current directory, mkdir makes a directory, rm removes a file, cp copies a file and there are many many more… This may be vulnerable because there are some directories / files you just don’t want to mess around with. Be careful and seek for help in the beginning.

We’ll have to see what languages are the most popular for their respective usage on Linux operating system. I’ll present a few of them…

1) C/C++

Probably languages that are most popular and most spread around on the internet regarding the tutorials, learning, “playing” with different functions to get something you want from them etc. What you can do with C/C++ is that you can create processes, set their priorities, set what do you want the processor to do at certain times etc.

First, you should start with downloading a compiler and that is done with these commands:

sudo apt-get update
sudo apt-get install gcc

 

Next, you’ll need a text editor, you can choose any text editor you like, I prefer gedit. Type in the code and compile it with simple gcc name_of_file.c or gcc name_of_file.cpp

C++ dominates in a few aspects and those are High performance computing and developing AAA games.

 

2) Perl

One of the most popular scripting language out there. It came installed on UNIX/Linux systems by default because of it’s usage and compatibility with these systems. According to wikipedia, it’s used by more than 11000 authors in more than 140000 modules. Although it is a old languages, and new languages have come to replace it (PHP, Python, Ruby), we shouldn’t throw Perl away because it won’t go away any time soon.

3) Java

It was always thought that Linux is just a natural habitat for Java, because of it’s wide usage in many problems in computing and programming, starting from server side apps to well designed applications that are very portable. I’ll just use one example; many of you have probably heard of the game Minecraft. Little do you know, it’s built entirely in Java. Also, Java is powering many Internet gaming service, so it’s just a one plus language to learn for it’s incredible usage in industry today. Also when we talk about Java, don’t mix it with Javascript – a front end developing language that has become very popular in the last couple of months.

Besides these popular languages used for programming in Linux, there is also one incredible thing you’ll need to try and master and that is – shell programming.

In shell, you can write some scripts that may be very useful for you. I’ll show you some basics, but first, there are a few requirements:

1) The file must have a special first line that names an appropriate command processor ( shebang ) . For example: !/bin/bash

2) The file must be made executable by changing its permission bits. Example:

chmod +x (script filename)

3) Your shell script has a special extension .sh. You can execute your shell script like this:

./scriptname.sh

 

Open your favorite editor and type:

#!/bin/bash
echo "Hello, world."

 

Save it and execute it as I wrote before. It should write out on the screen the message: “Hello, world”.

You can find a lot of tutorials on shell scripting on the internet, this post isn’t about that, but I just wanted to introduce all of you to some of the fun things you could do in Linux. Everything is in your hands, it’s your choice how much do you want to learn. For some this post may be how to install your first compiler, why would you choose Linux, for some about bash or just choosing a language, for some terminal stuff and a lot of things you just can’t do on Windows (creating job hierarchy – only available from win 8.1 and that is not really what it is).

If you really want to start programming in linux, I suggest to learn C. Probably the best language to play around with different processes and API’s, easy readable code, and just some amazing results. Probably the closest you’ll get to assembler when it comes to Linux.  

Leave a Reply

Your email address will not be published. Required fields are marked *