Fast Basics in Programming --------------------------------------- >> Types of languages ------------------------------------------------ Hello. Just before you start programming, here are some important things you should know: There are 3 types of programming languages: compilable, interpreted and Assembly. The computer's CPU (central processing unit) executes machine instructions (machine code). Assembly is pretty much the raw instructions, in readable text instead of binary format. Assembly (ASM) is therefore quite hard to master because of how low-level and cryptic it is. An assembler translates the text program into binary machine code, usually adding the needed executable header so that the executable is valid for the OS. Otherwise it's called a "flat binary" and the OS won't run it, although it's correct from the CPU's standpoint. Accomplishing complex tasks is very difficult in ASM because of its low-levelness. Keywords: assembler, translates, text, binary Enter the compilable language! For example C. It is much easier to use than ASM because there's a lot of abstraction and the nasty stuff are done for you. When you compile the C source program, it gets translated into "object code", which is part of the final executable. Because you will use pre-fabricated stuff in your C program, the resulted object code must be completed with those pre-fabricated "libraries" - which is what the linker does, by "linking" your code. It also adds the needed file headers so your executable is valid for the operating system. Most compilers run the linker automatically for you. But you can change that if needed. Keywords: source, compiler, object code, library, linker, executable Interpreted languages don't have to be translated into another form in order to work; more specifically, into machine code. Shell scripts, makefiles, web sites, XML, JavaScript, Python, are all interpreted languages. It is the "interpreter" program which does the work, not the OS or CPU directly. For shell scripts, the interpreter is BASH, for makefiles it's Make, for web sites it is your chosen web browser, and so on. Keywords: interpreted >> Makefiles ------------------------------------------------ Since we got that sorted, there is a difference between how programmers usually work in Linux versus Win. You still have IDEs (Integrated Desktop Environments) here, where you'll create a project and add files visually then hit a "Build" button and so on. Then again, many people like to use the command line. For to automate the process, you will use the "make" utility. When you run it in the current folder, it will search for a file named "Makefile" - name is case sensitive, but can be "makefile" too, as said in the manpage. Otherwise you can manually specify the file with the -f switch. (Example: `make -f mymakefile.fl') The Makefile contains the actual commands so that you don't have to write them yourself every time. The commands are put in sections: for example "all:" or "arandomlabelname:". Here's a sample Makefile (note the compulsory Tabs; and the arrows are not part of it): <-----------------------------------------------> all: gcc somethingtasty.c -o somethingtasty.elf32 -m32 && ./somethingtasty.elf32 gcc somethingtasty.c -o somethingtasty.elf64 -m64 # this is a comment line; # the "clean" section below removes our 32-bit executable, # while "status" prints info about the freshly compiled stuff. # by the way, you can use any label names you want, even "Candlejack" and nothing bad wi status: file somethingtasty.elf32 file somethingtasty.elf64 clean: # remove that tasty file! ;) rm somethingtasty.elf32 <-----------------------------------------------> First label, whatever the name, is always executed if a label is not specified. Otherwise we would run `make clean'. As you can see, in this form (makefiles can get more intricate) the makefile consists of basic shell commands. More commands can be aded to a section. Chaining them with && and || is also possible, but inelegant. In the above example, the "all:" label compiles for 32 bits and then runs your program, then compiles a 64-bit version. Also, pressing Tab before specifying the label will signal "make" to help you with autocompletion. ;) For a BASH beginner's tutorial, start the Konsole and type `intro' or see Section 3. -RF