- Podcasts
- Happy Path Programming
- #3 Nulls, ADTs, and Code Formatting
#3 Nulls, ADTs, and Code Formatting
Happy Path Programming
- September 15, 2020
- 1 h 3 min
- Season 1, episode 3
About this episodeA bike-shedless discussion about nulls, algebraic data types, and code formatting. Discuss this episode: https://discord.gg/nPa76qF
A bike-shedless discussion about nulls, algebraic data types, and code formatting.
Discuss this episode: https://discord.gg/nPa76qF
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#3 Nulls, ADTs, and Code Formatting
Welcome to happy path programming. I'm Brew cycle. I'm James Ward. I've been thinking a lot about how Badly null is explained in programming. And, and for me to it's like only recently, have I really started looking at that going. Oh, that means this because I've always, I came from see an assembly and C++ and initially, it was just either uninitialized or set to zero or whatever. And it was just like, yeah, don't do that. Don't don't use that.
Yeah. And At like what Bill encounters a lot is people not paying attention and ending up with null pointer exceptions in Java. Yeah. And when you really start looking at it, you're going well, what are you trying to convey? Yeah, with this null and you reel and then but it wasn't until I started looking at the optionals and either's and all, you know, all the monadic things where they're going.
We have more information to convey here than just The result. Yep. And then you start and then you look at the way cotton does it. And it seems a little strange at first because they do all this trouble to get rid of the nulls that they get from java. And yet their model for results is result or null?
Yeah. And well what's up with that? And it's like well that is kind of pseudo, monadic way of doing it. Yeah, it's definitely the ATT algebraic data type for modeling. If something can has a value or doesn't, is you join together, the two types with it would be a, or an expression and algebraic data types. So this is a dog or a nothing, right? And then the zo stuff says, well, as long as we're sending this package along, maybe we want to add some other things that everybody needs to.
And it's like when you start thinking of it in terms of these packages that are being transferred from one function to another, to me, it starts to make sense. The chain ability is, yes, is critical to the whole thing because Essence, if, if if you only have her call one thing, none of this really matters, like nope, it's all about composition. It's like either you're to either you're doing these chains or you're composing a new function by putting these other things in and you don't want to have to To insert after every single call, you don't want to have to insert did the succeed. Or and, and then once you realize that, that's a, that's an option to have this package of information that flows. Then you can say, oh well, maybe I want something from the environment or something for the user interface that I'm talking to or I think bills using time that way. Yeah, now it starts to make sense and I think that the The attic idea is just I mean that
part is just okay if you want to do this can we have math? That shows us what is the right package to ship between these two things? This is just my thinking right now, I don't know. That's right. Yeah I mean what what are the expectations that this thing conveys? Right exactly and and what the, you know, the usual the problem that happens is people get fascinated with that and they say Say that's the essence of it and that's not it's the composability chain ability thing. That is the essence of why we're doing this at all. And I couldn't understand it because I didn't know what the motivation was right.
What? I just saw a tweet this week, that showed a block of code, it was like a block of code that you would see in so many books and samples. It was like, okay I'm going to talk to the database, I'm going to get a person and then I'm going to use That person to look up some other piece of data about them.
And the interesting thing about that example and it was pointed out was that that code will never be production quality code, because it doesn't address the potential for failure. It doesn't address the potential that the person couldn't be found. It didn't address. The what happens if the network is unreliable and I need to do a Try, it doesn't address. Dependency injections.
The ability to like change change how I do that. Look up based on my environment. Testability testability. And so it was really an interesting example of why these why are programming languages are adding features, or changing the way that we do things, so that we can have the conciseness of that code. But also deal with the, the the Issues with with, actually putting that kind of code into production because you, yeah, and this is the way we teach programming. We teach happy path programming and that's the way I learned it and I still remember like encountering a C library that says.
So you have to allocate storage past the storage in and then use the result and then release the storage and I was like what why isn't it doing it for me? Well, I mean I still want it to do everything for me but you know, I hadn't seen any of that. It was always just you do this and it happens, right?
And you got a whole thing could ever go wrong nothing could ever go wrong. And so you get a whole bunch of people coming out of school mean, I've only been to happy path program. Happy past programming and because I know that's, this is one of the things that I know in particular Cody has been really focusing on because, you know, he's only been out of school for a couple of years.
And it and it's like, testing. I want to know more about testing because I don't trust this coat which is great. I'm deaf, you know, I'm so glad he has that attitude, but he's had to learn. He's had to go through the path of learning testing himself and it's so that seems so fundamental that and I think they had to teach themselves get as well, you know, just all of these things.
But the trade-off to that is that it can get really challenging when there's so much When so much explicit information is conveyed. And so, I think, what we're discovering is ways to not make it so hard to deal with the explicitness that's being conveyed through those function calls. So, I think the, the kotlin null syntax, is a great example of that.
It's like, okay, we know that we need to convey. Null ability in the type system, and we've discovered the att's are a great way to model. All that hmm. Well I mean I at least my view of it is that there's two different things, there's handling nulls so that they don't happen and then there's using null as the failure return type. But because you have that null, hamling the compiler forces. You see, that's the thing because when you get back an either or whatever you don't have to, I mean you don't have to check the failure value, you can just pretend that it's okay. Just do have you do that with with Colin to it just it it feels dirty and I think that's part of with it with air handling, its how dirty does it feel to ignore the possible air conditioned and with Scala and monads? It feels really dirty.
Like I feel like I need to take a shower. If I call Dot get on something that could fail. Is basically just saying, ignore the failure. Mmm. And in kotlin, you have to say, I mean, you have to get like really explicit about it so I have to go back saying bang Bang. Yeah, I'm and and you know that's glaring at you.
Yeah, it's like yes. I so I think your again here and thinking that no, it will never fail. And I think that's part of the the counter act in the happy path. Programming is to say this feels really dirty to ignore this error and we're going to make You do something that should jump out in a code review and say this is really bad and you can easily grab for it.
You know, you know we've got some null pointers. Let's look for the ignore the null operators. When I bet there's a compiler flag or build plug-in that would say, don't let this code compile. If a bang bang, is put in there. Scala has some, you can say all warnings are failures. You think Colin has the same thing. So so warning would be hey you called that get on this thing or you did bang bang.
And I was then you can turn that into a compile error with the was compiled flag. Hmm, yes, yeah, I think we are culturally shifting from Happy path programming. But I wonder if universities are shifting and that's maybe where the always wants lowers needs to happen. Yes. Like our programming languages or certainly shifting. I mean, even go like it made it explicit that every function can return can return in are, right?
I mean, like, python days. So who is weird about that in goes that? A tuple is should be a an and ADT Wright? Like a conveying that to values? Can can fill that space in the case of a? That's what you want billion people? That's I think what goes kind of style was was. Yes, what? And then you have to check, like did you return the value or did you return the thing?
Whereas really, Leanne or ATT is much better fits, what they're trying to convey, because no, it's either it's either a value or it's an heir. We should probably remind people because you're throwing around the term ATT algebraic data type. Right? So that what is it look like? So there are there is the or and there's the and the or is a dog or a bird.
So that so people have usually seen these or something very similar to these with enums. So the way that you do it is If you if you, if you've said that my return type is a dog or a bird, then you return either a dog or a bird and so comes back as a dog typewriter or a bird type or does it come back as a box, containing a dog or a bird? It comes back as a rapper that the, the type, the actual type would be dog or Bird, right?
So I think the way that most compilers do att's is they actually generate types that the Are the ADT the the aggregate type. So when you say this is a dog Roberta goes, okay, I got this. I'll make this little package that can contain your dog, your bird. And so then usually pattern matching is the way that you then deal with the what it can. What you actually got.
So eliminates the need for an either-or. In either is a is a way to do a, neither in scholar other languages have users as well, is a way to do. Do a or type with a, with a rapper. So that so your you are not having the compiler, give you a type, that is the ADT. You are explicitly defining creating it, but if it's supporting this, then it just does that for you and mix a little more seamless.
Yeah, right. Yeah. Because I always felt awkward using that they, you know, the left's and the rights and everything, I'm going to that doesn't mean anything right? And I haven't like that. Where is it? This well in and also your Imagine is much cleaner because you don't have to then pull things out of the wrapper your pattern matching can just say case dog. Do this.
Yeah and and it knows how the compiler knows how to take that or type that it created for you and in the pattern and unpack it right. Right. Yeah. That just seems that that would have been a much easier thing for me to absorb rather than trying to figure out the the either's. And, you know, the there's also the a Uh, and ktt, which is, let's say that I have a type where I needed dog and a dog house and I want those in a, in a single type.
So the the way that we see these is through data classes case, classes in Scala, other languages have other way, wreck new record types in Java are essentially the way to model and and type. And what that's saying is that I have a type. Holds a dog and a dog house and we would call that, I don't know, yard with dog or something like that. And so we would give it a name and then would be able to extract the individual pieces out as it was almost, like, just building the class for you that we would normally do by hand. Yeah, yeah.
So but the, but if you have a language that has in hand ATT then you don't need to explicitly. Define the the like case class or data class. You just say dog and dog house. Hmm, what you know with and and or whatever or single and I can't remember what it's called through, does it? But and then it generates the type that represents that like it does in the case of or hmm.
Something that's right? Yeah. Yeah. That one doesn't. I mean, I guess because I'm so used to making my own named classes that one doesn't seem as essential to me as the as the or yeah. Because it seems to me like the or solves that problem of the ugly object coming out that I have to them unpack. So the next level of error handling in the back to you, like no ability is Let's say you have a function that returns a dog or nothing saying that that maybe maybe you couldn't find the dog.
Sure. And so, so you get, you get docked escaped. It's escaped. Yep. And so so you get nothing but what if you want to add more information or more possible error, handling scenarios into that. So let's say that, that it could be nothing or it could be a service was unavailable and you want to you want You convey that information in the type system, so that, then the caller can decide what to do in that, in that case, not just Mmm, right?
Because, because nothing could be. I couldn't find. I tried and I couldn't find it, the network, I can ride. And I failed to actually try or not in the dictionary, the Network's down. Something's gone. Yeah, it's like, well, and this. So, I was just describing this in the very introductory chapter in an atomic scholar, whatever. I am viciously decided to, to say, here's one of the great features about the language is that it's more than just like when how do you deal with no result and and part of the problem is that for efficiency sake we go oh well I have an ENT and to show no result.
See did this, you know, I'll put a minus 1 in or you know they tried all these Dimensions. Yeah. And it's like and that was for efficiency sake because there When we don't want to use up extra storage and what we actually do is, yes, we do want to have that extra information. Yeah. Along with us so that we can say, why do you have no value right?
You know, because I need to maybe I need to do something based on. Yeah, so it's a lot more than just I mean and that's where I guess just null is better. I mean no at least tells you that no value has come back and it's not just some random -1 or value, it's not just some unlikely value that could actually happen.
Yeah. But it's still not enough information in my opinion to be able to actually, you know, right? Deal with the error. Yes, it's not that different from throwing an exception. I mean the exception can sometimes carry more information but still yeah. So taking a TT. Even further you can, this is kind of outside of the realm of the way that Colin does it with, no ability.
But using hey TTS, you can have a function that returns a dog or a and then in parentheses we're going to group these next block together. So or a nothing or nothing or a. So you could even an these things together. So dog or a nothing and the reason for Being right? Or or you could do it and say and nothing or a network error.
Yeah, yeah, which is ultimately what we need in order to be able to Chain these operations together? Yeah, so Hmm, on the subject of Algebra, I saw this great video on Twitter where this girl was asking why was algebra invented what problem are they trying to solve and then invented Algebra I thought it was fascinating. There is a few most people are just saying that it was a really good question, because I guess she got bagged on 44. People thought it was a stupid question actually is really no. That's that's yeah, that's an excellent question because well, and it's the kind of question.
I was just thinking about this in terms of, you know, our monad description where people go to. It's a monoid in the category of endo functors in. It's like doesn't describe it doesn't. And when you present that to somebody who's like just trying to program, they going, why are you telling me math and when you're in math class and those are obnoxious people would raise their hands and go.
How do I use this in real life? And it would bug me. And now I go they were asking a good question. That is because As you know, just saying learn math. It's like in Rick and Morty. You know, he keeps the math teacher keeps saying, math is so important, it controls everything in life and you know, they're not connecting with that. That's like you really do and it's the same with explaining monads if you explain it from the mathematical and nobody's gonna get it.
But if you say, hey, we want to chain functions together or compose them or, you know, we want it. We want to do this thing and not have to deal with then. That's when it first started making sense to me, is when I could see it that way. And so asking, I mean, now I want to know who who said, hey, we should have algebra or just the idea. I mean, it's almost like what I was musing about earlier, with, with zeros, it's like you have some things. And now you have nothing, right?
Nothing of what, you know, you could have nothing of anything, whereas you can only have five chickens gray and and coming up with zeros and ones and how they're different from all the other numbers. Yeah. When you really start thinking about that, it sort of blows your mind and it's the same thing.
I mean, my guess would be somebody said, boy, it. Sure would be helpful, convenient, or whatever. If we could I have something rather than a number we could say, placeholder for number, right? And so, no. I think it's, I mean, this girl should probably be a mathematician. Yeah, because she asked that question.
She also had asked something along the lines of is math. Real, like like, did we discover that thing's a mathematician? She should, she should definitely study math. Did we actually discover this thing that existed or did we just create a Concept to help us explain something. That is deeper and unexplainable.
And I and I think the answer is yes to both of those because there is pure math and applied math. And when I was in physics, I would and an engineering as I was studying, applied math. And so we were just looking at moving things around and and seeing if we could, I didn't understand this at the time. But seeing if we could get the equation 2, Represent, what was going on in the real world and you didn't care whether, you know, it was math, you know, it had to work mathematically, but it wasn't like deriving a theorem from first principles. It was just going well balls moving this way. And So, based on our experience will say that it has a partial derivative of this.
And that I didn't know what was going on at the time. But they were just trying to piece these Things together. Now we would use machine learning, we go. Let's let's look at all this data for all these balls and then come up with this model and this model and that's all we were doing. Yeah but both of those things are super important you know. So so I think to her question in regards to algebraic data types is why algebraic data types like why? Why do we have them?
And for me I think, What it comes down to is that we most of us understand at least a little bit of algebra. We understand that plus is commutative, right? That is that the one where you can flip it? A plus, b is B say, right. Yeah. And so, we understand, we understand these basic algebraic laws because around multiplication and addition because we were taught those in. What grade was that Fifth grade sixth and seventh grade anywhere somewhere around there.
And so, so even though I can't remember the laws and can't remember the names and what they actually mean off the top of my head, I've internalized those rules. And so, when I encounter algebraic data types in a program, it makes sense that the expectations that I can place on, on those types. I know that if I have a dog or bird a dog, or bird type, It's the same thing as a birder dog type. Hmm.
Right. Right. Yeah. They actually, the thing that really hooked me, I think Bill explained it because I wasn't sure what when he was talking about algebraic data types. He was saying, suppose you pass it in as an argument, so you could have a dog, or a bird or football, and it says, then in your, you know, pattern match. It's explicit.
It's like, it's like a not a final class what field seals class in cotton. And so then you guys are the only things that could possibly be. So there and there's no else and if you change the signature of your function, the compiler says you're missing one here. That's right. And it's like oh well that's nice. That would be a little bit better. Than what we have.
But then you see other things that you're describing, make it even more compelling. Yeah, yeah. And are there any other languages than Escala three? That has those Like built in there are, I'm sure there. I'm sure like mathematical language is, I'm address or whatever, probably has it. So, cock is another one that I think has has led a lot of the research in these areas.
So I don't know a lot about them, but, but I think we see, I think we see them in a lot of languages, but they haven't necessarily been called algebraic data types. Like we've seen tuples in languages for a long. I am but but people haven't referred to that as as an ATT. Yeah. And it allows calling in an ATT allows you, I think to think about it a little differently because I mean python has has had tuples forever, right?
But I've just thought well if you want to return more than one type, use a tuple and packet on the other end, if it gets too unwieldy you. Turn it into a class. Yeah. Yep. But just give it a name. You give it a name. It's just very in fact. There are there. They added a feature called. Name two people.
So so your, it shouldn't just be a class though. Like maybe syntactic. Where were you? It was added a long time after tuples were so. Apparently there was a perceived need for it. Yeah. And I am people are I think pretty enthusiastic about it. I've not really used them very much, but maybe, maybe I'll internalize it and start using them. Yeah.
But yeah, I typically prefer a named I mean, just a class cuz But anyway people yeah, people find Value in it. So yeah there are times when I'm prototyping something and I don't know what the name should be, where I use it to pull. And then after I've explored the domain sufficiently and have arrived at what the thing is. Yeah.
Is that the the rules can get applied in different ways? There's a, there's a matrix of how these, these algebraic rules can get applied and so we can actually give names to different ways that different rules get applied together. And so there's, I don't know all of them but there's like lattices and mono Eads and And then monads.
And so these there's all these names for just different structures of these laws together. And so, so I think that right now ATT is are coming up in a lot of programming languages. And what we may see, over time is more of these, aggregations of algebraic laws and the names for them percolating into programming and other ways as well. Hmm.
So that'll be interesting to see how that plays out, but is it is where it's hard. Is that in seventh grade algebra, whatever? I learned addition and multiplication. The, the algebraic laws of addition and multiplication. I didn't learn the algebraic laws of monads, right? And I mean, I learned a lot, as I didn't learn the term. It was also hard to I could just plow through and And do those things.
But I realize now that if I'd had some kind of motivation behind it, it would have just completely changed my perspective. Yeah, I just it just seems like there was a lot of wasted time there, which could have been put to better use but yeah, that's a different. So let's see we got partway through or we got money, a lot of the way through discussing kotlin features kotlin 1.4 was released Last week to, it wasn't sweet exciting.
I switch some apps over to it and everything just worked, which was awesome. But I reading the release announcement. There wasn't like a ton of programming model changes. It was a lot of it seemed like a lot of internal stuffed in. There was a lot of internal stuff. Yeah. That, um, Dave and I teens in fiber, like there was internal changes to that, but but yeah, I mean the single abstract method stuff. That's right.
Which is an optimization for jvm bytecode applicant? No, it's a, it's a programming thing. So you're able to say if you have a an interface that has a single member function in it because that's what we call them and Colin and you put fun in front of so it says fun. Face. And then the compiler will make sure that you only have 10 cool and then you can you can use it as a method reference. So just like in Java like I think job that's modeled after Javas and something.
So if I want to implement that interface I can just for example I could just like use a Lambda R and the lambdas single function will fit that and I don't have to do all the rest of the stuff. Yeah. Why don't you say, you have to have a name. So I can say return interface name and then give it a Lambda. Yeah, and then, so from a succinct - standpoint it's really nice.
And I went through the book and found all the examples that I could and and either just did them as Sam things or did them both ways and said, here's the old way and here's how you can do it the same. So nice. Yeah. And you updated the book to 1.4 Yeah. I mean we were working with early versions and want to fight for all along but there wasn't any, you know, it was just additive stuff.
Yeah, but yeah, and I've kept it up to date with the latest Gradle. The latest versions that have come out. So it's yeah, it's it's basically 1.4 compatible. And yesterday, I finished the text of the book. We still have exercises to be the exercises and solutions are all done. Done. But they need to be converted into this form, so that you can do the exercises inside of IntelliJ, IDEA, and it gives you hints and answers and things.
So, we're on our kotlin.com, people can Atomic cotton.com has, they can go there and it has all the instructions. It's awesome. The book is through its being. Well, there's a system that jetbrains I think, I don't know if they own the company outright, or they're just supporting it, and then there's a lien.
Which is has been very useful. And so that's how you get the book and then the print book will be mean. I mean it's ready. It's just, you know, we have the cover there's needs to be some adjustments with the spine and things like that and but yeah, I think it'll be remarkably soon that the print book will also be available and it should be assuming the Ingram spark thing goes well it'll show up everywhere. Yeah, be available everywhere.
I think I read through some very early versions of it. Probably if it was a while back, there's a lot. Of rewriting. There's some things I need to learn. Like what's the by thing? So in Colin you can say Foo by lazier food by some other identifiers or something. That is delegation, okay, so you can say I want to implement this interface using that object okay? And it enables things like lazy or late initialization. So lazy initialization.
Allows you to have a non null reference. So it's, it's still has that non-null ability benefit that you have, but it doesn't get initialized until the first time you use it, right? And then late initialization is so is lazy actually than a keyword in Colin or Because I've seen by and then other identifiers.
Yes, is well, yeah, yeah, it's not. It by is not just lazy. It's, it's, it's delegation in general. So, another thing that you can do with delegation, which is really nice because it's kind of halfway between inheritance and composition. So, delegation would allow you to say, all right, I want to create this object from that other object, but I don't want to inherit from it. I want, you know, maybe I'm already inheriting from something else and we can't do it today. You can do multiple delegation and you can still up cast to the multiple delegates.
Yeah. So you get which is really what multiple inheritance as far as if you want them up, cast more than one base talk. So you get that with delegation but what's really nice is you can say, okay, I've got this thing. I've got a couple of methods, and I want the whole Kitten caboodle from this other object but I want it to be exposed as my interface.
So it's just, it's, it's kind of another way to do polymorphism. Well yeah, I guess because you can up cast so it's more. I mean, I think of it more as a way to assemble objects with less code because I mean, maybe, maybe you're right, maybe it should be thought of as another way to do polymorphism.
But my first impression was, oh, I want maybe a couple of objects in my other thing and I want their interfaces to be exposed to The other. Yeah and I don't want to have to write all those you know, functions that are simply saying okay call this call this. Yes and it does it for you so but then it also enables things like the lazy and late initialization stuff. If it's I am back to ADT is I wonder if it's also another way to create a product type If it's some special Syntax for generating product types.
Yeah, I guess the trick would be to see to figure out what you can do with delegation and what you can do with a DTS and see how much they intersect. Yeah. If they do intersect, yeah, we need a mother's intuition to do that. Yeah. So but yeah, no, it's a very powerful thing and we have Multiple atoms in the book on delegation delegation, because, because it's used, I mean, there's, you know, basic delegation. And then they're there.
It's used in a number of different other ways. So yeah, it is, it is, but yeah, very powerful syntax. Um, so, yeah, one of the things that I don't think we emphasized a lot when we talked about it before is just the syntax Simplicity and Clarity in the Less code and like I've forgotten it now because I'm used to using both Python and kotlin. But then when I come across well my friend Luciano who wrote fluent python he's quoted me as coming up with this term semicolon languages, which is to me a language where the designers felt like the compiler writer was more important than the programmer.
That's pretty harsh, I know. But It's, it's kind of what I mean, you know, I was just telling you about this one language designer, who wants to keep semicolons in, and when I objected to it, he says, well, you still put periods at the end of sentences, which I just, I don't know what to do with that.
Its it just seems so archaic to me now and what didn't see. You know, I forgotten did De Scala, get rid of some of their optional, so they're optional. Okay. Well, that's fine. I mean they're optional in kotlin to so yeah. So they led the way with that? Well, I mean python did too and well, and then comparing it to Java being able to Top-level functions rather than forcing everything to be a class. That was just, yeah.
That was just what they were trying to make it small talk. So yeah. You know that with what a this interesting thing recently where I started applying Katie lent which is the Cotton linting tool, I did not know about to some projects and it out of the box. It was pretty strict on ordering of imports, which is interesting because Katie Lynn had different rules than IntelliJ.
So, but it would check the file name against the class name and stuff like that. There was there was rules to me that seemed like, okay if I'm working in a team and I want all the code to be structured, the same and look the same, like these are useful rules but then there was rules that were oh yeah, like this should just be a every column program or should should abide by these rules and so Yeah, it was it was a interesting, useful experiment, and I did it in this case because the, my pull request was being marked as failed because the, the pull request was automatically, having Katie, Lynn run. And so then I had to add Katie lint and get it work locally. So that then I could get my pull request to get a thumbs up. Hmm.
Well, it sounds, I mean, I like those things because I know we used to have Arguments about code, formatting and style in this. And that, that would just go on forever. And for me, if I apply a formatting, an automated formatting standardization, and the argument because it's there's never been any there.
Should not eat like, shedding review. Like I think. I tweeted recently, something along the lines of if a code review, involves discussion about, formatting and code structure. She's a waste of time. Type it exactly. It's like you got to be thinking of it. In terms of we have a team. Everybody has to read the code.
I'm sorry if this doesn't fit with your personal coding style but that's not the most important thing. And if you think it is you're not a good fit on this team or we we've automated this. So Katie like can also Auto format your code for you. So just like automate it so that and yeah if you if you like Madden code a different way, like sorry, like just yeah, it's not.
It's a communication. It's I don't know. It's like I hate goes formatting style heat it, but when I'm writing go code I abide by the go formatting because you're gonna yeah, because I'm working on a team with people and I understand why would you do that? It's just like, like they offend me to the point where In died in IntelliJ, I have tabs tab show up in space is show up.
And if I see that like Arrow, like IQ, always just as visceral reaction. It's so what I meant. So when I'm working on go code, I tell angele IntelliJ, don't you two? Don't, don't show me alone. Just don't show it to me because gonna know exactly, and, and when I don't see it, it's fine. I can get through cutting just fine. I can, I could see that I could see. Yeah, there were a lot, I think there were a lot of things that Java imposed on us.
And didn't understand certainly didn't understand C++ well enough. Yeah, to say that I think before tools were sophisticated, maybe there was some value to being able to know where a particular Definition resided, but now with tools, you just control, click on the thing and it takes you to it. Yeah.
Yeah but you know, I mean to job so the way I presented Java in the cotton book was I said it did two really important things for us and it was basically bringing these ideas into the mainstream that we previously thought were impractical, which is garbage collection and virtual machines, and before that, it's like, well, yeah, we knew that.
And so people go on others are impractical and then Java comes along and it goes well both of these things were showing you can use it, the rest of it was, you know, we're moving on from it. I think we're all moving on. So in Java is continuing to evolve and getting some great features. So it is, I mean, what Ryan gets us doing with Java is like mind-blowing.
I would have looked at it and said, this is hopeless and he goes in. And he like pulls these magic tricks out of his hat that are just like, that's why he's so. Brilliant is brilliant. And as he as I've heard him, say he has last mover Advantage, which I just love. It's their advantages to let everyone.
I all sorts of stuff. And then once, once all the experiments have been done, then they can adopt what works. Well, that's basically what Colin did. And yes, because virtually all its features except for extension lambdas, that's that feature, they invented. But every other feature, they lifted from another language already been proven, not just that it works, but that people got Got a lot of value from it. This is what I really respect about that decision making process and like, you know, they put in things like ranges, which are small, but really nice, you know, just being able to say 1.5 rather than, you know, range, you know, rather than calling a function.
But once you have a garbage collector you're creating everything on the Heap anyway and so you don't need a new keyword. Yeah I mean if you are the scholar three is getting rid of the new keyword there are making an optional I should say yes. Right. So that backwards that yeah but effectively getting rid of it.
Yeah which is which is Which is really nice and that. Yeah, and there's a bunch of other things that they did which initially they had. Like main was more like, I don't know I guess it was kind of like Javas, you know, you had you had extra things in Maine that you like the arguments to man you would never use, right? And the Caitlyn.
Caitlyn told me that on my man function that I wasn't actually using the arguments. Oh, so you can take them out. Yeah. Okay, okay. But I Thank you, Katie Lynn, I love I mean it's I find it so annoying. I mean like Javis you know helloworld in Java. Get out of class. You got a system out print line, you got to have a public static void. Main you have you know?
Yeah. You think about all the concepts you have to understand to like really understand? Hello world. And it's a dozen, it's a lot. And in Colin, what's what your minimum? Just fun main open, parentheses close parentheses, Embrace open curly brace and that's it, right? Print line, hello world? Yeah, and you can explain it.
Like, which whereas in thinking and job for the concepts there you have to understand our function. If you can understand, not even arguments, not even types like you, there's no type. No, I mean there are types. But they're not explode. They're all in plaid and for. Yeah. Yeah. But yeah, so that's really nice. Yeah, you have one concept you have to understand for. Hello.
Is when I wrote thinking in Java my route, my rule was I'm not going to I'm not going to do the thing that so many people do go. Well, don't worry about this code will explain it later I'm going. No, I'm not going to give you hello world that you don't understand all the pieces of, and it took a lot of writing before I could do helloworld in Java and so yeah, I mean, things like that.
Yeah, if you're trying to avoid forward reference, Has in Java. It's like a dozen chapters before you can get to hello world. Mmm. No, it's called, it's probably like six. Mmm. Yeah I found it. Like none. Right. None. Because you don't even have to have flame and you just say, print, hello world here.
Alright, so so great. All know. Well, we built associate 80s, we built it, using groovy groovy Gillis and so I kind of haven't touched it because we have a, you know, all the everything's automated. Yeah. So I haven't I kind of haven't touched it but I am thinking, but maybe in the second edition we'll we'll make it all because it seems like, yes we should be using kotlin script. And for Gradle things, but Gretel, I was like if it works, I don't want to touch it because that there's, it doesn't make sense to me.
Gretel doesn't make sense to me. It doesn't make sense to me there. I've come to appreciate SBT a lot more because of Gradle, which is saying something. Yeah, and I don't even know how to ask questions about Gradle, and we know the guy. Yeah whence we both know Hans. Yeah. The challenges that like like what we've found with declarative dsls is that There's always a life cycle that is behind that DSL.
And in the case of Gradle the lifecycle of your build definition, gets intertwined into the life cycle of the build in a way that is Incomprehensible to me too, me too. And so that's one of the things that purely declarative builds like Maven, it's nice because you don't have to think about how your, your, your state modifications when and how they get applied to the build tools State Management and life cycle. And I think that's been the hardest thing about Gradle is I just don't know how.
And when State changes are happening, hmm between what I write and what the build tool is doing so and we'll least you understand it. Well enough to even explain it that way because I can't, I'm not, you know, I'm just looking at it going. Okay, I need to put this in here and now it works but if I put it in a slightly different way, it doesn't work and I mean I used make four years and it's like make us got lots of limitations but it was super fast and it was like this depends on this and when the dependencies are out of date, you do this. No it's like there's make for you a sentence. Yeah.
And it's like I don't know how to describe Gradle but yeah, that works. I can use it. Yeah. There are some very nice things about cradle griddles, caching is amazing. Their dependency management stuff is really great like rewrote the whole Maven, dependency management stuff and it and they did a really good job with that.
I do like getting to write my bills and kotlin but it does have the side effect of that the the state just being magic and very hard for me to debug. So Are some things I really like about gradual. Yeah, I guess my thing is as much as I've used it. I still don't like if I want to do a thing, I don't know where to start.
Here's what I do and it's yeah, and build tools. Yeah. Build tools. There still isn't one. That is the Silver Bullet know. And I think to figure that out maybe we need a mathematician again somebody who says you know what is the essence of a build tool? Yeah. Well, and then that language that you were just talking about Unison Unison. See, there's there.
Yeah, I don't yeah. I had a thought. Yeah, this week about build tools, which was why, why do I have to like, run my compiler when my code changes like shouldn't a compiler, understand a stream of file changes instead of just because the way that I think most compilers work today is you run the compiler, it gets a bunch of files and it does what it needs to. Why isn't there a compiler that instead can receive a stream of file changes?
And so it can, the compiler can remain running. And whenever a file changes it, the nose. Oh, okay, that file change. Here's what I need to update, right? It's like fundamentally. We have not looked at compilers as filestream consumers, because what happens in a compiler? Is you've got all these phases.
You have to come up with like, this whole tree of information about, you know, the whole graph of the syntax. And Herbs and all that kind of stuff, right? And so the so it has to compute all this information every single time it runs, mmm. But as a developer, like I'm changing one file at a time and why can't the compiler Run come up? With that tree of information?
It gets it is then reading a stream of files and says oh I've already computed everything except for this one little piece and I think that compilers have a lot of this. This Mechanics for through caching is that they know what things? They don't need to recompute now, better than they used to, but it seems like a better architecture just receive receive a stream.
And then I started using them and it was like first, I used IntelliJ because I thought, oh well, I'll just, you know, I'll do this. I alright, a horse to or whatever for something and then it was like, oh my gosh, this is doing so much more for me than any of the other things. And then, I immediately switch to pycharm for python because that also does things. Oh, and it has a plug-in that looks at your code and makes suggestions more than just what pycharm does. But there's an additional plug-in, which I forget the name of and it's like, oh you could write your code better this way, I'm liking that and but my experience now with using say IntelliJ with kotlin is that that's how I find out whether things work.
And then once that's working then I run my normal bill just to double-check. Yeah, but it's It is I mean I feel like it's very similar to the experience that you're talking about it's just constantly checking the yeah I think you're right I don't understand the internal architecture very well of IntelliJ but but I think that it is probably more similar to the model that I described of maintaining that state and and then getting a stream of changes so it doesn't have to continually recompute.
All of that state hmm. And it does seem to To cash it like and maybe this is one of the things that happened in 1.4 because I feel like I started noticing like if because I've got my whole book in a single project. Yeah. And so, you know, sometimes it has to rebuild everything but then a lot of times it doesn't, you know? And it's just boom, yummy.
The answer is right there and it doesn't because so it's caching all of that, it's knowing what's already been built? Yeah. So yeah yeah. It's just I mean such an amazing experience that so much time. Wasted not using that tool. Yeah, there's some interesting Innovation happening in this particular space where you've got your compiler and it's having to come up with all the information about your program. And then you've got your IDE, that is also having to come up with all the information about your program when it be nice, if you could just unify those two.
And so this is the, the language sir. Server protocol mlsp and so Scala SBT just added support for for this language server protocol thing. And now tools are beginning to consume that that information and provide its ovs code. I think is the primary driver and Microsoft are the primary drivers of doing of this protocol and doing this. It's I think they've been doing a lot around typescript envious code but the really Same part of this is that now you have essentially one your compiler is providing one one way to access all the information it needs about the syntax and the type. So doesn't have to run reinvented in every tool. That's right.
Exactly. Which makes a lot of sense. Yeah. Yeah. So I think there's, I'm excited to see The Innovation happening in that particular space. Now, IntelliJ has not gone this direction because they've got not so much investment into the indexing protocol, the right? They've already invented and and it's really efficient. It's been, you know, created around. Yeah.
Like I don't know, 100 millisecond responsiveness getting an answer from the index and so I can see why they haven't haven't necessarily embraced jumped because it's going to be a huge. Yeah, thing for them? Yeah, eventually probably they'll they'll move over. I suspect as I think more compilers implement the protocol. Like, I don't know what Collins plans are for implementing the protocol, and that sort of thing, but yeah. So there's interesting Innovation happening. In that space.
Yes, it is. Are we? I think we're at an hour. So I'm yeah. So that seems to be, what, what we do is an hour, it's a, yeah. And then we're out of thoughts and we're out of, well, no, we have many more thoughts, but We need to save them for their fur next time. That's right. Yeah. Until next time until next
