SlideShare a Scribd company logo
1 of 27
Download to read offline
Lisp for Python Developers

       Vsevolod Dyomkin
           @vseloved
          2013-01-26
Topics

* A short intro
* Some myths and facts
* What Lisp offers
Hello World
CL-USER> "Hello world"
"Hello world"

CL-USER> (print "Hello world")

"Hello world"
"Hello world"
Horner's Rule
         (Is Lisp a functional language?)

(defun horner (coeffs x)
  (reduce (lambda (coef acc)
            (+ (* acc x) coef))
          coeffs
          :from-end t
          :initial-value 0))

From Rosetta Code:
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation
Horner's Rule
           (Python version)


def horner(coeffs, x):
  return reduce(lambda acc, c: 
                     acc * x + c,
                reversed(coeffs),
                0)
Lisp Tools

1. Implementations - multiple
2. IDEs - SLIME, SLIMV
3. quicklisp
Myths
*   The   syntax myth
*   The   libraries myth
*   The   community myth
*   The   slowness myth
*   The   outdatedness myth
*   The   myth of too much choice
*   The   myth of academic language
Myth              |        Fact
LISP = Lost In           )))))))])))))])]) —
Stupid Parenthesis       the joy of debugging
                         ASTs
Your eyes are gonna
                         -- Armin Ronacher
bleed!!!!                (https://twitter.com/mitsuhi
                         ko/status/88527153158815744)
Lisp in 1 slide
Myth             |       Fact
There are no Lisp       1961 libraries in
libraries               Quicklisp
Myth             |       Fact
There are no Lisp       1961 libraries in
libraries               Quicklisp

                        27413 libraries in
                        PyPI
(defun graylog (message &key level backtrace file line-no)
 (let (sock)
   (unwind-protect
        (let ((msg (salza2:compress-data
                    (babel:string-to-octets
                     (json:encode-json-to-string
                      #{:version "1.0" :facility "lisp"
                        :host (get-hostname)
                        :|short_message| message
                        :|full_message| backtrace
                        :timestamp (local-time:timestamp-to-unix
                                    (local-time:now))
                        :level level :file file :line line-no
                       })
                     :encoding :utf-8)
                    'salza2:zlib-compressor)))
          (setf sock (usocket:socket-connect *graylog-host*
                                             *graylog-port*
                                             :protocol :datagram
                                             :element-type 'ub8))
          (usocket:socket-send sock msg (length msg))))
     (usocket:socket-close sock)))
Myth                   |            Fact
There's no Lisp                  SBCL – more than 10
programmers                      people contribute to
                                 each release, ABCL –
There's no Lisp                  more than 5, etc.
jobs
                                 This year: 2 Lisp
Lisp community is                conferences in Europe
full of trolls                   for up to 100 people
                                 (ECLM & ECLS) &
Lisp hasn't been                 numerous Lisp user
developed for years              groups meetings

 http://lisp-univ-etc.blogspot.com/search/label/lisp-hackers
Myth        |       Fact
Lisp is slow       Lisp is the fastest
                   of popular dynamic
                   languages

                   Lisp can be faster
                   than Java

                   … or even C

                   http://benchmarksgame.
                   alioth.debian.org/u32q
                   /lisp.php
Cool Lisp Features
1.   Macros
2.   All the functional stuff
3.   CLOS multimethods
4.   Special variables
5.   Condition system
6.   Read macros
7.   The richest calling convention
8.   Etc.
Macros

This page is intentionally left blank
Condition system
Jedis redis = Redis.getClient(Redis.SOME_DB);
try {
    while (!Thread.interrupted())
         try {
             // do some useful work
             break;
         } catch (JedisException e) {
             Redis.returnBrokenClient(redis);
             redis = Redis.getClient(Redis.SOME_DB);
         }
    // do some other stuff
} finally {
      Redis.returnClient(redis);
}
Condition system
Jedis redis = Redis.getClient(Redis.SOME_DB);
try {
    while (!Thread.interrupted())
         try {
             // do some useful work
             break;
         } catch (JedisException e) {
             Redis.returnBrokenClient(redis);
             redis = Redis.getClient(Redis.SOME_DB);
         }
    // do some other stuff
} finally {
      Redis.returnClient(redis);
}
Condition system
(with-persistent-connection (host port)
  ;; do useful stuff
  )
Condition system
(with-persistent-connection (host port)
  ;; do useful stuff
  )

(defmacro with-persistent-connection
    ((&key (host #(127 0 0 1)) (port 6379))
     &body body)
  `(with-connection (:host ,host :port ,port)
     (handler-bind ((redis-connection-error
                     (lambda (e)
                       (warn "Reconnecting.")
                       (invoke-restart :reconnect))))
       ,@body)))
Condition system
(defmacro with-reconnect-restart (&body body)
  `(handler-case (progn ,@body)
     (usocket:connection-refused-error (e)
       (reconnect-restart-case
         (:error e :comment "Can't connect”)
         ,@body))
     ((or usocket:socket-error
          stream-error end-of-file) (e)
        (reconnect-restart-case (:error e)
          ,@body)))))
Condition system
(defmacro reconnect-restart-case
     ((&key error comment) &body body)
  `(if *pipelined*
       (progn ,@body)
       (restart-case (error 'redis-connection-error
                            :error ,error
                            :comment ,comment)
         (:reconnect ()
           :report "Trying to reconnect"
           (reconnect)
           ,@body))))

http://lisp-univ-etc.blogspot.com/2012/11/cl-redis-separation-
of-concerns-in.html
Read macros
{ x ! x <- (loop :for i :upto 10 :collect i) }
'(0 1 2 3 4 5 6 7 8 9 10 )

{x ! x <- '(1 nil 2) ! x}
'(1 2)

{x y ! x <- '(1 2 3) y <- '(5 6 7) ! (oddp x) (> y 5)}
'((3 7))

{ (+ x y) ! x <- '(1 2 3) y <- '(5 6 7) ! (oddp x) (> y 5) }
'(10)

(set-macro-character #{ #'read-listcomp)
(set-macro-character #} (get-macro-character #)))
(defun read-listcomp (stream char)
  "Read list comprehension { vars ! generators [! conditions]? }"
  (declare (ignore char))
  (let (rezs srcs conds state)
    (dolist (item (read-delimited-list #} stream))
      (if (eql '! item)
          (setf state (if state :cond :src))
          (case state
            (:src       (push item srcs))
            (:cond      (push item conds))
            (otherwise (push item rezs)))))
    (setf rezs (reverse rezs)
          srcs (reverse srcs)
          conds (reverse conds))
    (let ((binds (mapcar #`(cons (first %) (third %))
                          (group 3 srcs))))
      `(mapcan (lambda ,(mapcar #'car binds)
                  (when (and ,@conds)
                    (list ,(if (rest rezs)
                               (cons 'list rezs)
                               (first rezs)))))
               ,@(mapcar #'cdr binds)))))
Lisp is Python on
     steroids

     but w/o
  batteries :)
Lisp in My View
1.   Rich, non-exclusive culture
2.   Consistency & simplicity
3.   Mature interactive environment
4.   Multi-paradigm language
5.   Unique features
6.   Cool non-unique features
7.   Performant grown-up runtimes
Lisp Resources
1. Hyperspec -
http://clhs.lisp.se/Front/Contents.htm
2. Cookbook -
http://cl-cookbook.sourceforge.net/
3. Cliki – http://cliki.net
4. lispdoc - http://lispdoc.com/
5. Google Styleguide -
http://google-styleguide.googlecode.com/svn/trunk/lispguide.xml

6. L1sp.org - http://l1sp.org/
7. Lisp books -
http://pinterest.com/vseloved/lisp-books/

More Related Content

What's hot

2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekingeProf. Wim Van Criekinge
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
KafNafParserPy: a python library for parsing/creating KAF and NAF files
KafNafParserPy: a python library for parsing/creating KAF and NAF filesKafNafParserPy: a python library for parsing/creating KAF and NAF files
KafNafParserPy: a python library for parsing/creating KAF and NAF filesRubén Izquierdo Beviá
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of FlatteryJosé Paumard
 
Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?Alex Payne
 
JDK8 Functional API
JDK8 Functional APIJDK8 Functional API
JDK8 Functional APIJustin Lin
 
DevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingDevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingHenri Tremblay
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Fariz Darari
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPTShivam Gupta
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdbWei-Bo Chen
 
Odessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonOdessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonMax Klymyshyn
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaRahul Jain
 
Performance and predictability (1)
Performance and predictability (1)Performance and predictability (1)
Performance and predictability (1)RichardWarburton
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + ScalaShouheng Yi
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJosé Paumard
 
Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Ken Kousen
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To ScalaPeter Maas
 

What's hot (20)

2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge2016 bioinformatics i_python_part_1_wim_vancriekinge
2016 bioinformatics i_python_part_1_wim_vancriekinge
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
KafNafParserPy: a python library for parsing/creating KAF and NAF files
KafNafParserPy: a python library for parsing/creating KAF and NAF filesKafNafParserPy: a python library for parsing/creating KAF and NAF files
KafNafParserPy: a python library for parsing/creating KAF and NAF files
 
Python made easy
Python made easy Python made easy
Python made easy
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of Flattery
 
Python to scala
Python to scalaPython to scala
Python to scala
 
Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?
 
JDK8 Functional API
JDK8 Functional APIJDK8 Functional API
JDK8 Functional API
 
DevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingDevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programming
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
 
Odessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonOdessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and Python
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Performance and predictability (1)
Performance and predictability (1)Performance and predictability (1)
Performance and predictability (1)
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + Scala
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
 
Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 

Viewers also liked

NLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language IdentificationNLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language IdentificationVsevolod Dyomkin
 
Crash-course in Natural Language Processing
Crash-course in Natural Language ProcessingCrash-course in Natural Language Processing
Crash-course in Natural Language ProcessingVsevolod Dyomkin
 
Tedxkyiv communication guidelines
Tedxkyiv communication guidelinesTedxkyiv communication guidelines
Tedxkyiv communication guidelinesVsevolod Dyomkin
 
Новые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхНовые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхVsevolod Dyomkin
 
Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Vsevolod Dyomkin
 
Lisp как универсальная обертка
Lisp как универсальная оберткаLisp как универсальная обертка
Lisp как универсальная оберткаVsevolod Dyomkin
 
Can functional programming be liberated from static typing?
Can functional programming be liberated from static typing?Can functional programming be liberated from static typing?
Can functional programming be liberated from static typing?Vsevolod Dyomkin
 
Экосистема Common Lisp
Экосистема Common LispЭкосистема Common Lisp
Экосистема Common LispVsevolod Dyomkin
 
Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)Vsevolod Dyomkin
 
Natural Language Processing in Practice
Natural Language Processing in PracticeNatural Language Processing in Practice
Natural Language Processing in PracticeVsevolod Dyomkin
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday DeveloperRoss Tuck
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationrjsmelo
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in PracticeNoah Davis
 

Viewers also liked (18)

Aspects of NLP Practice
Aspects of NLP PracticeAspects of NLP Practice
Aspects of NLP Practice
 
NLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language IdentificationNLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language Identification
 
Practical NLP with Lisp
Practical NLP with LispPractical NLP with Lisp
Practical NLP with Lisp
 
NLP Project Full Cycle
NLP Project Full CycleNLP Project Full Cycle
NLP Project Full Cycle
 
Crash-course in Natural Language Processing
Crash-course in Natural Language ProcessingCrash-course in Natural Language Processing
Crash-course in Natural Language Processing
 
Lisp Machine Prunciples
Lisp Machine PrunciplesLisp Machine Prunciples
Lisp Machine Prunciples
 
Tedxkyiv communication guidelines
Tedxkyiv communication guidelinesTedxkyiv communication guidelines
Tedxkyiv communication guidelines
 
Новые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхНовые нереляционные системы хранения данных
Новые нереляционные системы хранения данных
 
Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?
 
Lisp как универсальная обертка
Lisp как универсальная оберткаLisp как универсальная обертка
Lisp как универсальная обертка
 
Can functional programming be liberated from static typing?
Can functional programming be liberated from static typing?Can functional programming be liberated from static typing?
Can functional programming be liberated from static typing?
 
CL-NLP
CL-NLPCL-NLP
CL-NLP
 
Экосистема Common Lisp
Экосистема Common LispЭкосистема Common Lisp
Экосистема Common Lisp
 
Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)
 
Natural Language Processing in Practice
Natural Language Processing in PracticeNatural Language Processing in Practice
Natural Language Processing in Practice
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in Practice
 

Similar to Lisp for Python Programmers

Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Hajime Tazaki
 
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이GangSeok Lee
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp languageDavid Gu
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12Tim Bunce
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийSigma Software
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Tim Bunce
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the webMichiel Borkent
 
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in... ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...Saurabh Nanda
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon KickoffItamar Haber
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with ModulesItamar Haber
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerVladimir Sedach
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentJim Mlodgenski
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"Hyuk Hur
 
Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable LispAstrails
 

Similar to Lisp for Python Programmers (20)

Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01
 
Lisp Primer Key
Lisp Primer KeyLisp Primer Key
Lisp Primer Key
 
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the web
 
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in... ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
Redis Lua Scripts
Redis Lua ScriptsRedis Lua Scripts
Redis Lua Scripts
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL Environment
 
Profiling Ruby
Profiling RubyProfiling Ruby
Profiling Ruby
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"Let'swift "Concurrency in swift"
Let'swift "Concurrency in swift"
 
Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable Lisp
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Lisp for Python Programmers

  • 1. Lisp for Python Developers Vsevolod Dyomkin @vseloved 2013-01-26
  • 2. Topics * A short intro * Some myths and facts * What Lisp offers
  • 3. Hello World CL-USER> "Hello world" "Hello world" CL-USER> (print "Hello world") "Hello world" "Hello world"
  • 4. Horner's Rule (Is Lisp a functional language?) (defun horner (coeffs x) (reduce (lambda (coef acc) (+ (* acc x) coef)) coeffs :from-end t :initial-value 0)) From Rosetta Code: http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation
  • 5. Horner's Rule (Python version) def horner(coeffs, x): return reduce(lambda acc, c: acc * x + c, reversed(coeffs), 0)
  • 6. Lisp Tools 1. Implementations - multiple 2. IDEs - SLIME, SLIMV 3. quicklisp
  • 7. Myths * The syntax myth * The libraries myth * The community myth * The slowness myth * The outdatedness myth * The myth of too much choice * The myth of academic language
  • 8. Myth | Fact LISP = Lost In )))))))])))))])]) — Stupid Parenthesis the joy of debugging ASTs Your eyes are gonna -- Armin Ronacher bleed!!!! (https://twitter.com/mitsuhi ko/status/88527153158815744)
  • 9. Lisp in 1 slide
  • 10. Myth | Fact There are no Lisp 1961 libraries in libraries Quicklisp
  • 11. Myth | Fact There are no Lisp 1961 libraries in libraries Quicklisp 27413 libraries in PyPI
  • 12. (defun graylog (message &key level backtrace file line-no) (let (sock) (unwind-protect (let ((msg (salza2:compress-data (babel:string-to-octets (json:encode-json-to-string #{:version "1.0" :facility "lisp" :host (get-hostname) :|short_message| message :|full_message| backtrace :timestamp (local-time:timestamp-to-unix (local-time:now)) :level level :file file :line line-no }) :encoding :utf-8) 'salza2:zlib-compressor))) (setf sock (usocket:socket-connect *graylog-host* *graylog-port* :protocol :datagram :element-type 'ub8)) (usocket:socket-send sock msg (length msg)))) (usocket:socket-close sock)))
  • 13. Myth | Fact There's no Lisp SBCL – more than 10 programmers people contribute to each release, ABCL – There's no Lisp more than 5, etc. jobs This year: 2 Lisp Lisp community is conferences in Europe full of trolls for up to 100 people (ECLM & ECLS) & Lisp hasn't been numerous Lisp user developed for years groups meetings http://lisp-univ-etc.blogspot.com/search/label/lisp-hackers
  • 14. Myth | Fact Lisp is slow Lisp is the fastest of popular dynamic languages Lisp can be faster than Java … or even C http://benchmarksgame. alioth.debian.org/u32q /lisp.php
  • 15. Cool Lisp Features 1. Macros 2. All the functional stuff 3. CLOS multimethods 4. Special variables 5. Condition system 6. Read macros 7. The richest calling convention 8. Etc.
  • 16. Macros This page is intentionally left blank
  • 17. Condition system Jedis redis = Redis.getClient(Redis.SOME_DB); try { while (!Thread.interrupted()) try { // do some useful work break; } catch (JedisException e) { Redis.returnBrokenClient(redis); redis = Redis.getClient(Redis.SOME_DB); } // do some other stuff } finally { Redis.returnClient(redis); }
  • 18. Condition system Jedis redis = Redis.getClient(Redis.SOME_DB); try { while (!Thread.interrupted()) try { // do some useful work break; } catch (JedisException e) { Redis.returnBrokenClient(redis); redis = Redis.getClient(Redis.SOME_DB); } // do some other stuff } finally { Redis.returnClient(redis); }
  • 20. Condition system (with-persistent-connection (host port) ;; do useful stuff ) (defmacro with-persistent-connection ((&key (host #(127 0 0 1)) (port 6379)) &body body) `(with-connection (:host ,host :port ,port) (handler-bind ((redis-connection-error (lambda (e) (warn "Reconnecting.") (invoke-restart :reconnect)))) ,@body)))
  • 21. Condition system (defmacro with-reconnect-restart (&body body) `(handler-case (progn ,@body) (usocket:connection-refused-error (e) (reconnect-restart-case (:error e :comment "Can't connect”) ,@body)) ((or usocket:socket-error stream-error end-of-file) (e) (reconnect-restart-case (:error e) ,@body)))))
  • 22. Condition system (defmacro reconnect-restart-case ((&key error comment) &body body) `(if *pipelined* (progn ,@body) (restart-case (error 'redis-connection-error :error ,error :comment ,comment) (:reconnect () :report "Trying to reconnect" (reconnect) ,@body)))) http://lisp-univ-etc.blogspot.com/2012/11/cl-redis-separation- of-concerns-in.html
  • 23. Read macros { x ! x <- (loop :for i :upto 10 :collect i) } '(0 1 2 3 4 5 6 7 8 9 10 ) {x ! x <- '(1 nil 2) ! x} '(1 2) {x y ! x <- '(1 2 3) y <- '(5 6 7) ! (oddp x) (> y 5)} '((3 7)) { (+ x y) ! x <- '(1 2 3) y <- '(5 6 7) ! (oddp x) (> y 5) } '(10) (set-macro-character #{ #'read-listcomp) (set-macro-character #} (get-macro-character #)))
  • 24. (defun read-listcomp (stream char) "Read list comprehension { vars ! generators [! conditions]? }" (declare (ignore char)) (let (rezs srcs conds state) (dolist (item (read-delimited-list #} stream)) (if (eql '! item) (setf state (if state :cond :src)) (case state (:src (push item srcs)) (:cond (push item conds)) (otherwise (push item rezs))))) (setf rezs (reverse rezs) srcs (reverse srcs) conds (reverse conds)) (let ((binds (mapcar #`(cons (first %) (third %)) (group 3 srcs)))) `(mapcan (lambda ,(mapcar #'car binds) (when (and ,@conds) (list ,(if (rest rezs) (cons 'list rezs) (first rezs))))) ,@(mapcar #'cdr binds)))))
  • 25. Lisp is Python on steroids but w/o batteries :)
  • 26. Lisp in My View 1. Rich, non-exclusive culture 2. Consistency & simplicity 3. Mature interactive environment 4. Multi-paradigm language 5. Unique features 6. Cool non-unique features 7. Performant grown-up runtimes
  • 27. Lisp Resources 1. Hyperspec - http://clhs.lisp.se/Front/Contents.htm 2. Cookbook - http://cl-cookbook.sourceforge.net/ 3. Cliki – http://cliki.net 4. lispdoc - http://lispdoc.com/ 5. Google Styleguide - http://google-styleguide.googlecode.com/svn/trunk/lispguide.xml 6. L1sp.org - http://l1sp.org/ 7. Lisp books - http://pinterest.com/vseloved/lisp-books/