![]() |
Chat on IRC |
Learning C
By Psion The C programming language may be the most widely used language in applications and server software today. You may have heard a lot about C++ and assumed that C++ is the "next version" of C that everyone uses now, but very little code for UNIX and its derivatives has strayed away from C, the language that was created to make UNIX possible. If you are at all interested in creating efficient programs or anything that interacts with "system-level" interfaces, then you should probably learn C. It also isn't too shabby as a language to learn to jump-start yourself into programming, though simpler languages like BASIC or Pascal may be preferable for those without too much prior experience. There are several places on the web where you can read C language tutorials. The following are some of the options. For those of you who have worked with BASIC or similar interpreted languages before, moving to C may seem a little strange. Interpreted languages require a special program, called an interpreter, to read in the code written in a specific human-readable language each time that it is to be run. The result is a pretty much unavoidable speed decrease, and a large one at that. Though any language can be either interpreted or compiled, BASIC tends to be interpreted. C is generally compiled, meaning that a series of software tools converts your code into machine code that can be run without the need for a special interpreter. This may seem daunted if you've only used BASIC before, but it is much more convenient to widely distribute your programs when end users don't need special software to run them. One common mistake that people new to C make is to think that the IDE, integrated development environment or code editor that features tools tailored towards the compiler, is the compiler. The compiler is generally a command line tool, just like dir for DOS or ls for UNIX. You don't need an IDE to use it, and indeed many people edit their code in simple text editors, as you don't need a fancy environment in which to both write and run your code; it is a full-fledged program once compiled and doesn't require the software you used to code it any more than Windows 98 requires QBasic to run. (Which is a bad example, because Windows isn't coded in BASIC, but I'm sure you get the idea. :-) ) The general process that you will use to develop a program using C works as follows. You create a number of .c source files describing your program. The C compiler than compiles these into object files which may have the extensions .o, .obj, or something else tool-dependent. These files have your code translated to machine language, something one step above machine language called assembly, or some other format close to that found in a real executable. The difference between object files and the end result is that the object files also contain information on the variables and functions in your program. If you don't know what these are, that's OK. All that matters is that a linker combines your object files, and perhaps some stored libraries of object files with code that you will often want to re-use found in .a or .lib files, and links them together into a final program. The information about the higher-level details of your source code that was preserved in the object files has been used to allow code from different source files to "communicate," accessing shared information and code. I'm sure at this point you're itching to get started. Chances are you may not have a compiler and the other tools needed to code in C, so here is a list of links to where you can download various free compilers.
| ||