Skip to content
GK24
GK NotesComputer AwarenessProgramming Languages

Programming Languages: Generations, Compilers and PYQs

Computer awareness notes on programming languages: the five generations, assembler, compiler and interpreter, and famous languages with their creators.

By · Published · 4 min read

Programming Languages: Generations, Compilers and PYQs — GK24 title card
Programming Languages: Generations, Compilers and PYQs — GK24 title card

A computer does nothing on its own; it follows a set of instructions called a program, and the language in which that program is written is a programming language. The hardware understands only electrical states written as 0 and 1, so every language above that level has to be translated before the machine can run it. Banking, SSC and Railway papers take a steady set of questions from this chapter: the generation a language belongs to, the difference between a compiler and an interpreter, and the person who created each famous language.

The five generations of languages

The first generation is machine language, written only in the binary digits 0 and 1. It runs directly on the processor and needs no translation, so it is the fastest, but it is machine dependent and almost impossible for a person to write or correct. The second generation is assembly language, in which short words called mnemonics, such as ADD, SUB and MOV, stand for machine instructions. It is still machine dependent and needs a translator called an assembler. The third generation is the high-level languages, close to English and independent of the machine, which include FORTRAN, COBOL, BASIC, Pascal, C, C++, Java and Python; each statement of a high-level language becomes many machine instructions. The fourth generation is the non-procedural languages, in which the programmer states what is wanted rather than how it is to be done, the best known being SQL for databases. The fifth generation is the languages of artificial intelligence and logic programming, such as PROLOG and LISP. Machine and assembly languages together are called low-level languages.

Translators: assembler, compiler and interpreter

TranslatorWhat it doesPoint to remember
AssemblerConverts assembly language into machine languageWorks only for second-generation code
CompilerTranslates the whole program at once and then runs itLists all errors together; execution is faster; used by C and C++
InterpreterTranslates and executes one line at a timeStops at the first error; slower; used by BASIC and Python
LinkerJoins the object code with library code into one executableComes after compilation
LoaderLoads the executable program into the main memoryThe last step before a program runs

The program as the programmer writes it is called the source code, and what the translator produces is called the object code. A mistake that breaks the grammar of the language, such as a missing semicolon, is a syntax error and is caught by the translator; a mistake in the reasoning, which gives a wrong answer though the program runs, is a logical error and must be found by testing. Removing errors is called debugging.

Famous languages, their creators and their uses

LanguageCreated byChiefly used for
FORTRAN, 1957John Backus at IBMThe first high-level language; scientific and engineering work
LISP, 1958John McCarthyArtificial intelligence and list processing
COBOL, 1959A committee, with Grace Hopper as the moving spiritBusiness and commercial data processing
BASIC, 1964John Kemeny and Thomas KurtzTeaching beginners
Pascal, 1970Niklaus WirthStructured programming; named after Blaise Pascal
C, 1972Dennis Ritchie at Bell LaboratoriesSystem software, including the UNIX operating system
C++Bjarne StroustrupObject-oriented programming; an extension of C
Python, 1991Guido van RossumGeneral purpose, data science and automation
Java, 1995James Gosling at Sun MicrosystemsPlatform-independent applications; first named Oak
JavaScript, 1995Brendan EichMaking web pages interactive

Java and the idea of platform independence

Java is asked about more than any other language because of one property. A Java program is not compiled into the machine code of a particular processor; the compiler, invoked by the command javac, turns the source file into an intermediate form called bytecode, and that bytecode is run by a Java Virtual Machine, which exists for every kind of computer. The same compiled file therefore runs anywhere, and the slogan write once, run anywhere describes it. Java has eight primitive data types, namely byte, short, int, long, float, double, char and boolean; long double belongs to C and C++ and not to Java, which is a favourite trap. Java is case sensitive, its keywords cannot be used as variable names, and a variable name must begin with a letter, an underscore or a dollar sign.

Ways of programming and other terms

Procedural programming, as in C, organises a program as a sequence of procedures or functions. Object-oriented programming, as in C++, Java and Python, organises it around objects that hold both data and the methods that work on the data; its four pillars are encapsulation, inheritance, polymorphism and abstraction. A class is the blueprint and an object is the actual instance made from it. An algorithm is the step-by-step method of solving a problem, and a flowchart is its diagram, in which an oval stands for start or stop, a parallelogram for input or output, a rectangle for a process and a diamond for a decision. An integrated development environment is a single program that provides the editor, the translator and the debugger together. Finally, remember that HTML is a markup language that describes how a page is laid out and is not a programming language at all.

Exam Point of View

Four question types repeat from this chapter. First, generation to language: which is a low-level language, which generation SQL or PROLOG belongs to, and the fact that machine language needs no translation. Second, compiler against interpreter, usually framed as which one translates line by line or which reports all errors together; the assembler is slipped in as a distractor. Third, creator to language: Ritchie for C, Stroustrup for C++, Gosling for Java, van Rossum for Python, Backus for FORTRAN, Wirth for Pascal. Fourth, Java facts, because banking and Railway technical papers like them: the work of javac, bytecode and the Java Virtual Machine, the eight primitive types with long double as the standard wrong option, and the rules for naming a variable. One more single-line favourite is that HTML is a markup language and not a programming language.

Important Facts

First generationMachine language, written in 0 and 1
Second generationAssembly language, translated by an assembler
First high-level languageFORTRAN, 1957, by John Backus
Language of business data processingCOBOL
C languageDennis Ritchie, Bell Laboratories, 1972
C++ languageBjarne Stroustrup
JavaJames Gosling, Sun Microsystems, 1995; earlier called Oak
PythonGuido van Rossum, 1991
PascalNiklaus Wirth, named after Blaise Pascal
Command that compiles a Java programjavac
Java intermediate codeBytecode, executed by the Java Virtual Machine
Number of primitive types in JavaEight
Fourth-generation languageSQL, used for databases
Fifth-generation languagesPROLOG and LISP, used in artificial intelligence
Source code and object codeWhat the programmer writes and what the translator produces
Not a programming languageHTML, which is a markup language

Practice MCQs on this topic

Q1.Computer AwarenessMedium

Which of the following is considered the first high-level programming language?

  1. A.COBOL
  2. B.FORTRAN
  3. C.BASIC
  4. D.Pascal
Show answer

Correct answer: B. FORTRAN

Explanation

The correct answer is B, FORTRAN. Its name is short for Formula Translation, it was developed by a team under John Backus at IBM and released in 1957, and it was the first language in which a programmer could write ordinary algebraic formulas instead of machine codes, which is why it is counted as the first high-level language; it is still used for heavy scientific and engineering computation. Option A is wrong because COBOL came two years later, in 1959, and was designed for business and commercial data processing, with Grace Hopper as the moving spirit behind it. Option C is wrong because BASIC was written in 1964 by John Kemeny and Thomas Kurtz to teach beginners, long after FORTRAN. Option D is wrong because Pascal was designed by Niklaus Wirth around 1970 to teach structured programming and is named after the mathematician Blaise Pascal. Keep the four years in order and this family of questions becomes easy.

Q2.Computer AwarenessEasy

The C programming language was developed by:

  1. A.James Gosling
  2. B.Bjarne Stroustrup
  3. C.Dennis Ritchie
  4. D.Guido van Rossum
Show answer

Correct answer: C. Dennis Ritchie

Explanation

The correct answer is C, Dennis Ritchie. He created C at Bell Laboratories in the early 1970s and used it to rewrite the UNIX operating system, which is why C is called the mother of system programming languages and still underlies most operating systems. Option A is wrong because James Gosling developed Java at Sun Microsystems and released it in 1995, having first named it Oak. Option B is wrong because Bjarne Stroustrup extended C with classes and objects and named the result C++, so he is the creator of C++ and not of C. Option D is wrong because Guido van Rossum created Python and released the first version in 1991. Examiners set this as a match-the-pair question with all four names in one column, so learn the set together: Ritchie for C, Stroustrup for C++, Gosling for Java, van Rossum for Python, Backus for FORTRAN and Wirth for Pascal.

Q3.Computer AwarenessAsked in: RRB JE · 30 Aug 2019Medium

What is the use of the 'javac' command?

  1. A.Execute a java program
  2. B.Debug a java program
  3. C.Interpret a java program
  4. D.Compile a java program
Show answer

Correct answer: D. Compile a java program

Explanation

The correct answer is D, compile a java program. The command javac is the Java compiler: it takes a source file with the extension .java, checks its grammar and converts it into a class file containing bytecode, the intermediate code that any Java Virtual Machine can run. Option A is wrong because a compiled program is executed by the separate command java, which loads the class file into the virtual machine and starts it. Option B is wrong because debugging is done with a tool such as jdb or the debugger built into a development environment, not with javac, which only reports errors of grammar. Option C is wrong because interpretation of the bytecode is the work of the Java Virtual Machine at the time the program runs; javac finishes its work before that. Remember the two-step chain that makes Java platform independent: javac produces bytecode, and the virtual machine on each computer runs that bytecode.

Q4.Computer AwarenessEasy

Which translator converts a high-level program into machine language one statement at a time?

  1. A.Compiler
  2. B.Interpreter
  3. C.Assembler
  4. D.Loader
Show answer

Correct answer: B. Interpreter

Explanation

The correct answer is B, interpreter. An interpreter reads one statement of the source program, translates it and executes it immediately before moving to the next, so it stops at the first error it meets and tells the programmer about that error alone; this makes it convenient for learning and for testing small pieces of code, though execution is slower because translation happens every time the program runs. Option A is wrong because a compiler translates the entire program in one pass, lists all the errors together and produces an object file that runs quickly thereafter. Option C is wrong because an assembler is a special translator that converts assembly language, a second-generation language, into machine code. Option D is wrong because a loader does no translation at all; it merely places the ready executable program into main memory so that the processor can start it. BASIC and Python are the standard examples of interpreted languages.

Q5.Computer AwarenessAsked in: RRB JE · 30 Aug 2019Hard

Which of the following is NOT a java primitive type?

  1. A.short
  2. B.long
  3. C.long double
  4. D.boolean
Show answer

Correct answer: C. long double

Explanation

The correct answer is C, long double. Java has exactly eight primitive data types, namely byte, short, int, long, float, double, char and boolean, and long double is not among them; it belongs to C and C++, where it denotes an extended precision floating point number, so the option is a deliberate trap for candidates who have learnt C first. Option A is wrong as an answer because short is a genuine Java primitive, a sixteen-bit signed integer. Option B is wrong because long is also genuine, a sixty-four-bit signed integer used when int is too small. Option D is wrong because boolean is a primitive that holds only the two values true and false and is the type of every condition in Java. A useful way to hold the eight in mind is to group them: four integer types, two floating point types, one character type and one logical type.

Q6.Computer AwarenessAsked in: RRB JE · 30 Aug 2019Medium

Which of the following is/are the rules to declare variables in Java?

  1. A.Java keywords cannot be used as variable names
  2. B.All of the options
  3. C.Variable names are case-sensitive
  4. D.The first character must be a letter
Show answer

Correct answer: B. All of the options

Explanation

The correct answer is B, all of the options, because each of the other three statements is a genuine rule of the language and the question asks which of them apply. Option A is a true statement and therefore not the answer by itself: reserved words such as class, int, public and static already have a meaning for the compiler and cannot be reused as identifiers. Option C is likewise true on its own: Java is case sensitive, so total, Total and TOTAL are three different variables, and a mismatch of case is one of the commonest beginner errors. Option D states the usual rule that an identifier begins with a letter, although Java also allows an underscore or a dollar sign as the first character and never allows a digit there. Since every listed statement holds good, the combined option is the one to mark; whenever three individually correct statements appear with an all of the above choice, check each and then take the combined option.

Q7.Computer AwarenessEasy

Machine language, the first generation of programming languages, is written using:

  1. A.English words
  2. B.Mnemonics such as ADD and MOV
  3. C.The binary digits 0 and 1
  4. D.Query statements
Show answer

Correct answer: C. The binary digits 0 and 1

Explanation

The correct answer is C, the binary digits 0 and 1. Machine language is the only language the processor understands directly, because each instruction is a pattern of electrical states that is written as a string of zeros and ones; a program in machine language therefore needs no translation and runs fastest, but it is tied to one processor and is very hard for a person to write or correct. Option A is wrong because English-like statements belong to the high-level languages of the third generation, such as COBOL, C and Java. Option B is wrong because mnemonics such as ADD, SUB and MOV belong to assembly language, the second generation, which needs an assembler to be converted into machine code. Option D is wrong because query statements belong to the fourth generation, of which SQL is the standard example and in which the programmer says what is wanted rather than how to get it. Machine and assembly language together form the low-level group.

Q8.Computer AwarenessMedium

Which of the following is NOT a programming language?

  1. A.Python
  2. B.HTML
  3. C.Java
  4. D.C++
Show answer

Correct answer: B. HTML

Explanation

The correct answer is B, HTML. HyperText Markup Language uses tags to describe how the content of a web page is arranged, such as headings, paragraphs, lists, tables and images, but it has no variables, no conditions and no loops, so it cannot express logic or take decisions; for that reason it is called a markup language and not a programming language. Option A is wrong because Python is a full general-purpose language, created by Guido van Rossum, widely used today for data science, automation and web work. Option C is wrong because Java is a general-purpose, object-oriented language whose compiled bytecode runs on the Java Virtual Machine. Option D is wrong because C++ is a general-purpose language built on C by Bjarne Stroustrup with support for classes and objects. The usual companion question asks which language makes a web page interactive, and the answer there is JavaScript, which despite the similar name is unrelated to Java.

Q9.Computer AwarenessMedium

The Python programming language was created by:

  1. A.Guido van Rossum
  2. B.Brendan Eich
  3. C.Niklaus Wirth
  4. D.John Backus
Show answer

Correct answer: A. Guido van Rossum

Explanation

The correct answer is A, Guido van Rossum. He designed Python in the Netherlands and released the first version in 1991, choosing a syntax with indentation instead of braces so that programs would be easy to read; the name comes from a television comedy series and not from the snake. Option B is wrong because Brendan Eich created JavaScript in 1995 to add interactivity to web pages in a browser. Option C is wrong because Niklaus Wirth designed Pascal around 1970 for teaching structured programming, and it is named after the mathematician Blaise Pascal. Option D is wrong because John Backus led the IBM team that produced FORTRAN in 1957, the first high-level language. In papers set for banking and Railway examinations this pairing of language and creator is asked almost every year, so revise the list as one block rather than one name at a time.

Q10.Computer AwarenessMedium

SQL, a fourth-generation language, is mainly used for:

  1. A.Designing web pages
  2. B.Working with databases
  3. C.Writing operating systems
  4. D.Editing images
Show answer

Correct answer: B. Working with databases

Explanation

The correct answer is B, working with databases. SQL stands for Structured Query Language, and it is used to create tables, insert rows, update and delete data and, above all, to ask questions of a relational database with statements such as SELECT; it is called non-procedural because the programmer states what result is wanted and the database system decides how to obtain it. Option A is wrong because web pages are laid out with HTML and styled with CSS, and made interactive with JavaScript. Option C is wrong because operating systems are written mainly in C, which gives direct control of memory and hardware; UNIX is the classic example. Option D is wrong because image editing is done by application software such as a photo editor, not by a query language. The fifth generation, which comes after SQL, contains PROLOG and LISP and is associated with artificial intelligence.

Frequently Asked Questions

What is the difference between a compiler and an interpreter?

A compiler takes the whole source program, translates it in one go and reports every error together; the translated program then runs quickly and can be run again without retranslation. An interpreter takes one line at a time, translates it and executes it at once, stopping at the first error it meets, so it is friendlier for learning but slower in execution.

Why is Java called a platform-independent language?

Because the Java compiler does not produce machine code for one processor. It produces bytecode, an intermediate form, and every computer runs that bytecode through its own Java Virtual Machine. The same compiled file therefore works on a Windows, Linux or Mac computer without being compiled again, which is the meaning of write once, run anywhere.

Is HTML a programming language?

No. HTML, or HyperText Markup Language, uses tags to describe the structure and layout of a web page, such as headings, paragraphs, tables and links. It has no variables, no conditions and no loops, so it cannot express logic, and that is why it is called a markup language. JavaScript, which is a programming language, is added to a page to give it logic and interactivity.

What is the difference between a syntax error and a logical error?

A syntax error breaks the grammar of the language, such as a missing semicolon or a misspelt keyword, and the compiler or interpreter refuses to translate the program until it is corrected. A logical error leaves the program perfectly legal, so it runs, but the reasoning is wrong and the answer it produces is wrong; only testing with known data reveals it.

Which languages belong to the low-level group?

Machine language and assembly language. Machine language is written directly in binary and is executed by the processor without translation, while assembly language replaces those binary codes with short mnemonics such as ADD and MOV and needs an assembler. Both are tied to a particular processor, which is what the term machine dependent means.

Sources

  • Computer Science, Class XI, Chapter on Getting Started with Python and Programming Basics — NCERT
  • Informatics Practices, Class XI, Introduction to Computer Systems — NCERT
  • Computers and Communication Technology, Class XI — NCERT
View all