REPLs

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    REPLs - Presentation Transcript

    1. REPLs (Entornos interactivos de programación) Antonio Ognio Cesti <gnrfan@gnrfan.org> http://gnrfan.org
    2. REPLs / Antonio Ognio ¿Qué es un REPL? ● Read-Eval-Print Loop ● Entorno interactivo de programación ● Escribo código y obtengo el resultado de inmediato ● Ideal para probar ideas y estrategias ● Manera rápida y fácil de obtener el fragmento de programación buscado
    3. REPLs / Antonio Ognio Mas sobre los REPLs ● El nombre viene de las funciones que se utilizaron en su implementación en LISP ● Muchas veces se le llama intérprete sin embargo esto no es exacto porque hay lenguages como Python o C# que si compilan el código fuente a bytecode y lo ejecutan el código de forma interactiva ● Actualmente se encuentran disponibles para muchos lenguajes y cada vez hay más y nuevas implementaciones
    4. REPLs / Antonio Ognio Lenguajes con REPLs disponibles ● LISP (top-level) ● Perl (Perl Console) ● F# (fsi) ● Python / Ipython ● Clojure ● Java (Beanshell) ● C (c-repl) ● Ruby (IRB) ● Ocaml (top-level) ● Haskell (ghci) ● C# (CSREPL) ● PHP (phpsh) ● Scheme (top-level) ● Javascript (Rhino js) ● Otros mas... ● Scala (scala) ● Erlang (erl)
    5. REPLs / Antonio Ognio Cualquier linea de comandos... ● Bash / C Shell / Z Shell (UNIX) ● command.com (DOS) ● Microsoft Powershell (.Net) ● Cualquier otro “intérprete” de comandos
    6. REPLs / Antonio Ognio Los REPLs nos acompañan hace mucho tiempo... ● Orígenes en LISP en los 60's y 70's ● Integración con editor Emacs (SLIME) ● Popular con Logo en los 80's
    7. REPLs / Antonio Ognio La tortuga de Logo...
    8. REPLs / Antonio Ognio Commodore 64 logo
    9. REPLs / Antonio Ognio Turtle Art en OLPC
    10. REPLs / Antonio Ognio F# Interactive en Visual Studio
    11. REPLs / Antonio Ognio Ventajas de un REPL ● Ideal para dar los primeros pasos ● Programación exploratoria ● Depuración ● Aprender a usar una API ● Prototipear alguna idea ● Afinar una expresión y/o algoritmo ● Demostraciones en vivo! :)
    12. REPLs / Antonio Ognio Desventajas de un REPL ● Los errores se notan de inmediato y no hay mucha oportunidad de corregirlos ● ¿Esto último es un feature o un bug? ● No es muy cómodo editar muchas líneas de código ● No funcionan muchas características presentes en un IDE
    13. REPLs / Antonio Ognio Algunos REPLs disponibles en Ubuntu ● c-repl ● ipython ● irb ● erlang-base (erl) ● slime ● rhino ● haskell-mode (ghci) ● bsh (Bean Shell)
    14. REPLs / Antonio Ognio ... a solo un apt-get install de distancia $ sudo apt-get install <paquete>
    15. REPLs / Antonio Ognio Ejemplo: iPython $ sudo apt-get install ipython
    16. REPLs / Antonio Ognio Demo de iPython
    17. REPLs / Antonio Ognio Demo de iPython
    18. REPLs / Antonio Ognio Características de iPython ● “pretty-printing” de resultados ● Autocompletar con Tab ● Auto identación ● Historial de comandos ● Ayuda formateada ● Traceback enriquecidos ● plain ● context ● verbose
    19. REPLs / Antonio Ognio Demo Online Python REPL http://datamech.com/devan/trypython/trypython.py
    20. REPLs / Antonio Ognio http://tryruby.hobix.com/
    21. REPLs / Antonio Ognio http://www.phpsh.org http://developers.facebook.com/opensource.php
    22. REPLs / Antonio Ognio [gnrfan]:~/src/phpsh-0.86b$./phpsh ejemplo.php phpsh (c)2006 by Charlie Cheever and Dan Corson and Facebook, Inc. type 'h' or 'help' to see instructions & features Commandline: php -q ./phpsh.php example.php php> = 3 + 3 6 php> = $_ 6 php> = $_+ $_ 12 php> $x = $_ php> print $x 12 php> $y = $x * $x php> print \"$y=144\" 144=144
    23. REPLs / Antonio Ognio php> = starts_with starts_with starts_with($s, $prefix) php> = starts_with(\"abc\", \"a\") 1 php> d starts_with function starts_with($s, $prefix) { type=None file=example.php /home/.dogmatic/ccheever/src/phpsh-0.86b/example.php, lines 2-10: /** * Returns true if the first arg starts with the second arg * @param string $big_string * @param string $little_string * @return true or false * * @author ccheever */ php> = 2 + \\ 2 4
    24. REPLs / Antonio Ognio php> = array(array(1,2,3), array(\"a\" => \"b\", \"c\" => \"d\", \"e\" => \"f\"), 'g', 'h') Array ( [0] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [1] => Array ( [a] => b [c] => d [e] => f ) [2] => g [3] => h ) php> q
    25. REPLs / Antonio Ognio http://www.mono-project.com/CsharpRepl
    26. REPLs / Antonio Ognio
    27. REPLs / Antonio Ognio
    28. REPLs / Antonio Ognio
    29. REPLs / Antonio Ognio
    30. REPLs / Antonio Ognio $ ./manage.py shell
    31. REPLs / Antonio Ognio $ ./manage.py shell $ ./manage.py shell Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type \"help\", \"copyright\", \"credits\" or \"license\" for more Type \"help\", \"copyright\", \"credits\" or \"license\" for more information. information. (InteractiveConsole) (InteractiveConsole) >>> from django.contrib.auth.models import User >>> from django.contrib.auth.models import User >>> user = User() >>> user = User() >>> user.email = 'gnrfan@gnrfan.org' >>> user.email = 'gnrfan@gnrfan.org' >>> dir(user) >>> dir(user) >>> user.username = 'gnrfan' >>> user.username = 'gnrfan' >>> user.first_name = 'Antonio' >>> user.first_name = 'Antonio' >>> user.last_name = 'Ognio' >>> user.last_name = 'Ognio' >>> user.save() >>> user.save()
    32. REPLs / Antonio Ognio Conclusiones ● Los REPLs son fáciles de usar ● Nos facilitan aprender programación ● Nos permiten descubrir nuevas APIs ● Nos ayudan a plasmar ideas en código ● Existen para muchos lenguajes ● Es posible que un REPL para tu lenguaje favorito este a la vuelta de la esquina
    33. Gracias!!! Antonio Ognio Cesti <gnrfan@gnrfan.org> http://gnrfan.org
    SlideShare Zeitgeist 2009

    + gnrfangnrfan Nominate

    custom

    361 views, 0 favs, 0 embeds more stats

    Una mirada a los entornos REPL (Read-Eval-Print-Loo more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 361
      • 361 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 3
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories