Sei sulla pagina 1di 7

11/14/2019 noobtuts - Programming Languages Overview

Tutorials Articles Premium Books About

Programming Languages Overview


Foreword
Which programming language to choose? Whats the difference between
C and C++? What's the whole deal about functional programming? In
this article we will give an overview about the major programming
languages, provide a code sample for each one and talk about the
characteristics a bit.

The Overview
There are a lot of programming langues, but we will only cover the most
popluar ones here (based on the TIOBE Index):

Java
C
Objective-C
C++
C#
PHP
Visual Basic
Python
Ruby
Perl
JavaScript
Bash
Lisp
SQL
Delphi
Lua
Assembly

Object Oriented means that the language works with objects, like
Player(which has health and mana), Monster, World and so on. Object
oriented languages usually deal with Objects all the time, for example
when adding a Player to the World. Object Oriented languages are
usually easy to learn and understand.

https://noobtuts.com/articles/programming-languages-overview 1/7
11/14/2019 noobtuts - Programming Languages Overview

Functional languages are very close to pure Math. In functional


languages it's often easy to solve complex problems, but harder to do
simpler things. For example: pathfinding can be done with 10 lines of
code in a functional language, even though it takes about 1000 lines of
code in a Object Oriented one. Functional languages are hard to learn
and to understand, but they can be incredibly powerful.

Java
Java is a object oriented programming language. It runs about
everywhere, writing code can be very comfortable due to the Eclipse
IDE. The code is executed in a Virtual Machine and sometimes Java
programs can take a whole lot of RAM. Java is a good choice for a whole
lot of fields. While it's not always optimal, it's still often a solid choice.

Some typical Java code:


void test() {
Player p = new Player("SomeName");
p.moveTo(new Vector3(1.0f, 2.0f, 3.0f));
someFunction(p);
}

C
C is a very system near language, completely without objects. We can do
a whole lot of crazy things, like developing operating systems or
creating drivers for our hardware. Of course making games is possible
too. The language itself is loved for its simplicity, yet it can be hard to
learn and managing your our own memory or messing around with
Pointers easily leads to bugs in the code.

Some typical C code:


float vec2_length( const float v[2] )
{
return sqrt( ( v[0] * v[0] ) + ( v[1] * v[1] ) );
}

Objective-C
Objective C is similiar to C, but with Objects.

C++
C++ is like Objective-C, just with a whole lot of more features. There is
an endless discussion going on about if this is a good or a bad thing. If
you like simplicity, then this is a bad thing. Due to the language being so
incredibly complex, reading other peoples code is hard. Say that we
want to use someones physics library in our game. This task can be so
incredibly frustrating in C++, it can easily take a week of fixing linker
errors (even if you already know C++ for 6 years or so).

Some typical C++ code:

https://noobtuts.com/articles/programming-languages-overview 2/7
11/14/2019 noobtuts - Programming Languages Overview
void test()
{
std::vector<Player> playerList = new std::vector<Player>();
playerList.push_back(new Player("SomeName"));
playerList.at(0).moveTo(new Vector3(1.0f, 2.0f, 3.0f));
Player* ptr = &playerList.at(0);
ptr->moveTo(new Vector3(2.0f, 3.0f, 4.0f));
}

C
C# is pre y much Java reinvented by Microsoft. There are a few li le
differences, but the syntax is almost exactly the same. C# uses the .NET
framework a lot, which is a big library of functions developed by
Microsoft. If you are a fan of Microsoft, then this might be a good
language for you.

Some typical C# code:


void test()
{
Player p = new Player("SomeName");
p.runTowards(new Vector3(1.0f, 2.0f, 3.0f));
someFunction(p);
}

PHP
PHP is mostly used for web servers. If we open a website in our
browser, it's very likely that the site was created by some PHP code
running on the webserver. PHP can come in handy when making
browser games, but for the common singleplayer 3D game it's not very
suitable.

Some typical PHP code:


$s = 'someText';
if(function_exists('someFunction'))
{
$something = true;
}

Visual Basic
VB is a event driven programming language developed by Microsoft.
VB had its peak a few decades ago in a lot of Windows programs.
Microsoft has stopped supporting it in 2008, hence why the language is
slowly dying.

Some typical VB code:


Private Sub Form_Load()
' Hello World MessageBox test
MsgBox "Hello, World!"End Sub

Python

https://noobtuts.com/articles/programming-languages-overview 3/7
11/14/2019 noobtuts - Programming Languages Overview

A lot of programmers fell in love with the Python language. It's a rapid
development language, which means that it saves us a lot of time when
developing programs. It works well with functional programming
styles, but object orientation can be used as well. One of the major
characteristics of the language is the importance of intendention to
organise blocks of code. Python is a general purpose language, and it's
definitely worth a look no ma er what you want to develope. Note that
according to the developers a program in Python can take up to 15x less
code than in other languages like Java.

Some typical Python code:


def fac(n):
if n <= 1:
return 1
return n * fac(n - 1)

Ruby
Ruby is not used very often to make games. It's basically a object
oriented scripting language.

Some typical Ruby code:


do
puts "Hello World"
end

Perl
Perl is yet another scripting language which is often used when it comes
to working with text.

Some typical Perl code:


sub logger {
my $logmessage = shift;
open my $logfile, ">>", "my.log" or die "Could not open my.log:
print $logfile $logmessage;
}

JavaScript
As the name says, JavaScript is a scripting language as well. It's mostly
used on websites and it's very easy to learn. The language is hated by a
lot of people due to its slowness and security vulnerabilities, and
because it's used to display advertisements often.

Some typical JavaScript code:


function message()
{
try
{
adddlert("Test");
}
catch(err)

https://noobtuts.com/articles/programming-languages-overview 4/7
11/14/2019 noobtuts - Programming Languages Overview
{
alert("There was an error");
}
}

Bash
Bash is a language to process commands on Unix systems. It's not very
interesting when it comes to making games.

Some typical Bash code:


declare -A x
i=3; j=1
x[$i,$j]=13
echo ${x[$i,$j]}

Lisp
Lisp is a functional language that was and is used for a long time
(created in 1958). The language is all about paranthesis and math. It's
hard to learn, but LISP experts tend to say that it's the most powerful of
all the languages.

Some typical Lisp code:


(if (= 1 2 2)
(list 1 2 "test")
(list 3 4 "abc"))

SQL
SQL is the language of choice when it comes to working with databases.
When making a multiplayer game, chances are high that we need to
know SQL in order to store the players account data in some database.
SQL is easy to learn, but the language itself makes not too much sense at
some points. Its design got messed up over the years. Often there are
two words for the exact same thing (which increases complexity), and
sometimes a word means something completely different when used
with another query.

Some typical SQL code:


SELECT * FROM accounts WHERE username = 'SomeName';

Delphi
Delphi is a very solid object oriented language. It's very easy to learn as
a first language, and creating graphical user interfaces is very easy. The
syntax is really easy to understand, yet it's a ma er of taste. The
downside is that it's a proprietary language. It's a solid choice to learn
how to make games.

Some typical Delphi code:


procedure TForm1.Button1Click(Sender: TObject);
begin
https://noobtuts.com/articles/programming-languages-overview 5/7
11/14/2019 noobtuts - Programming Languages Overview
Label1.Caption := 'Test';
end;

Lua
Lua is yet another scripting language. It's often the number one choice
when it comes to scripting in games (for example to develope some
monsters behaviour). It's really lightweight and often a good choice.

Some typical Lua code:


local start,finish,delta = 10,1,-1
for index = start,finish,delta do
print(index)
end

Assembly
Assembly is raw machine code. This is what our computer reads when
he executes a program. Other languages are always a layer of
abstraction to make things easier for us humans, but in the end they are
almost always translated to Assembly, so the machines can understand
the code.

Some typical Assembly code:


mov eax, edx
add eax, 3
push eax

Which one to choose?


There is no perfect programming language. Which one to choose always
depends on the circumstances. It's probably impossible to create a driver
in JavaScript, but it also wouldn't make much sense to use Assembly on
websites (hence where JavaScript is be er for).

Time is always an important aspect. Making a simple tower defense


game in Assembly could easily take a whole year (including a lot of
headaches). Making the same game in Java could be possible in a month
or two. The difference is immense! Just think about it: instead of making
one game per year, it's possible to make six games per year by simply
choosing a different programming language.

In the end, games are about fun. If you found a language that you enjoy,
then just use it! Having fun will decrease the chance of giving up along
the way.

If you came here to find an easy language and you don't want to try all
of them then take a look at: Java, Delphi, C#, Python and just for the
experience one of the system near languages like C++ and one of the
functional languages like Lisp.

https://noobtuts.com/articles/programming-languages-overview 6/7
11/14/2019 noobtuts - Programming Languages Overview

© 2012-2019 noobtuts.com

https://noobtuts.com/articles/programming-languages-overview 7/7

Potrebbero piacerti anche