Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:package:why_lisp [2015/05/08 16:22] gkazhoyadoc:package:why_lisp [2015/05/08 16:48] 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.
Line 9: Line 11:
 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. 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.