Monday, December 04, 2006

Examples of programming languages

Here is a list non-exhaustive of programming languages :

Assembler

An assembler is a program that takes basic computer instructions and converts them into a pattern of bits that the computer's processor can use to perform its basic operations.
In the earliest computers, programmers actually wrote programs in machine code, but assembler languages or instruction sets were soon developed to speed up programming. Today, assembler programming is used only where very efficient control over processor operations is needed. It requires knowledge of a particular computer's instruction set, however. Historically, most programs have been written in "higher-level" languages such as
C. These languages are easier to learn and faster to write programs with than assembler language.


C

C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C. With the increasing popularity of object-oriented programming, C is being rapidly replaced as "the" programming language by C++, a superset of the C language that uses an entirely different set of programming concepts.


C++

C++ is an object-oriented programming language that is now generally viewed as the best language for creating large-scale application programs. C++ is a superset of the C language.


HTML (Hypertext Markup Language)

HTML is the set of "markup" symbols or codes inserted in a file intended for display on a World Wide Web browser. The markup tells the Web browser how to display a Web page's words and images for the user.
HTML is defined in practice both by Netscape and Microsoft as they add changes to their Web browsers and more officially for the industry by the World Wide Web Consortium (W3C). A new version of HTML called HTML 4 has recently been officially recommended by W3C, making this level an effective standard.


JavaScript

JavaScript is an interpreted programming or script language from Netscape. In general, script languages are easier and faster to code in than the more structured and compiled languages such as C and C++ and are ideal for programs of limited capability or that can reuse and tie together existing compiled programs.
JavaScript is used in Web site development to do such things as:
Automatically change a formatted date on a Web page
Cause a linked-to page to appear in a popup window
Cause text or a graphic image to change during a mouse rollover
JavaScript uses some of the same ideas found in Java, the compiled object-oriented language derived from C++. JavaScript code can be imbedded in
HTML pages and interpreted by the Web browser (or client).

Types of programming errors

Programs often contain errors which may cause the program not to run or, even worse, to run but yield incorrect results. Much of the task of programming is to locate and correct these errors to produce a program that runs correctly.

There are two main classes of errors : syntax (or grammatical) errors and semantic (or logical) errors :

Syntax errors

This first class of errors that can be made are relatively easy to detect, in the first case by a human and in the second case by a compiler at compile-time. It's just like a grammar error in a language. For example in English : "I is hungry" instead of "I am hungry".

Semantic errors

This second class of errors that can be made are much harder to detect for humans and in general impossible for the compiler to pick up (obviously the computer does not know what the programmer intended). If we keep the example of the English language, it's like if you tell somebody : "Let's meet tomorrow at 8am" but you meant 8pm.

Programming style


Programming style is a term used to describe the effort a programmer should take to make his or her code easy to read and easy to understand. No two programmers write the code identically, so the way to name variables, to structure the logic, or to organize the code has to follow a certain logic.
Here are styles and conventions to help any reader to understand what the program does and why.

Minimize the number of lines of Code.
Minimize the number of variables - localize as much as possible.
Minimize the number of routines - localize as much as possible.
Modules are free standing and have a specific objective. Just keep everything simple. The fewer of anything you have in your code, the easier it is to reuse, maintain, and enhance.

Give your variables, functions, and types self-explanatory names easy to understand for everybody (including you). Make sure it's not the same as a program command. Calling them i and j is short, and easy to type, but hard to debug.

Indent your code to make it legible. It will help you to see the blocks of the program easily. You can use whatever spacing looks good to you, but indent at least 2 spaces.

Comment your code liberally. If your program can be broken down easily into stages, comment each stage. If you have defined your own functions or datatypes, comment them extensively, explaining what they do, and what they're for. If you come up with an implementation that's in any way obscure, cute, or hacked, comment it well. You may want to use the same trick again someday, and it's helpful to know how it worked.

The Elements of Programming Style

1. Say what you mean, simply and directly.
2. Write clearly - don't be too clever.
3. Don't use conditional expressions as a substitute for a logical expression.
4. Parenthesize to avoid ambiguity.
5. Follow each decision as closely as possible with its associated action.
6. Use the good features of a language; avoid the bad ones.
7. Each module should do one thing well.
8. Make sure comments and code agree.
9. Don't just echo the code with comments - make every comment count.
10. Don't comment bad code - rewrite it.
11. Use symbolic constants for magic numbers.
12. Watch out for side effects and order of evaluation.
13. Macros are not functions.
14. Watch out for off-by-one errors.
15. Test programs at their boundaries.
16. Program defensively.
17. Make sure input cannot violate the limits of the program.
18. Make it right before you make it faster.
19. Keep it right when you make it faster.
20. Don't sacrifice clarity for small gains in efficiency.
21. Don't stop with your first draft.

The phases of development


In order to do a good computer program there are different phases of development to respect :
Problem Solving Phase
Analysis and Specification : understand (define) the problem and what the solution must do.
Algorithm Development : develop a comprehensive unambiguous logical sequence of steps to solve the problem.
Verification of Algorithm : follow steps closely (manually) to see if solution works.
Implementation Phase
Program Development : translate algorithm into a program written in a programming language.
Program Testing : test program for syntactical and logical errors. Fix the errors.
Maintenance Phase
Use : use the program to solve real world problems.
Maintain : modify the program to meet changing r

What is a computer program ?


In computing, a program is a specific set of ordered operations for a computer to perform. In the modern computer that John von Neumann outlined in 1945, the program contains a one-at-a-time sequence of instructions that the computer follows. Typically, the program is put into a storage area accessible to the computer. The computer gets one instruction and performs it and then gets the next instruction. The storage area or memory can also contain the data that the instruction operates on. (Note that a program is also a special kind of "data" that tells how to operate on "application or user data.")
Programs can be characterized as interactive or batch in terms of what drives them and how continuously they run. An interactive program receives data from an interactive user (or possibly from another program that simulates an interactive user). A batch program runs and does its work, and then stops. Batch programs can be started by interactive users who request their interactive program to run the batch program. A command interpreter or a Web browser is an example of an interactive program. A program that computes and prints out a company payroll is an example of a batch program. Print jobs are also batch programs.
When you create a program, you write it using some kind of computer language. Your language statements are the source program. You then "compile" the source program (with a special program called a language compiler) and the result is called an object program (not to be confused with object-oriented programming). There are several synonyms for object program, including object module and compiled program. The object program contains the string of 0s and 1s called machine language that the logic processor works with.
The machine language of the computer is constructed by the language compiler with an understanding of the computer's logic architecture, including the set of possible computer instructions and the length (number of bits) in an instruction.