SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
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
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
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>
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 quot;helpquot;, quot;copyrightquot;, quot;creditsquot; or quot;licensequot; for more
Type quot;helpquot;, quot;copyrightquot;, quot;creditsquot; or quot;licensequot; 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