Why Sponsor Oils? | blog | oilshell.org
I made a table to emphasize a point I made in the last post: Most "Unix sludge" is string-ish, but YSH has garbage-collected data structures.
That is, YSH moves shell from the left to the right — from less powerful to more powerful.
No Garbage Collection | Garbage Collection | |
---|---|---|
(string-ish languages, often cursed by users) Traditional Unix Shell |
→ |
(GC implies general data structures) YSH |
Make CMake m4 (autoconf) |
Lisp and Scheme, Python, JavaScript, Ruby, Lua |
|
(arrays that can't be nested) awk fish |
(mixed value/reference semantics) Perl PHP |
Garbage-collected data structures lets you express a larger range of programs naturally, like ones that deal with build graphs.
Yesterday, I published:
So it's not just OSH that's smaller than bash, but all of Oils.
That includes YSH, and that's despite its greater power, which is due in part to garbage collection.
Note that I'm measuring lines of source, not binary size, and the oils-for-unix
binary is currently ~2x larger than bash.
But lines of source is a more stable metric, and mycpp gives us leverage to make the binary smaller, if we want to. (It's more important to make it faster, but ideally we do both.)
Here are two long docs, with many examples:
And here's a short example, extracted from demo/url-search-params.ysh, a messy but real piece of code inspired by a problem that Samuel had. (We need syntax highlighting!)
proc test-query() {
### Oracle test for parsing URL: foo?name=foo+bar&k=v
for s in (QUERY_CASES) {
echo 'INPUT'
echo " $s"
# Shell out to node.js as an oracle
js-decode-query $s | json read (&js_pairs)
echo 'JS'
pp value (js_pairs)
# Call YSH function
var ysh_pairs = URLSearchParams(s)
echo 'YSH'
pp value (ysh_pairs)
# Are they equal? This compares structured data
assert [ysh_pairs === js_pairs]
echo
}
}
There are other shells with structured data, like PowerShell, nushell, Elvish, and dozens of other projects:
The main difference is that the design of Oils is "exterior" like POSIX shell and bash, not "interior".
This is a fancy way of saying that we use normal Unix processes and files, like JSON over Unix pipes.
We don't invent our own narrow waist of say Powershell cmdlets and objects. †
I wrote two blog posts about this:
These ideas will continue to appear on the blog.
† Based on feedback, I'll sometimes call a narrow waist an M × N waist.
This is where we are in the current series:
The next post will be a bit critical!