Hacker News new | past | comments | ask | show | jobs | submit login

Oils/YSH has structured data and JSON! This was finished earlier this year

Garbage Collection Makes YSH Different (than POSIX shell, awk, cmake, make, ...) - https://www.oilshell.org/blog/2024/09/gc.html

You need GC for arbitrary recursive data structures, and traditionally Unix didn't have those languages.

Lisp was the first GC language, and pre-dated Unix, and then Java made GC popular, and Java was not integrated with Unix (it wanted to be its own OS)

----

So now you can do

    # create some JSON
    ysh-0.23.0$ echo '{"foo":[1,2,3]}' > x.json

    # read it into the variable x -- you will get a syntax error if it's malformed
    ysh-0.23.0$ json read (&x) < x.json


    # pretty print the resulting data structure, = comes from Lua
    ysh-0.23.0$ = x
    (Dict)  {foo: [1, 2, 3]}

    # use it in some computation
    ysh-0.23.0$ var y = x.foo[1]
    ysh ysh-0.23.0$ = y
    (Int)   2



Structured shells are neat and I love them, but the Unix philosophy is explicitly built around plain text - the "structured" part of structured shells isn't Unixy.


It's not either-or -- I'd think of it as LAYERED

- JSON denotes a data structure, but it is also text - you can use grep and sed on it, or jq

- TSV denotes a data structure [1], but it is also text - you can use grep on it, or xsv or recutils or ...

(on the other hand, protobuf or Apache arrow not text, and you can't use grep on them directly. But that doesn't mean they're bad or not useful, just not interoperable in a Unix style. The way you use them with Unix is to "project" onto text)

etc.

That is the layered philosophy of Oils, as shown in this diagram - https://www.oilshell.org/blog/2022/02/diagrams.html#bytes-fl...

IMO this is significantly different and better than say PowerShell, which is all about objects inside a VM

what I call "interior vs. exterior"

processes and files/JSON/TSV are "exterior", while cmdlets and objects inside a .NET VM are "interior"

Oils Is Exterior-First (Code, Text, and Structured Data) - https://www.oilshell.org/blog/2023/06/ysh-design.html

---

[1] Oils fixes some flaws in the common text formats with "J8 Notation", an optional and compatible upgrade. Both JSON and TSV have some "text-y" quirks, like UTF-16 legacy and inablity to represent tabs

So J8 Notation cleans up those rough edges, and makes them more like "real" data structures with clean / composable semantics


> It's not either-or -- I'd think of it as LAYERED

You can almost always represent one format inside of another. I can put JSON in a text system, or I can hold text in Protobuf. That doesn't mean that the systems are equivalently powerful, or that a text-oriented system supports structured data.

> on the other hand, protobuf or Apache arrow not text, and you can't use grep on them directly

This is kind of tautological, because of course you can't grep through them, because Unix and grep don't understand structure, because they're built around text.

> IMO this is significantly different and better than say PowerShell, which is all about objects inside a VM

Why?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: