text stringlengths 0 1.62k |
|---|
[859.92 --> 863.94] uh and this is because naturally a processor just does bad things right like when you teach a person |
[863.94 --> 867.44] programming one of the first things you learn is that computers are not smart they're actually |
[867.44 --> 871.96] stupid and they do exactly what you tell them to even if what you tell them to do is just terribly wrong |
[871.96 --> 877.58] one of the innovations that came along actually uh in originally in the list paper uh by john mccarthy |
[877.58 --> 883.18] was this idea of a garbage collector and uh so instead of you managing memory manually through pointers |
[883.18 --> 887.74] you would ask garbage collector for memory and it would give it to you and then you're done with it it would |
[887.74 --> 892.90] automatically figure out how to get rid of that memory so fast forward you know 50 years this is |
[892.90 --> 897.80] a very common thing most of us work in languages that are garbage collected but garbage collectors |
[897.80 --> 902.84] like all things in engineering have upsides and downsides and there are certain domains in which |
[902.84 --> 907.72] a garbage collector's downside is completely unacceptable and there's other domains in which a garbage |
[907.72 --> 912.14] collector's downsides might not be as good as their upsides even if it's still possibly usable |
[912.14 --> 916.96] so in those domains where it's absolutely impossible you pretty much need a language like |
[916.96 --> 922.52] in modern days c or c plus plus that do not have one built into the language um and so rust is trying |
[922.52 --> 927.26] to tackle that sort of space because when you're building a web browser you need a ton of performance |
[927.26 --> 932.96] people expect their css transitions to be really snappy and like javascript to operate very quickly and so |
[932.96 --> 938.04] performance you know really really matters a lot and so in that context a gc is not really an |
[938.04 --> 942.76] acceptable mountain of latency there's other ones too like for example uh if you're implementing a |
[942.76 --> 947.00] programming language and you want to write a garbage collector uh it's much nicer if you're not |
[947.00 --> 951.32] fighting with a host language as a garbage collector so you may want to use one or if you're writing a |
[951.32 --> 957.32] triple a game uh you know when you need to have 60 frames a second uh a gc pause is unacceptable |
[957.32 --> 960.92] there's just all sorts of domains where this kind of thing happens i mean i think you hear this case |
[960.92 --> 966.82] actually interesting so maybe let's talk about that for a moment yeah so our domain is just we're already |
[966.82 --> 972.00] we're embedding into a language that already has a garbage collector and cycles between two languages with a |
[972.00 --> 977.96] garbage collector uh pretty much cause leaks no matter how careful you are especially if both |
[977.96 --> 983.94] languages have closures so if you're writing in uh trying to embed javascript in ruby or go in ruby |
[983.94 --> 990.02] or interoperating between like java 8 and ruby the only way that that ends up working correctly is if |
[990.02 --> 995.30] both parts of the system are talking to the same memory management system um so if you're for example |
[995.30 --> 1000.52] jruby the correct solution is that jruby doesn't come with its own garbage collector jruby uses the host |
[1000.52 --> 1004.32] garbage collector that's one strategy that you can use and that works fine if you're embedding |
[1004.32 --> 1009.28] your language inside of another language right but in this case where ruby is the host language |
[1009.28 --> 1013.18] which means that we don't and we probably don't want the thing that we're embedding to use ruby's |
[1013.18 --> 1019.38] garbage collector right we're writing lower level code so the only real solution is to have the thing |
[1019.38 --> 1023.16] that we're embedding use the system's memory management the system's memory management is malloc |
[1023.16 --> 1030.04] right so that's the way to avoid causing uh conflicts but of course now if the only option |
[1030.04 --> 1034.36] that you have is malloc now you're writing extremely low level code that has the possibility of taking |
[1034.36 --> 1041.28] down the entire process with you so uh in my in my case we could have written in a modern dialect of c++ |
[1041.28 --> 1048.18] which does a certain amount of work to make this plausible but i as a programmer i just don't trust |
[1048.18 --> 1053.86] myself to write code that never crashes and so i wasn't willing to write i wasn't willing to basically |
[1053.86 --> 1058.18] go to nasa levels of engineering just to write a thing that collected information from your reels app |
[1058.18 --> 1063.42] and i really wanted some uh to use a language that would that would give us guarantees about that stuff |
[1063.42 --> 1068.82] so we if rust didn't exist i think we would have had a deep struggle inside of the company because |
[1068.82 --> 1073.74] i think there was a strong pressure to use c++ because that would give us the guarantees that we |
[1073.74 --> 1078.04] needed in terms of performance but a bunch of the rest of us were like you know who's going to |
[1078.04 --> 1081.24] maintain that how are we going to make sure we don't crash who's going to take the support tickets |
[1081.24 --> 1085.44] from the guy that's complaining that we're segregating that process um and so rust was |
[1085.44 --> 1089.50] really came it came just at the right time for us because it allowed us to say we're going to be |
[1089.50 --> 1092.68] able to have low level control we're going to be able to use the systems memory management |
[1092.68 --> 1098.04] but we're also going to have a absolute confidence that the program we write doesn't take down the host |
[1098.04 --> 1101.76] with it and and we're not the only people that are writing programs with this problem pretty much |
[1101.76 --> 1107.50] any c extension in ruby has this kind of problem and i would imagine that over time more and more |
[1107.50 --> 1112.52] cases where people are using c effectively as a glue layer or as an embedding language more and |
[1112.52 --> 1117.32] more people will move to rust just as a strictly better c yeah and so that's like that's like the |
[1117.32 --> 1122.00] drawbacks of the gc angles it sort of leads right into that so memory safety without garbage |
[1122.00 --> 1127.18] collection means that we give you this degree of safety that you're not going to screw things up |
[1127.18 --> 1133.02] without needing to use the gc to do it so i think that's probably a good spot for us to pause and |
[1133.02 --> 1137.58] hear from a sponsor when we come back i want to hear exactly how it gives us this memory safety |
[1137.58 --> 1141.14] without garbage collection so let's uh let's pause we back in a sec |
[1141.14 --> 1147.26] i want to share a more personal note today with you about our awesome sponsor top towel |
[1147.26 --> 1151.92] you've heard us talk about top towel several times for long-time listeners you know that top towel |
[1151.92 --> 1156.18] has been supporting the show for the better part of a year to a year and a half now |
[1156.18 --> 1161.84] if you want to go to their website while i'm talking here it's t-o-p-t-a-l.com it's one of |
[1161.84 --> 1166.96] the best places to work as a freelance software developer we've been working with top towel like i |
[1166.96 --> 1171.24] said for about a year year and a half now and over this year and a half i've gotten to know |
[1171.24 --> 1176.48] their co-founder brendan very very well i love what they're doing for the software development |
[1176.48 --> 1181.28] community they care deeply about software developers having awesome engagements to work on |
[1181.28 --> 1185.86] and they also care about awesome engagements having really awesome software engineers to work |
[1185.86 --> 1189.98] with them so they really make the marriage between a business with great opportunities |
[1189.98 --> 1195.38] and an engineer needing great opportunities to work on they make that marriage possible |
[1195.38 --> 1200.38] well we took our relationship to the next level and went there ourselves we're building something |
[1200.38 --> 1204.98] very cool behind the scenes here to change law to power the future of what we're becoming you're |
[1204.98 --> 1209.06] going to love what we're doing we hired a software engineer through top towel his name's |
[1209.06 --> 1213.66] so if you're a member and you're in the members of the slack room say hi to hafail he's in there |
[1213.66 --> 1219.18] but i wanted to tell you just how deeply we care about our relationship with top towel and how much we |
[1219.18 --> 1224.24] trust who they are and if you're freelancing right now as a software developer and you're looking for a |
[1224.24 --> 1229.64] way to work with top clients maybe even us on projects that are interesting to you challenging |
[1229.64 --> 1236.14] and using the technologies you want to use i will go as far to say that top towel is the place for you |
[1236.14 --> 1243.94] head to top towel.com slash developers that's top towel.com slash developers learn more and tell |
[1243.94 --> 1249.72] them the change law sent you all right steve and you know we're talking memory safety without garbage |
[1249.72 --> 1255.60] collection sounds like rust has that as a defining feature um you said it has it but like how does it |
[1255.60 --> 1259.98] actually work can i i'll just jump in and say one thing and then let steve answer it in more detail |
[1259.98 --> 1264.42] which is what i wrote a blog post about this called uh rust means never having to close the socket |
[1264.42 --> 1269.22] which i would recommend people read to get more details about this stuff beyond what we'll talk |
[1269.22 --> 1274.72] about here but one thing that was pretty uh like a pretty big aha for me when i started writing rust |
[1274.72 --> 1280.48] is that garbage collection is actually pretty awesome at managing the resource called memory so garbage |
[1280.48 --> 1285.86] collection is able to say when i create a new you know if i create 5k memory and i no longer need it |
[1285.86 --> 1291.38] it will get cleaned up but garbage collection is actually very bad at closing resources like files |
[1291.38 --> 1297.98] locks and things like this and uh if you if you ever wrote c++ which it turns out most people who |
[1297.98 --> 1303.58] wrote write ruby didn't there's actually a pretty nice system in in c++ and other language and a bunch |
[1303.58 --> 1309.32] of other languages which basically will uh automatically manage resources in the same way that memory is |
[1309.32 --> 1315.20] managed uh unfortunately in c++ that comes at the cost of of a lack of safety which basically makes it a |
[1315.20 --> 1321.28] non-starter for uh for people who are trying to write safe line writing safe language but the i didn't |
[1321.28 --> 1325.34] really occur to me before that while i had this awesome strategy for dealing with memory management |
[1325.34 --> 1329.60] basically i just you know i just did something that new i got a new thing and when i was done with it |
[1329.60 --> 1334.16] got cleaned up but if i started to use a file or if i started to use a lock i suddenly had to do |
[1334.16 --> 1339.70] all this manual work to make sure it got cleaned up and if i if i use a socket outside of the area where i was |
[1339.70 --> 1343.96] allowed to use it just like if i tried to use memory outside the area i'm allowed to use it in c or c++ |
[1343.96 --> 1348.26] i would get weird errors and it just didn't occur to me that one of the trade-offs for having a |
[1348.26 --> 1351.70] garbage collector which is very good at managing memory is that suddenly i have to do all this |
[1351.70 --> 1358.44] manual work to manage sockets and other kinds of resources files and things like that so uh steve |
[1358.44 --> 1364.68] can answer the original question uh yeah that was a good detour though so it's it's important while |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.