User login

Programming

No public posts in this group. You must register or login and become a subscriber in order to post messages, and view any private posts.
Tags:

Computer Programming is the act of creating Software (or a set of instructions which will be processed on a piece of Hardware). Literally, one is providing an ordered list of commands which tell the computer what to do.  

There are a number of different levels to a computer which may be interacted with.  The underlying hardware has a certain set of functions it will perform, and methods for interacting with it.  

The very base programs provide a friendlier way to interface with the hardware functions, and one by one, layers of software begin to build on the lower levels.  Each layer provides an interface to deal with functions of lower levels.  A 'Programming Language' is a set of syntax and rules which provide a means of translating what the human wants the computer to do into something the lower levels can understand, all the way down to the hardware, where it's actually executed.   

Types of Programming Languages

Programming languages come in a variety of flavors and styles, each suited to a particular task, and each operating at a certain level.  

So-called 'Low Level Languages' are refered to as such because they are close to the hardware.  Low level languages provide very literal, specific instructions, and tend to be structured much more in the way that computers operate.  Low level languages come much closer to 'speaking the computer's own language' than human languages do.  They tend to be very fast, providing the programmer with very explicit control of what the computer is doing, yet are often harder to learn and work with.  

Conversely, 'High Level Languages' are designed to be much friendlier to human language, and provide a layer of abstraction to cover the more base functions--thus, the programmer can think more in terms of what he/she is trying to accomplish, and worry less about the mechanics and specifics of how the underlying levels deal with reality.  High level languages make it easier to program by letting the programmer tell the computer more of what he/she wants to do, rather than explicitly telling the computer how to do it.  

The most very basic 'language' is sometimes referred to as machine code--these are the binary (ones and zeroes) inputs which filter right through the logic gates of the processor, making the magic happen.  In essence, machine language is the computer's own native language--very foreign to most humans.   

The next step up the food chain would be Assembly Language (ASM).  Assembly is basically just providing a set of symbols to refer to the individual commands (or words, if you prefer) which make up the machine language.  It's important to understand that, like a machine language, each type of processor in existance speaks its own particular dialect of assembly.  In other words, each processor (architecture) has its own specific Assembly Language.  A special program called an 'Assembler' translates the ASM codes into the ones and zeroes the processor it was designed for is expecting. 

On to the higher levels of languages....

As stated earlier, low level languages are very dry, explicit, and literal, as well as specific to the platform they were made for, so they are very different from the abstract and complex thoughts humans use every day.  

High Level Languages provide an intermediary, to free the programmer from having to translate their ideas directly into Computerese.  High level languages also have the benefit of Portability--that is, a program can be written in a high level language, and then that can be translated into different types of machine code for different processors to run.  

Compiled code--A program written in a high level language begins life as a plain old text file (called source code), where the programmer writes out (in the Syntax of the language being used) all the instructions to be performed, and the order to do them in.  The computer can't understand all of these higher level languages because all it speaks is its machine code.  Enter compilers:  a compiler will take the source code and translate it down into the lower level languages so the computer can understand.  Thus, a compiler is written once for each platform, and can then take all the higher level source code and translate it for its computer.  (Side Note:  In practice, this doesn't always work due to differing implementations of compilers and the libraries they make use of, but the theory holds true--if everybody's following the same standard, you can take a high level piece of source code and compile it on any platform.)  

Interpreted code--Compiled code runs very fast, but it must be compiled before it will run at all.  Interpreted code works basically the same way, but the translation process happens on the fly, rather than in advance.  This means it doesn't run quite as fast because every line must be translated in order to be run, but it also means that it does not have to be compiled in advance--it's all on the fly.  

The Real World

Everything I've told you here, so far, is sort of a glossed over version of what happens, but (hopefully) it gets the concepts across.  In the real world, languages don't always fall neatly into one category or the other.  For instance Java is somewhere in between being Compiled and Interpreted.  Java source code is turned into something called byte-code (which is kind of an intermediate step)--it will not run natively on a system, but must instead be processed in a special program called a Virtual Machine, which finishes the translation process.  Like a compiler, the Virtual Machine must be written specifically for the platform it will be running on.  

Some Programming Languages

C - A medium (I say that because it is fairly machine independent and has high level functions, but you can still get down and dirty with the machine at a pretty low level) level language.  C is very fast, powerful and flexible, as well as being widely supported on a variety of systems. 

C++  - Based on C, C++ adds Object Oriented capabilities. 

C# - Created by Microsoft (though, now it has been approved by ECMA and ISO as a standard), C# is based on C++, but with influence by certain other languages (like Java).  

BASIC - Beginner's All-purpose Symbolic Instruction Code - BASIC was developed as an easy to learn language.  

COBOL - COmmon Business Oriented Langage - COBOL (quickly becoming defunct) tends to be used much more on heavy metal (read: mainframe) business systems and the like.  

FORTRAN - FORmula TRANslator - Mostly used in scientific endeavors.  

Java - Based largely on C/C++ and created by Sun Microsystems, Java is an attempt to create a write once-run anywhere type of system.  What this means is Java programs don't run by themselves--there is a special program (similar to a an interpreter or comiler) called the Java Virtual Machine written for each particular operating system.  If you've got the Java VM environment running on your computer, you can run Java.  Java is frequently used on web pages in small, embedded formats known as 'Applets' (like tiny Applicatons).  

JavaScript (not to be confused with Java) - JavaScript isn't even related to Java--it's a 'Scripting Language' (or a special kind of interpreted language with uses scripts (text files with the instructions, like source code) and then interprets each line of the program as it runs--slower to run than compiled code, but easier to update/change).  

Visual Basic - Again, created by Microsoft, and based on BASIC, VB adds powerful new features, a set of ready made tools to use in your programs (like buttons, text boxes, timers, etc.), and a visual environment to design the layout of your program.  VB only works on Windows.  

VBSript - Microsofts scripting language which inherits its name from Visual Basic

Gambas - Gambas Almost Means BASIC - Not a clone, exactly, but definitely similar to Visual Basic, Gambas provides the same kind of visual environment for creating programs in Linux.  

Lisp - LISt Processor - Lisp is a family of languages, and kind of an odd one at that.  Lisp has a lot of interesting features which make it very open-ended.  Lisp source code can be altered by Lisp programs, making it a popular choice for Artifical Intelligence programs.  

Ada - Similar in capabilities ot C and C++, Ada tends to be more strict, with extremely high reliability.  Ada is frequently used in important, mission critial/life critical type roles.  

SQL - Sequential (or Standard) Query Langugage - Not really so much a programming language as a special language for talking with Databases. 

Batch - Script files for the older MS-DOS operating system, Batch files are very limited in their capabilities.  

Shell Script - Similar to Batch, but exponentially more powerful, Shell Scripts are the scripting languages for Unix/Linux Shells (the Shell is the Command Line interface).  

Programming Concepts and Paradigms

So, as you've seen, the term 'Programming Language' covers a pretty broad range of subject matter, and it's true, that many of the tools, styles and methods used differ depending on the tools being used and the platform(s) being designed for, but there are many basic concepts which carry over between most or all programming languages.   

 

Variables and Constants

A variable is simply a container for a particular value.  To use a variable, you declare it (give it a name, and specify what type of data will go there (i.e. an integer, a decimal, a character, etc.)), and then it can hold its info happily until you ask what it's holding.  The reason it's called a variable is because you can change what it's holding--i.e. it varies.  

A constant is simply a variable which doesn't change (hence, it's constant).  

Arrays

An array is also a really useful idea--an array is just a group variable--a variable with more than one slot for holding data.  It works like this 'ArrayName[x]' where 'x' is the index number of whichever slot you're looking in.  Easy, huh?   

Conditional Branch Statements 

Computer programs would really be all that useful if they couldn't make decisions--nothing would be interactive.  Conditional Statements allow the program to branch out and execute different instructions for different circumstances.  The most common way to do this is the If...Then statement.  It works like this.....

 

If Condition = True Then

Execute This Code Right Here

Else If Condition2 = True

Do This Instead 

Else

Do This Instead 

End If  

Loops

Another extremely powerful and useful feature that programmers have available to them is what's known as a loop.  Basically a loop is just what it sounds like--there's a certain block of code that get's run again and again as long as a certain condition is either true or false.  It's a way to automate repetitive tasks without writing the same code again and again.  There are a few kinds loops, and the most basic is probably the While loop.  It works like this.....

 

While ConditionX = True

Do All The Code

Right In This Area

And Then Loop

 

Each time the loop gets ready to go, it'll check to see if the condition is true or not, that way it knows when to quit.  Be careful, though--if there's ever a situation where the condition will never be false, the computer won't realize--it'll just keep looping and looping.  This is what's known as an 'Infinite Loop'.  

Functions, Methods and Subroutines

Depending on what language you're using, these terms might mean the same or different things, but they're basically all doing a similar thing.  

The bottom line is that they break the program up into logical chunks which each perform some sort of task.  This is important for three reasons--it makes it easier to read the source code,  easier to focus on making each function do its own job really well, and also provides the possibility for re-using some of your code--if you make a really good function for drawing a circle on the screen, you'll be able to use that same code in any program you write that'll need to draw a circle.   

admin