This document describes programming languages developed to illustrate different programming paradigms for educational purposes. It summarizes three languages created: Nya, a multi-paradigm scripting language; Sukimoe, a tiny Scheme interpreter; and Ghostree, a stack-based virtual machine with an assembler. Nya demonstrates imperative, object-oriented, functional, and prototype-based paradigms. Sukimoe focuses on partial evaluation and lazy evaluation. Ghostree includes a compiler and interpreter. The document concludes that the languages can support programming language education and proposes future improvements to Nya.
2. Aims and objectives
Aim
To develop a suite of experimental programming
languages to support language courses
Objectives
Implement several languages to illustrate different
programming paradigms: Imperative, Procedure,
OOP, Functional, Prototype
Implement languages in different techniques to
demonstrate principles and implementations of
compiler/interpreter which including: parsing
techniques, semantic translation, code generation
and HLLVM.
Saturday, May 11, 13
4. Nya
Procedure
Similar to natural languages
OOP
Class inheritance
Polymorphism
Class reopen
i.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.new
cat = Cat.new
Bird = Bird.new
#Polymorphism
dog.cry # ”woof”
cat.cry # “Animal cry”
bird.cry # “Animal cry”
#Class reopen
Class Cat {
print cry{
print “mew“;
}
}
cat.cry # “mew”
Saturday, May 11, 13
5. Nya
Prototype
Slots accessing
Message dispatching
Lambda expression
Closure
DO NOT support lazy evaluation
def 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 error
Saturday, May 11, 13
6. Nya -Implementation
Front end
CFG(LALR(1)) VS PEG
Static parsing VS Dynamic parsing
Back end
Syntax directed translation
Top down interpreting
Program
Expressions Expression
Literal CallAssign
......
Saturday, May 11, 13
7. Sukimoe
Language features
Partial evaluation(Currying)
Lazy evaluation
Implementation
PEG
List-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
9. Conclusion and Future
worksConclusion
A suite of teaching purpose programming languages have been
produced. I believe they can make a decent programming language
course.
A lot about academic research and software development process
have been learned.
Improvements for Nya
Native compilation
Type inferencing
Runtime configurable grammar
Better error messaging
Saturday, May 11, 13