text
stringlengths
0
2.35k
[287.98 --> 290.46] That sounds like a pinky caveat.
[290.46 --> 291.58] It is.
[291.72 --> 292.80] It is a pinky caveat.
[293.50 --> 294.28] Okay, fine.
[294.94 --> 296.08] We won't mention them by name.
[296.22 --> 296.70] Well, that's it.
[296.76 --> 297.40] We'll see how we go.
[297.94 --> 298.30] Well, yeah.
[298.38 --> 303.30] So this episode, like, obviously, there's a lot of people blogging and talking about
[303.30 --> 305.44] the big sort of headline features that we are.
[305.70 --> 307.70] A lot of people are very excited.
[307.86 --> 310.40] A lot of people are very dismayed about generics in particular.
[310.52 --> 311.00] I've just said it.
[311.10 --> 311.62] I can't believe it.
[311.64 --> 312.60] I have to leave the podcast.
[313.46 --> 314.94] But a raft of other things.
[314.94 --> 320.42] And this release in particular seems very packed and dense with features.
[320.76 --> 322.30] Why is that, do we think?
[322.80 --> 326.04] I believe they've been saving a few large features for some time.
[326.24 --> 330.02] Like, they've been building up to generics for, like, nearly two years now.
[330.10 --> 331.16] And now it's shipping, right?
[331.56 --> 333.68] And I did mention the taboo subject.
[333.84 --> 337.24] But I think it's also happened with fuzzing, which has been in the works for, like, a year now.
[337.38 --> 338.08] Yeah, I see.
[338.20 --> 341.68] By the way, just mentioning another taboo subject doesn't cancel out the other one.
[342.62 --> 343.02] Yeah.
[343.02 --> 345.10] You're just compounding your crimes.
[345.10 --> 353.94] I asked Daniel and Michael to find a list of the things that they're sort of excited about or interested in that we can go through and talk about.
[354.74 --> 358.82] And obviously, Michael worked on module workspaces as well.
[358.82 --> 362.36] So we'll carve some time out at the end to talk about that in particular.
[362.96 --> 366.04] But, Daniel, maybe you could kick us off.
[366.12 --> 372.50] There's a really interesting one that, to me, seemed like a silly, unnecessary helper.
[372.86 --> 375.52] But turns out to be actually quite worthy.
[375.96 --> 378.12] That was strings.cut.
[378.26 --> 379.16] Could you tell us about that?
[379.16 --> 385.26] Yeah, so I think anybody who's written any non-trivial amount of code knows that they have to deal with strings.
[385.42 --> 388.58] They have to add strings, look at prefixes and suffixes and so on.
[388.98 --> 392.28] And one quite common operation is wanting to cut a string in two.
[392.78 --> 396.52] So, for example, maybe you've got a domain name and you want the actual name and the extension.
[397.16 --> 399.68] Or maybe you've got a file name and you want the file name extension.
[400.04 --> 400.72] That kind of thing.
[400.72 --> 408.22] You can use Go APIs like strings.index or there's also strings.splitn and you can give it the number two.
[408.44 --> 412.18] So, like, split this string in up to two pieces, right?
[412.52 --> 415.22] But these APIs are not super easy to use.
[415.38 --> 417.80] For example, if you use index, it may give you minus one.
[418.34 --> 420.38] And if you don't check for that, that might panic.
[421.16 --> 422.78] And split has the same issue, right?
[422.80 --> 424.68] Because it gives you a slice.
[425.04 --> 430.18] So cut is, it has, you could say cut has less sharp edges.
[430.18 --> 436.64] So it only gives you two strings for the two sides and a boolean telling you whether or not it successfully cut.
[437.22 --> 437.98] Yeah, so that's nice.
[438.04 --> 445.30] So if, say, you were cutting on a colon and there wasn't a colon in there, it wouldn't be in any way like a panic or a problem.
[445.52 --> 448.28] You'd just get a false as the second argument.
[448.52 --> 448.82] Exactly.
[449.18 --> 449.36] Yeah.
[449.82 --> 450.74] What do you think about that, Michael?
[451.18 --> 454.04] Have you written code that cuts things up like this?
[454.26 --> 454.78] I have.
[454.94 --> 457.22] Yeah, it would be a nice convenience.
[457.54 --> 458.40] I like conveniences.
[458.40 --> 462.34] Yeah, I thought this was like an unnecessary helper.
[462.52 --> 466.46] Because whenever you can already do something, that's usually my preferred way.
[466.46 --> 469.56] I looked at some of the commentary on this one.
[469.56 --> 476.42] And the number of cases where people were basically doing this same operation over and over again, it's kind of everywhere.
[476.72 --> 484.58] And including some places where we'd done it incorrectly or in a way that would panic if it got some bad input or something.
[484.58 --> 491.76] If there was like some testing tool that helped you try to test out all these different possible ways of responding to input, that'd be great.
[491.88 --> 493.22] But not on this episode, there isn't.
[493.88 --> 494.44] But yeah, okay.
[494.58 --> 497.18] So strings cut and that's coming in Go 118.
[497.82 --> 499.48] Okay, Daniel, have you got another one for us?
[499.48 --> 503.66] So I've got another one that's significantly more complex than strings.cut.
[503.78 --> 507.48] And I believe it was developed by the people at Tailscale over a few years.
[507.48 --> 510.74] And it's essentially a replacement for the net.ip type.
[511.32 --> 516.26] So right now, IP addresses in Go, they represent it as a byte slice.
[516.26 --> 519.24] So you can think of a byte slice, it can have many lengths.
[519.60 --> 523.56] So an IPv4 is going to be shorter than an IP version 6, for example.
[524.22 --> 527.74] And they designed a new IP package, which they called NetAdder.
[528.02 --> 530.58] But now it's being merged as NetIP.
[531.18 --> 532.50] So it's net slash NetIP.
[533.12 --> 537.26] And it's got a bunch of advantages, mostly related around performance.
[537.70 --> 543.24] But the two main properties that it has as part of its design, which do not use a slice, essentially.
[543.84 --> 544.86] One, it's comparable.
[545.14 --> 546.38] So you cannot compare slices.
[546.44 --> 547.56] You can only compare them to nil.
[548.18 --> 550.54] And the other one is that it doesn't allocate.
[550.54 --> 554.68] So you can create a new IP without calling make or new or anything like that.
[554.68 --> 558.20] Because I think it's backed by what is essentially a bunch of integers.
[559.18 --> 563.22] So will the standard library bits of it be rewritten to use this new type?
[563.56 --> 567.78] Or is this just going to be something that's available for calling code?
[568.06 --> 568.96] I think that's a good question.
[568.96 --> 575.04] And I think anything that exposes APIs with the old type will have to remain the same because of backwards compatibility.
[575.64 --> 590.20] I seem to recall one of the reasons to add this to a standard library is so that, for example, HTTP 2 and 3, which I think it's only HTTP 3, which re-implements something like TCP, right, in user space.
[590.70 --> 593.08] And that deals with a lot of IP addresses.
[593.08 --> 598.64] So if you can remove a bunch of internal allocations that don't leak into the API, that can be a very large plus.
[599.10 --> 599.56] Yeah, that's nice.
[599.84 --> 603.24] And do you know if they're going to be helpers to kind of switch between the two?
[603.32 --> 606.38] Do you think we're going to see code like that flying around for a bit?
[606.56 --> 610.32] I believe the package comes with helpers, but my memory is failing me.
[610.88 --> 611.14] Okay.
[611.42 --> 614.50] I mean, if not, people will probably end up doing that, I imagine.