kink: developing a programming language on the jvm
TRANSCRIPT
2010-08-28
Kink: developing a programming
language on the JVM
@miyakawa taku
What is Kink• A programming language on the JVM
• Hosted on Google Code
– http://code.google.com/p/kink-lang/
What kind of language
• Prototype-based
– No classes, only constructor methods
– Like Lua and JavaScript
• Functional (not purely)
– First-class lambda
– List processing methods
– Like Lisps, especially Scheme
Bank account example
&account = { %[ &INITIAL = 0 ]&BALANCE = INITIALvalue(
’balance’ : { BALANCE }’withdraw’ : { &BALANCE << BALANCE - __ }’deposit’ : { &BALANCE << BALANCE + __ }
)}&MY_ACCOUNT = account( 100 )MY_ACCOUNT.deposit( 32.5 )MY_ACCOUNT.balance.dump # => 132.5
Swing example
@use ’Java’@use_class ’javax.swing.JFrame’@use_class ’javax.swing.JButton’@use_class ’javax.swing.JOptionPane’&BUTTON = JButton.new( ’Push me’ )BUTTON.addActionListener {{
JOptionPane.showMessageDialog( null ’Pushed!’ )}}&FRAME = JFrame.new( "Swingin’" )FRAME.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE )FRAME.getContentPane.add( BUTTON )FRAME.packFRAME.setVisible( true )
Pros and cons• Pros: simple semantics/syntax
– No classes
– No semicolons and no commas
– Easy-to-write lambda: { * 2 }• Cons: VERY slow
– time tak(12, 6, 0)
JRuby 1.4 5 seconds
Kink 246 seconds
– But also JRuby WAS very slow
What is great about JRuby
• Performance
• Compatibility
– With MRI and POSIX
– Write many, run anywhere!
Developing a language on the JVM
• Good way to learn Java SE, JVM, and
programming
– Class loading
– Byte code generation
– Design patterns
• Write your language, it’s fun!