233

387 views
329 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
387
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

233

  1. 1. Exploring Programming ParadigmsThrough Educational ProgrammingLanguages DevelopmentDesigned and Developed byComputer Science BScSaturday, May 11, 13
  2. 2. Aims and objectivesAimTo develop a suite of experimental programminglanguages to support language coursesObjectivesImplement several languages to illustrate differentprogramming paradigms: Imperative, Procedure,OOP, Functional, PrototypeImplement languages in different techniques todemonstrate principles and implementations ofcompiler/interpreter which including: parsingtechniques, semantic translation, code generationand HLLVM.Saturday, May 11, 13
  3. 3. ProductsNya - A multi-paradigm script languageSukimoe - A tiny Scheme interpreterGhostree - A high level languagevirtual machineclass Nya {}hello = Nya.new;hello[“say”]= (name){print “Hello:”; print name;};hello.say;(define hello (lambda n (print n)))(hello “Hello World!”)// / |/ / / |/ / / |/ / / |/ / / |/ / |/ / / / |/ / / / / / |/ / / |/ / / | / / / / / |/ / / | / / / / / |********Saturday, May 11, 13
  4. 4. NyaProcedureSimilar to natural languagesOOPClass inheritancePolymorphismClass reopeni.will go unless it.rains;class Animal{def cry{print “Animal cry”;}}Class Dog << Animal{print cry{print “woof“;}}Class Cat << Animal{}Class Bird << Animal{}dog = Dog.newcat = Cat.newBird = Bird.new#Polymorphismdog.cry # ”woof”cat.cry # “Animal cry”bird.cry # “Animal cry”#Class reopenClass Cat {print cry{print “mew“;}}cat.cry # “mew”Saturday, May 11, 13
  5. 5. NyaPrototypeSlots accessingMessage dispatchingLambda expressionClosureDO NOT support lazy evaluationdef gen_hello(name){return (n){print “hello: ”;print name};}hello = gen_hello(“Nyaruko”);hello(); #”hello nNyaruko”bird[“@cry”] = “twitter”;bird[“cry”] = {print @cry};bird.cry(); # “twitter”bird.dummy(); # Run time errorSaturday, May 11, 13
  6. 6. Nya -ImplementationFront endCFG(LALR(1)) VS PEGStatic parsing VS Dynamic parsingBack endSyntax directed translationTop down interpretingProgramExpressions ExpressionLiteral CallAssign......Saturday, May 11, 13
  7. 7. SukimoeLanguage featuresPartial evaluation(Currying)Lazy evaluationImplementationPEGList-lisp style translation(define add (lambda x (lambda y (+x y))))(define add4 (add 4))(print (add4 1)) ;;;5(print (add4 1));;;(print add 4 1);;;(print lambda 4( +1 y));;;(print + 4 1)Saturday, May 11, 13
  8. 8. GhostreeStack based VMFancy assemblerComplete Compiler// |/ | // | / // | / // / | // | / // / | // | / // | / // / | / // / | / // | / // | / / `| / // | / + / / /| // | / / / / ^ // | / / / / / /******************ruby ghostree.rb fib.gt1st:12nd:2size:101 2 3 5 8 13 21 34 55Sourcecode2/3+10*2Assembler Byte code/ / / / | push 10push 2multiply...20InterpretingSaturday, May 11, 13
  9. 9. Conclusion and FutureworksConclusionA suite of teaching purpose programming languages have beenproduced. I believe they can make a decent programming languagecourse.A lot about academic research and software development processhave been learned.Improvements for NyaNative compilationType inferencingRuntime configurable grammarBetter error messagingSaturday, May 11, 13

×