How Not to Design a Scripting Language

How Not to Design a Scripting Language

Introduction How not to design a scripting language How not to Design a Scripting Language Paul Biggar Department of Computer Science and Statistics Trinity College Dublin StackOverflow London, 28th October, 2009 How not to Design a Scripting Language Paul Biggar PhD Dissertation Design and Implementation of an Ahead-of-time PHP Compiler phc (http://phpcompiler.org) Introduction How not to design a scripting language About me • PhD candidate, Trinity College Dublin • Topic: Compilers, optimizations, scripting languages. How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language About me • PhD candidate, Trinity College Dublin • Topic: Compilers, optimizations, scripting languages. PhD Dissertation Design and Implementation of an Ahead-of-time PHP Compiler phc (http://phpcompiler.org) How not to Design a Scripting Language Paul Biggar • Speed Introduction How not to design a scripting language How not to design a scripting language • Compilers • Scripting Languages How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language How not to design a scripting language • Compilers • Scripting Languages • Speed How not to Design a Scripting Language Paul Biggar Common Features: • Dynamic typing • Duck typing • Interpreted by default • FFI via C API Introduction How not to design a scripting language What is a scripting language? • Javascript • Lua • Perl • PHP • Python • Ruby How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language What is a scripting language? • Javascript • Lua • Perl • PHP • Python • Ruby Common Features: • Dynamic typing • Duck typing • Interpreted by default • FFI via C API How not to Design a Scripting Language Paul Biggar NOT THE DRAGON BOOK Engineering a Compiler by Cooper/Torczon Modern Compiler Implementation in X by Appel • Compilers: Not too hard, sometimes portable, optimizations • Just-in-time compilers: Very difficult, unportable, fast interpreter. Introduction How not to design a scripting language Language implementation • Interpreters: Easy, portable How not to Design a Scripting Language Paul Biggar • Just-in-time compilers: Very difficult, unportable, fast NOTinterpreter THE DRAGON. BOOK Engineering a Compiler by Cooper/Torczon Modern Compiler Implementation in X by Appel Introduction How not to design a scripting language Language implementation • Interpreters: Easy, portable • Compilers: Not too hard, sometimes portable, optimizations How not to Design a Scripting Language Paul Biggar • Just-in-time compilers: Very difficult, unportable, fast interpreter. Introduction How not to design a scripting language Language implementation • Interpreters: Easy, portable • Compilers: Not too hard, sometimes portable, optimizations NOT THE DRAGON BOOK Engineering a Compiler by Cooper/Torczon Modern Compiler Implementation in X by Appel How not to Design a Scripting Language Paul Biggar NOT THE DRAGON BOOK Engineering a Compiler by Cooper/Torczon Modern Compiler Implementation in X by Appel Introduction How not to design a scripting language Language implementation • Interpreters: Easy, portable • Compilers: Not too hard, sometimes portable, optimizations • Just-in-time compilers: Very difficult, unportable, fast interpreter. How not to Design a Scripting Language Paul Biggar 1 Elegant and well designed, 2 High level of abstraction, 3 Dynamic typing (and duck typing). Introduction How not to design a scripting language What’s right with scripting languages? How not to Design a Scripting Language Paul Biggar 2 High level of abstraction, 3 Dynamic typing (and duck typing). Introduction How not to design a scripting language What’s right with scripting languages? 1 Elegant and well designed, How not to Design a Scripting Language Paul Biggar 3 Dynamic typing (and duck typing). Introduction How not to design a scripting language What’s right with scripting languages? 1 Elegant and well designed, 2 High level of abstraction, How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language What’s right with scripting languages? 1 Elegant and well designed, 2 High level of abstraction, 3 Dynamic typing (and duck typing). How not to Design a Scripting Language Paul Biggar Problem: Language designed for one interpreters specific interpreter • Run-time source code execution • Foreign Function Interface Introduction How not to design a scripting language What’s wrong with scripting languages? Symptoms: Speed, Portability How not to Design a Scripting Language Paul Biggar Problem: Language designed for one specific interpreter • Foreign Function Interface Introduction How not to design a scripting language What’s wrong with scripting languages? Symptoms: Speed, Portability Problem: Language designed for interpreters • Run-time source code execution How not to Design a Scripting Language Paul Biggar Problem: Language designed for interpreters Introduction How not to design a scripting language What’s wrong with scripting languages? Symptoms: Speed, Portability Problem: Language designed for one specific interpreter • Run-time source code execution • Foreign Function Interface How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language FFI FFI Foreign Function Interface based on CPython interpreter • Access to C libraries • Script C applications using Python scripts • Rewrite hot code in C How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language FFI FFI (good) implications • Libraries not that slow • Can break out of Python for slow code. How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language FFI FFI (bad) implications • Language is allowed to be slow • Must break out of Python for speed. How not to Design a Scripting Language Paul Biggar • Reimplementations Introduction How not to design a scripting language FFI FFI (worse) implications • Legacy issues How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language FFI FFI (worse) implications • Legacy issues • Reimplementations How not to Design a Scripting Language Paul Biggar • Only one way of FFI is better • Declarative is best • Any reimplementation can reuse the same libraries without any modifications • CPython itself can change without hassle Introduction How not to design a scripting language FFI FFI solution Don’t expose yourself! • Importing functions into Python with a Domain Specific Language is good How not to Design a Scripting Language Paul Biggar • Declarative is best • Any reimplementation can reuse the same libraries without any modifications • CPython itself can change without hassle Introduction How not to design a scripting language FFI FFI solution Don’t expose yourself! • Importing functions into Python with a Domain Specific Language is good • Only one way of FFI is better How not to Design a Scripting Language Paul Biggar • Any reimplementation can reuse the same libraries without any modifications • CPython itself can change without hassle Introduction How not to design a scripting language FFI FFI solution Don’t expose yourself! • Importing functions into Python with a Domain Specific Language is good • Only one way of FFI is better • Declarative is best How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language FFI FFI solution Don’t expose yourself! • Importing functions into Python with a Domain Specific Language is good • Only one way of FFI is better • Declarative is best • Any reimplementation can reuse the same libraries without any modifications • CPython itself can change without hassle How not to Design a Scripting Language Paul Biggar eval (mysql_read (...)[0]); username="myname" $langpassword= ....="mypass; " includeserver="(srv.domain.com"localisation/locale." $lang.php"); • meta-programming • .rc files • localization Introduction How not to design a scripting language Compiled and interpreted models Dynamic source code generation • eval and dynamic include/import How not to Design a Scripting Language Paul Biggar username="myname" $langpassword= ....="mypass; " includeserver="(srv.domain.com"localisation/locale." $lang.php"); • .rc files • localization Introduction How not to design a scripting language Compiled and interpreted models Dynamic source code generation • eval and dynamic include/import • meta-programming eval (mysql_read (...)[0]); How not to Design a Scripting Language Paul Biggar $lang= ....; include ("localisation/locale.$lang.php"); eval (mysql_read (...)[0]); • localization Introduction How not to design a scripting language Compiled and interpreted models Dynamic source code generation • eval and dynamic include/import • meta-programming • .rc files username="myname" password="mypass" server="srv.domain.com" How not to Design a Scripting Language Paul Biggar eval (mysql_read (...)[0]); username="myname" password="mypass" server="srv.domain.com" Introduction How not to design a scripting language Compiled and interpreted models Dynamic source code generation • eval and dynamic include/import • meta-programming • .rc files • localization $lang= ....; include ("localisation/locale.$lang.php"); How not to Design a Scripting Language Paul Biggar Introduction How not to design a scripting language Compiled and interpreted models Dynamic source code generation We don’t even know the full program source!! How not to Design a Scripting Language Paul

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    45 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us