by ajkjk · 9y ago · 0 comments
I'm aware of, like, TermKit[0], but that didn't get finished and I don't recall hearing about any newer efforts.
I have a minimal Unix setup, with lots of little programs that do one thing and do it well. For example, mutt is my MUA (mail user agent). It just reads my emails, but fetching or sending is carried out by other programs. Fine.
Now, the issue is that every little Unix utility that is non-trivial comes with its own little DSL for configuration. Most are inflexible, naive and different to each other. It's hard to script mutt. If you want to do some stuff the author hasn't planned for, you are better off patching the code. Flexibility, and composability, is not as good as they preach.
For this reason, I am migrating everything to emacs. It offers me what Unix only promises but falls short at. Everything is an elisp function and thus easy to combine. Things are more organic. And still minimal.
" We really are using a 1970s era operating system well past its sell-by date. We get a lot done, and we have fun, but let's face it, the fundamental design of Unix is older than many of the readers of Slashdot, while lots of different, great ideas about computing and networks have been developed in the last 30 years. Using Unix is the computing equivalent of listening only to music by David Cassidy."
Rob Pike, https://interviews.slashdot.org/story/04/10/18/1153211/rob-p...
But overall, I am more comfortable on live environments like Smalltalk or Emacs. There's just one fundamental abstraction, and things can be composed beautifully.
In Unix, on the other hand, everything is not a file. And even if it was, little applications like mutt are silos. The code is static, it can't be easily changed or opened. A file interface, in the form of STDIN/STDOUT is too unstructured.
After Amiga, Atari, Acorn and Windows, getting to learn UNIX ideas seemed quite interesting (I started with Xenix).
However, once at the university I got the opportunity to dive into the work of Xerox PARC and ETHZ, the more I learned about them, the more I came to realize that I actually cared more about their vision about how computing should look like, than anything I ever used in UNIX variants.
Of course, Plan 9, Inferno and C+@ are other Bell Labs ideas that would have improved the overall UNIX experience, but as you say, have been ignored.
Some features are plain mistakes, but some of them are useful things that newer shells aren't taking into account (particularly with regard to file descriptors). I'm aiming for a superset of bash semantics, but with different syntax. Importantly, it will be backward compatible, because bash can be converted to oil automatically. (I'm working on that now, not released yet.)
http://www.oilshell.org/blog/2016/11/09.html
The rest of the blog has a bunch of shell corner cases, like:
http://www.oilshell.org/blog/2016/11/06.html
http://www.oilshell.org/blog/2016/10/28.html
Although I probably only blogged about 20% of the weird stuff I found.
I'll add that my ideal "command and control language" (as I've been thinking of it) would also be one that's strong at expressing data literals. If there are a number of data types like maps, sets, lists, etc., then it should be easy to initialize them with literals (not true in languages like Java). There are so many configuration file formats that I wonder if they could be subsumed into files with literals expressed in this language (perhaps with a "data mode" to prohibit executable code).
I've been wanting to design a language along these lines as well. I'll start by learning about oil, and reach out if I'm interested and able to contribute!
There is also going to be influence from R and CSV files (which goes with awk).
I have thought about the config problem a lot -- and a configurable sandboxed "data mode" you are talking about is probably what I will go with.
If you squint, the oil shell will look not unlike nginx configs, e.g. a bunch of words with nested {} for blocks. Maybe like https://github.com/vstakhov/libucl or https://github.com/hashicorp/hcl (hm this seems to even have here docs!)
This kind of thing was done a lot with Python at my last job, to various degrees of success (e.g. https://bazel.build/ - the build language is derived from Python). Python sort of has some "data mode" sandboxing features, like being able to set __builtins__ when you exec/eval, but probably not enough. It didn't work well enough to prevent people from writing their own config file parser eventually. The syntax is close but not exactly what you want for some use cases.
And I realize I made an omission in my post. I meant to say not just learnings, but use. I would think the biggest hurdle for you will be building a user base.
I'm want to publish the test matrix and get some help because filling out the corners takes a lot of time. The general architecture is pretty sound though -- I hit all the "major areas" of shell, although I may need to make another pass at globbing.
If you are adventurous you should be able to clone it, follow the instructions for ./pybuild.sh. Then ./spec.sh install-shells, and then run './spec.sh smoke'. That test should pass, but there are like 15-20 other categories in spec.sh in various states of disarray!
Of course this is in Python, but to me it makes sense to fill out a sketch before porting it to C++ (only the runtime; I'm hoping to bootstrap the parsers in oil itself). Not sure if that will inhibit or help contribution.
You can also see a list of other shells on the GitHub wiki page titled ExternalResources: https://github.com/oilshell/oil/wiki/ExternalResources
I'm focusing on the shell as a programming language at first, in contrast to TermKit.
Fish does have bugs though. I've seen enough stack traces while running early builds to question the security (although I'm sure we all remember the bash shell-shcok bug that was laying around for years).
If you haven't tried fish, I highly recommend it. It takes a little getting use to, but overall it adds a lot of really amazing functionality that I find really useful.
Serious question (that I've asked elsethread): what does fish offer than zsh & bash lack? A quick perusal of the docs reveals nothing obvious, but … I could be missing stuff.
* Instant auto suggestions, you just type stuff, like in a web browser.
* Sane defaults, no need to bring around your own config. On a new machine I just install fish, run fish_config and customize the prompt with the web UI.
* Scripting with simple syntax, especially for one-liners. Yes, fish is incompatible with bash, but it's less of issue in this case.
Which is better than the days when csh and different Bourne flavors were common.
let (foo bar)
ls foo "bim/baz" ${foo}
Might be turned into the equivalent of 'ls foo bim/baz bar' in sh.In fact, with a minimum of work I think this could be turned into a Lisp shell …
command arg1 arg2 ...
then whatever is built to this requirement is going to feel decades old to some extent.What feels ancient is the lack of good parse error messages and runtime error messages in bash.
And syntax like a=X but not a = X or a = 'X' -- the difference being the spaces.
And (echo hi) is OK for a subshell, but you need { echo hi; } for a group -- space and ; are required in the latter case, but not the former.
The lack of proper functions in shell also feels ancient. For example, writing a completion function in bash is a pretty horrible experience. As another example, a simple function to escape HTML is either 'sed' or three statements like ${foo/&/&}, both of which are obtuse.
Is that developer are THE WORST. Them will refuse to switch to anything better if it means to a small change in his old ways.
That is why C/C++/Js/Bash rule the world...
The takeaway after all that was, rarely is one language better than another, its really about trade-offs.
And frankly the older ones are a lot better at following the KISS principal and actually providing an uncluttered framework for writing _EFFICIENT_ code. For example, everyone knows that Java is a "better" and more productive language than COBOL, yet when you start talking to people trying to port old COBOL apps to java, what you discover is that it turns out that COBOL might actually do a better job in the business/transaction space. Same with python and Fortran in the HPC space, and strangely enough the core infrastructure all these more modern efficient languages are running on tends to be "C" based. Which despite the laundry list of issues that people like to parade around, seems to solve systems programming problems better than anything else.
None of this would really be a problem except for the fact that the new up and coming language that is cool this year changes from year to year leaving a wasteland of abandoned poorly maintained projects using languages that no one really knew, and are despised by the people who are hired and have to learn them for that one job before moving on to the next one.
So, yes bash is a POS, but its universal at this point, isn't really that bad at solving the core problems its designed to solve, and any developer with 1/2 a brain can write a sys V init script (or a lot of similar things) with little more than a couple hours and without the baggage of yet another 1/2GB language/framework/etc pulled in to sit alongside the dozen others already in the project.
</rant> Now get off my yard.
Adoption would be even harder, but any resulting language is not going to look like Python or any other "mainstream" language, if it's intended to actually be usable.
Oil is parsed line by line like any other shell, and there will be a simple rule to determine whether you're in command mode or expression mode.
The "lexer modes" technique (previous referred to as "lexical state") should handle the two sublanguages easily. You basically need it to parse bash, and you will need much less of it to parse oil. My bash parser has 13 lexical states (up from 8), but I expect oil to have somewhere between 4 and 8.
How it's used in the bash parser: http://www.oilshell.org/blog/2016/10/19.html
However, still developers will not buy it. I think maybe it could work for a subset of the user that need to work with data-science and subset of system automation.
Last I checked I think the thing I'm missing from using iPython purely as a shell is the ability to pipe?