Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
doc:package:why_lisp [2015/05/08 16:18]
gkazhoya created
doc:package:why_lisp [2015/05/08 16:53] (current)
gkazhoya
Line 1: Line 1:
 ====== Why Lisp? ====== ====== Why Lisp? ======
 +
 +==== Advantages ====
  
 There is a number of reasons why Common Lisp was chosen as the language for CRAM. There is a number of reasons why Common Lisp was chosen as the language for CRAM.
  
 == Macros == == Macros ==
-Due to its powerful ​macros ​mechanism Lisp is known to be good for implementing ​other domain-specific languages. This characteristic was extensively used during the implementation of CRAM: a new reactive planning language CPL (CRAM Plan Language) was developed for CRAM. It is used for programming cognition-enabled control systems and is based on [[http://​citeseerx.ist.psu.edu/​viewdoc/​download?​doi=10.1.1.51.7438&​rep=rep1&​type=pdf|RPL]].+Due to its powerful ​macro mechanism Lisp is known to be good for implementing domain-specific ​programming ​languages. This characteristic was extensively used during the implementation of CRAM: a new reactive planning language CPL (CRAM Plan Language) was developed for CRAM. It is used for programming cognition-enabled control systems and is based on [[http://​citeseerx.ist.psu.edu/​viewdoc/​download?​doi=10.1.1.51.7438&​rep=rep1&​type=pdf|RPL]].
  
 == Code as first-class object == == Code as first-class object ==
-In Lisp, code is represented using standard data types. Thus, code can be assigned to a variable, code that was generated on the fly can be executed straight away, e.g., generated at run-time, using the powerful macros mechanism custom code can also be generated at compile time, and as any other data object code can be easily modified. That enables for automatic generation and transformation of robot plans.+In Lisp, code is represented using standard data types (it is, basically, a List). Thus, code can be assigned to a variable, it can be generated at run-time, i.e., code that was generated on the fly can be executed straight away, using the powerful macros mechanism custom code can also be generated at compile time, and as any other data object code can also be easily modified ​by other code. That enables for automatic generation and transformation of robot plans.
  
-== Symbols ​as first-class object == +== Symbol ​as first-class object == 
-Symbol is a built-in type in Lisp. In conventional programming languages symbolic data would usually be represented either as strings or enumerations,​ which both have their drawbacks. On the other hand, the existence of type "​symbol"​ makes Lisp prefect for representing and processing symbolic data, and, in combination with the macro mechanism, makes it convenient for writing symbolic reasoning systems. CRAM has a custom Prolog interpreter (also written in Lisp) that can perform logic reasoning and, as opposed to traditional Prolog, use specialized inference methods (based on math etc.) for the cases when logical inference has a too large of a search space.+Symbol is a built-in type in Lisp. In conventional programming languages symbolic data would usually be represented either as strings or enumerations,​ which both have their drawbacks. On the other hand, the existence of type "​symbol"​ makes Lisp prefect for representing and processing symbolic data, and, in combination with the macro mechanism, makes it convenient for writing symbolic reasoning systems. CRAM has a custom Prolog interpreter (also written in Lisp) that can perform logic reasoning and, in addition, as opposed to traditional Prolog, use specialized inference methods (based on math etc.) for the cases when logical inference has a too large of a search space.
  
 == Rapid prototyping == == Rapid prototyping ==
-Historically Lisp was an interpreted language. Although the implementation ​used in CRAM (Steel Bank Common Lisp) is fully compiled, Lisp is still very convenient for rapid prototyping. It has an interactive shell where new pieces of code can be immediately tested. It supports hot swapping: it is possible to make changes in a chunk of code and recompile it at run time and the changes will immediately take place, without having to stop the program execution.+Historically Lisp was an interpreted language. Although the compiler ​used in CRAM (Steel Bank Common Lisp) compiles every chunk of code unless explicitly asked to interpret it, Lisp is still very convenient for rapid prototyping. It has an interactive shell where new pieces of code can be immediately tested. It also supports hot swapping: it is possible to make changes in a chunk of code and recompile it at run time and the changes will immediately take place, without having to stop the program execution.
  
 == Expressiveness == == Expressiveness ==
-The last but not the least reason for choosing Common Lisp is that it is a very powerful and flexible language and is exciting ​to program with. In addition to supporting functional programming,​ it also has the advantages of the object-oriented programming languages, as it supports such concepts, as classes, multiple inheritance,​ function overloading etc. through Common Lisp Object System (CLOS), which is its built in facility.+The last but not the least reason for choosing Common Lisp is that it is a very powerful and flexible language and is fun to program with. In addition to supporting functional programming,​ it also has the advantages of the object-oriented programming languages, as it supports such concepts, as classes, multiple inheritance,​ function overloading etc. through Common Lisp Object System (CLOS), which is its built in facility.
  
-=== Efficiency concerns === +==== Efficiency concerns ​==== 
-In terms of efficiency Lisp is generally faster than many languages, such as Python or Ruby, but, slower than, for example, C++ or Java 6 (based on the benchmarks from http://​shootout.alioth.debian.org/​). However, CRAM runs on a robot in real-time and the robot usually has enough time to think about its future actions while performing current actions: physical execution of actions is in most cases slower than the computation. In addition, SBCL has many possibilities to improve code using the optimization declarations.+In terms of efficiency Lisp is generally faster than many languages, such as Python or Ruby, but, slower than, for example, C++ or Java 6 (based on the benchmarks from http://​shootout.alioth.debian.org/ ​by the time of writing). However, CRAM runs on a robot in real-time and the robot usually has enough time to think about its future actions while performing current actions: physical execution of actions is in most cases slower than the computation, so efficiency is not a major concern in CRAM. In addition, SBCL has many possibilities to improve code using the optimization declarations ​when really needed.
  
  
-=== Disadvantages of using Lisp ===+==== Disadvantages of using Lisp ====
  
 The choice of a programming language is, of course, always a trade-off of the advantages and disadvantages of using a certain language for a certain problem. Lisp for CRAM is not an exception. The choice of a programming language is, of course, always a trade-off of the advantages and disadvantages of using a certain language for a certain problem. Lisp for CRAM is not an exception.
Line 28: Line 30:
 One of the major problems with Lisp is that it is not widely accepted in the computer scientists community. Due to its functional programming nature it is really hard to get into for people that are used to the traditional imperative programming way of thinking. In the recent years though functional programming seems to finally be finding acceptance in the wider masses, so there is a good perspective also for Lisp. One of the major problems with Lisp is that it is not widely accepted in the computer scientists community. Due to its functional programming nature it is really hard to get into for people that are used to the traditional imperative programming way of thinking. In the recent years though functional programming seems to finally be finding acceptance in the wider masses, so there is a good perspective also for Lisp.
  
-Despite the SBCL compiler being an industrial strength product, as a language, Common Lisp was not designed with industry in mind. Its dynamic typing system, loose encapsulation,​ allowing for side-effects and the fact that it gives the programmer so much freedom and does not put many restrictions on the programming style, results in Lisp sacrificing robustness and security for expressiveness and ease of rapid programming. Generally, Common Lisp is more suitable for rapid prototyping and testing research approaches than for writing an industrial application. However, please note that CRAM does not claim to be an industrial library and is in fact a research tool.+Despite the SBCL compiler being an industrial strength product, as a language, Common Lisp was not designed with industry in mind. Its dynamic typing system, loose encapsulation,​ allowing for side-effects and the fact that it gives the programmer so much freedom and does not put many restrictions on the programming style, results in Lisp sacrificing robustness and security for expressiveness and ease of use. Generally, Common Lisp is more suitable for rapid prototyping and testing research approaches than for writing an industrial application. However, please note that CRAM does not claim to be an industrial library and is in fact a research tool.