Programming in Linux

It’s time to talk about programming. In Linux we can work with pretty much every programming language, so in the end of the day it is only matter of choice or specifics of task. To start with any of programming languages – all you need is text editor and interpreter/compiler, get one and you can do pretty much what ever you want.

This old-school guy is very useful for many purposes, especially when the talk comes to high performance. to start with it first thing to do is to check whether compiler is installed. In terminal simply type ‘g++’ and if something like ‘no input file’ appear – that means you already have. So let’s start with program.  In some text editor, create following program:

using namespace std;
int main()
cout << “Hello world” << endl;
return 0;

Save it, for example, with name ‘HelloCpp.cpp’. And in the command line compile like that: “g++ -o helloCpp helloCpp.cpp”, where parameter ‘-o’ specifies a name for output file. Here we go, to run the program simply type “./helloCpp” and that’s it.

Mostly used in production for many years programming language. Just as before ensure that you have development kit by following command “sudo apt-get install openjdk-7-jdk”. Now lets go to text editor and do same program:

class HelloJava {
public static void main(String[] args){
System.out.println(“Hallo world”);

To compile it use following “javac”, and then just run it “java HelloJava”.

This language along with Python suits very well for quick development. To start, firstly get interpreter and libraries by command “sudo apt-get install ruby-full”.  When it is installed just as with any other language create a file ‘helloRuby.rb’ and in that file simply put:

puts ‘Hello world!!!’

Since Ruby is scripting language – there is no need to have entry point for a program. After that simply type following command: “ruby helloRuby.rb”. More than that ruby has Interactive Ruby Shell, which can be called in command line ‘irb’, and it gives possibility to run ruby commands in real time without need to create source code file.

Octave is high-level interpreted language with specific purpose – mathematical computations. It perfectly suits for algorithm prototyping. It can be installed with simple command “sudo apt-get install octave”. Octave can be used only through interactive shell, however it doesn’t mean that no files can be used. Let’s create file “helloOctave.m” and in that file we will define following function:

function helloOctave(a, c)
x = (1:10)’
y = x.*a+c
plot(x, y);

Then, we just need to run Octave by command ‘octave’, and call the function “helloOctave(5,2)”

To try this one, simply either create file and run it “echo ‘print “Hello”‘ >” and then “python” or just call interactive shell by command “Python”.

###Have fun, and don’t forget – Chuck Norris is watching for you###

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>