So, what is the best programming language?

January 30th, 2008 yudi Posted in Types of Language No Comments »

No single “best” programming language exists. If you want to write programs professionally, you want to learn at least one high-level language (most likely C++ because it’s the most popular of the high-level languages) and one database programming language (such as SQL). You can’t go wrong learning C++. With so many companies writing programs in C++, people with C++ programming experience can get a job almost anywhere.

Even if you can’t find a job programming in C++, you can often find a job programming in a similar language, such as C, C#, Perl, Python, or Java, all of which resemble C++ to a large extent.

If you prefer to work for yourself, one of the most lucrative markets is writing custom databases for companies. To get into this field, you obviously must know a database programming language, such as SQL. If you plan to create Web pages, you need to know HTML and gain some familiarity with Java, JavaScript, Ajax, and the other Internet programming languages. Ultimately, the best programming language to know is the one that enables you to accomplish a task as quickly and easily as possible, whether that language is C++, BASIC, Java, SQL, or assembly language.

Technical Stuff For a quick introduction to the way different programming languages solve the same problem, visit the Hello World! Web site at www.latech.edu/~acm/HelloWorld.shtml. This Web site provides sample programs, written in a variety of programming languages, that tell the computer to display the words “Hello World!” on-screen.

Image from book

The programming language “religious” wars

Ask ten different programmers the best language to learn and you’ll likely get ten different answers from ten passionate programmers who can cite endless studies, reports, and other empirical evidence on why their particular favorite programming language is the “best” language to learn and use.

Even worse, many programming language fanatics go so far as to claim that a program written in one language is actually inferior to an equivalent program written in a different language.

The truth is that no single language is best for all possible tasks, and the language you use to write a program doesn’t determine the quality of your program any more than the paper you use determines the quality of a written report. The main reason why people defend their chosen programming language and attack the other languages is because they want to feel “right” about their decision to use a particular programming language.

So if you want to learn C++, do it because you want to and not because you think it will make you “cool” or more computer savvy. Knowing C++ won’t make you any more knowledgeable about computers than knowing French will make you more knowledgeable about French cooking.

A programming language is nothing but a tool for expressing ideas. A great BASIC programmer will always be more productive than a mediocre C++ programmer.

So the next time you hear programmers argue about which language is superior, walk away and do something more productive with your time (like mastering your favorite language). Or watch and listen to these meaningless programming language arguments that are about as useful as arguing whether the color red is superior to the color purple, or whether zinc is a better mineral than iodine. The quality of a program is a direct reflection of the quality of the programmer; the language will always be secondary.

Image from book
AddThis Social Bookmark Button

Scripting programming languages

January 30th, 2008 yudi Posted in Types of Language No Comments »

 

Writing a program from scratch gives you the most flexibility but can take a really long time and drive you nuts in the process. Suppose, for example, that you want to write a word processor specifically for creating screenplays.

If you decide to use a general-purpose language such as C++ or Pascal, you first need to write instructions that create a simple word processor; you then need to write additional instructions to give the word processor the features necessary to create and format screenplays.

As an alternative to going mad by writing everything yourself, many programs offer their own scripting languages. Instead of writing an entire word processor from scratch, you can buy an existing word processor (such as WordPerfect or Microsoft Word) and then use that word processor’s scripting language to make the word processor do what you want it to do (such as create and format screenplays). A scripting language enables you to focus on the task that you want to accomplish without worrying about irrelevant details.

Technical Stuff Most Microsoft programs, such as Word, Excel, PowerPoint, and Access, offer a scripting language known as Visual Basic for Applications (VBA), which is nearly identical to Visual Basic. The Macintosh operating system also includes a scripting language, known as AppleScript, so you can write programs to automate your Macintosh (to a limited extent). The following code shows how to use AppleScript to display the “Take a nap!” message on-screen:

 


on DisplayMessage()
 display dialog “Take a nap!” buttons {”OK”}
end DisplayMessage
DisplayMessage()

Scripting programming languages can come in handy in the following ways:

  • Image from book Modification fun: A scripting language enables you to modify an existing program, such as a word processor or spreadsheet. That way, you can create sophisticated programs quickly with very little programming.

  • Image from book Easy learning curve: Scripting languages are generally easier to learn than more powerful programming languages, such as C++. As a result, you can learn and start writing programs faster.

But before you jump wholeheartedly into learning and using a scripting language, beware of the following problems:

  • Image from book Specificity: Scripting languages are tied to a specific program. If you customize a word processor by using a scripting language, your program runs only on computers that run that particular word processor. If you customize Microsoft Word, your program works only on computers that can run Microsoft Word, such as Windows and Macintosh computers.

  • Image from book Limited marketability: Selling and distributing your programs is much more difficult. To use your program, people must buy or already own the program (word processor, spreadsheet, and so on) that you customize. So if you create a custom program for WordPerfect, Microsoft Word users can’t use it.

  • Image from book Limited flexibility: A scripting language provides much less flexibility than does a general-purpose programming language such as C++. Make sure that the trade-off of convenience and ease of programming is worth the limitations of using a scripting language.

Remember In this site, you learn a scripting language called Revolution, which you use to control a program called Revolution. Because Revolution runs on Windows, Macintosh, and Linux computers, the Revolution scripting language can create programs that run on multiple computers with little or no modification.

Technical Stuff Most programs are designed to run only on a single operating system or platform. If a program can run on different operating systems (also called platforms), it’s called cross-platform.

AddThis Social Bookmark Button

Database programming languages

January 30th, 2008 yudi Posted in Types of Language No Comments »

Programming languages such as C++, BASIC, and Pascal were designed as general-purpose languages, which means that you can use them to write practically anything, such as a flight simulator, an accounting program, a voice-recognition program, or a word processor.

Technical Stuff Microsoft Windows is written in C/C++, whereas the original Macintosh operating system was written in Pascal. The latest version of the Macintosh operating system, Mac OS X, is written in a programming language called Objective-C, which looks similar to C and C++.

One of the most popular uses for computers, however, is storing and retrieving information, such as names, addresses, phone numbers, prison records, credit history, and past job experience. Computers store such information in databases.

Almost every business relies on databases to store information about customers, inventories, and employees, so nearly every company uses a database program.

Unfortunately, most people don’t want to know the strange and often bizarre commands necessary to store, retrieve, or print information from a database. To make databases easier to use, most databases include a programming language.

Most popular database programs, such as FileMaker and Microsoft Access, offer their own special programming languages. For manipulating large amounts of data such as what’s stored on big mainframe computers, database programs tend to use a language known as SQL (which stands for Structured Query Language). The following SQL code displays the message “Take a nap!”


select ‘Take a nap!’ from dual;

Database programming languages can fill the following specific needs:

  •  Speedy writing: If you’re writing a program that stores huge chunks of information, you can write it much faster by using a database programming language than by using a general-purpose language such as C++ or Pascal.

  •  Compact and understandable: A program written in a database language is much smaller and easier to understand than an equivalent program written in C++ or Pascal.

  •  Big bucks: Database programming is a lucrative field. If you know how to create customized databases, you almost never need to worry about being unemployed or not making enough money.

Of course, database programming languages aren’t for everybody. They have several crucial limitations, as the following list describes:

  •  Program specificity: Database programs are often tied to a specific computer. If you write a custom database by using FileMaker, for example, you can run your program only on any computer that can also run the FileMaker program. Because FileMaker is currently limited to the Macintosh and Windows operating systems, you can’t run a FileMaker program on a computer that uses Linux.

  •  Limited uses: Database programming languages are great for making custom databases but lousy for making anything else, such as video games, word processors, or utility programs (such as antivirus utilities). If you need to create a variety of programs, you can’t rely on a database programming language by itself.

AddThis Social Bookmark Button

Rapid application development (RAD) programming languages

January 30th, 2008 yudi Posted in Types of Language No Comments »

Most programming languages were designed back in the days when computer screens displayed nothing but text. The screen didn’t show graphics, mouse pointers, buttons, or windows.

Because computer screens could display only text, languages such as C++, BASIC, and Pascal had simple commands to display information, such as the following BASIC command:


PRINT “This sentence appears on-screen.”

After computers developed fancy graphical user interfaces with windows, scroll bars, and toolbars, people began demanding programs that included all these fancy graphical features. To help programmers create programs with graphical user interfaces, many companies developed special dialects of existing languages, which they dubbed rapid application development (RAD) languages.

RAD languages enable programmers to design the way that they want their programs to look (the user interface) and then write source code to make that user interface actually do something useful, such as display information in a window. 

Some popular RAD languages are Visual Basic and REALbasic (based on BASIC), Delphi and Kylix (based on Pascal), and Visual C# (based on C#).

RAD languages offer the following benefits:

  •  Speedy writing: You can write programs with graphical user interfaces much faster by using RAD than you can by using ordinary C++, BASIC, or Pascal. 

  •  Less work: RAD languages simplify the process of creating user interfaces so that you can focus on getting the rest of your program to work. Without a RAD language, you’d need to write instructions to make the user interface work and then write additional instructions to make the rest of the program work as well, essentially doubling your work and the chance of making a mistake.

  •  Similarity to other languages: Because RAD languages derive from existing high-level languages (BASIC and Pascal), you can learn and start programming in a RAD language right away if you already know BASIC or Pascal.

Not surprisingly, RAD languages have a few major drawbacks, which shouldn’t surprise you because nothing involving computers is ever perfect. The following list describes these drawbacks:

  •  Low portability: Programs that you write in RAD languages may not be portable between different computers. Delphi and Kylix can only create programs that run on Microsoft Windows and Linux, but can never create programs that run on the Macintosh without extensive modification. (Early versions of both Visual Basic and Visual C# also created programs that could only run on Windows, but newer versions promise to run on other operating systems as well. However, note the word “promise.” If you need to create a program that runs on Windows, Linux, and Mac OS X right now, a “promise” for tomorrow isn’t going to help you today.)

  •  Large, slow programs: RAD languages create larger and slower programs than the equivalent programs written in pure BASIC or Pascal. A RAD language may help you create programs faster, but you sacrifice speed and program size.

AddThis Social Bookmark Button

High Level Programming

January 30th, 2008 yudi Posted in Types of Language No Comments »

Because writing machine- or assembly-language programs was so difficult and confusing, people developed additional languages that look more like human languages, with names such as FORTRAN, COBOL, BASIC, and Pascal. Programming languages that resemble written human languages are called high-level languages. The main goal of high-level languages is to make programs easier to write and modify later on.

One of the first high-level languages was FORTRAN (which stands for FORmula TRANslator). FORTRAN was designed specifically for mathematical calculations. Another early high-level language was COBOL (COmmon Business-Oriented Language), which was designed for business data processing.

Because each language has a specialized purpose, most people don’t use FORTRAN or COBOL to write video games, operating systems, or word processors (although you can still do so if you really want to try).

Beginners could start learning to program by using C, but the complexities of C often discouraged people too soon. (It was sort of like trying to learn how to ride a bicycle by hopping on a motorcycle in the middle of rush-hour traffic.) Because programming was still too difficult for many people, computer scientists soon created both Pascal and BASIC to teach people programming. BASIC (Beginner’s All-purpose Symbolic Instruction Code) was designed to teach complete novices how to program.

The main advantage of BASIC is its simplicity. To print the words “Take a nap!” on-screen, you need only the following command:

 PRINT “Take a nap!”

If you compare it with the equivalent C or assembly-language source code, BASIC source code enables you to focus on the task that you want to accomplish instead of worrying about the cryptic commands of a specific programming language.

Pascal (named after the French philosopher, Blaise Pascal) is another language designed to help beginners learn how to program. The main difference between BASIC and Pascal is that Pascal encourages you to write well-structured programs that you can easily read, understand, and modify at a later date. The following Pascal program displays “Take a nap!” on-screen:
Program Message (Input, Output);


Begin


  Writeln (’Take a nap!’);


End.

Compared with Pascal, BASIC is much less structured, which makes writing a BASIC program easy but makes reading and understanding large BASIC programs much more difficult. Pascal is more structured and forces you to plan your program before you write it. This planning may take longer, but your program will be more organized than if you rush into writing the program right away, which BASIC programmers often do because BASIC doesn’t require any planning whatsoever.

Technical Stuff BASIC is such a popular language that programmers have combined the structured features of Pascal with the simplicity of BASIC to create various dialects of BASIC. Two popular dialects of BASIC are Liberty BASIC and REALbasic. (The next section discusses REALbasic.) Liberty BASIC represents the simplicity of the original BASIC language, whereas REALbasic represents a more structured version of the BASIC language.

High-level programming languages such as Pascal, BASIC, FORTRAN, and COBOL offer the following advantages over C, assembly language, or machine language:

  • Image from book Speedy writing: You can write programs much faster in a high-level programming language than you can in assembly language or machine language. (You can write a program in C in roughly the same amount of time as you can in a high-level language such as Pascal.)

  • Image from book Easy learning curve: Learning and mastering a high-level programming language often takes less time than learning and mastering machine language, assembly language, or C programming.

  • Image from book Stability: Because high-level programming languages shield you from accessing all parts of a computer, they protect you from writing programs that accidentally mess up the computer, causing it to crash.

  • Image from book Easy reading and modifying: Reading and modifying a program written in a high-level language is much easier than reading and modifying an equivalent program written in C, assembly language, or machine language.

  • Image from book Portability: Programs written in high-level languages can run on a variety of computers as long as the other computer has a compiler for that particular programming language. If you write a program in a high-level language, you can (theoretically) port that program to run on a different computer.

Naturally, high-level languages have their own share of problems that include the following:

  • Image from book Complexity issues: Programs written in high-level languages are more complicated to translate into machine code, which means that a program written in FORTRAN or COBOL will likely run much slower and require more memory and hard drive space than a similar program written in C, assembly, or machine language.

  • Image from book Compiler woes: Creating a compiler for a high-level language is much harder than creating one for C. As a result, not all computers have compilers available for every high-level language. So if you write a program in Liberty BASIC, you may find it nearly impossible to port your program to another computer or operating system.

AddThis Social Bookmark Button

The Good Old C Language

January 30th, 2008 yudi Posted in Types of Language No Comments »

Writing assembly-language programs is often difficult and time-consuming, and the programs are difficult to modify and impossible to port from one computer to another. To combat this situation, programmers created a wide variety of different programming languages with names such as COBOL and FORTRAN.

But some programmers felt that they needed a language that offers the power to access hardware (like assembly language) but is easier to read, write, and modify (like COBOL and FORTRAN). Eventually, they invented a programming language known simply as C.

Technical Stuff Programmers based the C programming language on an early programming language by the name of B (although no programming language known as A ever existed).

Programmers wanted to make programming as easy as possible for themselves, so they made the C programming language look more like actual words that people can understand, as the following example demonstrates:


main()
{
    printf (”Take a nap!\n”);
}

This C program is equivalent to the assembly-language program found in the preceding section of this chapter. Both programs display “Take a nap!” on-screen. Comparing the two, you can see that the C language source code is smaller and easier to read than the equivalent assembly-language source code.

Remember To run a program written in assembly language, you need to convert the assembly-language commands into equivalent machine-language commands. Similarly, to run a program written in any other language, such as C (or BASIC, FORTRAN, Pascal, and so on), you must translate your commands into equivalent machine-language commands, which you do by using a special program called a compiler.

The programmers who created the C programming language had the following three main goals:

  •  To create a language that’s easier to read and write than assembly language.

  •  To offer programmers the capability to access all the parts of the computer just as they can by using assembly language.

  •  To provide a small, simple language that you can easily port from one computer to another. Programs that you write in C can run on different computers without massive rewriting, which is the main drawback with assembly- and machine-language programs.

The third goal may look strange, so here’s the rationale behind it: Computers don’t understand C any better than they understand assembly language. (Computers are notorious for not understanding much of anything, which is why programming must be so precise.) If you write an entire program in C, your computer doesn’t have the slightest clue how to read your instructions.

To make a computer read and understand instructions written in C, you must convert your C program into equivalent machine-language instructions. Programmers created special programs, known as compilers, to do this conversion for them. A compiler takes your C program and converts it into machine language, which is like translating a Jules Verne novel from French into English.

As is true of translations between human languages, the simpler the programming language, the easier the translation. Translating a children’s book from French into Japanese is much easier than translating a mathematics dissertation from French into Japanese, mainly because a children’s book uses simple words, whereas a mathematics dissertation uses more complicated words. Similarly, translating C into machine-language code is more difficult than translating assembly-language code into machine-language code.

So the only way that you can run a C program on another computer is if someone has already written a C compiler for that other computer. Because C is a simple language, writing C compilers for different computers is relatively easy.

Because C compilers are fairly easy to write, you can find C compilers for almost every computer in the world. Theoretically, you can write a C program for the Macintosh, copy it to a computer running Windows, recompile it, and run the program with just minor modifications.

Remember Although, in theory, C programs can run on different computers without modification, the reality is that you almost always must modify a C program slightly or drastically to get it to run on a different computer. Modifying a C program, however, is still much easier than rewriting an entire assembly- or machine-language program to run on different computers.

Given its power and portability, C has quickly become one of the most popular programming languages in the world. The majority of all programs are written in C although most newer programs are now written in a C derivative language called C++. Some of the more famous (or infamous) programs that have been written in C or C++ include operating systems such as Microsoft Windows, UNIX, and Linux, as well as major commercial programs such as Quicken, Photoshop, and Microsoft Word.

Although C is popular, it has its share of flaws:

  •  Large, slow programs: C creates larger and slower programs than equivalent assembly- or machine-language programs.

  •  Danger to computer memory: The C language gives programmers access to all parts of a computer, including the capability to manipulate the computer’s memory. Unfortunately, all this power can prove as dangerous as giving a hyperactive monkey a chain saw and a hand grenade. If you don’t write your C programs carefully, they can accidentally wreck your computer’s memory, causing your program to crash your computer.

Technical Stuff In a desperate attempt to make C programming more reliable, programmers developed languages similar to C, such as C++, Java, Perl, Python, and C#. All these C-derived languages try to protect programmers from writing programs that can mess up the computer’s memory, as C programs can do, which increases the chance of writing a program that won’t crash an entire computer.

AddThis Social Bookmark Button

The Lowly Assembly Language

January 30th, 2008 yudi Posted in Types of Language No Comments »

The whole purpose of any programming language is to make programming easier. So rather than force programmers to write cryptic programs with the 0s and 1s of machine language, assembly language uses short, easy-to-remember (to programmers, that is) commands with names such as JMP, MOV, and ADD. A single assembly-language command is a shortcut for typing multiple machine-language commands in much the same way that typing an abbreviation like LOL is a shortcut for writing out the phrase “Laughing Out Loud.”

As a result, assembly-language source code is not only shorter and easier to write than machine code, but also easier to read and modify. A typical assembly-language program looks like the following example:


title Nap Program
; This program displays “Take a nap!” on the screen
dosseg
.model small
.stack 100h
.data
my_message db ‘Take a nap!’,0dh,0ah,’$’
.code
main    proc
        mov ax,@data
        mov ds,ax
        mov ah,9
        mov dx,offset my_message
        int 21h
        mov ax,4C00h
        int 21h
        main endp
end main

Remember Making programs easy to read and modify is crucial because most programs don’t work right the first time you use them. If you can’t understand how a program works, you won’t be able to fix any problems with it.

Because computers understand only machine language, programmers have written special programs that translate and convert assembly-language commands into their equivalent machine-language commands. These special programs are known as assemblers. If you give your computer an assembly-language program, it won’t know how to follow your instructions until you feed your program to an assembler. The assembler translates your assembly-language program into machine code.

Assembly language offers the following two distinct advantages over machine language:

  • Image from book Easier reading: Assembly-language programs are much easier to read than machine-language programs.

  •  Easier writing: Assembly-language programs are much easier to write (and modify) than machine-language programs.

Of course, assembly language has the following disadvantages:

  •  Large, slow programs: Programs that you create by using assembly language run slower and gobble up more space (both physical hard drive space and memory) than equivalent programs that you may create with machine language.

  •  Limited portability: You can’t easily transfer (or, to use programming lingo, port) an assembly-language program from one computer to another computer.

  •  Frustration factor: Writing a program in assembly language can prove extremely tedious, time-consuming, and complicated. That’s why few people bother to write large programs in assembly language.

Remember In general, the easier the programming language is to read and write, the slower and larger are the programs it creates. The three main goals of computer programming are to create programs that are easy to write and modify, that run as fast as possible, and that take up as little space as possible.

AddThis Social Bookmark Button




eXTReMe Tracker