Latest / CyberSecurity Summary / C# 7 and .NET Core Cookbook
Transcript
- 0:00Speaker 1: Imagine you're building an application that handles like a million
- 0:03Speaker 1: transactions every single second.
- 0:05Speaker 2: Oh wow, Yeah, like a global banking app or a
- 0:07Speaker 2: massive multiplayer game or something.
- 0:09Speaker 1: Right exactly, And every time your code runs, it creates
- 0:12Speaker 1: this tiny temporary file in your system's memory just to
- 0:16Speaker 1: hold a couple of numbers right now, multiply that by
- 0:18Speaker 1: a million. Eventually a background process has to come through
- 0:22Speaker 1: and clean up those million tiny files, and when it does,
- 0:24Speaker 1: your entire server suddenly.
- 0:26Speaker 2: Just grinds to a complete halt.
- 0:28Speaker 1: Exactly. Users get disconnected, carts crash, it's a mess. So
- 0:32Speaker 1: today we're looking at how a seemingly minor tweak in
- 0:36Speaker 1: a programming language completely eliminates that problem.
- 0:39Speaker 2: It really is the butterfly effect of software development, you know,
- 0:43Speaker 2: a microscopic change, and how developer types a line of
- 0:46Speaker 2: code cascading upward to save entire server architectures from collapsing.
- 0:51Speaker 1: Welcome to today's deep dive. We are exploring the c
- 0:54Speaker 1: Sharp seven and dot net Core cookbook. It's written by
- 0:58Speaker 1: Dirk Strauss, who is a seasoned software developer and a
- 1:02Speaker 1: Microsoft MVP.
- 1:03Speaker 2: Yeah he really knows his stuff, he does.
- 1:06Speaker 1: But we aren't just like reading you a manual today.
- 1:09Speaker 1: The mission here is to help you cut through the
- 1:11Speaker 1: noise of modern software documentation. We're tracking an evolutionary leap
- 1:15Speaker 1: in how developers think about and write code.
- 1:17Speaker 2: And we're eventually going to zero in on one specific
- 1:20Speaker 2: highly anticipated feature from c Shark seven point zero release.
- 1:24Speaker 1: Right. And to really understand why this feature matters, we
- 1:28Speaker 1: have to look at the environment that well forced it
- 1:31Speaker 1: into existence.
- 1:32Speaker 2: Yeah, the macro context is huge. Here the forward of
- 1:34Speaker 2: this book, it's written by doctor James McCaffrey for Microsoft Research,
- 1:38Speaker 2: and he paints a pretty intense picture of the industry.
- 1:41Speaker 1: He really does.
- 1:42Speaker 2: He calls it this astonishing explosion of new technologies and
- 1:46Speaker 2: a title wave of various forms of documentation.
- 1:49Speaker 1: I mean, tidle wave almost feels like an understatement. If
- 1:51Speaker 1: you look at the sheer scope of what developers are
- 1:53Speaker 1: expected to manage today, it's it's honestly paralyzing. Oh. Absolutely,
- 1:58Speaker 1: You've got your legacy syst but now you're also expected
- 2:01Speaker 1: to build cross platform apps with net core one point
- 2:05Speaker 1: one that run seamlessly on Windows, Linux, mac op.
- 2:08Speaker 2: Right, and you're creating mobile apps using Zamorin and Cordova.
- 2:11Speaker 1: Yeah, and you're moving from old school monolithic architectures where
- 2:15Speaker 1: everything lives on one big server, to these cloud based
- 2:18Speaker 1: micro services on Azure service fabrics exactly.
- 2:21Speaker 2: Not to mention serverless computing right aws, Lambda S three
- 2:25Speaker 2: Azure functions. For a developer trying to stay relevant, it
- 2:29Speaker 2: really is just pure information overload.
- 2:31Speaker 1: So okay, let's unpack this. Yeah, because it's like standing
- 2:35Speaker 1: in front of this massive, globally themed all you can
- 2:39Speaker 1: eat buffet.
- 2:39Speaker 2: That's a great way to put it, right.
- 2:41Speaker 1: You've got sushi, tacos, roast, beef pasta, all just staring
- 2:44Speaker 1: at you. You're holding an empty plate, and if you
- 2:46Speaker 1: just start piling everything on without a strategy, it's gonna
- 2:49Speaker 1: be a complete.
- 2:49Speaker 2: Mess, a total disaster on a plate.
- 2:51Speaker 1: Yeah. So, how is a developer supposed to navigate this
- 2:55Speaker 1: massive landscape without feeling, you know, entirely paralyzed by all
- 3:00Speaker 1: this info overload?
- 3:01Speaker 2: Well, if we connect this to the bigger picture, this
- 3:04Speaker 2: is exactly why a cookbook approach is vital. A cookbook
- 3:07Speaker 2: doesn't ask you to eat the whole buffet. It offers quick,
- 3:10Speaker 2: targeted solutions, you know. But here's the underlying thread that
- 3:14Speaker 2: connects that massive buffet. Whether you are building a native
- 3:17Speaker 2: iOS app or an AWS lambda function. You are ultimately
- 3:21Speaker 2: relying on the foundational syntax of c sharp.
- 3:24Speaker 1: The language itself is the kitchen. So if we want
- 3:27Speaker 1: to survive this shift, we have to make sure our
- 3:29Speaker 1: kitchen tools are ruthlessly efficient.
- 3:31Speaker 2: Exactly, you can't afford memory leaks when you're running millions
- 3:35Speaker 2: of automated cloud function.
- 3:36Speaker 1: Right, And that architectural pressure actually forced the c Sharp
- 3:40Speaker 1: language designers to rethink something as basic as how a
- 3:43Speaker 1: method hands data back to a developer.
- 3:46Speaker 2: Which brings us to the blockbuster feature of c sharp
- 3:48Speaker 2: seven point zero. Matt's Turgerson, the Sea Sharp program manager,
- 3:51Speaker 2: went on a record saying that, alongside pattern matching, the
- 3:54Speaker 2: biggest feature by far.
- 3:56Speaker 1: Was tupples tuples. Okay, let's establish the technical floor here,
- 4:00Speaker 1: because the core problem top will solve is like incredibly relatable.
- 4:03Speaker 2: Oh yeah, every developer faces it.
- 4:05Speaker 1: Often. You write a function and you want that function
- 4:08Speaker 1: to give you back more than one piece of data, right, But.
- 4:10Speaker 2: A method naturally just wants to return one thing. It
- 4:13Speaker 2: calculates a result, hands it back, closes out right, But
- 4:17Speaker 2: real world logic rarely fits into a single result.
- 4:21Speaker 1: But wait, couldn't developers already return multiple values using other
- 4:26Speaker 1: clunky workarounds before this. I mean, I remember inheriting legacy
- 4:30Speaker 1: code where they used out parameters everywhere. Ah.
- 4:32Speaker 2: Yes, the classic out parameter trap.
- 4:35Speaker 1: It's so messy it breaks the entire flow. You have
- 4:38Speaker 1: to preemptively declare empty variables before you even call the method.
- 4:42Speaker 1: It sounds like going to a drive through and being
- 4:44Speaker 1: forced to make a separate transaction for your burger, your fries,
- 4:47Speaker 1: and your drink instead of just being able to order
- 4:49Speaker 1: the number two combo.
- 4:50Speaker 2: That is exactly what it felt like. And if you
- 4:52Speaker 2: didn't use out parameters, you had to build an entirely
- 4:55Speaker 2: new custom class or struct just to transport the data,
- 4:59Speaker 2: which is just boilerplate clutter exactly. So the tupple is
- 5:02Speaker 2: your number two combo. It's a lightweight structure that packages
- 5:05Speaker 2: multiple values together cleanly. But what's fascinating here isn't just
- 5:09Speaker 2: that tupples exist. It's the technical specifics of how they
- 5:13Speaker 2: are implemented.
- 5:14Speaker 1: Right, because not all data containers are created equal.
- 5:16Speaker 2: Precisely, in C sharp, tupples are implemented as strucks, meaning
- 5:21Speaker 2: they are value types rather than reference types.
- 5:24Speaker 1: Okay, that's a huge distinction.
- 5:26Speaker 2: It really is. It means they are created locally and
- 5:29Speaker 2: passed by copying the content.
- 5:31Speaker 1: So no heat allocation exactly.
- 5:33Speaker 2: No heat allocation, which means the garbage collector doesn't have
- 5:36Speaker 2: to come clean it up later. It is friction free
- 5:39Speaker 2: data transport. And they are completely mutable with public mutable fields.
- 5:45Speaker 1: Which makes perfect sense. If I hand you a combo meal,
- 5:47Speaker 1: you shouldn't have to jump through hoops just to change
- 5:49Speaker 1: out the fries for a salad.
- 5:51Speaker 2: Right, it's your local data exactly. It's lightweight, it's performance,
- 5:54Speaker 2: and it saves memory.
- 5:56Speaker 1: So what does this all mean, Like, how does this
- 5:58Speaker 1: actually change the code on a practice level.
- 6:00Speaker 2: Well, Strauss uses this really great scenario in the book
- 6:04Speaker 2: to demonstrate.
- 6:04Speaker 1: This, well, the student's score dilemma.
- 6:06Speaker 2: Yes, imagine you have a method that needs to calculate
- 6:09Speaker 2: the average score for a class, but because class sizes vary,
- 6:12Speaker 2: the method also needs to return the count of students processed.
- 6:16Speaker 1: Two pieces of data, the average and the count.
- 6:19Speaker 2: Right, And he provides this hard coded input array of
- 6:22Speaker 2: scores in the text just to ground it.
- 6:24Speaker 1: I actually have that right here. The array is seventeen
- 6:28Speaker 1: forty six thirty nine sixty two eighty one seventy nine,
- 6:31Speaker 1: fifty two, and twenty four perfect.
- 6:34Speaker 2: So with the new c sharp seven point zero return
- 6:37Speaker 2: type syntax, you just declare the methods return type using
- 6:40Speaker 2: a set of parentheses. You write public int innt, get
- 6:45Speaker 2: average and.
- 6:45Speaker 1: Account just int innt. That's so clean it is.
- 6:49Speaker 2: And inside the method as a dummy implementation, he shows
- 6:52Speaker 2: you can just write var return tuple equals zero zero
- 6:56Speaker 2: using a tupple literal.
- 6:57Speaker 1: Okay, but here's where I have to push back a
- 6:59Speaker 1: little on the implementation. Yeah, because the calling code still
- 7:02Speaker 1: has to consume it, and historically tuples rely on these
- 7:04Speaker 1: default properties, right.
- 7:05Speaker 2: Right, item one and item two.
- 7:07Speaker 1: Yeah, you have to type f item one for the
- 7:08Speaker 1: average and s item two for the count. That is
- 7:10Speaker 1: so confusing. Imagine reading that code three months later. Is
- 7:13Speaker 1: item one the average, that the count is the highest score.
- 7:16Speaker 2: It's completely opaque, You have zero context.
- 7:18Speaker 1: It's a breeding ground for bugs.
- 7:20Speaker 2: Oh absolutely, I completely agree. And that exact limitation of
- 7:23Speaker 2: default tuble naming is what leads to the final most
- 7:26Speaker 2: elegant feature of c sharp seven point zero tuples.
- 7:29Speaker 1: Here's where he gets really interesting, because.
- 7:31Speaker 2: They fixed this, right they did. You can declare variable
- 7:34Speaker 2: names directly in the return type now, so.
- 7:37Speaker 1: Instead of just inint INNT, you can write public int
- 7:40Speaker 1: average in student count, get average in count.
- 7:43Speaker 2: Exactly. You are attaching the semantic meaning right there in
- 7:46Speaker 2: the signature, and the.
- 7:47Speaker 1: Impact that has on the calling code is massive, because
- 7:50Speaker 1: you jump from generic item one tags to named elements
- 7:54Speaker 1: inside an interpolated string. You just type s dot average
- 7:57Speaker 1: in s student count, which.
- 7:59Speaker 2: Is incredible readable, and you can even name tupple literals internally,
- 8:03Speaker 2: like var return tupple, I've ave dot average, scout dot.
- 8:07Speaker 1: Right. It isn't just about making the code run faster,
- 8:09Speaker 1: It's about making it human readable for the nice person
- 8:12Speaker 1: who inherits the project.
- 8:13Speaker 2: And this raises an important question about how language features
- 8:17Speaker 2: fundamentally change team collaboration. Oh, for sure, writing code is
- 8:21Speaker 2: as much about communicating intent to other developers as it
- 8:25Speaker 2: is about giving instructions to a compiler, exactly.
- 8:28Speaker 1: But we do need warn people about a specific setup requirement.
- 8:32Speaker 2: Right, Yes, the gotcha, gotcha? If you are working in
- 8:36Speaker 2: Visual Studio twenty seventeen release candidate, this doesn't just work
- 8:40Speaker 2: right out of the box, right.
- 8:41Speaker 1: Because the core compiler didn't natively know how to process
- 8:43Speaker 1: value tech toples yet exactly.
- 8:45Speaker 2: So developers have to go to the new Get package
- 8:48Speaker 2: manager and actively install a package called system dot value tuple.
- 8:53Speaker 1: And hit accept on the Microsoft license agreement that pops up.
- 8:56Speaker 2: Yes, you have to accept the agreement for it to work.
- 8:59Speaker 2: It's a small hurb, but if you don't know it's required,
- 9:02Speaker 2: you'll be staring at compiler errors for hours completely baffled.
- 9:06Speaker 1: Yeah, well, I think that brings us full circle on
- 9:08Speaker 1: this deep dive. We started out looking at this overwhelming
- 9:11Speaker 1: macro world, right, micro services, serverless architecture, cross platform app,
- 9:16Speaker 1: giant buffet, the giant buffet, and we seemed all the
- 9:19Speaker 1: way down into the elegant micro level syntax of c
- 9:22Speaker 1: shark seven point zero tuples.
- 9:24Speaker 2: And mastering these precise quick solutions is exactly what makes
- 9:29Speaker 2: a developer truly formidable.
- 9:30Speaker 1: It really is, and it leads you with a final
- 9:32Speaker 1: somewhat provocative thought to mull over. Yeah, think about it.
- 9:36Speaker 1: If programming language syntax is constantly evolving to mirror natural
- 9:40Speaker 1: human logic, like seamlessly packaging and naming multiple related ideas
- 9:44Speaker 1: at once, like we saw with tuples, how close are
- 9:47Speaker 1: we to a future where code structure becomes almost indistinguishable
- 9:51Speaker 1: from plain English.
- 9:52Speaker 2: Wow, that's a huge question.
- 9:54Speaker 1: Right, And how are the tools you use today subtly
- 9:57Speaker 1: shaping the way you actually think about problems evolving in
- 10:00Speaker 1: your everyday life.
- 10:01Speaker 2: We shape our tools, and then our tools shape us.
- 10:04Speaker 1: Exactly something to think about the next time you write
- 10:07Speaker 1: a line of code. Thanks for joining us on this
- 10:09Speaker 1: deep dive.
- 10:10Speaker 2: Thanks for having me