2 ms·
I've been down exactly the rabbit hole you're speculating about, and my firm conclusion is: python is not a shell replacement. [update: some other posters here
by cturner 10y ago
I've been down exactly the rabbit hole you're speculating about, and my firm conclusion is: python is not a shell replacement. [update: some other posters here are referring to xonsh. Maybe they succeeded where I failed, and python can be done shellable. Will be looking into this.]
* Python does strange things with IO buffering. Just when you think you've nailed all the edge-cases of this, some more come along. Its decisions are good for a general-purpose programming language, and awful for a shell.
* Python is awkward for some close-to-the metal operations such as interaction with unix sessions and process groups.
* Python forking is wacky. There's magic in there, and there's some stuff that gets inherited under the cover. If you fork and don't immediately execv, you are probably in for Interesting Times.
When I looked at the code for Ansible, I felt a bit like I'd encountered a rival alien civilisation who had tested and reacted to the same laws of the universe, and reached identical conclusions. Ansible is written in Python. But it generates bash scripts, and then bash does dispatch.
Given the power of general-purpose languages we have on unix, it's remarkable how stunted shell evolution is. Which is to say, there is an exciting opportunity here.
A shell built as a Forth dialect could be a game-changer. It would have a certain number of powerful builtins. It may even evolve higher-level programming concepts. I am interested in further discussion towards this, and maybe a new github project, particularly a collaboration with someone with high fluency in Forth. I'm in London: beers.
The art of a good shell would merge (1) fluid interaction; (2) effective wrapping of the unix API; (3) high-enough-level programming.