MODULE 6 PROGRAMMING LANGUAGES Programming lang = series of commands written by programmer to give directions to a computer. Commands are sets of instructions and form a program. Whatever lang. we use to write a program , it must eventually be translated into binary code ( 0s and 1s) because computer understands only binary code -choice of programming lang. depends on type of task computer must perform THE FIRST GENERATION: MACHINE CODE -first computer lang. developed, instructions were in binary code and consisted of two parts: operation code (specified action to be carried out) and operand (memory address where that specific instruction could be found), easy and fast to execute (no translation necessary) but error-prone (difficult to remember all 0s and 1s), machine-dependent (same program doesn’t run on different hardware) THE SECOND GENERATION: ASSEMBLY LANGUAGE -Appeared in the 1950s, instructions written with mnemonics (abbreviations of English words) so more intelligible, less error-prone, but slower than machine code because program in assembly must be translated into binary code before execution (assembler) still machine-dependent Machine code and Assembly are low-level languages THE THIRD GENERATION: HIGH –LEVEL LANGUAGES PEOPLE-ORIENTED PROGRAMS Instructions in the form of English-like statements combined with mathematical symbols, not machinedependent ( same program can be executed on different machines with very little alteration) so peopleoriented, not machine-oriented, easier to write programs but program must be translated into binary code before execution. These lang are procedural lang. because instructions are written and executed sequentially according to a rigid procedure Examples: COBOL (Common Business-Oriented Language) for business systems, FORTRAN (Formula Translator) popular scientific language; PASCAL which is multipurpose THE FOURTH GENERATION: NON-PROCEDURAL LANGUAGES Their purpose is to simplify the programmer’s task, often associated with specific applications like databases. They use English-like instructions but specify WHAT to do not HOW to do it. Examples: QUERY LANGUAGES (enable user to specify and request information from a database); REPORT WRITERS (take information retrieved from a database and format it into an organized output) APPLICATION GENERATORS (enable user to specify a problem and describe desired results and application generator creates the program) OBJECT-ORIENTED LANGUAGES These languages do not define procedures but objects, objects are representations of what a programmer needs in the development of a program OBJECT= self-contained module that encapsulates data and the methods for manipulating the data. Objects are grouped hierarchically into classes and subclasses, each object in the subclass must have the same attributes and methods of the main class (inheritance) ADVANTAGES: easier to create and modify programs (existing objects can be reused), easy to add new objects to a class because they inherit properties of existing class, programmer doesn’t have to start from scratch to create a program but he can choose from available objects ex. C ++, Java SPECIAL LANGUAGES: COMPUTER LANGUAGE TRANSLATORS Whatever lang. we use to write a program, all programs, (except those in machine code), must be translated into binary code. There are three types of translators: ASSEMBLER: each statement in assembly produces a single line of machine code; the entire program is translated before it is sent to execution INTERPRETER: translates statements one at a time, each statement in high level lang. (source code), produces several lines of object code (instructions in binary). As each statement is translated, it is checked for errors and then executed, once executed the binary code instruction is discarded before the next statement is translated so program must be translated (or “interpreted”) every time it is executed so this process is slow but useful to locate errors COMPILER: translates entire program before sending anything in execution, whole program in binary code is then saved on disk so it can be reused without recompilation VISUAL LANGUAGES: ICONS FOR WORDS Visual programming replaces text-based instructions with symbolic icons, each icon represents an object VISUAL BASIC: most popular visual language, developed in 1990s by Microsoft (purpose was to offer an easy language which allowed to create Windows applications without having to learn the C language), Visual Basic allows programmers to drag-drop objects on a screen, make links between these objects using a visual interface, easy to learn and use (Visual C# for Internet- based applications)