Hacker News new | ask | show | jobs
by black-tea 2760 days ago
The only tools I've found with decent support for Python and other languages are all emacs based. Same goes for the Clojure and CL ones, actually. It's no surprise, I suppose, because this style of programming is so natural to an emacs user.

But it's difficult with Python as soon as you try to do anything beyond a single module. CL and Clojure have proper packages and namespaces so it works fine. But in Python you're limited to working on the context of a single module. If you modify a module that was imported then you have to restart the REPL because you can't reload modules. It just doesn't work.

In CL I would just load the entire system then eval whatever part I want to. From that point I would never not have the current version of the system completely loaded into the running image. Much the same with emacs itself. It is a running image of your emacs lisp system and you can just modify it and eval as-you-go. Does any other language even come close to this?

4 comments

>Does any other language even come close to this?

Smalltalk

Interesting. But one of the points of Clojure is to get away from the object-oriented way so I'm not sure that I'd like Smalltalk.
You have to try it to really understand what OO actually is. Its not the OO you might be familiar with..
Yeah that is why it supports a subset of CLOS.
Erlang and elixir.
If I understand it correctly, Smalltalk is really nothing like Java and the mainstream OOP that Clojure is a reaction to.
Smalltalk is dynamic and Java is static.

Smalltalk, it is an experience, given that language, IDE and runtime/OS are all blended together, while Java can only do so much, even with the more advanced IDEs.

Clojure might be a reaction to C++/Java/C# OOP style, but it surely adopts Common Lisp OOP style.

I think if things have private state that can't be seen externally and that's idiomatic then there's a conflict, if not then there isn't. Do you think it's worth learning Smalltalk? Is it still possible?
Have a look at http://pharo.org/documentation (a modern smalltalk implementation), they have some good materials, also a discord server.

I think it's worth learning, even if you never use it.

> But in Python you're limited to working on the context of a single module. If you modify a module that was imported then you have to restart the REPL because you can't reload modules. It just doesn't work.

This is so frustrating, the Python REPL does some kind of module caching, and I haven't found how to disable it. When I asked on IRC a few years ago, I was told that I was using the REPL for the wrong purpose.

Have you considered using ipython as your REPL? I use ipython and in my profile, I have the following setting. This enables auto-reload and it works almost all the time.

Here is the option I have in my profile file. You can run this command inside the ipython session as well:

%autoreload 2

The times I have seen auto-reload fail is when there is lot of class creation magic going on or while dealing with global connection objects which sql alchemy might be creating. But, other than that it works very nicely.

I stumbled upon importlib.reload(module_name) in the Spyder IPython console, which I use as a REPL alongside the code editor in Spyder. REPL based programming has spoiled me and I find myself drifting towards lispy things like Clojure for the REPL alone, nevermind all the other good things.
Haskell (in the form of intero+emacs at least) also has very nice REPL integration and will automatically reload any changed modules and any modules that depend on the changed modules. The debugging facilities are nowhere near what CL/SLIME offers, but I find I need a debugger much less often in Haskell anyway.
If you look at commercial tooling for Common Lisp, they can do a little more than plain old Emacs.