KEMBAR78
Lua vs python | PPT
P ytho n vs L ua




                   S K p la ne t
                       신호철
Background
Script for making Applications


 Background
 - The complexity of applications increased extremely.
 - Applications need to be applied large-scale refactoring.


 What can the script do ?
 - Can reduce code-size and increase maintainability.
 - Make it easy to append new applications.
 - When the middleware layer is modified, the modification doesn’t propagate to the
   application layer.
   It’s limited to the script-engine layer.


 Candidate script languages
 - Lua, Python
Lua porting
What’s Lua

      Lua is Implemented and maintained by Tecgraf*1.


      Lua has used in many industrial applications
       such as Adobe’s Photoshop Lightroom.


      Lua is the leading scripting language in games.


      Lua is Embedded in games ( e.g. World of Warcraft ) and Ginga*2.




 : Tecgraf - http://www.tecgraf.puc-rio.br/
*1

 : Ginga brasil – 브라질향 데이터방송 규격
*2
Why Lua

      Lua is small
      - The source contains around 17,000 Lines of C.
      - All standard libraries take just 144K Bytes.


      Lua is powerful
      - Lua provides meta-mechanisms for implementing classes and inheritance.
      - Lua provides garbage collection.


      Lua is fast
      - Several benchmarks show Lua as the one of the fastest languages.


      Lua is portable & embeddable
      - Lua is definitely easy to be embedded with small footprint.


      Lua is free : MIT License*1
 : MIT License - http://ko.wikipedia.org/wiki/MIT_%EB%9D%BC%EC%9D%B4%EC%84%A0%EC%8A%A4
*1
Lua-Application Prototyping - 1/2

  We ported mobile Calculator into Lua


   - We implemented UI Wrapper functions which are required in Calculator.
     - GTK-related functions and Softkey functions.


   - Calculator Logic is implemented by Lua script.
     - Main functions which is needed in 4 fundamental rules of Arithmetic are ported now.


   - The prototype of Lua-Calculator is successfully ported in our mobile platform.
Lua-Application Prototyping - 2/2

  GTK mapping
   - Wrapper functions are implemented.
     - makeWindow, makeButton, makeLabel,
       setLabel, makeSoftkey.


  Calculator Logic
   - 190 Lines of Lua code.


  Calculator UI
   - 54 Lines of Lua code.


  Wrapper Code & Lua script

       Main.c Calc.lua
Python porting
What’s Python

 Released first by Guido van Rossum in 1991.


 Now managed by Python Software Foundation*1


 Embedded as a scripting language in these S/W products. *2
  - GIMP, gedit, Vim, Maya etc
  - In mobile domain, Python for s60*3


 Features a fully dynamic type, automatic memory management.




 *1
   : Python Software Foundation – Wikipedia, http://en.wikipedia.org/wiki/Python_Software_Foundation
 *2
   : Python-embedded S/W – Wikipedia, http://en.wikipedia.org/wiki/Python_software
 *3
   : Python for s60 – nokia.com http://wiki.opensource.nokia.com/projects/Python_for_S60
Why Python

 Highly Readable
     - Python uses whitespace indentation to delimit statement blocks.


 Powerful Standard Library
     - Python has a very large standard library.


 Powerful Glue Language
     - Python has the ability to use a lower-level language such as C/C++.
     - Python can easily attach new modules by using ctypes*1 or swig*2, etc.


 Free
     - Python Software Foundation License*3
      : Allows modifications to the source code and derivative works.
*1
  : Ctypes – http://www.python.org/doc/2.5/lib/module-ctypes.html
*2
  : Swig – http://www.swig.org
*3
  : Python Software Foundation License – http://en.wikipedia.org/wiki/Python_Software_Foundation_License
Python-Application Prototyping : Calculator

 To wrap gtk layer, we try to use PyGTK*1.

 platform-dependent functions such as Softkeys
  are not yet implemented by hand.


 Calculator UI : 114 Lines of python code
     - Example UI code :
                                          Y:funcalc.py




 : PyGTK : GTK wrapper for python - http://www.pygtk.org/
*1
Lua vs Python
Lua vs Python


                                             Lua                            Python
Binary size                                  about 200KB                    About 2MB
                                             (Lua version 5.1)              (Python version 2.6)
Memory usage                                                     Lua is more compact
Speed                                                               Lua is faster*1
Multi-threading                              Thread-safe                    Poor-quality
Standard Library                             Small & compact                Rich & powerful
Glue ability                                 Easy                           Normal




*1
     : see also Lua vs Python : CPU+Memory
What is the most suitable for mobile applications

  Lua is more compact and faster than Python. But Python is further
   powerful.
   - Python has lots of build-in modules and many open-source wrapper modules such as
     pyGtk.


  In case of mobile application which has abundant resources,
   Python is the most suitable for applications.
Appendix
Lua vs Python : CPU+Memory

 CPU + Memory Usage + Lines of Code.

Lua vs python

  • 1.
    P ytho nvs L ua S K p la ne t 신호철
  • 2.
  • 3.
    Script for makingApplications  Background - The complexity of applications increased extremely. - Applications need to be applied large-scale refactoring.  What can the script do ? - Can reduce code-size and increase maintainability. - Make it easy to append new applications. - When the middleware layer is modified, the modification doesn’t propagate to the application layer. It’s limited to the script-engine layer.  Candidate script languages - Lua, Python
  • 4.
  • 5.
    What’s Lua  Lua is Implemented and maintained by Tecgraf*1.  Lua has used in many industrial applications such as Adobe’s Photoshop Lightroom.  Lua is the leading scripting language in games.  Lua is Embedded in games ( e.g. World of Warcraft ) and Ginga*2. : Tecgraf - http://www.tecgraf.puc-rio.br/ *1 : Ginga brasil – 브라질향 데이터방송 규격 *2
  • 6.
    Why Lua  Lua is small - The source contains around 17,000 Lines of C. - All standard libraries take just 144K Bytes.  Lua is powerful - Lua provides meta-mechanisms for implementing classes and inheritance. - Lua provides garbage collection.  Lua is fast - Several benchmarks show Lua as the one of the fastest languages.  Lua is portable & embeddable - Lua is definitely easy to be embedded with small footprint.  Lua is free : MIT License*1 : MIT License - http://ko.wikipedia.org/wiki/MIT_%EB%9D%BC%EC%9D%B4%EC%84%A0%EC%8A%A4 *1
  • 7.
    Lua-Application Prototyping -1/2  We ported mobile Calculator into Lua - We implemented UI Wrapper functions which are required in Calculator. - GTK-related functions and Softkey functions. - Calculator Logic is implemented by Lua script. - Main functions which is needed in 4 fundamental rules of Arithmetic are ported now. - The prototype of Lua-Calculator is successfully ported in our mobile platform.
  • 8.
    Lua-Application Prototyping -2/2  GTK mapping - Wrapper functions are implemented. - makeWindow, makeButton, makeLabel, setLabel, makeSoftkey.  Calculator Logic - 190 Lines of Lua code.  Calculator UI - 54 Lines of Lua code.  Wrapper Code & Lua script Main.c Calc.lua
  • 9.
  • 10.
    What’s Python  Releasedfirst by Guido van Rossum in 1991.  Now managed by Python Software Foundation*1  Embedded as a scripting language in these S/W products. *2 - GIMP, gedit, Vim, Maya etc - In mobile domain, Python for s60*3  Features a fully dynamic type, automatic memory management. *1 : Python Software Foundation – Wikipedia, http://en.wikipedia.org/wiki/Python_Software_Foundation *2 : Python-embedded S/W – Wikipedia, http://en.wikipedia.org/wiki/Python_software *3 : Python for s60 – nokia.com http://wiki.opensource.nokia.com/projects/Python_for_S60
  • 11.
    Why Python  HighlyReadable - Python uses whitespace indentation to delimit statement blocks.  Powerful Standard Library - Python has a very large standard library.  Powerful Glue Language - Python has the ability to use a lower-level language such as C/C++. - Python can easily attach new modules by using ctypes*1 or swig*2, etc.  Free - Python Software Foundation License*3 : Allows modifications to the source code and derivative works. *1 : Ctypes – http://www.python.org/doc/2.5/lib/module-ctypes.html *2 : Swig – http://www.swig.org *3 : Python Software Foundation License – http://en.wikipedia.org/wiki/Python_Software_Foundation_License
  • 12.
    Python-Application Prototyping :Calculator  To wrap gtk layer, we try to use PyGTK*1.  platform-dependent functions such as Softkeys are not yet implemented by hand.  Calculator UI : 114 Lines of python code - Example UI code : Y:funcalc.py : PyGTK : GTK wrapper for python - http://www.pygtk.org/ *1
  • 13.
  • 14.
    Lua vs Python Lua Python Binary size about 200KB About 2MB (Lua version 5.1) (Python version 2.6) Memory usage Lua is more compact Speed Lua is faster*1 Multi-threading Thread-safe Poor-quality Standard Library Small & compact Rich & powerful Glue ability Easy Normal *1 : see also Lua vs Python : CPU+Memory
  • 15.
    What is themost suitable for mobile applications  Lua is more compact and faster than Python. But Python is further powerful. - Python has lots of build-in modules and many open-source wrapper modules such as pyGtk.  In case of mobile application which has abundant resources, Python is the most suitable for applications.
  • 16.
  • 17.
    Lua vs Python: CPU+Memory  CPU + Memory Usage + Lines of Code.

Editor's Notes

  • #15 Cpu & memory 에 대한 비교는 다음 사이트를 참고했음 http://dada.perl.it/shootout/craps_cpumem.html
  • #18 http://dada.perl.it/shootout/craps_cpumemloc.html