Re:Why MIT switched from Scheme to Python
by sadfsa on Sunday May 03, 2009 @07:05PM
(#591517)
Ease of programming isn't the issue, at least not when it comes to writing libraries that must interface with C code (as a robot-interfacing library is likely to). Most Schemes and Lisps can interface to C by means of a few simple declarations, while Python requires the C code to accept and return Python's internal data structures (and convert them to a form that can be used by C code), and requires it to register those functions that are to be made visible to Python.
Scheme (PLT)
(require scheme/foreign)
(unsafe!)
(define my-c-lib (ffi-lib "libmylib")) ;; loads libmylib.so
(define my-c-func (get-ffi-obj 'my_c_func my-c-lib (_fun _long -> _long)))
;; The C code does not need to take Scheme into account--
;; Existing C libraries can be interfaced with Scheme
;; with a trivial amount of effort.
C (to be linked against Python code-- Python can load the resulting shared library as if it was written in Python). Notice that all this code does is interface Linux's htonl function to Python:
Scheme (PLT)
C (to be linked against Python code-- Python can load the resulting shared library as if it was written in Python). Notice that all this code does is interface Linux's htonl function to Python: