cover of episode Writing a shell in Go

Writing a shell in Go

2024/11/6
logo of podcast Go Time: Golang, Software Engineering

Go Time: Golang, Software Engineering

Chapters

Introduction to the podcast and the topic of writing a shell in Go, featuring guest Qi Xiao.
  • The episode discusses the challenges and considerations in writing a shell in Go.
  • Qi Xiao, the guest, shares insights on the complexities involved in such a project.

Shownotes Transcript

Translations:
中文

Let's go go time. Welcome to go time your source for wide ranging discussions from all around go community. If you like this show, you'll love the change log. It's news on mondays. Deep technical interviews on wednesday and on friday. An awesome talk show for your weekend enjoyment find us by searching for the change log wherever you listen to podcast big thanks to our partners at flight to I O launch your APP in five minutes or less all around the world learn how at fly that I.

O OK what's up nurse.

i'm here the curt magi cofounder and CEO of fly you know, we love lie. So because I want to talk to you about the magic of the cloud yeah thousand and is right.

I think it's valuable to understand the magic going to cloud because you can build Better features for users. Basically, if you understand that you can do a lot of stuff, particularly now that people are doing L M stuff, but you can do a lot of stuff if you get that, then can be created with.

So when you say clouds aren't magic because you're building a public cloud for developers and you go on to explain exactly how that works, what does that mean? You.

in some ways, that means these all came from somewhere like there was a simpler time before clouds, where we get a severe rag shack and we d or tell that into IT even and put file somewhere and run the web servers ourselves to serve them up to users. Clowns are not magic. On top of that, there is just more complicated ways of doing those same things in a way that meets the needs of a lot of people.

Instead, one of the things, I think, that people miss out on a lot of this is actually because A W B S and G C P have created such big black box subtractions like lambs, really black box. You can't like, pick up part land and see how works to the outside. You have to sort of just use that there.

But the early is like, land is not all that complicated. IT is the modern way to a large little vamp and serve some request from them and let them like kind of pause and resume and free up like physical computing. The interesting thing about understanding how clouds work is that let you build kind of features for your users.

You've never would expect IT, an archeology version of this for us, is that, like when we looked at how we wanted to ice like user code, we decided to just expose this machines concept, which is a much lower level interaction lama, that you could use to build lambda on top of. And what machines are just these vines that are designed to start really fast, or designed to stop and restart really fast, or designed to suspend sort of like your laptop does when I and resume their fast when you tell them to. And what we found is that giving people as preliminary is actually there's like new apps being built that couldn't be built before, specifically because we went solo level and made such a minimal abstraction on top of generally like linux internal features. A lot of our platform is actually just exposing a nice us linux s internal features, which I think is is kind of interesting. But like you still need to understand .

what they're doing to get the most use of them cool OK. So experience the magic of fly and get told the secrets of fly because that's what they want you to do. They want to share all the secrets behind the magic of the fly cloud, the cloud for productive developers, the club for developers to ship.

Learn more. And I started for free at fly dot I O. Again, fly dot I O.

Well, hello, hello, hello welcome listener. I'm john y. orco. Welcome to another episode of go time today. I have a very special guess, someone who decided to go on a very interesting journey, one that I have um I personally would find very daunting. This person, this individual, decided to a, write themselves a shell.

You that right, like the S, H, B, like he decided to write himself a shell, and he did IT and go welcome. 7HO, hello, hello. Where do we start? Like of all all the side projects, you could have come up with, why a shell?

right? So I started Elvish about eleven years ago, I think. And at that time, yet the alternatives you have begin. The show is like traditionally this bash that's always bash. And there's Z S, H.

And was fish was alone for quite a while, I just felt was felt all the shows were little bit limiting. And IT is something that people use all the time. And the show is this interesting thing.

Where is both a programming language? But IT is also kind of A U. I.

People used to access their Operating system is why is called a shells, as opposed to like a kernel of a system. And I think designing, implementing a programme language is pretty fun. And also, just like doing your eyes stuff, I is also pretty fun. And so I think a shell would make a good, interesting project.

And you've been to working on Elvis, right? That's that's what you named your your shell, your implementation ation. Um you've been work .

enough for .

how long is eleven years? wow. wow. Now is that because that's on another thing and primary in way you make a living. So that kind of it's not because in tokyo, seven years to get to get a working shoe is just more I you've been working on .

if for that long, right? Yeah, it's thing. I mean, I started the project when I was still in unique, so had a bit more spare time.

But as I got like a good time job, that is a slightly less going on. And i've not been working recently. So I spend more time recently on elfish.

嗯, but if I go back to full time employ and less time on. So a lot of the kind of the developments that get you a basic show kind of happened. Interesting, the first year.

So so I started kind of daily driving l, which just about half a year into developing IT. I was using, I was switching between sessions and fish at the time. But after, what can I fish for? About having your exercise this as enough features for fire, to use this as kind of my default terminal shell.

So this is your default right now. pretty. Everything you do that you need to do in a shell is busy. You consume me own dog food as they say.

yeah, yeah. I see.

I see. So we have out of touch and out of a water shell. Out of is, is both a programing languages of the environment for for executing, or for all string together. Most, most folks in listening to the show will know will be familiar with the concept. But like what util is a chargers is just an execution environment or how would you describe that to somebody who is not .

sort of the no yeah IT IT is a very good question actually. So I think from a purely technical perspective, the way I would describe a shoe is that it's like it's basically just another terminal application. So it's it's ARM the same level as like L, S or v.

Except I like vme is like obviously much more interactive than alos, right? But they pretty much function at the same level like they run determined, they write some outputs and they are capable taking A H L S is not capable of taking import that think about cat, its cable taking inputs. And there is a lot of obscure kind of terminal A P I stuff going on, but that that doesn't that's not kind of essential difference between these programs.

And on the technical level, we can think of the shell just other, just like another a term application, except that the the thing you do with the show is mostly just launching other applications, right? But on the technical level, they are there is similar, but that kind of a just a purely technical answer. But people often confuse shell with terminal, which I think is not because people are not, I think like on the one level, some people just not familiar with how the how like the way things are done kind of in the unique world.

But on the on the other, love, I think there is a bit of uh, there's a bit of kind of truth to that right to be when people think about the shell and the terminal, people think of this as kind of this like not exactly the same, but kind of part of your kind of, uh, text based of working environment. So in dances on a more conceptual level, you can say a shell is actually slightly different from all the other time, and applications seem that it's actually more in your environment instead of like yet another application. I think that that actually very interesting phenomenon and is almost historical, like the incident that unix decides to do things this way, like you have you have determined and you have the shelters are two different separate programs.

But it's easy to imagine a world where things don't work that way, like in the unique world that we live in. A shell is technically just another terminal application. But is is, is someone is a slightly special one in the depart with the first time and .

vacation that's launch by your right right exactly bing time launch program, a turning program, whether I need to be using mics, the the native to the terminal APP right that you have that comes with your Operating system and in the person. And I use an item now, which is another popular, popular one, but i'm sure they are other there. Those those things are program.

So by default, they launch a shell. I could be bash I about the fold. That's what the terminal APP does.

But when I when I launch, I turned the program IT launches a shell in my shell, right? I I miss. He didn't use.

I wanted to not stick with the defauts, which was bash. I wanted to use A Z, S, A and said, so I installed the E, S, H, and I made that my default. It's almost like a, the terminal. Could I could I think of IT as as the backing and the shell is the front end that I use interact with the back in?

Yeah, I think that's that's a way that's a good way to think about IT. You can almost think of determining as a kind of graphics runtime, except that the most of them only support graphics in the sense of like just text, text.

And you can another way to think about this, maybe you can think of the terminals broza and they can they can think of a shell, the alos cat, as just like websites except that the browser, the terminal does much less than the browser because part of its a part of its the functions is kind of dedicated to those applications like terminals sometimes as they don't do a top management. But you can use t max for that, right? Thomas can run other programs incident. So it's like a browser where you can next tiny other browsers inside browser.

Yeah and there was a um there was a time when when I used to use windows um many, many, many more, you know uh, I would see, you know h you like in the movies, like some movies. Did IT actually okay a job of representing what the hacker culture was? Um if anybody whose ever seen the the old school movie hackers with Angela, Angela and and some some other famous people, well remember, were actually using a terminal.

They are insuring commands. I like, this is so cool, how how do I become when people, right? So but I was on windows and like, know, you launched a command program. And windows, like, just not as cool, you know. So I started trying to use a sign back then, you know, which was no, there was no power shell back in those days and yeah like I kept trying to sort of embrace the shell life, if you will, eventually.

You know I I tried linux um back and there was still rough you know in the best top you know every year would like IT this is you up never quite made and that things have changed since then but eventually else OK I I need sort of my Operating system to get out of my way so I can get things. But I also need the power of a shell so I settled on macos and that whole and embassy started embracing the shell more, because ultimately, and we'll get into what somebody of behaving capabilities of a shell are, what Elvish does differently. But I thought noticing that, you know, or rather when when one is sort of learning or to use a shell, you go through this sort of minimum of of things you used to sort of point and click and, you know, to get things on, to move around your machine, no launching, find the windows and boch on navia system.

You start finding that you can sort of type away through that and do all pretty much virtually all of these things. But using text input instead, you go through this minimum, like, wow, this is like, this is really cool, right? Like A A regularly a 类 person would be like, what are you doing? Like, this is like, crazy. Why would you want to use a computer that way, but not for for a certain kind of individual? That is sort of the a dream, right?

Yeah, yeah. I think a lot of us went through that journey, right? I think I when I first got into linux, I was also very attracted by, like people doing cool stuff in this in this black window. Like one one example, always tell people about this, uh, F F M act because when people want to do like a not not exactly like video editing, but simple ish but not that simple video processing stuff, like um I just want the first ten minutes of this video right? Or like I want to just extract the audio out of this video if you are like in the gooey world, because that just so many different things you can think about doing video processing, either you try to find a very, very specific kind of for 故意 a that is like audio exact, and then you give me a few feeding A A video on file.

This is not do the very, very specialized going up all you go kind of go falling and install a video editing up that's like a hundred mega hundred, well, not mega bites, a hundred giga bites these days. And then you click through its manuals and do this one thing that you want. But when you come to kind of the terminal world, like it's just google for F F M pec command, it's probably like A A single end of command.

And you can do so many different things because because the terminal interface is such a kind of a thing, layer of abstraction over kind of the underlying code, right? Like I, I I suspect that the the C L I of F F M pack is probably just a small pot of the entire cold days. But if you do like a good application, if you do a guy equivalent of F F peg, most of this going to be like how how do I organize the menu, like how to place each fun like things to you. You have to think a lot about that kind of things. But in the terminal, because he is just such a thing, lay of attraction, you suddenly get access to much, much more, much, much more easily as well.

Of friends, i'm here the break with David, shoe founder and CEO of recall. So David reall has definitely call the market on internal tall soft development zone. After me was the big idea. What did you start real? What is the big idea with international software?

Yes, we all started at this point seven years ago, and we started retool. The core idea was that internal software is a giant, giant gory that no one really thinks about. And what's surprising to most people is that internal software represents something like fifty to sixty percent of all the code written in the world, which might sound pretty surprising.

But if you think about IT, most of us, silicon valley, we work as often are companies, whether it's like a airbnb, a google, meta, these are all companies that are software companies selling software. And so most external of physical software. But do you think about most software iner in the world, most soft engineers, the world actually don't work at these software companies.

This is not that many of these may be ten to one of them, big ones, at least most of the companies, the world driving non software companies, think about a company like an L, A, A selling software. They should have a lot of software in. And all the software engineers, all they do day in, a day up, is basically built in turtle software.

So that I think one risk start. The second reason we started with tool is if you look at all these internal software the people are building, IT is remarkably similar. So if you take a look at, you know, like a ZARA, for example, of a call off, two very different companies obviously want a clothing company, one a beverage company.

But if you really look at the a soft of the building internally to go run their Operations, IT is remarkably over. It's basically forms, buttons, tables, all this sort of pretty common building blocks, basically that come together in different ways. But that if you think about you know not the U I, but also what's the logic behind a lot of the stuff, the pretty just heading at in points adding database, you can ver edication to carve out authorization.

There are sort of a lot of common building blocks, people to eternal tools. It's a force. The inside was wow turtle software, a giant tegor so similar, and developers building IT. Could we create a sort of higher level framework, if you will, for building all this software? And that would be really cool.

That would be really cool. okay. So listeners, real is built for everyone, built for enterprise, built for scale, built for developers. And if you yourself com flash is the best way to build internal software to yourself favor, get a demo or start for free. Today, again, really dcom flash changed.

So why go why why pig go for such a task.

right? So so think about yourself in like eleven years ago and it's live is surprising about the kind of program program language landscape is actually a little bit different from today. So when I first started working on Elvish go actually just came out.

I was not literally go one point. Oh, I was one point one. So it's came out back half a year before that.

And when I was thinking about if I want to want to write, want to write a new shell, what are my choices at that time? The pretty much the choices are C O C plus plus java, or like a more halevy dynamic language like python, right? And go at that time was this very kind of modern kid that's that's much less above the java, that's much more expressive than C N, C.

Lus plus is also much faster than like 开放 or ruby。 So was pretty much a no brainer at that point, because go was this super modern language eleven years ago. 嗯, 哼, if people make a try, if people try, decide to write a new shell today and decide which language they they should do IT in, the choice will be slightly tougher.

Because today we have rust. Like rust didn't actually came out eleven years ago. I'm sure this a pre one point zero version in development, but he wasn't really known at that time that's rust as zig. And there there's a bunch of other kind of modern and compound languages, but I I was still do IT in go because of things will probably .

discuss later the yes, yes. So that's interesting. These days you write most people would think of of writing such A A project probably using rust or or egg.

One other one I am thinking about um stimulated. But I think you go used to be used to be labeled as sort of the systems language as well. Remember the early days of go, people used to refer to IT. I am even, and I think that go dock, I used to used to refer to go as a system s programme language. But I think, you know, over a time I found a niche sort of, you mean you can still do system programing stuff, but I think mostly all these days would pick up a lower level language and sort of go rules, sort of the cloud stuff right like that that's go on I battle alright. But yeah, it's like watching sort of the programing language itself out of fine, its niche right within attack ecosystem has been an interesting journey so to watch go um go .

through yeah I think kind of on the side note, I think the kind of the debate around system language is actually quite interesting because I think the original creators of goal when they say system program language, they're probably more thinking about distributed systems. Think of Operating systems. And I think today the niche of gold doesn't contradict that, right? Because all the cloud stuff for your doing is fancy distributed systems.

But yes, the kind of finish of more something more close to the Operating system is probably more occupied by like run zig these days. But you can still do a lot of like not real time low level stuff, but fairly low level stuff with goal. The goal has very complete binding for all the system calls on linux, P, S, D and windows. So you can do pretty low level stuff as long as it's not like literally real time that that if you can, if you can live with a little bit of garbage collection, lenny, then you proffer.

So so i'm curious if obviously being able to sort of a um distribute novation on all the all the major Operating systems as as you're able to do right now. I'm definite thinking I go definitely please, please are all not being able to have single binary for every single m on platform and in writing sort of building those features. Did you have to sort of, uh, do different things for different targeted o and platforms in your code?

Uh, yes, but not as much as you would think. So one thing I did differently for different platforms is how you read keyboard events from terminals. Because windows actually has a different A P, I for reading keyboard inputs that actually gives you.

So if if you are curious about the subject, you can just look up like terminal escape sequence, uh, something, some some keyboard like that. Uh, so the way keyboard input works in the terminal is much less than straight forward. If you if you type a simple letter, like if you type a or b, that's what the program sees.

But if you use a functions key like f one, f two, like home and or not forbid you use and modify with your functions key. There are ten different encoding schemes that 呃 that that the different terminal emulates used to represent those keys。 So you have to as a shell, you have to like pass or those escape sequences and back into keyboard, into like modifies and like functions keys.

But windows actually has a much more sensible A P I. That just gives you like, this is the functions key. This is the modify key.

So I used that windows, but the windows now also supports kind of the is called V T one hundred style escape sequences, like windows also supports that terrible way of encoding keys. So is secondary, no longer needed. But I I like the fact that windows actually has a much cleaner API for that.

So this is one place where it's different code paths on different Operating systems. And a say from that, there is actually surprisingly little platform dependent code. So one thing you might think that will be different is how to launch external programs.

But go actually has a very complete obstruction for that in the O S. Slash exact package. So IT gives you pretty much everything you need in a shell to launch external programs.

If you think about how shells launch external programs is some some of them can be pretty fine. Great, right? Like you need to control the environment of the uh, program.

You need to control where the outwood goes. Like if is in the pipeline, the outward goes to a pipe instead of to the terminal, like probably goes to a file like things like that. But go actually gives you everything in a portable way in O S slash exit.

So I didn't actually have to write. There's there's a tiny bit of platform dependent code there because O S thought exact the argument he takes contains this field. I don't remember the exact name of IT, but this way that basic says system dependent meddle a and that is the only thing that I need to make a kind of a platform.

But other than that, it's pretty it's quite possible. And obviously like there are some things that are unique specific that has to be platform dependent. Uh like unique has A U masks, uh which is like uh which is a bit field that applied when you create a new file. You this has your limits. Those kind of stuff, those are obviously has not dependent.

Yeah, some of those things don't Carry over quite well to the to the windows world, right? So yeah, we have talked really talked about sort of features of Elvish. When does when does Elvish have over? Like the the sort of the mainstays, like a bash, for example.

What does that do? Like what would ww me like? Wow, Elvish. Very different, very powerful.

What what up? right? So that kind of goes back to the origin story of why I decide to ride in your show. I kind of did IT mostly out of frustration. So I saw I had kind of two experienced with more traditional shells at that time.

One was, I was doing a little bit of a system mademoiselle tion for 那个 for some local linux service, and I got exposed to a hundred, not one hundred, a thousand nine, a batch script. And I was trying to, I was trying to maintain IT. And I just found IT impossible because it's like a it's like full of all those obscure things like, uh, you have always have to put your variables in doubles, right? Because otherwise, uh, the White space in the variables would do naughty things.

And you can never figure out what's the correct way of comparing to string s. Uh, there is a test command and batch has this a left bracket command that's the same matter, and also has the double left bracket command that's not the same as test buying. There is something else.

So all those, all those details pretty much drome same. So I thought there must be a way to write more sensible ells crips. But at that time, I didn't actually find a lot of things.

I didn't find a lot of good ways to rise of our shells groups. So that's that's one experience. Another experience was I was so I switched from bash to fish and I was trying to implement directory history.

Um because at that time, that was before things like all my dash came along. So there wasn't that many like out of the box thash plugins on flowing on the internet, floating on the internet at a time. So you kind of have to do the thing kind of yourself.

So I was trying to implement directory history, and I looked at, I read through a lot of the shes, a main page and the because they should actually has some fancy U I. Features like this type completion is pretty fancy. So I thought you must have good kind of primitives for doing sensible U.

I. stuff. But the entire U. S. System, I also got a little bit frustrate and basically gave up because I like the A P.

I is, really is. I mean, you can do very powerful things, but it's not the easiest to use, to be honest. So kind of these two experience made me think, one, we need to show that actually feels like a real programing language.

And second, we need a show of that actually has sensible eye features out of the box. So those are kind of the to make themes of Elvish is one has programme features, so for for as a starter, like obvious, has lists and maps, and they can be nested. There are in more traditional shells IT probably.

Well, if IT go back to the very origin like bomb S. H, the only thing has is, uh, strength, right? And you can split strings on spaces so you can put spaces in your strings that you can pretend you have lists, but not really.

And some later shells have actual lists and or even maps, but they don't nest like you can have a list of strings. You can have a map from string to string. I can't have like a list of lists or a maps of maps.

That's just not a thing. Emotion diary shells. But ovid has all of those things. It's it's like a real it's like a program like 我 就 like anything you can representing jay sun, you can representing navies. And Elvish also has lambda, uh, so he has functional programing.

IT is a very functional kind of programing seeing programme twice is a very functional programing programing language. So a lot of the code in irish will look a bit like lisp, because IT embraces kind of the F P, like F P paradise. 哼 so that's that's that's one thing。

Real program features by yourself has like out of the box U I features like one thing I will give two examples. One is that he has a building file manager. So if I just press control and innovation, IT gives you a view of your current directory, your parent directory, and a preview of the fire you have selected.

So if anybody has use ranger kind of the U I is very much a copycat of that. And another thing is, so in battle zh, you have this, you can press control our to search your command history, right? But the only gives you one match at a time. Wish I that kind of kind of stole the same key banding but if press control are IT doesn't let you search one command of the timing so I just gives a list of all your historical commands and you can just you can filter that command and you can see all the comments that match match your current filter so you .

can do things like that. So you ship with some some building, sorry, some building commands um but you also rely on external commands, I mean like pretty much you would in any other shell and long you run a good or um any sort of external tooling of the bilton command sort of gear towards sort of that the programing task that that you Normally need to do kind of thing.

right? So that's a very good question. So E I would say mostly yes, but there is also a bit more consideration about uh, what kind of commands people tend to use, tend to need in the shell, right? So it's very much built like a programing language.

So one interesting example that I can think of is, for instance, like um you have a in unique, you have A M K D I R command to make a directory and that's very much gear towards interactive use for insinuation can make mutual relations with IT. But in Elvish, Elvish actually also has a building M K D R directory, although he lives in a separate named is called O S column M K D I R. But that one actually only takes a single argument, because he actually functions very much like ghost M K D I R function in the O S package. And if you want to make moderate doctus can you can just write a loop. It's definite kind of more on the programing language side of fence, right?

So you you yeah so you not trying to maintain sort of compatibility with sort of existing sort tools out there right now. Like Normal, you do M, K, D, R, with a dash, with a dash P, A flag, and then you can do the whole multiple slashes and a case, know that tree, but not you like, okay, well, I don't need to do that. I need to create multiple directories. I'm going to use some four loops.

right? So IT is a slightly more on than that. So for as a starter, Elvish doesn't prevent you from using any of the existing programs.

So when i'm using Elvish, like I use, I use Michael most of time these days. I can still use the systems. And K, D, R, alright.

And I and I do use IT. A lot of times I use IT. I still use IT as my kind of default, the default way of making L V studio M K D I R.

But l vicious building M K D R also lives in the separate names face, as I mentioned, like is called O S column. M K D R instead, just M K D R. IT is useful when inferences you are trying to write a portable script that can run like on both unique environments under windows.

Oh, and did I mention aviation supports? Windows 还 挺棒。 他们是 怎么 so a lot of time those building commands, they really shine when you are trying to write those kind of possible scripts. But if you if your concerns really just like, uh, writing a script you use on your system, then you can just use anything that you want. You are not restricted in any way to use a vitious .

building commands. So i'm looking through the reference for the modules, right? Seem up beyond the building stuff.

You know you have a modules for documentation, for editing. There's a package manager, command line flag passing. There's math, there's there's a quite a few things here. So these things looking looking at them most are really sort of geared towards, I mean, as a lot of them that are geared to of so directory and file handle ling and what but know some like string money pollution, for example, are are things that you would sort of need to you if you need those who come in handy.

I would imagine so that there's a mixture of things here related to sort of system, sort of far, far and direct relation, but also some some run time stuff and and one that so IT sounds like you build a tool to deal with a thousand nine h so did you ever go back? Did you ever go back and and modified anything? Or had you moved on? Is this to tell you wish you had.

Yeah I didn't go back to that thousand line batch script t because somebody else to the maintenance of of star script and but I did rewrite. So ellish has scripts like the the the project report has a bunch of bs scripts incited. And over the years, I have been written all the bash script navies.

It's always it's always an improvement yeah like like the like the stream manipulation thing you are just mentioning. So like patch does have stream manipulation functionalities, but they usually have pretty obscure index spec bash. There's a building way in bash to remove a prefix from a string.

And the way you do IT is say, if you string is dollar s what you do is dollar and then brace s and then I think is hash and then hash prefix and then closing brace. So its users like this kind of very symbolic syntax use, makes extensive use of punctuations, which I guess if you do this on a daily basis, you will remember and you will like how to size IT is. But if you only do this like once per week, you probably are not going to remember IT.

And you will keep dousing yourself like a, is this the right punctuation tion? But in navy, because it's design like a programme language, you just go to the S T R module, and there is a function called S T R. Trim left.

This is also a module, this this S T R trim left and this S T R trim right. And are sorry, this S T R trim left and N S T R trim prefix. So those other things you to use because like IT makes is slightly longer, right? Then like just writing a hatch line, IT is much more readable. And if you, if you are, if you are go programmer, these are implemented using the same functions inside go strings yeah and they behave identically because it's literally just implemented using the function from from girl standard library。

Is there a particular feature that you implemented an Elvish where you were like, okay, this is why I picked to go. This is sort of the perfect use case.

yeah. So there actually two. One is what I was just going, where I was just going to write this, the standard library.

So go has a great standard library, is a very high quality, is very well documented. And it's like it's a lot of batteries, right? And it's a lot of good batteries.

So like you work just going through the reference menu of elfish. If you look at that, like half of is basically just ghost and library, just like an Elvish finding. So the S.

T, R library is just goes strings library. The R, E library for regular expression is just goes rex, a library. I, I made them. I made the names slightly shorter because in Elvish, like a module names and variable names, actually they don't even the same names space.

So I can afford to make IT 看 of a slightly more sliding shorter。 And there's um the power of libraries just goes O S stash stash path. Um the O S libraries is basically goes O S library like math is basically goes math.

So much of obvious stand library comes from not like some of them literally just come for free because this is there's a very straight d way to change that, to adapt that. Go A P I to an average. A P, I. I use reflection for that. And some of them requires a little bit of wrapping, but never too much.

So standard library is one very like large part of the reason of why, if I do IT today, I was still doing and go because I think most other languages, they don't they don't really have an extensive as a standard library. Ask you like if somebody asks that, can I have H T V library? I as part of every time library. And I can probably just use goals h to be library for that.

right? Yeah I just create the Elvish bindings. And yeah if you go yeah yeah exactly.

Although because H T V library deals with a lot of functions, function binding slightly hard, because go like the way you do a functional programing and go on Elvish are slightly different. Another thing, aside from the standard libraries, a very interesting in part of the wrong time, that I didn't I didn't really think about IT when I first started using go. But go is a garbage collecting language.

Elvish is also a garbage collecting language. So a happy consequence of this coincidence is that I don't have to implement my own garbage collector because average values, such as school values. So if an average value becomes scope ge IT also becomes scope ge kind of the goal run time, 所以 will be collected by the go garbage collector。 But if you write like a new programme language in rust and is a garbage collect language you have you do have to spend time writing your own garbage collector or maybe used one of the existing garbage collectors. But in any case, you will need your own garbage collector if you're writing and go, you don't need your own garbage.

Collect tor. I keep playing like these days when folks are making programming language decisions. You know slight engine here, but the the perhaps it's it's just me.

But I think the decision to use a programing language or not, the decision making process, uh, why you would pick a language over another IT, seems I felt like I used to be more more technical, like more more strAngely like a more like you had you had specific things you would be looking for, right? Know whether you had a garbage collected, I can interpret the language or or compiled one, or or a garbage collected one, or no garbage collection, right? Like these decisions, these a seems like whatever cool in a garbs tension.

But I think for our listeners know i'm so many are are taking, okay, the process of selecting a language should be bit more sort of critical, right? I should take more critical approach for medical critical eye, right? This, this goes back to the whole pick the right tool, the job kind of thing, right? You know, most, at least from what i've seen most programmer with know any sort of a medium to long term career.

We will pick up a few languages, put that in the two, and use appropriate language for the for the given situation. So when you mention that, okay, i'm writing Elvish. IT has G C, and I can just pick IT back on the languages, the underlying language.

G, C, like to me that like that of my OK. That's a good reason, right? To pick a language, right? You deciding what tool are you going to be using to build your own product?

Yeah, definitely. Although IT is something I I wasn't actually thinking about when I accident.

Yeah later.

when I was reading a lot of articles about implementing garbage collect in for the new language, I only realized, oh, I never had to do that. And I realized I never had to do that because I picked a coverage collective language as my implementation language.

nice.

He was, was the the right choice. But he was he was unconsciously made at that time betting. If I when I look back, it's a, it's a very sensible choice.

Was there any feature that go made particularly .

difficult, right? So not really, I would say so I don't think of like A I can't really point to like one feature now, which I say it's all goes for that. I have to write three times more code compare to implementing with us.

There is not a single feature that's like that. And I think it's because go is actually very good language for when you think about applications, it's a it's a very good language, is very much is very geared towards implementing applications and I mean of which is obviously an application. You can consume IT as a library, but is, I don't think of IT as a library that much.

I don't worry about IT has a library that much. However, there are things that I think doesn't IT kind of a slightly more painful, more ugly. Ingo, instead, again, goes back to, I don't think go is actually a very good language for implementing a library because I I would mention kind of two things.

One is that I go doesn't have true enough and he doesn't have true tag unions. And if you are thinking about implementing application, you don't really worry about that too much. But if if you think about implementing a library, a lot of time, the A P, I can be much more cleanly model if you have true enough or true tag unions.

And for instance, like the event ous posa, like there, there are maybe twenty different types of nodes in the in this industry。 And you'll be very handy if I actually have like a rust style e name that says, like a notice one of those twenty different types of notes that acri can be quite handy. IT makes a some big cleaner.

So even though I don't think of average itself is not libraries and application, but it's kind of made up of kind of us more. It's build as small modules, which themselves are kind of like or right, right and internally does create a little bit of conventional nal fiction, but he doesn't really show up on the overall application level. Another example is like go doesn't have keyword argument, default arguments.

And the way people walk around that this maybe like have a struct. And whenever you want, like turkey, what arguments are just make them feels of the struct. IT is fine if you are building a library that's consumed by a lot of people.

But if you are just building the kind of internal library, an internal A P I IT does feel like this is a bit too much boiler plate. So IT doesn't make for the go, doesn't make for the cleanest. A P.

I is kind of my take. So a lot of time I just keep looking, staring at a piece of code. I think I wish this looks a little bit clean. I wish this looks a little bit more beautiful. But you have to accept of the limit of the language.

So what's the next for l which is something you still adding sort of features to um or you just fixing bugs at this point. The state of the yeah .

so I think I have in the short term so in the past is like in the past few months, uh, I have been working on the new A T E framework in aviation. So if you think about like goes back to a very earlier discussion of what the shell really is, right? Like if you think all the browsers, there is a lot of those by frameworks, react angular view that you can use to build kind of very modern, very clean web applications.

I think there there are some that lets you build good clean term applications. But I think we could probably use some more, especially if IT is a two a framework that you can just access directly from your shell. So if it's something that you actually use every day and you can just you can use the tree framework kind of extend Elvish itself to give a bit more instructively.

We can just use IT to imply learn new two applications like probably implementors its in the new tree framework. So that is something that has been kind of in the works for motives month now, but it's A I hope I am hoping to kind of merged into the main branch of Elvish soon. So when that happens, Elvish will become like D.

U. I, like I, I, I said before, like the two main things about our vicious, that is a real programme language and has good U. I. features.

And I think if you have a two framework in average, this is where those two things actually kind of come together and become kind of a whole. This becomes A U. I think that you can very easily program.

I think that, that will be pretty cool. So that's the meat next thing. But if you think about kind of the long term future, again, this goes back to what we discuss before is a lot of people confuse shells with the terminals.

And I think this there's a lot of this a this a good insight in that in that I is really, is really, really be like just one wrong time where you can manage your programs, right? And there are lot of things that you can easily do because these are two separate programs like a if I I have all the like shell, have command histories, you can look at which commands you have run, but the communication don't tell you what the outputs of the commands are, is because the show actually does not have control over those commands. After they have been launched by the show, the terminal has control of those comments. Ts, so you can probably more cool things if like your show, i'm determined, is actually kind of more tightly integrated or even just like one application, but that kind of very big, very futuristic.

Okay, i'm kind of please, if you mention i'm gonna in there and have that generate commands for you. It's a new hotness. These body needs to put Jenny eyes somewhere whatever they're building.

Yeah but I think with the new tree framework ook, maybe somebody will build that into Elvish kind of as a plugin, i'm sure. And to be honest, like L M S, they can they are used like i've had some success in asking them like a crafting F F M peg commands. Yes, F F beg just has so many different options. It's quite, it's quite useful, but sometimes does give you like very settle RAM shell groups. So I would probably trust l ms for like wine off commands, but I really wouldn't trust IT .

for writing screens exactly, especially with anything with any country where where IT has a destructive effects, the never ask generate, the rest is too high.

Kay friends, i'm here with the new friend, and of hours over at time skill afthernoon. So athor help me understand what exactly is time scale?

So time scales a post gress company. We build tools in the cloud and in the open source system that allow developers to do more with progress. So using IT for things like time series and and more recently, air applications like crag in such an agents.

okay. If our listeners we're trying to get start with post grass time scale AI application development, what would you tell them what's .

a good romp if you are developed about the your either, getting top late building in AI application or you're interested and you're seeing all the innovation going on in the space and want to get involved yourself? And the good news is that any developed today can become an A I engineer using tools that they already know and love.

And so the work that we've been doing, a timescale with the P G A I project, is allowing developers to build A I applications with the tools and with the database that they are already know. And that being posed. Ss, what this means is that you can actually level up your career.

You can bold, new, interesting projects. You can add more skills without learning a whole new set of technologies. And the best part is it's all open source for P G A I N P G V, our open source.

You can go and spend IT up on your local machine by a docker, follow one of the tutorials of the time scope, log bull, these cutting edge applications like a rag and such, without having to learn ten different new technologies. And just using post gress in the single create language that you will probably already know and familiar with. H, yeah, that's IT get started today. It's A P, G, A, I project and just go to any of the time scale get up report is, uh either the P, G, I one or the P G Better scale one and follow one of the tories to get started with becoming an a okay.

just use post grass, and just use post grass to get start with A I development build rag, search A I agents in its open source. Go to time skill, dcom flash ai play with P G A, I play with P G vector scale, all locally under desktop, its open source, once again time ale 点 com flash ai。

I actually think should probably leave.

Okay, so yeah, I hoped. But some on popular opinions.

you got one for me. Yeah, of course. So my unpopular peniel is that when IT comes to testing one hundred percent, code coverage should be the minimum, not the end.

Go what you want. You want a hundred percent test coverage? yeah.

Okay, okay. Like explain that. I'm pretty sure that a few people explain yourself.

right? right? So let me make this probably slightly uh, less radical but not by changing what I said but by saying that like because we actually we all of us one one hundred percent cold coverage, but if you look at the test courage of your of your application of your library is probably not one hundred percent.

But we all think that all of the code must have been wrong at least once for us to know that actually functions read, if there's if there are ten lines of code in your coat ways that just has never been wrong before. Like, why do you even have IT? Like why do you keep IT? And your answer to that, maybe I actually did the menu testing, and that relies on this thin lines of code, is just not captured by my automatic tests.

I would say that in spirit, that counts as one hundred percent called coverage. So IT is actually something we all strive. We just can't achieve one hundred person code coverage in automatic tests, in unit tests, but kind of deeping our hard. We all know that if you have written ten lines of code, you must have run at once to make sure that is actually useful.

And the and the reason I say is the bare minimum is that running the code, making sure the code has been run at least once, is really just the start, right? Because if you have written a program that just prints out like a and b, and in support also print out A, M, B, but actually print out c and do you have run IT? You have run IT once, but you didn't check, but you never check what the ottawa is.

That code like technically has one hundred percent called coverage. But you are still not sure that IT is correct. And to make sure that IT is correct, you have actually pull the correct checks in place.

So having run the code ones is the start. You also have to make sure that you have actually check the effect of that coat. So this is my, this is my take uncle coverage. And I think the reason people shy away from one hundred person test coverage is, first, we are not really adequately capturing all the activities we have done into like cold cover read.

And if you do if you write a program and into menu testing, the code that you have triggered during your menu testing is not counted as part of a coal coverage and was still sometimes if you do integration testing, tooling Price also prevents you from accounting that as part of a coke up. And most of the metrics only actually count unit tests. But I think I think goal actually a few versions back, they actually implemented support for counting into n test on coverage.

So you can now generate code coverage for into n tests, which I think will make a lot of projects. Coke verage go up a lot because when you when you actually run the binary as a whole, instead of like running a single function in the unit test, that usually exercise of a lot of code paths. So I think we should all embrace that.

And another reason is that a lot of libraries are just like a outright untestable, right? For instance, if my program just, if I function just like a cause O S stop exit, like you're not going to put test that in your unit test because that would just exit the entire like a united program. But why not? You should be able to test those things.

And if you if your program sends something over the network, that can be a little bit hard to mock. And what we were usually do is just like a extract the computation part of your program and only test those parts and you don't test the power, we actually interact with the real world. But I think you should and am not blaming everybody for not doing that. I'm saying that the the echo system doesn't give us enough support to like do those test easily, but I think that is something that should be changed.

okay. Well, I mean, not a not an extreme radical take now it's I think no, I I can park some sensibility in there you know it's it's right .

alright yeah I have I have perhaps .

not not not a popular opinion but like I recently um as as well recording this take a few days ago, there was a key note that I watched IT was a good tob universe conference going on there was a there was a king oo and key no there was talking about the copilot. And you know its ability to um like the whole Spark system, whatever its ability, generate sort of apps from scratch stuff and and that's usually one of the selling pots, the the market stuff that says you can build an APP from scratch h wallah.

And and it's always like um the pitch is always to generate these new sort of one off, usually very small, very sort of a low feature kind of thing kind of application, just a showed hey, look at this thing, you don't even need the program anymore um but these things are usually like very simplistic, you know, sort of applications. Not to say that some of them are softish gated, but when you generating things from scratch, like, you know, a Green field, right, you have the benefit of basically being writing everything from scratch for existing system, for existing large systems that have been around for years, you know, decades even, right? Those are the that that I need help with.

Those are the things that you know, when i'm tasked maintaining a system that know, say, I was hired by a company and they've been running the software, runs their business for for well over a decade. And here I to make a change or need a feature, whatever, in in those are the things that I need help with, right? I'm not generating, you know like cloud apps or to do apps, you know, with the lamp from scratch.

I'm trying to work into an existing code base. So one of the things that they showed was there was some sort of I just available for a java, but there was something that could help you upgrade or something like your application maybe like you have an old school, you know, java APP, maybe you need to upgrade you know the which version machine version that uses or whenever case may be. But and it's going through all the different thousand and in the project and and basically changing the santa, maybe you use old school santa x new centage represent some time you wanted use lambda whatever IT is right.

It's going through instead allowing you to change all these different files, upgrading an existing application, right? But I think even that doesn't go far enough. And I think there's always gonna be a need for a human to provide some additional contacts, right? Some back story for L M.

That wants to change because so much technical that i've seen in my time, a lot of people not go who no go work on the organza. They walk out the door with insular knowledge in their heads. You know it's not documented. You see a piece of code and you probably the situation, you change something and you think you are doing the right thing and the notice you broke something else somewhere else, not taking that, oh wow, I didn't know why, just like wrong thing, I just think and then you end up breaking something else you didn't know was relying or relying on on the code to work a particular way, right, so that this technical sort of stacks up over time.

And it's not like, know people keeping track of, you know the the reasons why they can change or shouldn't change something, right? So when when you throw on allama these kinds of situation, not to say that one day we won't be able to sort of have models powerful enough to sort of fix those things, but these are the kind of like when they're doing those those marketing presentations and getting everybody excited about you lost language models in geni. Those are a kind of demo I want to see take an existing APP with a lot of assumptions, victim like receptor, that because that's my job, i'm not generating you know 3d chess program now for work and that's not what i'm doing that I how I know what are my living。

I work on old like legacy systems with a lot of assumptions and a lot of decisions that were made prior to me getting in front of this code base. Like held media with that mess, right? Not not the trivial stuff.

So perhaps not a popular opinion, but more like, I guess you know a request what is is more of is more of perhaps let everybody know that yes, the demos are cool. But we're still some some ways from truly being able leverage l ams to do the things that we really, really care about, right? Unless you are building something trivial in in Greenfield, which is not most of us. So ironically.

I think this is where one hundred percent test coverage will help. If you, if your code has really good test courage, you may be more confident in letting a language model try to make changes to IT because you have some confidence that some .

of the old behave is probably kept come with a big ten sort of assumptions that were made for the code that they're testing, right?

And I think language models may also be useful for kind of suggesting you uh helping you achieve uh, higher test courage, suggesting like they're good that really good at generating things right so you can make the generate tests as well.

That that is sure that is something I increasingly relying on on models to do. You know if it's which is kind of interesting um the i'm wondering how T D D pus are are dealing with this right because if I can just focus on making the code work and then I can then throw an enemy and say, hey right test for this, then then I can focus on know getting the the proof concept or the the the working code.

I can focus on getting that done because I don't think I think a lot of people have come across the love writing test because IT helps them through the thinking process, right. But of us we like to write the code first test later. So perhaps you know those of would like to um I guess you you could also have an L M generate your test first.

But you'd have to be very descriptive your prom to tell gender you before you go right to code that passes the test. But yeah, it's an interesting, an interesting time to be a developer. I'll tell you that.

Yeah, definitely.

Oh, right. Well, it's been a pleasure having you. It's been great to actually learn about.

Elvish what he does in in how go has helped along in that journey. Yeah, I wish project continue success. Thanks for coming on.

Well, i'm glad to be here. Thank you.

Thank you for your listening to go time. We appreciate you spending time with us each week. If you haven't yet, check out change log news.

It's the industries only weekly newsletter. That's also a podcast. One reader calls IT so good. He consider IT a competitive advantage. Read and listen to the latest issue at change on 点 com special news。

Thanks once again to our partners at flight, to I O, to our beat freak, the goat breakfasters cylinders into our longer sponsors at century we live. You might to use code change log save hundred box on the team plan too easy. That's for now, but we will talk again next time on go time.