|[Home] [Credit Search] [Category Browser] [Staff Roll Call]||The LINUX.COM Article Archive|
|Originally Published: Monday, 30 July 2001||Author: Matt Michie|
|Published to: develop_articles/Development Articles||Page: 1/3 - [Printable]|
Introduction to Programming on Linux
Linux.com editor Matt Michie takes a look at the first choices you need to make when contemplating learning to program on your Linux system.
|Page 1 of 3 >>|
Thus spake the master programmer:
IntroductionAfter using Linux for some time, it becomes irresistible for many to become a more active participant in the open source world. The daily chores of a Linux user are solved by the plethora of free software. It is also not uncommon for a "regular" user to download a tarball of C code, modify the makefile and compile the code into a usable binary.
This familiarity with using the tools of development fosters even more development thoughts. The intention of this article is to give a brief overview on how to get started down the path of a Linux hacker.
Once one has made the decision to become a developer, it is easy to be put off by the number of choices to make. Which editor to use? Which language to learn? Object oriented, procedural, or functional?
ParadigmsThis brings us to the first fork in the road. Which style of programming should a beginner take up first? Some of the choices are functional, procedural, and object oriented. To become a good programmer, the beginner should eventually at least expose themselves to one language from each paradigm.
The comp.lang.functional FAQ defines functional languages as, "a style of programming that emphasizes the evaluation of expressions, rather than execution of commands. The expressions in these language are formed by using functions to combine basic values. A functional language is a language that supports and encourages programming in a functional style."
Some common functional languages available on Linux are: ML, Haskell, and Scheme.
Procedural languages are a style of programming that breaks up tasks into "procedures". Think of a flowchart and you'll get a good feeling of how a typical procedural program is put together.
Common procedural languages are: Pascal and C
Object oriented languages are built around the idea that code should be represented as objects. For instance, a programmer wishing to write a highway simulation would start out by defining a vehicle class, which would contain code essential to all vehicles. Later, the programmer can "inherit" code from this vehicle class to a truck object for instance.
Common object oriented languages on Linux are: C++, Java, Python, Smalltalk and Eiffel.
There are also hybrid languages in which you can program using multiple paradigms that include PHP and Perl.
Even though you want to expose yourself to each paradigm eventually, this can seem like an overwhelming chore. First define a project that you want to complete. You probably have encountered something that you wish you could automate, or make simpler under Linux. Once you have a clear goal, the choice of languages becomes simple. The problem domain that you choose should show you which language makes solving it easier. Learn this language first.
For instance, when I wanted to learn more about databases and web programming, I decided to make a books database containing the books I owned and those I wished to purchase. The languages that were well suited for solving this problem happened to be PHP and MySQL. After a bit of experimentation I was able to complete the database and put it onto the web: http://daimyo.org/books.
My own personal experience has led me to focus on at least four languages: C, PHP, SQL, and Perl. C is almost a pre-requisite for any other programming language. It has become so pervasive that any other language designed after C is likely to incorporate some of C's syntax. Therefore if you learn C early on you will have an easier time learning other languages.
The down side to learning C is that it is barely considered a "high-level" language. This makes it good for writing kernels and drivers, but not always the easiest for writing more advanced programs. However, there are so many good libraries and tools for developing C in Linux, so you can't go wrong learning it.
PHP, or PHP: Hyper-text Processor is an interpreted language that typically runs on web servers, giving HTML a scripting component. Once you know C, learning PHP can be done in a day. PHP gives you the flexibility to do web programming well.
SQL or Standard Query Language is the defacto database language. This goes hand in hand with learning PHP, since many of the applications one uses PHP for are connecting database components to the web. SQL was designed to be used by business people and therefore has a lot of syntactical sugar and English-style grammar. If you can pick up PHP and C, SQL is a snap.
Perl rounds out my language toolbox. Originally designed by Larry Wall, Perl has become a "glue" language, borrowing much of its syntax from C, and Unix shell tools. Perl makes it easy to manipulate text, and glue together disparate programs into a whole. While Perl's regular expressions will seem complicated at first, Perl regular expression syntax is fast becoming standard in other programs that have RE libraries. You'll be able to carry over your knowledge gained here to other languages down the road. Perl also has plenty of add-on modules available in its CPAN archive, which make coding easy.
|Page 1 of 3 >>|