Fork me on GitHub
#off-topic
<
2021-06-15
>
Eric Auld16:06:31

Hi, folks, there’s a comment that Rich Hickey makes in his talk https://youtu.be/MCZ3YgeEUPg?t=2550 which I don’t understand. He’s using the metaphor of musical instrument design for language design. At 43:40 he calls our attention to the fact that “these things (i.e. old synthesizers) had a machine interface first…and then they put a human interface (i.e. knobs) on it…Imagine if someone had built something without any machine interfaces, but primarily with human interfaces…” and he gives SQL and Unix as examples. What does he mean by this? How do SQL and Unix have “human interfaces” but no “machine interfaces”?

3
vncz16:06:59

The way I take that is SQL is essentially a string you send over the wire, and this has a number of implications. SQL was meant to be written directly by an human; but if you want to programmatically construct a SQL statement from something else, you will realize that is not exactly that easy. You will inevitably end up with some terrible string concatenations, making sure you put a comma in the right place, or make sure the HAVING clause comes after the WHERE. And that’s one of the reasons ORMs were born. Imagine instead a “sql” that would not be a gigantic string, but instead a series of data structures; a new where clause would not be some weird string concatenation, but just a new element pushed into a vector or something like that (Datalog? trollface). When you have that as a base (instead of strings) then constructing a human interface (the SQL we have now or any other DSL that pleases you) is way way easier.

👍 4
Dimitar Uzunov16:06:24

In UNIX you have the shell which was invented with human interaction, but ended used as a scripting language. SQL afaik was also intended to be used for ad-hoc queries, hence the natural language-like syntax (select something from database where …)

👍 2
Dimitar Uzunov16:06:39

since the design focused on the UI first it ended up being inferior (proof being the tons of different shells, management tools, configuration management and interpreted languages for UNIX) and ORMs for SQL

Eric Auld16:06:09

In principle, what could a “machine interface” for Unix look like, generally? Having a hard time imagining it.

Dimitar Uzunov16:06:24

I would imagine something like Ansible, K8s or Nix

vncz16:06:03

@eric.auld Think about all the commands you have in Unix, such as cat, tail ; can you programmatically use them, or are you forced to throw sh commands from your software (which is just wrong?)

vncz16:06:25

Wouldn’t it be great if all the commands you have on unix would also be available as standard unix api?

vncz16:06:51

The Human Interface would be a byproduct of the good underlying API, and not the only way to use the unix command itself. Am I making sense?

👍 4
Eric Auld16:06:15

I’m still learning programming, but I think I understand what you mean. There don’t exist the analog of “system calls” you can make from, say, Python into the *nix OS to do things like cat. Instead you have to instruct the system to run a shell script to do those things, which is a wasted layer. Is that right?

vncz16:06:50

Not only is a wasted layer, but it’s brittle. Managing error is hard and most of the time unsuccessful

vncz16:06:18

The only reliable information you can get is the return code (0, -1). Any other detail is left at the mercy of the standard output string that you need to read, parse, hope that it does not change and break everything.

👍 4
vncz16:06:59

The way I take that is SQL is essentially a string you send over the wire, and this has a number of implications. SQL was meant to be written directly by an human; but if you want to programmatically construct a SQL statement from something else, you will realize that is not exactly that easy. You will inevitably end up with some terrible string concatenations, making sure you put a comma in the right place, or make sure the HAVING clause comes after the WHERE. And that’s one of the reasons ORMs were born. Imagine instead a “sql” that would not be a gigantic string, but instead a series of data structures; a new where clause would not be some weird string concatenation, but just a new element pushed into a vector or something like that (Datalog? trollface). When you have that as a base (instead of strings) then constructing a human interface (the SQL we have now or any other DSL that pleases you) is way way easier.

👍 4
vncz16:06:49

Or also, think about the fact that SQL Statements would be data structures, a software could easily analyze them be like “I think I’m gonna send this modified query to the database server, and I’ll do this additional filter here on the application server directly because I know better how to do that”

vncz16:06:28

TL;DR: send data over the wire. Data won.

☝️ 5
Eric Auld16:06:47

By “data” you mean something more like a vector and less like a raw, bloated string?

simongray07:06:28

I think in the Clojure community we often say “data” (since that is what Rich Hickey says), but what we really mean is structured data.

👍 3
simongray07:06:48

And in Clojure terms that structured data is a composition of the built-in data literals rather than some DSL contained in a string of bytes.

👍 3
walterl16:06:14

> Imagine instead a “sql” that would not be a gigantic string, but instead a series of data structures; a new where clause would not be some weird string concatenation, but just a new element pushed into a vector or something like that (Datalog? trollface). -- @vincenz.chianese I haven't worked with Datalog before, but this description is exactly why I've come to love HoneySQL's approach: it retains the expressiveness of vanilla SQL (mostly), while actually applying the structure from Structured Query Language. That last part is why we generally use ORMs over SQL: so we know the SQL is correct. HoneySQL might not guarantee correct SQL (especially when mixing in raw SQL bits), but for 95+% of your queries, it will. On top of that it's easier to manipulate the structure of the SQL by using normal, built-in data structure operations. TL;DR: I ❤️ HoneySQL for the reason you described above 😝

walterl16:06:50

The two examples you gave ("comma in the right place", and "`HAVING` clause comes after the WHERE") are, for example, completely solved by HoneySQL

vncz16:06:42

I am not familiar with the specific library you’re mentioned but I took a quick look and that gets the point, yes 🙂

seancorfield16:06:06

We love the composability of HoneySQL at work: we can pass a “query” (data structure) into a function and it can easily add new columns to be selected and a new join clause and additional where clauses and pass back that updated “query” (data structure).

dpsutton17:06:06

i recently had to make a 5 table union all query, and being able to introspect the individual queries, gather all the columns, and backfill the missing columns (selecting null) into the other queries greatly simplified the whole thing

borkdude17:06:38

I'm also using honeysql more and more, flexibility ftw! and also inspectability!

mauricio.szabo23:06:18

One more satisfied user of HoneySQL here too 🙂. I even hacked some "ad-hoc queries" over a chatbot for people to make queries, and because it's all data structures, I was also able to make joins automatically!

👀 3
nate sire17:06:10

Anytime I open the Slack client... it crashes. I am guessing it has a memory leak.

nate sire17:06:48

I have seen many workspaces slow down... very little traffic... It could be the problem for many. The app is not working.

nate sire17:06:20

I tried to run it on a desktop with 4gb of ram... And it crashes.

nate sire17:06:49

I guess I need to upgrade to 32 GB :rolling_on_the_floor_laughing:

seancorfield17:06:59

Run it in a web browser?

nate sire17:06:08

ok... I remember doing that

nate sire17:06:25

but it always tries to force me to use the app

nate sire17:06:58

Lightning blew out 3 of my ram modules

😬 2
nate sire17:06:13

my friend found them... slightly burned on the edges

nate sire17:06:39

used a flashlight to see the slightly burned enamel

nate sire17:06:13

thanks @seancorfield I found the link hidden behind the popup... to open the browser... I miss this way of using the app

ksd20:06:20

today I learned there is a language called Tabloid, and it is hilarious:

DISCOVER HOW TO fibonacci WITH a, b, n
RUMOR HAS IT
    WHAT IF n SMALLER THAN 1
        SHOCKING DEVELOPMENT b
    LIES! RUMOR HAS IT
        YOU WON'T WANT TO MISS b
        SHOCKING DEVELOPMENT
            fibonacci OF b, a PLUS b, n MINUS 1
    END OF STORY
END OF STORY

EXPERTS CLAIM limit TO BE 10
YOU WON'T WANT TO MISS 'First 10 Fibonacci numbers'
EXPERTS CLAIM nothing TO BE fibonacci OF 0, 1, limit

PLEASE LIKE AND SUBSCRIBE

😄 14
lol 4