text
stringlengths
0
2.35k
[2247.62 --> 2277.60] Again, for some of the more advanced thing.
[2277.60 --> 2279.02] It's not two hours ago.
[2279.02 --> 2286.10] You know, higher kind of types add a ton of complexity to a compiler and a type checker inside of the compiler.
[2286.72 --> 2294.42] But, you know, they do offer basically something called a type constructor, which is a type that depends on another type.
[2294.62 --> 2294.80] Right.
[2294.80 --> 2300.08] And if you can do that, I'll leave it as an exercise to the reader or listener or watcher.
[2300.78 --> 2302.94] What kinds of things could you do with that?
[2303.22 --> 2304.52] Take me a while to get into it.
[2304.68 --> 2306.04] So I'm not going to go there now.
[2306.04 --> 2316.22] But if you had that right now, assuming it was correct in the compiler, you can start to do some very advanced things.
[2317.08 --> 2330.50] But the only thing that I'll say is whenever I've seen that feature in a language or not in the language and then introduced into the language, at that point, it starts to become what you called sort of a functional language.
[2330.50 --> 2331.10] Right.
[2331.10 --> 2331.20] Right.
[2331.70 --> 2342.08] Because getting to that level of sophistication in the type system often means that there are a bunch of people already there who have been demanding it.
[2342.44 --> 2344.84] And those people are the majority.
[2345.16 --> 2349.00] And those people write very heavily function oriented code.
[2349.00 --> 2354.44] So really, I'm going to just limit it to the type parameters on methods thing because that thing is not very controversial.
[2355.26 --> 2367.12] But higher kinded types or high order types are a very interesting and cool thing that I really do wish was in Go because it would enable some very slick FP things.
[2367.56 --> 2368.98] Yeah, that is not controversial to me.
[2369.10 --> 2369.88] I could see that.
[2370.12 --> 2370.28] Okay.
[2370.56 --> 2371.04] Some might.
[2371.14 --> 2372.32] Maybe some people will think of it.
[2372.32 --> 2372.64] Okay.
[2379.00 --> 2384.56] We are going to ship it.
[2384.56 --> 2387.08] Three, two, one.
[2387.54 --> 2394.80] I'm Karhara Zhu, host of Ship It, a show with weekly episodes about getting your best ideas into the world and seeing what happens.
[2394.80 --> 2401.30] We talk about code, ops, infrastructure, and the people that make it happen like charity majors from Honeycomb.
[2401.72 --> 2404.56] We act like great engineers make great teams.
[2404.78 --> 2406.22] And it's exactly the opposite.
[2406.22 --> 2409.84] In fact, it is great teams that make great engineers.
[2410.42 --> 2413.74] And they finally win the founders of continuous delivery.
[2414.12 --> 2416.90] Start off assuming that we're wrong rather than assuming that we're right.
[2417.16 --> 2418.16] Test our ideas.
[2418.28 --> 2419.78] Try and falsify our ideas.
[2419.92 --> 2421.92] Those are better ways of doing work.
[2421.98 --> 2424.20] And it doesn't really matter what work it is that you're doing.
[2424.34 --> 2426.00] That stuff just works better.
[2426.00 --> 2437.62] We even experiment on our own open source podcasting platform so that you can see how we implement specific tools and services within changelog.com, what works and what fails.
[2437.62 --> 2441.86] It's like there's a brand new hammer and we grab hold of it and everyone gathers around.
[2441.94 --> 2445.74] We put our hand out and we strike it right on our thumb.
[2445.96 --> 2450.10] And then everybody knows that hammer really hurts when you strike it on your thumb.
[2450.18 --> 2451.46] I'm glad those guys did it.
[2451.54 --> 2452.90] I've learned something instead.
[2453.04 --> 2453.16] Yeah.
[2453.32 --> 2457.92] I think that's a very interesting perspective, but I don't see that way.
[2458.06 --> 2458.32] Okay.
[2458.42 --> 2461.52] It's an amazing analogy, but I'm not sure that applies here.
[2461.52 --> 2464.16] Listen to an episode that seems interesting or helpful.
[2464.32 --> 2465.98] And if you like it, subscribe today.
[2466.08 --> 2467.22] We'd love to have you with us.
[2471.70 --> 2472.10] Okay.
[2472.20 --> 2476.72] So before we transition into unpopular opinions, maybe I want one of those controversial ideas.
[2478.48 --> 2478.88] Okay.
[2479.64 --> 2480.12] All right.
[2480.46 --> 2481.14] Let's get it going.
[2481.72 --> 2490.88] I'm not going to give one that talks about higher kind of types because it's been a while, first of all, so I don't think I would do it justice or maybe even get some parts incorrect.
[2490.88 --> 2493.50] But also it would take me a while.
[2493.94 --> 2499.38] But I want to mention one pattern from FP that I think is really great.
[2499.92 --> 2503.16] And it's not that hard to do yourself in your code.
[2503.52 --> 2507.44] I also don't think it's too hard to imagine how it would work in a code base.
[2507.96 --> 2509.12] It's called the lens.
[2509.84 --> 2513.48] So it maybe sounds like an intimidating thing to some people.
[2513.64 --> 2514.72] It certainly did to me.
[2515.38 --> 2518.14] The lens is essentially a tuple of two functions.
[2518.14 --> 2520.92] One function is a getter for some data.
[2521.44 --> 2526.22] And then the other function is the setter for some probably the same type of data.
[2526.72 --> 2528.26] But you can have separate things too.
[2528.34 --> 2533.24] You can have a getter for one piece of data and a setter for another piece of data in the same tuple.
[2533.80 --> 2537.82] So usually it's the getter first in the tuple and then the setter second in the tuple.
[2537.82 --> 2543.12] Now the first function takes no parameters and returns the result, the data.
[2543.70 --> 2550.48] It might take one parameter if the data is multidimensional like a map and you want it to specify a key.
[2551.14 --> 2551.82] And that's up to you.
[2551.90 --> 2553.10] That's part of the design pattern.
[2554.04 --> 2559.00] And then the setter potentially takes in the dimension of the data, again like the key of the map.
[2559.00 --> 2563.80] And then it also takes in the data that you want to set into that place.
[2564.72 --> 2570.86] So it might be the value of a map if we're going to use the map, like the example of a map.
[2571.50 --> 2573.00] And then it returns nothing.
[2573.46 --> 2579.74] These things can alternatively return an error if this is like doing something over the network or something that might fail.
[2580.14 --> 2581.24] But traditionally they're not.
[2581.24 --> 2590.00] All right, so if you could kind of imagine how these functions would be created, they would probably be closures.
[2590.58 --> 2592.40] They would close over your data.
[2593.04 --> 2595.18] They would take some parameter in the get.
[2595.34 --> 2596.78] Let's take the get case, for example.
[2597.28 --> 2601.90] They would take the parameter for the thing to get and then they would return the value of it.
[2602.26 --> 2603.16] Same thing with the set.
[2603.24 --> 2605.34] It would close over the data and then do its thing.
[2605.34 --> 2613.00] It's a fancy term called a lens, but it's a fairly basic foundational thing.
[2613.80 --> 2618.30] And that is a common theme in FP actually.
[2618.98 --> 2623.70] So I called this the lens and it is in Wikipedia and it's in the textbook and everything.
[2624.14 --> 2628.12] But it just boils down to functions like most things in FP do.
[2628.66 --> 2633.32] They just boil down to one or more functions, maybe combined together in some creative way.
[2633.32 --> 2637.88] Or maybe one function applied across the data structure in some other way.
[2638.24 --> 2643.52] So I would challenge everyone listening to just give it some thought.
[2643.80 --> 2647.48] Can that reduce code somewhere in your code base?
[2648.12 --> 2656.10] If you have a bunch of getters, can you get rid of those getters and just replace them with a closure of the lens?
[2656.52 --> 2661.66] That's a very interesting one to me because it is exceptionally simple.
[2661.66 --> 2663.10] I'll put it a different way.
[2663.26 --> 2665.72] The return on investment is very high.
[2666.28 --> 2671.02] It's very simple, but it tends to be applicable and useful in a lot of places in the code base.