Skip to content

gloryofrobots/childtalk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

childtalk

Simple Smalltalk dialect written in Java for self-educational reasons.

Project is not developing now.

Childtalk was my first completed interpreter. I tried to write it in clear and good style, but, as always, bugs and fixes do their job well.

Childtalk is based on Smalltalk YX. Actually parser and lexer are Java versions of Syx parser and lexer, but I added AST generation between parser and compiler, and built compiler around visitor pattern (it has very good explanation in Andrew Appel books). Also all runtime modules are totally different from Syx and even different from almost all smalltalk systems I studied. At first I wrote them like lisp system, but than I understood simple rule: your runtime structure must be very close to your language. So I have already changed a lot of code. Than I decided to rewrite everything everywhere. And at last I decided to leave Childtalk as this. However it was a funny month when I wrote Childtalk code and slept poorly.

FEATURES

  • Stackless. All methods and blocks run in serial queue.
  • Easy declarative syntax based on GNU Smalltalk
  • Many standart smalltalk features supported. You can read tests code and see what childtalk can do.
  • Working set of standart objects : SmallInteger, LargeInteger, Float, String, Symbol, Collection, Dictionary etc...
  • Simple code. Not ideal, and I am ashamed of some things. However may be it helps you to create your own

PROBLEMS AND FAILS

  • It`s slow. Very slow. I decided to completely ignore perfomance factor. So, sorry fo that.
  • Only fake green thread processes avalaible.
  • No filestream and stdiostream support.
  • Image creation based on Java serialization. I simply serialize image instances without optimisations.
  • Static initializers "initialize" for classes not called automatically.

Syntax example

Robot subclass: Destroyer [
    "I am comment"
    
    "Static variables"
    \controlCenter\

    "Instance variables"
    |rocketLauncher machineGun|
    
    "Static method"
   (+) new [
        ^ self new intialize.
    ]

    "Instance methods"
    initialize [
    	rocketLauncher := RocketLauncher new.
        machineGun := MachineGun new.
    ]

    destroy: aTarget [
    	"Temporary variable"
    	|counter|
        counter := 1000000000000000.
        1 to: counter do: [:i| 
                            rocketLauncher fireOn: aTarget withNumberOfRockets: i.
                            machineGun fireOn: aTarget].
    ]
]

"Extending of existed class"
Destroyer extend [
      version [
          ^ 'Destroyer 2.35'.
      ]
]

"Eval block"
Eval [
    "Eval has temporaries too. "
     |target|
     target := Human new.
     Destroyer new destroy: target.
]

About

Smalltalk dialect written in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published