“There are only two kinds of programming languages: those...
Transcript of “There are only two kinds of programming languages: those...
![Page 1: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/1.jpg)
03-60-440:PrinciplesofProgrammingLanguages
Classifica:onofprogramminglanguages
“Thereareonlytwokindsofprogramminglanguages:thosepeoplealwaysbitchaboutandthosenobodyuses.”--BjarneStroustrup
![Page 2: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/2.jpg)
1Generated using wordle.net from the text of this ppt file
![Page 3: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/3.jpg)
2
Categoriesofprogramminglanguages,wikipedia,20101Arraylanguages
2Aspect-orientedlanguages
3Assemblylanguages
4Authoringlanguages
5Commandlineinterfacelanguages
6Compiledlanguages
7Concurrentlanguages
8Dataflowlanguages
9Data-orientedlanguages
10Data-structuredlanguages
11Declara:velanguages
12Esotericlanguages
13Extensionlanguages
14Fourth-genera:onlanguages
15Func:onallanguages
16Interac:vemodelanguages
17Interpretedlanguages
18Itera:velanguages
19List-basedlanguages–LISPs
20LiWlelanguages
21Logic-basedlanguages
22Machinelanguages
23Macrolanguages
24Metaprogramminglanguages
25Mul:paradigmlanguages
26Numericalanalysis
27Non-English-basedlanguages
28Object-orientedclass-basedlanguages
29Object-orientedprototype-basedlanguages
30Off-siderulelanguages
31Procedurallanguages
32Reflec:velanguages
33Rule-basedlanguages
34Scrip:nglanguages
35Stack-basedlanguages
36Synchronouslanguages
37Syntaxhandlinglanguages
38Visuallanguages
39Wirthlanguages
40XML-basedlanguages
![Page 4: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/4.jpg)
FromWikipedia20171 Arraylanguages2 Assemblylanguages3 Authoringlanguages4 Constraintprogramminglanguages5 Begin...Endlanguages6 Commandlineinterfacelanguages7 Compiledlanguages8 Concurrentlanguages9 Curly-bracketlanguages10 Dataflowlanguages11 Data-orientedlanguages12 Data-structuredlanguages13 Decisiontablelanguages14 Declara:velanguages15 Embeddablelanguages15.1 Insourcecode15.1.1 Serverside15.1.2 Clientside15.2 Inobjectcode16 Educa:onallanguages17 Esotericlanguages18 Extensionlanguages19 Fourth-genera:onlanguages20 Func:onallanguages20.1 Pure20.2 Impure21 Hardwaredescrip:onlanguages21.1 HDLsforanalogcircuitdesign21.2 HDLsfordigitalcircuitdesign22 Impera:velanguages23 Interac:vemodelanguages24 Interpretedlanguages25 Itera:velanguages26 Languagesbymemorymanagementtype26.1 Garbagecollectedlanguages26.2 Languageswithmanualmemorymanagement27 List-basedlanguages–LISPs28 LiWlelanguages29 Logic-basedlanguages30 Machinelanguages31 Macrolanguages31.1 Textualsubs:tu:onmacrolanguages31.2 Applica:onmacrolanguages32 Metaprogramminglanguages33
Mul:paradigmlanguages34 Numericalanalysis35 Non-English-basedlanguages36 Object-orientedclass-basedlanguages36.1 Mul:pledispatch36.2 Singledispatch37 Object-orientedprototype-basedlanguages38 Off-siderulelanguages39 Procedurallanguages40 Reflec:velanguages41 Rule-basedlanguages42 Scrip:nglanguages43 Stack-basedlanguages44 Synchronouslanguages45 Syntaxhandlinglanguages46 Transforma:onlanguages47 Visuallanguages48 Wirthlanguages49 XML-basedlanguages
3
![Page 5: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/5.jpg)
4
Classifica:onofProgrammingLanguages• Therearedifferentwaysofgroupingprogramminglanguagestogether
– Byabstrac:onlevel– Lowlevel,highlevel,veryhighlevel
– Bydomain– businesslanguages,scien:ficlanguages,AIlanguages,systemslanguages,scrip:ng
languages,XML-basedlanguages
– Bygenerality– generalpurposevs.specialpurpose
– Byimplementa:onmethods– Interpretedvs.compiled
– Byparadigm– aparadigmisawayofviewingprogramming,basedonunderlyingtheoriesofproblem
solvingstyles– programminglanguagesgroupedinthesameparadigmaresimilarintheirapproachto
problemsolving– impera:ve,object-oriented,logic-based,func:onal,etc.
![Page 6: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/6.jpg)
5
Byabstractlevelfromthemachine
• Low-levellanguages– Machinelanguages,assemblylanguages
• High-levellanguages– Algol,Pascal,C++,Java,C#,etc.
• Veryhigh-levellanguages– Usuallylimitedtoaveryspecificapplica:on.– Duetothislimita:oninscope,theymightusesyntaxthatisneverusedinotherprogramminglanguages.
– E.g.,Prolog,SQL• Notethattheterms"high-level"and"low-level"areinherentlyrela:ve.
– OriginallyCwasconsideredhighlevelbutnowadaysmanyprogrammersmightreferCaslowlevel,asits:llsallowsmemorytobeaccessedbyaddress,andprovidesdirectaccesstotheassemblylevel.
Classification by level
![Page 7: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/7.jpg)
6
High–levelvs.lowlevellanguages• “High-level”referstothehigherlevelofabstrac:onfrommachinelanguage.
– itdoesnotimplythatthelanguageissuperiortolow-levelprogramminglanguages.• Characteris:cs:
– High-levellanguagesdealwithvariables,arraysandcomplexarithme:corbooleanexpressions;
– “low-level”languagesdealwithregisters,memoryaddressesetc.• Prosandcons
– High-levellanguagesmakeprogrammingsimpler;– whilelow-levellanguagesproducemoreefficientcode;– codewhichneedstorunefficientlymaybewriWeninalower-levellanguage.
thought
Languages machine
High Level Language
Assembly Language
Machine Language
Very high level Language
Closer to humans
Classification by level
![Page 8: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/8.jpg)
7
Lowvs.highlevellanguages
• unsignedintgcd(unsignedinta,unsignedintb){if(a==0&&b==0)b=1;elseif(b==0)b=a;elseif(a!=0)while(a!=b)if(a<b)b-=a;elsea-=b;returnb;}
; Author: Paul Hsieh gcd: neg eax je L3 L1: neg eax xchg eax,edx L2: sub eax,edx jg L2 jne L1 L3: add eax,edx jne L4 inc eax L4: ret
; WATCOM C/C++ v10.0a output gcd: mov ebx,eax mov eax,edx test ebx,ebx jne L1 test edx,edx jne L1 mov eax,1 ret L1: test eax,eax jne L2 mov eax,ebx ret L2: test ebx,ebx je L5 L3; cmp ebx,eax je L5 jae L4 sub eax,ebx jmp L3 L4: sub ebx,eax jmp L3 L5: ret
Classification by level
![Page 9: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/9.jpg)
8
Javaandbytecode
publicclassHello{
publicsta:cvoidmain(String[]a){
System.out.println("Hello");
}
}
Btw,Howtoviewthebytecode?
javap–cHello
publicclassHelloextendsjava.lang.Object{
publicHello();
Code:
0:aload_0
1:invokespecial#1;//Methodjava/lang/Object."<init>":()V
4:return
publicsta:cvoidmain(java.lang.String[]);
Code:
0:getsta:c#2;//Fieldjava/lang/System.out:Ljava/io/PrintStream;
3:ldc#3;//StringHello
5:invokevirtual#4;//Methodjava/io/PrintStream.println:(Ljava/lang/String;)V
8:return
}
Classification by level
![Page 10: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/10.jpg)
9
ClassifyingLanguagesbyDomain:Scien:fic• Historically,languageswereclassifiedmostoxenbydomains.
– Scien:fic,Business(DataProcessing),AI,System,Scrip:ng.
• Thefirstdigitalcomputerwasusedandinventedforscien:ficapplica:on.
• Thefirsthighlevelprogramminglanguageisforscien:fic(engineering)applica:on
– Simpledatastructuresbutlargenumberoffloa:ng-pointarithme:ccomputa:ons.
• Thisisincontrasttobusinessapplica:onthatrequiresstronglanguagesupportforfilemanipula:on,tablelookup,reportgenera:on,etc.
• Oxenefficient
• Examplelanguages:Fortran,Algol.
Classification by dom
ain
![Page 11: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/11.jpg)
10
ClassifyingLanguagesbyDomain:Business
• Business(some:mesa.k.a.dataprocessing)– Languagefeaturesemphasizefilehandling,tablelookup,reportgenera:on,etc.
– Weaklanguagesupportformathfunc:ons,graphics,recursion,etc.
– Examplelanguage:COBOL(COmmonBusinessOrientedLanguage),ini:alversionin1960.
– Nowmostlyhandledbydatabasesystems,spreadsheets,etc.
Classification by dom
ain
![Page 12: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/12.jpg)
11
ClassifyingLanguagesbyDomain:Ar:ficialIntelligence
• Highlevelofabstrac:onforsymbolmanipula:on,ratherthannumericcomputa:on
– Symbolicmanipula:on:symbols,consis:ngofnamesratherthannumbers,arecomputed
– Linkedlists(oxenbuilt-in)ratherthanarray,declara:ve,recursionratherthanloop,self-modifica:on,etc.
• Oxen(very)high-level,inefficient
• Examplelanguages:– Lisp(LIStProcessing),Scheme,ML,Miranda,etc.
– Prolog(Frenchfor“logicprogramming”),etc.
Classification by dom
ain
![Page 13: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/13.jpg)
12
ClassifyingLanguagesbyDomain:Systems
• Languagesforsystemsoxware– Systemsoxwareincludesopera:ngsystemsandprogrammingsupporttools.
• Languagesupportforhardwareinterface,opera:ngsystemcalls,directmemory/deviceaccess,etc.
• LiWleornodirectsupportforprogrammerdefinedabstrac:on,complextypes,symbolmanipula:on
• Low-level,veryefficient
• Veryfewrestric:onsonprogrammer(accesstoeverything)
• Examplelanguages:C,Go– Lowlevel,efficient,fewsafetyrestric:ons.
Classification by dom
ain
![Page 14: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/14.jpg)
13
ClassifyingLanguagesbyDomain:Scrip:ng
• Scrip:ng:connec:ngdiversepre-exis:ngcomponentstoaccomplishanewrelatedtask.
• Ini:allydesignedfor"scrip:ng"theopera:onsofacomputer.– Earlyscriptlanguageswereoxencalledbatchlanguagesorjobcontrollanguages(ShellScript),suchas.bat,csh.
rmA3Scanner.*A3Parser.*A3User.classA3Symbol.*A3.outputjavaJLex.MainA3.lexjavajava_cup.Main-parserA3Parser-symbolsA3Symbol<A3.cupjavacA3.lex.javaA3Parser.javaA3Symbol.javaA3User.javajavaA3UsermoreA3.output
– Ascriptismoreusuallyinterpretedthancompiled,butnotalways.
Classification by dom
ain
![Page 15: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/15.jpg)
14
Scrip:nglanguage(2)
• Nowscrip:nglanguagescanbequitesophis:cated,beyondautoma:ngcomputertasks;
– JavaScript,PHP:Webprogramming;
– Perl:textprocessing,butlaterdevelopedintoageneralpurposelanguages;
• Characteris:cs:– Favorrapiddevelopmentoverefficiencyofexecu:on;
– Oxenimplementedwithinterpretersratherthancompilers;
– Strongatcommunica:onwithprogramcomponentswriWeninotherlanguages.
Classification by dom
ain
![Page 16: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/16.jpg)
15
XML-basedlanguages
• Languagesthat– OperateonXMLdocuments
– UsuallythesyntaxofthelanguageisXML
• Examples– XPath– XQuery– XSLT
Classification by dom
ain
![Page 17: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/17.jpg)
16
ClassifyingLanguagesbyGenerality
• GeneralPurpose– Languageswithfeaturesthatallowimplementa:onofvirtuallyanyalgorithm
– Roughlyuniformlevelofabstrac:onoverlanguagefeatures
– C,C++,Java,Delphi,etc.,etc.,etc.
• SpecialPurpose– Languageswithaveryrestrictedsetoffeatures– Highlevelofabstrac:onamongfeatures
– SQL,MATLAB,R,lex/yacc(JLex/JavaCup),etc.etc.
Classification by generality
![Page 18: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/18.jpg)
17
MATLAB
• Matrixmanipula:on
• Plo|ng
• Widelyusedbyengineersandappliedsta:s:cians
• Examplex=1:10;
y=x.^2
plot(y)
• No:cethereisnoexplicitloop!
Classification by generality
![Page 19: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/19.jpg)
18
figure
[X,Y]=meshgrid(-8:.5:8);
R=sqrt(X.^2+Y.^2)+eps;
Z=sin(R)./R;mesh(X,Y,Z)
![Page 20: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/20.jpg)
19
Classifyinglanguagesbyimplementa:onmethods
• Compila:on:transla:nghigh-levelprogram(sourcelanguage)intomachinecode(machinelanguage)
– Slowtransla:on,fastexecu:on
• PureInterpreta:on:Programsareinterpretedbyanotherprogramknownasaninterpreter
– Ittakeslongertorunaprogramunderaninterpreterthantorunthecompiledcode.
• HybridImplementa:onSystems– Acompromisebetweencompilersandpureinterpreters
Classification by im
plementation m
ethods
![Page 21: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/21.jpg)
20
Compilation and execution
Output Data Input Data
Target Program
Abstract Program (Optimized)
Parse Tree Symbol Table
Source program
Code Optimization
Semantic Analysis
Loader / Linker Code Generation
Computer
Lexical Analysis (scanning)
Syntactic Analysis (parsing)
compiler
Token Sequence
Abstract Program (Intermediate code)
Object Program (Native Code)
Classification by im
plementation m
ethods
![Page 22: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/22.jpg)
21
Implementa:onmethods:Compila:on
• Compila:onprocesshasseveralphases:– Lexicalanalysis:convertscharactersinthesourceprogramintolexicalunits
– Syntaxanalysis:transformslexicalunitsintoparsetreeswhichrepresentthesyntac:cstructureofprogram
– SemanDcsanalysis:checktypesetc;generateintermediatecode
– CodegeneraDon:machinecodeisgenerated
• Addi:onalCompila:onTerminologies– Linkingandloading:Whenloadingcompiledprogramsintocomputermemory,theyarelinkedtotherelevantprogramresources,andthenthefullyresolvedcodesareintocomputermemory,forexecu:on.
Classification by im
plementation m
ethods
![Page 23: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/23.jpg)
22
Runjava-verbosesol:~/440>java-verboseHello
[Opened/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Opened/usr/jdk/instances/jdk1.5.0/jre/lib/jsse.jar]
[Opened/usr/jdk/instances/jdk1.5.0/jre/lib/jce.jar]
[Opened/usr/jdk/instances/jdk1.5.0/jre/lib/charsets.jar]
[Loadedjava.lang.Objectfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.io.Serializablefrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.Comparablefrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.CharSequencefrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.Stringfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.reflect.GenericDeclara:onfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.reflect.Typefrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.reflect.AnnotatedElementfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.Classfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.Cloneablefrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.ClassLoaderfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.Systemfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
…(hundredsofrelatedclasses)
[LoadedHellofromfile:/global/fac2/jlu/440/]
Hello
[Loadedjava.lang.Shutdownfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
[Loadedjava.lang.Shutdown$Lockfrom/usr/jdk/instances/jdk1.5.0/jre/lib/rt.jar]
public class Hello { public static void main(String [] a){ System.out.println("Hello"); } }
Classification by im
plementation m
ethods
![Page 24: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/24.jpg)
23
Interpretedlanguage
• Programsareexecutedfromsourceform,byaninterpreter.– manylanguageshavebothcompilersandinterpreters,includingLisp,Scheme,BASIC,andPython.
• Disadvantages:– Muchslower
– Real:metransla:on;– Ini:ally,interpretedlanguageswerecompiledline-by-line;eachlinewas
compiledasitwasabouttobeexecuted,andifalooporsubrou:necausedcertainlinestobeexecutedmul:ple:mes,theywouldberecompiledevery:me.
– Requiremorespace.– Sourcecode,symboltable,…
• Advantageofinterpretedlanguages– Easyimplementa:onofsource-leveldebuggingopera:ons,becauserun-:meerrorscanrefertosource-levelunits
– E.g.,ifanarrayindexisoutofrange,theerrormessagecaneasilyindicatethesourcelineandthenameofthearray.
– Itcantakeless:metointerpretitthanthetotal:merequiredtocompileandrunit.Thisisespeciallyimportantwhenprototypingandtes:ngcodewhenanedit-interpret-debugcyclecanoxenbemuchshorterthananedit-compile-run-debugcycle.(e.g.,csh)
Classification by im
plementation m
ethods
![Page 25: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/25.jpg)
24
Hybridimplementa:on
• Acompromisebetweencompilersandpureinterpreters
– Translatehigh-levellanguageprogramintointermediatelanguagedesignedtoalloweasyinterpreta:on;
– Fasterthanpureinterpreta:onsincethesourceistranslatedonlyonce.
– Example:Java.– Providesportabilitytoanymachinethat
supporttheintermediatelanguage
– Otherlanguagethatuseshybridimplementa:on?
• Canwemakeitfaster?– JIT(Just-In-Time)compiler
Classification by im
plementation m
ethods
![Page 26: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/26.jpg)
25
JITcompiler
• Ajust-in-:mecompiler(JIT)improvesperformanceofbytecodesbycompilingthemintona:vemachinecodebeforeexecu:ngthem.
– Translatesbytecodes(orotherintermediatecode)intomachineinstruc:onsastheyarereadin;
– Performsadegreeofop:miza:on;
– Theresul:ngprogramisthenrun;
– Partsoftheprogramthatdon'texecutearen'tcompiled,soaJITdoesn'twaste:meop:mizingcodethatneverruns.
– Themachineinstruc:onsaren'tsavedanywhereexceptinmemory.Thenext:metheprogramisrun,thebytecodesaretranslatedintomachinecodeonceagain.– Theresultisthatthebytecodesares:llportable,– andtheytypicallyrunmuchfasterthantheywouldinanormalinterpreter.
• IntroducedinSunJRE1.2
Classification by im
plementation m
ethods
![Page 27: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/27.jpg)
26
Review
• Classifyinglanguagesby– Abstrac:onlevel(lowlevel,highlevel,veryhighlevel)– Domain(scien:fic,dataprocessing,scrip:ng…)
– Generalpurposevs.specialpurpose– Implementa:onmethods(interpreter,compiler,hybrid)
– compila:onprocess
– ……– Paradigms
• “languageshapesthewaywethink,anddetermineswhatwecanthinkabout.“–B.L.Whorf
![Page 28: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/28.jpg)
27
ProgrammingParadigms
• Astyleofprogramming
• Aprogrammingparadigmprovidestheviewthattheprogrammerhasoftheexecu:onoftheprogram.
– Object-orientedprogramming:programmersthinkofaprogramasacollec:onofinterac:ngobjects;
– Func:onalprogramming:aprogramcanbethoughtofasasequenceofstatelessfunc:onevalua:ons.
• Manyprogrammingparadigmsareaswell-knownforwhattechniquestheyforbidasforwhattheyenable.
– Purefunc:onalprogrammingdisallowstheuseofside-effects;
– Structuredprogrammingdisallowstheuseofgoto.
Classification by paradigm
s
![Page 29: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/29.jpg)
28
Paradigmsandlanguages• Somelanguagesaredesignedtosupportonepar:cularparadigm
– Smalltalksupportsobject-orientedprogramming– Schemesupportsfunc:onalprogramming.
• Aprogramminglanguagecansupportmul:pleparadigms.– E.g.,Javaisdesignedtosupportimpera:veprogramming,object-orientedprogramming,andgenericprogramming.
• Aprogramminglanguageadvocates(notenforce)aparadigm(s).– Programmersdecidehowtobuildaprogramusingthoseparadigmelements.– E.g.,onecanwriteapurelyimpera:veprograminJava(notencouraged)– ThefollowingsareunstructuredandstructuredprogramwriWeninthesamelanguage
dim i for i = 1 to 10 print i & " squared = " & square(i) next print "Program Completed." function square(i) square = i * i end function
10 dim i 20 i = 0 30 i = i + 1 40 if i <> 10 then goto 90 50 if i = 10 then goto 70 60 goto 30 70 print "Program Completed." 80 end 90 print i & " squared = " & i * i 100 goto 30
Classification by paradigm
s
paradigms languages
![Page 30: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/30.jpg)
29
Exampleparadigms
• Structuredprogrammingvs.Unstructuredprogramming
• Impera:veprogrammingvs.Declara:veprogramming
• Object-orientedprogramming
• AspectOrientedProgramming
• Func:onalprogramming
• Logicprogramming
• Serviceorientedprogramming
Classification by paradigm
s
![Page 31: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/31.jpg)
30
Someprogrammingparadigms• Impera:ve:
– howdowesolveaproblem(whatstepsdoesasolu:onhave)?
• Logic-based:– whatistheproblemtobesolved?(Thelanguageimplementa:ondecideshowtodoit.)
• Func:onal:– whatsimpleopera=ons(func=ons)canbeappliedtosolveaproblem,howaretheymutuallyrelated,andhowcantheybecombined?
• Object-oriented:– Whatobjectsplayrolesinaproblem,whatcantheydo,andhowdotheyinteracttosolvetheproblem?
• Aspect-oriented:– Whataretheconcernsandcrosscu|ngconcerns?Howtoallowtheconcernsinteractwitheachother?
Classification by program
ming paradigm
s
![Page 32: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/32.jpg)
31
Structuredvs.unstructuredprogramming• Unstructuredprogramming:Allcodeiscontainedinasinglecon:nuousblock.
– Havetorelyonexecu:onflowstatementssuchasGoto,usedinmanylanguagestojumptoaspecifiedsec:onofcode.
– Complexandtangled,difficulttoreadanddebug;– Unstructuredprogrammingresultsinspaghe|code– Discouragedinprogramminglanguagesthatsupportanykindofstructure.
• anexampleSpaghe|codeinBASIC:10dimi20i=030i=i+140ifi<>10thengoto9050ifi=10thengoto7060goto3070print"ProgramCompleted."80end90printi&"squared="&i*i100goto30
Classification by program
ming paradigm
s
![Page 33: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/33.jpg)
32
Structuredvs.unstructured• Structuredprogramming:
– Programma:ctasksaresplitintosmallersec:ons(knownasfunc:onsorsubrou:nes)thatcanbecalledwhenevertheyarerequired.
– RemoveGOTOstatements;– Singleentry(andsingleexit)foreachprogramsec:on.
• Consider:– IsJavaastructuredprogramminglanguage?– ComparedwithC++,whichoneismorestructured?
• HereisanexampleSpaghe|codeandstructuredcodeinBASIC:
10dimi20i=030i=i+140ifi<>10thengoto9050ifi=10thengoto7060goto3070print"ProgramCompleted."80end90printi&"squared="&i*i100goto30
• Canweturnallunstructuredcodetostructuredone?
dimifori=1to10printi&"squared="&square(i)nextprint"ProgramCompleted."func:onsquare(i)square=i*iendfunc:on
Classification by program
ming paradigm
s
![Page 34: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/34.jpg)
33
Structuredprogramming• Structuredprogramtheorem
• Anyprogramcanbegoto-free(1966,BöhmandJacopini,CACM)– anyprogramwithgotoscouldbetransformedintoagoto-freeforminvolvingonly– Sequen:alcomposi:on– choice(IFTHENELSE)and– loops(WHILEcondi:onDOxxx),– possiblywithduplicatedcodeand/ortheaddi:onofBooleanvariables(true/false
flags).
C
S
Y N S2
C
S1
Y N
S1 S2
Classification by program
ming paradigm
s
![Page 35: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/35.jpg)
34
Impera:vevs.declara:ve• Impera:ve:aprogrammingparadigmthatdescribescomputa:onintermsofaprogramstateandstatementsthatchangetheprogramstate.
– Inmuchthesamewayastheimpera:vemoodinnaturallanguagesexpressescommandstotakeac:on,impera:veprogramsareasequenceofcommandsforthecomputertoperform.
– DerivedfromVonNeumannmachine– Acomputerfunc:onsbyexecu:ngsimpleinstruc:onsoneaxeranother– Impera:velanguagesmirrorthisbehaviourataslightlyhigherlevelofabstrac:onfrommachine:– theprogrammerspecifiesopera:onstobeexecutedandspecifiestheorderof
execu:ontosolveaproblem– theimpera:velanguageopera:onsarethemselvesjustabstrac:onsofsome
sequenceoflower-levelmachineinstruc:ons– Programmermusts:lldescribeindetailhowaproblemistobesolved(i.e.,allofthestepsinvolvedinsolvingtheproblem)
• Mostofthelanguagesweusesupportimpera:veparadigm,whichincludeassembly,Fortran,Algol,Ada,Pascal,C,C++,etc.,etc.
Classification by program
ming paradigm
s
![Page 36: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/36.jpg)
35
Impera:vevs.declara:ve
• Aprogramis"declara:ve"ifitdescribeswhatsomethingis,ratherthanhowtocreateit.
– Impera:veprogramsmakethealgorithmexplicitandleavethegoalimplicit;
– Declara:veprogramsmakethegoalexplicitandleavethealgorithmimplicit.
• Examplesofdeclara:velanguages:– Func:onalprogramminglanguages,Logicprogramminglanguages,SQL.
• Twomajordifferencesbetweenimpera:veanddeclara:veprogramming:– Assignmentstatement;
– Orderofexecu:on.
Classification by program
ming paradigm
s
![Page 37: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/37.jpg)
36
Declara:vevs.Impera:ve:Assignment
• Impera:velanguage:– basedontheconceptofvariablesnameswhichcanbeassociatedwithchangeablevaluesthroughexpressions.
– differentvaluesarecon:nuallyassociatedwithapar:cularvariablenameisreferredtoasdestruc:veassignment-eachfreshassignmentobliteratestheexis:ngvalue.
• Declara:velanguage:– variablescanonlyeverhaveonevalue"assigned"tothemandthisvaluecannotbealteredduringaprogram'sexecu:on.
– Werefertothisasnon-destruc:veassignment.
• Codenotallowedindeclara:veprogramming:IntX=10;…X=11;
Classification by program
ming paradigm
s
![Page 38: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/38.jpg)
37
Declara:vevs.impera:ve:orderofexecu:on
• Impera:velanguage:– Valueofavariablecanbechanged;– orderofexecu:oniscrucial.– Avariable'svaluemaybechangedbeforethatvariableisusedinthenextexpression,i.e.impera:veexpressionshavesideeffects.
– commandscanonlybeunderstoodinthecontextofthepreviouscomputa:on.
• Declara:velanguage– Thevaluesassociatedwithvariablenamescannotbechanged.– theorderinwhichdefini:onsarecalleddoesnotmaWer,i.e.theyareorderindependent.– declara:vedefini:onsdonotpermitsideeffects,i.e.thecomputa:onofonevaluewillnoteffectsomeothervalue.
– declara:veprogramsmustbeexecutedinsomeorder,buttheordershouldnotaffectthefinalresult.
– programstatementsareindependentofthecomputa:onalcontext.
• Examplex=f(y)+f(y)*f(y);èz=f(y);x=z+z*z;
Classification by program
ming paradigm
s
![Page 39: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/39.jpg)
38
Exampleofimpera:veanddeclara:veprogramming
voidinser:onSort(int[]A){intj;for(inti=1;i<A.length;i++){inta=A[i];for(j=i-1;j>=0&&A[j]>a;j--)A[j+1]=A[j];A[j+1]=a;}
}
fun insertsort [] = [] | insertsort (x::xs) = let fun insert (x:real, []) = [x] | insert (x:real, y::ys) = if x<=y then x::y::ys else y::insert(x, ys) in insert(x, insertsort xs) end;
• Declarative programming: • Declare what to do, but not how to do it; • Don’t change values of variables; • No loop constructs; • Execution sequence is not specified.
Classification by paradigm
s
![Page 40: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/40.jpg)
39
Func:onalprogramming
• Aproblemissolvedastheevalua:onofafunc:on– Aprogramconsistsofasetoffunc:ondefini:ons,whereafunc:onissimplyamappingfromelementsofonesettoelementsofanotherset
– Programexecu:onconsistsofevalua:ngatop-levelfunc:on(i.e.,applyingafunc:ontospecifiedelementsofaset)
– Thelanguageitselfisthefunc:onevaluator;theevalua:onmechanismisnotvisibletotheprogrammer(majorproceduralabstrac=on!)
– Novariables,noassignment
– “everythingisafunc:on”– canapplyfunc:onstofunc:onstoo!
• Lisp,Scheme,CommonLisp,ML,CAML,Haskell
Classification by program
ming paradigm
s
![Page 41: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/41.jpg)
40
Func:onalprogramming
• Trulydifferentfromimpera:velanguages:– Cannotassignvaluestovariablesorchangeavariable’svalue;– Noloopconstruct;– Orderofexecu:onofstatementssupposedtobeirrelevant(andunknown)
funinsertsort[]=[]|insertsort(x::xs)=letfuninsert(x:real,[])=[x]|insert(x:real,y::ys)=ifx<=ythenx::y::yselsey::insert(x,ys)ininsert(x,insertsortxs)end;
Classification by paradigm
s
![Page 42: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/42.jpg)
41
Declara:veprogrammingexample:SQL• Considerthefollowingquery:
– customers(id,name,phone)– Orders(o-id,c-id,product,price,date)
SELECTproduct,price,dateFROMcustomers,ordersWHEREcustomers.id=orders.c-idAND customers.name=“john”
• Itdeclareswhatwewant.Doesnotspecifyhowtoimplementit.
– e.g.whichcondi:ontorunfirst?• Therearemanydifferentwaystoimplement.
– Anaïveonewouldbeveryexpensive(constructtheCartesianproductofthetwotables,jointwoidsfirst)wouldbeveryexpensive;
• Queryengine(compiler)willtakecareoftheseimplementa:onissue.
• Conclusions:– Declara:veprogrammingfocusonhigherlevelofabstrac:on;
– Itismoredifficulttoimplement.
id name phone 123 Mike 2533000
124 john 2345678
125 Vivian 123 4567
O-id C-id product price Date
01 123 Coke 1.00 06-01-11
02 124 water 6 06-01-02
03 123 juice 4 06-01-03
04 125 milk 3.8 06-01-01
id name Phone O-id C-id Product price date
123 Mike 2533000 01 123 Coke 1.00 ..
123 Mike 2533000 03 123 Juice 4 ..
124 john 2345678 02 124 Water 6 ..
125 Vivian 123 4567 04 125 Wilk 3.8 ..
Classification by program
ming paradigm
s
![Page 43: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/43.jpg)
42
Logicprogramming
• Aproblemissolvedbysta:ngtheproblemintermsoflogic(usuallyfirst-orderlogic,a.k.a.predicatecalculus)
– aprogramconsistsofknownfactsoftheproblemstateaswellasrulesforcombiningfacts(andpossiblyotherrules)
– programexecu:onconsistsofconstruc:ngaresolu=onproofofastatedproposi:on(calledthegoal)
– Atheoremproverisbuilt-intothelanguageandisnotvisibletotheprogrammer(majorproceduralabstrac=on!)
• Prolog,Datalog
Classification by program
ming paradigm
s
![Page 44: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/44.jpg)
43
Prolog
• Trulydifferentfromimpera:velanguages– Cannotassignvaluestovariablesorchangeavariable’svalue;– Noloopconstruct;– Orderofexecu:onofstatementssupposedtobeirrelevant(andunknown),theore:cally.
isort([],[]).isort([X|UnSorted],AllSorted):-isort(UnSorted,Sorted),insert(X,Sorted,AllSorted).insert(X,[],[X]).insert(X,[Y|L],[X,Y|L]):-X=<Y.insert(X,[Y|L],[Y|IL]):-X>Y,insert(X,L,IL).
Classification by paradigm
s
![Page 45: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/45.jpg)
44
ClassifyingLanguagesbyParadigm
• AllisaboutABSTRACTION• Aprogramconsistsofdataandprocedure.
• Thereareproceduralabstrac:onanddataabstrac:on• Controlinfunc:onal/logicparadigmsisabstractedtothepointofnonexistence
• InOOyous:llhaveloops,func:ons(methods),blocksofsequen:alcodeinwhichorderofexecu:onmaWers,etc.
object-oriented
functional; logic-based
imperative
mor
e pr
oced
ural
abs
tract
ion
more data abstraction
Classification by program
ming paradigm
s
![Page 46: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/46.jpg)
45
Object-Orientedprogramming• Programiscomposedofacollec:onofindividualunits,orobjects,thatactoneachother,
– Tradi:onal(impera:ve)view:aprogramisalistofinstruc:onstothecomputer.
• Objectsasaprogrammingen::eswerefirstintroducedinSimula67,aprogramminglanguagedesignedformakingsimula:ons.
• TheSmalltalklanguage,whichwasdevelopedatXeroxPARC,introducedthetermObject-orientedprogrammingtorepresentthepervasiveuseofobjectsandmessagesasthebasisforthecomputa:on.
• Aproblemissolvedbyspecifyingobjectsinvolvedintheproblem– ObjectsinOOcorrespondroughlytoreal-worldobjectsintheproblem– Objectsareinstancesofclasses(abstractdatatypes)– Classesarearrangedinhierarchies,withsubclassesinheri:ngproper:esofsuperclasses– Opera:ons(calledmethods)aredefinedspecifictoeachclass– Problemsolvingisaccomplishedthroughmessagepassingbetweenobjects(amessageisacalltoamethodofaspecificobject)
• OOlanguages:Simula,Smalltalk,C++,Java,C#etc.
Classification by program
ming paradigm
s
![Page 47: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/47.jpg)
46
Paradigms:Aspect-OrientedProgramming
• Alessgeneralsolu:on– AspectOrientedprogramminglanguageshouldbeusedtogetherwithotherlanguages;
– Baselanguagedefinesfunc:onality– AOPdescribescrosscu|ngconcerns.
• Simpleandpowerful
• Becamepopularandwide-spread
• Manyapproaches,manyimplementa:ons
• AlsocalledAOSD,Aspect-OrientedSoxwareDevelopment
• Mostfamous:AspectJ
Classification by program
ming paradigm
s
![Page 48: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/48.jpg)
Programminglanguagehistory
Createdbywordle.net,fromthetextinthisslide
![Page 49: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/49.jpg)
48
![Page 50: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/50.jpg)
03-60-440:Programminglanguagehistory
Tower of Babel, CACM cover, Jan. 1961
Babel: 1. a city in Shinar where the
building of a tower is held in Genesis to have been halted by the confusion of tongues
2. a confusion of sounds or voices
3. a scene of noise or confusion
--Webster
![Page 51: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/51.jpg)
50
Evolu:onofprogramminglanguages
Imperative Functional
![Page 52: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/52.jpg)
-10 -8 -6 -4 -2 0 2 4 6 8 10-10
-8
-6
-4
-2
0
2
4
6
8
10
JavaScript
Java
ObjectiveC
Python
RubyNone
PHP
C
HTML
Go
CSS
C++Swift
ShellC#
VimLCoffeeScript
Clojure
Scala
Emacs-Lisp
Perl
Lua
Haskell
Erlang
TeX
Rust
Makefile
Jupyter-Notebook
TypeScript
Groovy
ActionScript
ROCaml
Assembly
Elixir
PowerShell
Groff
Haxe
ApacheConf
XSLT
Processing
Julia
Objective-J
Kotlin
Common-Lisp
LiveScript
Eagle
Dart ObjectiveC++
Arduino
Nginx
Matlab
D
PostScript
Perl6
Scheme
Batchfile
F#
Vala
Pascal
XML
IDL
MoonScript
wisp
ModelicaYacc
NSIS
PLpgSQL
Racket
AGS-Script
SQLPL
Mirah
Awk
GLSL
FORTRAN
Mathematica
Nix
PigLatin
Protocol-Buffer
Vue
Nimrod CMake
Crystal
KiCad
PureBasic
Cuda
Frege
nesC
Stan
Elm
Arc
Handlebars
RedQML
51Relations between languages derived from GitHub user interactions. Generated by Zhongpei Zhang and Jianguo Lu
![Page 53: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/53.jpg)
52
FORTRAN(FormulaTranslator)
• Itisthefirsthighlevelprogramminglanguage– ThePreliminaryReport,1954,claimsthatFORTRANwillvirtuallyeliminatecodinganddebugging.
– DevelopedbyJohnBackus,atIBM.– Majorversions:FortranIIin1958,FortranIVin1961,Fortran77,Fortran95,Fortran2003(OOsupport).
• Ini:alversionsrelyheavilyonGOTOstatement;
• Itremainsthelanguageofchoiceforhighperformancenumericalcompu:nginscienceandengineeringcommuni:es
– Exampleapplica:ons:– Weatherandclimatemodeling,solarsystemdynamics,simula:onofautocrashes.
![Page 54: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/54.jpg)
53
ALGOL(ALGOrithmicLanguage)
• defactostandardwaytoreportalgorithmsinprint
• DesignedtoimproveFortran
• JohnBackusdevelopedtheBackusNaurFormmethodofdescribingprogramminglanguages.
• ALGOL60inspiredmanylanguagesthatfollowedit"ALGOL60wasagreatimprovementonitssuccessors.“Thefullquoteis"Hereisalanguagesofaraheadofits:me,thatitwasnotonlyanimprovementonitspredecessors,butalsoonnearlyallitssuccessors"--C.A.RHoare
procedureAbsmax(a)Size:(n,m)Result:(y)Subscripts:(i,k);valuen,m;arraya;integern,m,i,k;realy;commentTheabsolutegreatestelementofthematrixa,ofsizenbymistransferredtoy,andthesubscriptsofthis
elementtoiandk;beginintegerp,q;y:=0;i:=k:=1;forp:=1step1unDlndoforq:=1step1unDlmdoifabs(a[p,q])>ythenbeginy:=abs(a[p,q]);i:=p;k:=qendendAbsmax
![Page 55: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/55.jpg)
54
TheoriginofOOP:SimulaandSmalltalk
• Simula67:– Developedin1960’s,byOle-JohanDahl– Simula:onofcomplexsystems
– Introducedobjects,classes,andinheritance.
• Smalltalk:– DevelopedatXeroxPARC,ini:allybyAlanKay,in1970’s.– Firstfullimplementa:onofanobject-orientedlanguage(dataabstrac:on,inheritance,anddynamictypebinding)
– Pioneeredthegraphicaluserinterfacedesign– PromotedOOP
![Page 56: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/56.jpg)
55
Java(andcomparisonwithC++)
• DerivedfromC++.Smaller,simpler,andmorereliable– e.g.,nopointers,nomul:pleinheritance,automatedgarbagecollec:on.
• Designphilosophy– Javawascreatedtosupportnetworkingcompu:ng,embeddedsystems.
– C++wascreatedtoaddOOtoC.Supportsystemsprogramming.
• Versionhistory– 1.0:1996– 1.2:1998,IntroducedSwing,JIT– 1.4:2002,assert,regularexpression,XMLparsing
– 1.5(5):2004,generics,enumera:on
– 6:Dec2006webservicesupport(JAXWS)
– 7:July2011– 8:2014,lambdaexpression,higherorderfunc:ons
![Page 57: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/57.jpg)
56
JavaandC#
• ThesyntaxofbothlanguagesissimilartoC++,whichwasinturnderivedfromC.
• Bothlanguagesweredesignedtobeobjectorientedfromthegroundup;unlikeC++,theywerenotdesignedtobecompa:blewithC.
• Bothprovideparametricpolymorphismbygenericclasses.
• Bothlanguagesrelyonavirtualmachine.– BoththeJavaVMandthe.NETpla�ormop:mizecodeatrun:methroughjust-in-:mecompila:on(JIT).
• Bothincludegarbagecollec=on.• Bothincludeboxingandunboxingofprimi:vetypes,allowingnumberstobehandledasobjects.
• Bothincludeforeach,anenhancediterator-basedforloop.
![Page 58: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/58.jpg)
57
Foreachstatement:anexampleofabstrac:on
• Javaitera:on:tradi:onalway(before2004)Listnames=newArrayList();names.add("a");names.add("b");names.add("c");
for(Iteratorit=names.iterator();it.hasNext();){Stringname=(String)it.next();System.out.println(name.charAt(0));}
• Java1.5:for(Stringname:names)System.out.println(name.charAt(0));
• Newloopstructureismoredeclara:ve.
![Page 59: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/59.jpg)
58
XMLprogramming
• XPath• XQuery• XSLT• JSP• Webserviceprogramming
![Page 60: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/60.jpg)
59
IDE(IntegratedDevelopmentEnvironment)
• IDEforJava:Eclipse
![Page 61: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/61.jpg)
60
Turingaward(Nobelprizeincomputerscience)recipientsrelevanttothiscourse
Year Recipient Contribution to programming languages 1966 Alan Jay Perlis Compiler and Algol 1971 John McCarthy Lisp 1972 Edsger Dijkstra Algol, Structured programming 1977 John Backus Fortran, BNF 1980 C.A.R. Hoare Axiomatic semantics 1983 Ken Thompson and
Dennis M. Ritchie c and unix
1984 Niklaus Wirth Modula, PASCAL 2001 Ole-Johan Dahl and
Kristen Nygaard SIMULA, OO
2003 Alan Kay SMALLTALK, OO 2005 Peter Naur Algol, BNF
![Page 62: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/62.jpg)
Languagepopularityoveryears
61
• Measured by how often language tutorials are searched on Google. • This is the trend in USA. • You can get the trend of other languages from
http://pypl.github.io/PYPL.html?country=US
![Page 63: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/63.jpg)
Popularityworldwide
62
![Page 64: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/64.jpg)
63
Popularityofprogramminglanguages
• Fromlangpop.comSept2010.MeasuredfromGoogleCode.
![Page 65: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/65.jpg)
64
Popularityofprogramminglanguages
• Thisisachartshowingcombinedresultsfromalldatasets
![Page 66: “There are only two kinds of programming languages: those ...jlu.myweb.cs.uwindsor.ca/440/440classification2017.pdf · “There are only two kinds of programming languages: those](https://reader031.fdocuments.us/reader031/viewer/2022030407/5a8424f37f8b9afc5d8b695a/html5/thumbnails/66.jpg)
programmer
65