text stringlengths 0 2.46k |
|---|
**Jerod Santo:** Yeah. So have you ever tried using your database schema as the schema? Or do you need like an internal representation and an external representation? |
**Yehonathan Sharvit:** No, usually it's different, because usually in the application you don't treat your data as tables. You have maps instead of tables, and those maps are denormalized instead of normalized... So I don't think it's a -- but I'm sure that there are tools that takes an SQL schema and translates it in... |
**Jerod Santo:** How does GraphQL fit into this story? |
**Yehonathan Sharvit:** Don't talk with me about GraphQL... I tried GraphQL and I was so upset, so upset. |
**Jerod Santo:** Why? |
**Yehonathan Sharvit:** Because it's too rigid. It's too rigid. |
**Jerod Santo:** Too rigid. |
**Yehonathan Sharvit:** Too rigid. And I really tried hard. Like many things, when you start, it's great; for Hello World or an MVP, it's great. But then when the complexity of your requirements grows, it becomes unmanageable. And we had to do so many tricks to please the GraphQL type checker... And it added too much c... |
**Jerod Santo:** So JSON schema in relation to GraphQL is much less rigid. JSON schema is much more -- |
**Yehonathan Sharvit:** It's much more flexible. I prefer to have REST plus JSON schema, than GraphQL. GraphQL also has the thing that -- let me just give you an example. If I remember correctly, you cannot have union types for input data, something like that. They decided it should not be done. And there is debate on ... |
**Break:** \[37:47\] |
**Jerod Santo:** Let's loop back to principle number three, because we skipped over it... Treating data as immutable. This one is an easy sell for people who have been doing FP for a while, but it's a hard sell for a lot of OOP proponents. |
**Yehonathan Sharvit:** So I think it's a hard sell just because we got used to mutation... And I think that a while ago in Java strings were mutable, and then they fixed it to be immutable, and it's much, much, much better. And I don't think that anybody likes mutation. It's just they think that if you go to immutabil... |
**Jerod Santo:** Right. Because you're copying data around. |
**Yehonathan Sharvit:** So I think the interesting question is "How can you manipulate data in an immutable way, without the performance hit?" That's the interesting question. |
**Jerod Santo:** What's the interesting answer? |
**Yehonathan Sharvit:** The interesting answer is Git. |
**Jerod Santo:** Git? |
**Yehonathan Sharvit:** Yeah. Git is an immutable source control tool, and every time you do a commit, you don't do a modification; you create a new node in the tree, and you just move the pointer of the branch that says, "Hey, now you're going to point to this commit." But the previous commit is not modified. So the G... |
**Jerod Santo:** No. |
**Yehonathan Sharvit:** Okay. So let's start with Git, and then we will see how it applies in the data. So Git - you have folders, and in each folders you have folders, and folders, and folders, and then files. So imagine that you have a hierarchy of 10 folders, and you want to change a file at the bottom of the hierar... |
\[42:08\] So let's say you have a map with 10 fields, and field number 10 is also a map; and you want to modify a field inside field number 10. So you copy by reference the nine maps, and no matter how big they are, it's just a pointer copy. And for node number 10, the map, you create a new node, and you copy all the c... |
**Jerod Santo:** Gotcha. So you're only copying the diffs. The new stuff is the only thing that's actually getting new memory allocated; everything else is just referencing existing... And so that's why it's better than it used to be. Yeah. |
Okay, so imagine for the sake of conversation that you've completely convinced me, I bought in, I'm now a data-oriented programmer... So I separate my code from my data, I use only generic data structures in my application, everything's immutable, I'm not doing any mutations, and I have a separate data schema from my d... |
**Yehonathan Sharvit:** Yeah. So first of all you, you belong to the population that is enlightened, and you are grateful for that. And now you look at all your former colleagues and you see how much they suffer, and you pray for them. |
**Jerod Santo:** \[laughs\] |
**Yehonathan Sharvit:** And you buy them books, "Data-oriented programming", with your money, and you give them away to your friends, hoping that they will also make the move and be enlightened. |
**Jerod Santo:** There you go. |
**Yehonathan Sharvit:** Seriously. \[laughs\] Let me just mention - I don't know if it was clear, but those paradigms, those principles are applicable in any programming language. It's not applicable only in Clojure. You can apply them in Java, or JavaScript, in Ruby, in Python... Virtually, in any programming language... |
Okay, now let's say you decided to write your HTTP server in the data-oriented programming way. How does your life look like? So if your life looks like that you deal only with the business logic. You don't deal with pleasing the compiler, or pleasing the language. In data-oriented programming you have so many goodies ... |
**Jerod Santo:** \[46:27\] So you've got to have those schemas. That's the discipline. |
**Yehonathan Sharvit:** Yeah. I think that's the problem that is not yet solved. It's a tooling problem. We don't yet, in 2022, have a common way to combine, to express that this argument is expected to be of this schema. We can do that, as I mentioned, but it feels a bit awkward. It's a problem that is not yet solved.... |
**Jerod Santo:** Yeah, I think we did a show on Ballerina. It's like designed specifically for APIs, right? |
**Yehonathan Sharvit:** Exactly. So you did a show. |
**Jerod Santo:** Or for the cloud. I can't remember how they pitch it. Yeah, we did a show like two or three years ago on Ballerina. I haven't heard of it since, honestly. |
**Yehonathan Sharvit:** Okay. So it has continued its evolution, and the Ballerina of 2022, it is marketed as a data-oriented language. So those guys came to me -- you know, it's an army of developers. It's 100 developers working for five years. And the manager of all this army came to me and said, "Oh, your books look... |
So the syntax for maps is very similar to JavaScript - you know, curly braces and JSON - but for accessing a member, you have two different syntaxes. You have the dot notation, and the square bracket notation. In JavaScript, both notations are equivalent, but in Ballerina the dot notation is for fields that are at comp... |
**Jerod Santo:** You can splurge a little, you know? You can go out for the evening. |
**Yehonathan Sharvit:** Exactly. |
**Jerod Santo:** Treat yourself nice, yeah. |
**Yehonathan Sharvit:** And for me, I think it's the future. I don't know if Ballerina is going to nail it down, or maybe another language... But I don't think that everything is perfect in the dynamically-typed languages; even with JSON schema, like I mentioned, we have the tooling problem. With static typing we have ... |
**Jerod Santo:** Yeah. Or maybe that language is not Ballerina specifically, but this panacea -- maybe it's too good to be true. Maybe there is no such middle ground that we can actually stake out... Because the requirement of discipline - you know, if you provide me the ability to shoot myself the foot, I may just do ... |
**Yehonathan Sharvit:** \[50:21\] Yes. And the tooling also gets better and better. |
**Jerod Santo:** It does. |
**Yehonathan Sharvit:** Like I said, in Clojure we have clj-kondo, with malli, and there is decent integration. It's not like, you know, Java IDs, but it's getting closer. But future will tell. |
**Jerod Santo:** Very cool. Well, anything -- I'm sure there's areas that we didn't touch. The one thing that you mentioned you might return to was the circumstance in which the schema representation is worse than static typing. You mentioned in the case of API endpoints with JSON schema it's better, for the two reason... |
**Yehonathan Sharvit:** Yeah, so it's not the kind of program, but like where in the program. |
**Jerod Santo:** Okay. Where. |
**Yehonathan Sharvit:** So we have two kinds of data validation. One at the boundaries of our programs - and there, the validation is inherently dynamic, because you get output from the outside. So the validation, by definition, cannot happen at compile-time. It cannot be static; it has to be dynamic. So that's where d... |
**Jerod Santo:** Alright. Well, what about community? Is there a place where data-oriented programmers hang out, discuss, tell horror stories? Is it the Clojure community? Are these just the same communities? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.