Hacker News new | ask | show | jobs
by gknoy 4054 days ago
I don't think there are very many "real world" problems that you CAN solve in Lisp, and CANNOT solve in Python. Anything [0] you can write in Python, you can likely solve in Lisp, probably in similar line count (without macros).

One thing I __really__ miss from working in lisp is the idea that I can reload things in the repl. In Python, once I've imported something, I can't really redefine it without pasting in the definition, which makes iterating on a class definition much harder. In Lisp, I can hit a key in my editor and the running REPL gets the new definition, and I can start working with it (or rewriting tests, etc).

The power of the REPL in lisp is __amazing__. I love me some IPython (it's awesome), but there just isn't the same tight integration between that and a running system. The "default" Python likely has all the tools you need to do that, but it just isn't presented as the Way you Do It.

Django's auto-reload when code changes is an example of this. The trouble is, I can't get to a REPL easily within that, without invoking ipdb. I don't know how to integrate my editor with the Python process in a similar way, etc.

All that said, I still love coding in Python. Hy makes me excited, but then I just started writing python-with-parens and wasn't sure what I had gained. :)

0: I'm sure there is someone who can give a counterexample, but I cannot thnk of any.

2 comments

ipython has a killer autoreload function: http://ipython.org/ipython-doc/stable/config/extensions/auto...

In [1]: %load_ext autoreload

In [2]: %autoreload 2

In [3]: from foo import some_function

In [4]: some_function()

Out[4]: 42

In [5]: # open foo.py in an editor and change some_function to return 43

In [6]: some_function()

Out[6]: 43

It's nothing like a proper lisp repl, but you can sorta do this in vanilla python too, if you don't mind some annoyances. `reload` reloads a module:

>>> import mymodule

>>> print mymodule.myfunction()

3

>>> reload(mymodule)

>>> print mymodule.myfunction()

5

Downside is you have to use the module, `from mymodule import function` won't reload.

Thanks a TON! I am Frequently Slightly Annoyed by pressing control-. and having to re-import things, declare things, etc. I'm looking forward to using this.
I reload things in ipython all the time, just do an execfile (and maybe be sure to define __name__ to something besides '__main__' so it doesn't trigger the usual checks).

The sage version, and maybe this is backported to ipython by now, I don't know, you can do an %attach on a file and it gets reloaded into the workspace every time it changes.