Programming LanguagesSecond-generationlanguage(2GL)AssemblylanguageStored as text.Example:toaddEAXandEBXregistersand storetheresultbacktoEAX:add EAX,EBXEachassembly instruction represents exactly onemachineinstruction.Assembler is needed to convert assembly language programs into machine code so thatthey can be executed.Eachtypeofcomputersunderstands itsownassemblylanguageonlyie.alsomachine-dependent.Wemayhavetolearnanewassembly languagewhenwe useanothertype of computer.8.ProgrammingConcepts-6Introductionto ComputerProgramming
Introduction to Computer Programming 8. Programming Concepts - 6 Programming Languages Second-generation language (2GL) • Assembly language. • Stored as text. • Example: to add EAX and EBX registers and store the result back to EAX: add EAX, EBX • Each assembly instruction represents exactly one machine instruction. • Assembler is needed to convert assembly language programs into machine code so that they can be executed. • Each type of computers understands its own assembly language only. ie. also machine-dependent. • We may have to learn a new assembly language when we use another type of computer
Programming LanguagesThird-generation language(3GL)Also called Procedural language:solvesaproblembyexecutingasequenceofsteps (ie.how)Examples:Java,C,PascalFourth-generation language (4GL)Also calleddeclarativelanguage:specifies what needs to be done without going into the details.Oftenusedtoaccessdatabases.Example:StructuredQueryLanguage(SQL)SELECT*FROM RECORDS WHERE SURNAME="CHAN"Question:Whichgeneration does JavaScriptbelongto?8.ProgrammingConcepts-7
Introduction to Computer Programming 8. Programming Concepts - 7 Programming Languages Third-generation language (3GL) • Also called Procedural language: solves a problem by executing a sequence of steps (ie. how). • Examples: Java, C, Pascal Fourth-generation language (4GL) • Also called declarative language: specifies what needs to be done without going into the details. • Often used to access databases. • Example: Structured Query Language (SQL) SELECT * FROM RECORDS WHERE SURNAME = "CHAN" Question: Which generation does JavaScript belong to?
Programming LanguagesLow-levelandHigh-levelProgrammingLanguagesProgramming languages can also be classified as high-level and low-level.Low-level programming languages:Machine language and Assembly languageHigh-levelprogramminglanguages:3GLand4GLInstructionsare English-like.A single instruction can be written to define many operations at the machine level.Convertedtomachine languages beforetheycanbe executed.Machine-independent.Example:thesameCprogramcanbecompiled torun in(1)Personal computer running windows XP-using the compilers provided by someprogramming software like the Borland C and Microsoft Visual Studio etc..aswell as(2) Unix machine - using the Unix C compilers (eg. gcc, cc)8.ProgrammingConcepts-8Introduction to Computer Programming
Introduction to Computer Programming 8. Programming Concepts - 8 Programming Languages Low-level and High-level Programming Languages Programming languages can also be classified as high-level and low-level. Low-level programming languages: Machine language and Assembly language High-level programming languages: 3GL and 4GL • Instructions are English-like. • A single instruction can be written to define many operations at the machine level. • Converted to machine languages before they can be executed. • Machine-independent. • Example: the same C program can be compiled to run in (1) Personal computer running windows XP – using the compilers provided by some programming software like the Borland C and Microsoft Visual Studio etc. as well as (2) Unix machine – using the Unix C compilers (eg. gcc, cc)
Programming LanguagesMicrosoftVisualStudiotesting-MicrosoftVisual Studio口0区EileEdityiewProjectBuildDebugToolsWindowCommunityHelp国中国园、园DebugSolutio...XsrcMain.cXB国(Global Scope)[ Solution 'testin=#include<stdiib.h>testingS#include <stdio.h)Heade#include<tine.h>Resour2SourcePBuoidnain()sroLint i=o;int counterSnall-a; //counter for randon nunbersint counterLarge-a; //counter for randon nunbersBorland CIIGENERATE RANDOH NUMBERS43M/35M-File Edit Search Run Compnle lebug ProjectUptionsWindowsHelpc:/Tut11.CountRandonNunbers.cI/in c anguage,we need to randonisrand((unsigned)tine(HULL));#include<stdlib.h>#include<stdio.h>I/Generate randon nunbers one by on#include<tine.h>while(i<10000)void main()SCPint i-o;int counterSmall-B;//counterfor randonnunbers e.oooe=.Find Results 18int counterLarge=o;1/counter for randon nunbers 8.58oe-同自威路I/GENERATE RANDOM NUMBERSCodeDefinitionWindow Call BrowseroutputFindResults1MessageWindoConpiling:c:/Tut11_CountRandonNumbers.cCol 1ReadyLn1Ch1noerrorsEnterJumptosourceAlt+FyComprle belBeleteCtrl+bel Beleteall Alt+xUuit8.ProgrammingConcepts-9Introduction toComputerProgramming
Introduction to Computer Programming 8. Programming Concepts - 9 Programming Languages Borland C Microsoft Visual Studio