Latest / CyberSecurity Summary / Get Programming with F#: A guide for .NET developers
Transcript
- 0:00Speaker 1: Okay, let's unpact this. You're staring at your screen, it's
- 0:02Speaker 1: a Tuesday morning, and you're tracking down a bug that
- 0:05Speaker 1: makes absolutely zero sense.
- 0:07Speaker 2: Oh yeah, we have all been there.
- 0:08Speaker 1: Right, I mean, the state of an object mutated somewhere
- 0:11Speaker 1: across like three different files, and despite your rigorous, solid
- 0:17Speaker 1: principles and your dependency injection and this endless suite of
- 0:21Speaker 1: unit tests, your application just crashed in production.
- 0:24Speaker 2: Anyway, It is the ultimate developer nightmare, it really is.
- 0:27Speaker 1: We've built these incredibly heavy scaffolding systems in object oriented
- 0:32Speaker 1: programming just to keep our software from collapsing under its
- 0:34Speaker 1: own weight. But what if the problem isn't that you
- 0:37Speaker 1: need more scaffolding. What if the problem is the very
- 0:40Speaker 1: materials you're using to build.
- 0:42Speaker 2: Well, that is exactly the core question we are tackling today.
- 0:46Speaker 2: We are looking at this radical shift in perspective for developers,
- 0:49Speaker 2: like how changing your programming language can physically push you
- 0:52Speaker 2: into what we call a pit of success. The pit
- 0:55Speaker 2: of success, Yeah, a place where writing correct code is
- 0:57Speaker 2: actually easier than writing broken code.
- 1:00Speaker 1: Which sounds like magic. But to figure out how to
- 1:03Speaker 1: get there, we are diving deep into excerpts from the
- 1:05Speaker 1: book get Programming with f sharp, A guy for dot
- 1:09Speaker 1: net developers. This is by Isaac Abraham, published by Manning.
- 1:12Speaker 2: It's a fantastic resource, it is, and.
- 1:15Speaker 1: Our mission for this deep dive is to explore the
- 1:17Speaker 1: shift from that traditional object oriented paradigm we all grow
- 1:21Speaker 1: up on to the functional first world of SHTAR. We
- 1:24Speaker 1: want to understand the literal mechanics of how fshar lets
- 1:27Speaker 1: you write software faster, with fewer bugs and without that
- 1:31Speaker 1: exhausting overhead of constant design patterns.
- 1:35Speaker 2: So to really grasp why a seasoned developer would just
- 1:37Speaker 2: throw out their established playbook, we kind of have to
- 1:40Speaker 2: look at Isaac Abraham's own breaking point, because you know,
- 1:43Speaker 2: he wasn't some academic sitting in an ivory tower hating
- 1:46Speaker 2: on object oriented programming.
- 1:48Speaker 3: He's in the trenches exactly.
- 1:49Speaker 2: He was a highly successful sea sharp developer working for
- 1:51Speaker 2: a dot net consultancy in the UK, and he was
- 1:54Speaker 2: deeply invested in doing things the right way. I mean,
- 1:56Speaker 2: he was a fanatic for test driven development and classic
- 1:59Speaker 2: O designs, and.
- 2:01Speaker 1: The book points out that his code quality actually did
- 2:03Speaker 1: improve with those patterns, right like his bug rades dropped.
- 2:07Speaker 2: They did, but the cognitive load required to maintain that
- 2:10Speaker 2: level of quality was just draining his love for software development.
- 2:14Speaker 1: It's exhausting, it is.
- 2:15Speaker 2: And the ultimate catalyst happened when he was tasked with
- 2:19Speaker 2: building a rules engine for a financial services company. They
- 2:22Speaker 2: were trying to monitor like suspicious dodging looking trades.
- 2:27Speaker 3: Oh okay, so high stakes, very high stakes.
- 2:29Speaker 2: And he spent eighteen months on that project, a year
- 2:33Speaker 2: and a half trying to create this component based rules
- 2:36Speaker 2: engine with pluggable rules, and eventually he just had this
- 2:40Speaker 2: stark realization he and his team had essentially spent eighteen
- 2:43Speaker 2: months trying to force clumsy object oriented constructs to behave
- 2:47Speaker 2: like a functional pipeline.
- 2:49Speaker 1: But wait, I mean, if we're taught that PDD and
- 2:53Speaker 1: interfaces and dependency injection are the gold standards of software engineering,
- 2:57Speaker 1: why would he feel like they were clumsy? Aren't those
- 2:59Speaker 1: patterns the exact mechanisms that guarantee our code is robust?
- 3:03Speaker 2: Well yeah, but only if you assume that complex state
- 3:06Speaker 2: mutation is unavoidable. Oh interesting, right, because in opiddoh, you
- 3:09Speaker 2: are constantly managing objects that hold both data and behavior,
- 3:13Speaker 2: and that data can change. So all those patterns you mentioned,
- 3:17Speaker 2: like dependency injection and massive mock libraries. For TDD, they're
- 3:21Speaker 2: largely just defense mechanisms.
- 3:23Speaker 1: Defense mechanisms against the changing state exactly.
- 3:26Speaker 2: They exist to manage the complexity of state mutation. And
- 3:30Speaker 2: Abertlin realized the rigor wasn't the goal. Robust software was
- 3:34Speaker 2: the goal. So when he discovered f shar, he found
- 3:37Speaker 2: a language whose fundamental mechanics naturally suited the logic he
- 3:41Speaker 2: was trying to express.
- 3:42Speaker 3: Just fit better it did.
- 3:43Speaker 2: It allowed for rapid delivery with high confidence, totally minus
- 3:47Speaker 2: the defensive scaffolding.
- 3:49Speaker 1: Which brings us to the core philosophical difference. Here we
- 3:51Speaker 1: are moving from the O cool world of sishar to
- 3:54Speaker 1: a functional first paradigm. But what does that actually mean
- 3:58Speaker 1: for the code you're typing every day?
- 4:00Speaker 2: So the text defines three main pillars of functional programming,
- 4:02Speaker 2: or FP, and the first one is immutability. Okay, and
- 4:05Speaker 2: FP values never change. Once you define a piece of
- 4:08Speaker 2: data and memory, it is locked in for its lifetime.
- 4:10Speaker 1: Wow. Okay.
- 4:11Speaker 2: Yeah, So if you want to update a user's name,
- 4:13Speaker 2: you don't mutate the existing user object in place. The
- 4:17Speaker 2: system creates a brand new user object with the updated name,
- 4:20Speaker 2: and it just leaves the original completely intact.
- 4:23Speaker 1: I mean that sounds incredibly memory intensive at first glance.
- 4:26Speaker 1: It does, but I know, like under the hood, FHAG
- 4:29Speaker 1: uses structural sharing, so it's not actually duplicating the entire
- 4:33Speaker 1: object every single time, right, it's just duplicating the delta.
- 4:36Speaker 2: Yes, exactly.
- 4:37Speaker 1: It's highly optimized, and the payoff there is that it
- 4:39Speaker 1: creates this crystal clear separation of data and functionality. You
- 4:44Speaker 1: completely eliminate those unpredictable run time bugs where a variable
- 4:49Speaker 1: changes state unexpectedly on some totally different thread.
- 4:52Speaker 2: Precisely you don't need locks or mutexes for thread safety.
- 4:56Speaker 2: If the data literally cannot change, that is huge.
- 4:58Speaker 3: It really is.
- 5:00Speaker 2: Second pillar is expressions. So instead of writing imperative statements
- 5:03Speaker 2: like a wild loop that just executes and alters the
- 5:06Speaker 2: state of the machine silently in the background, you write expressions.
- 5:09Speaker 1: And expressions always return something.
- 5:11Speaker 2: Right, right, They always evaluate to a tangible value. Every
- 5:15Speaker 2: operation has a predictable input and a predictable output.
- 5:18Speaker 1: Got it. And the third pillar is treating functions as values. Yes,
- 5:22Speaker 1: meaning you can pass a function into another function as
- 5:25Speaker 1: an argument, return it as an output, or share it
- 5:28Speaker 1: around just like you would an integer or.
- 5:29Speaker 2: A strength which is really the foundation of building complex
- 5:32Speaker 2: systems from very simple, testable building blocks.
- 5:35Speaker 1: But I know developers listening right now are probably thinking, ah,
- 5:38Speaker 1: C sharp has evolved massively, like we have lambed expressions,
- 5:43Speaker 1: we have LI and Q, we even have record types.
- 5:46Speaker 1: Now can't I just write functional code and C sharp
- 5:48Speaker 1: and get the best of both worlds without learning a
- 5:51Speaker 1: whole new syntax.
- 5:52Speaker 2: I mean, you can certainly write functional style code in
- 5:55Speaker 2: C sharp, sure, but it all comes down to this
- 5:57Speaker 2: concept of idiomatic.
- 5:59Speaker 3: Defaults uneumatic defaults.
- 6:01Speaker 1: Okay, explain that.
- 6:02Speaker 2: So the path of least resistance in a language dictates
- 6:05Speaker 2: how the vast majority of a codebase is going to
- 6:07Speaker 2: be written, and in C sharp, mutability is still the default.
- 6:10Speaker 2: If you type var name equals isaac, you can just
- 6:13Speaker 2: reassign that variable on the very next line if you
- 6:15Speaker 2: want to make it immutable. The language forces you to
- 6:18Speaker 2: jump through hoops. You have to add extra keywords like
- 6:22Speaker 2: read only or use very specific read only collections.
- 6:25Speaker 1: So you're constantly fighting the grain of the wood. The
- 6:28Speaker 1: language is passively encouraging you to do the unsafe.
- 6:31Speaker 2: Thing exactly, and f SHARV flips that entirely on its head.
- 6:34Speaker 2: Immutability is the default there. If you write let name
- 6:39Speaker 2: equals isaac, that value is mathematically lost.
- 6:42Speaker 1: It's done.
- 6:43Speaker 2: It's done. The compiler will actually throw an air if
- 6:45Speaker 2: you try to reassign it. But what if you actually
- 6:47Speaker 2: needed to change If you have a specific performance optimization
- 6:50Speaker 2: that genuinely requires mutability, you have to explicitly ask the
- 6:54Speaker 2: compiler for permission by typing let mutable name equals isaac.
- 6:58Speaker 1: Oh, so the language does itself places a syntactic tax
- 7:02Speaker 1: on the behaviors that lead to complex bugs. Yes, and
- 7:05Speaker 1: it makes the safest behaviors the absolute easiest to type.
- 7:08Speaker 2: That is the whole point.
- 7:09Speaker 1: Yeah. So if f sharp is pushing us toward this
- 7:12Speaker 1: functional first utopia, what does that actually look like on
- 7:16Speaker 1: the screen, Because I mean, the syntax of s shard
- 7:20Speaker 1: is jarring. If you're coming from C style language.
- 7:22Speaker 2: It definitely takes a minute to adjust.
- 7:24Speaker 1: The book points out that there are no curly braces,
- 7:27Speaker 1: there are no semic hoolens. Scope is determined entirely by
- 7:30Speaker 1: white space and indentation, and perhaps the most terrifying part
- 7:34Speaker 1: for an enterprise C sharp developer, there are almost no type.
- 7:37Speaker 2: Declarations right, and that lack of type declarations is usually
- 7:41Speaker 2: where developers just panic. They assume f sharp is a
- 7:44Speaker 2: dynamic language like JavaScript or Python, which can become notoriously
- 7:48Speaker 2: unmintainable at scale because you never really know what type
- 7:51Speaker 2: of object is being passed around.
- 7:52Speaker 3: Right, you get those run time errors everywhere exactly.
- 7:55Speaker 2: But f sharp is fully statically typed and compiled. It
- 7:58Speaker 2: achieves this brevity through an incredibly powerful type inference engine.
- 8:01Speaker 1: How does that actually work though? If I don't explicitly
- 8:04Speaker 1: say this is a string or this is a list
- 8:07Speaker 1: of integers, how does the compiler know, and more importantly,
- 8:10Speaker 1: how does it enforce type safety?
- 8:12Speaker 2: So the eshtart compiler uses a mathematical concept called unification.
- 8:16Speaker 2: Unification right, it looks at the constraints you place on
- 8:19Speaker 2: your data and it just deduces what the type must be.
- 8:22Speaker 2: For instance, let's say you write a function that takes
- 8:25Speaker 2: a variable called age and uses the greater than operator
- 8:29Speaker 2: to compare it to eighteen. Okay, the compiler says, ah,
- 8:32Speaker 2: greater than eighteen, this parameter must be an integer. You
- 8:36Speaker 2: didn't type in, but the compiler locked it in as
- 8:38Speaker 2: an integer at compile time.
- 8:40Speaker 1: Oh wow.
- 8:41Speaker 2: Yeah, And if you try to pass a string into
- 8:42Speaker 2: that function somewhere else in your code. The build breaks immediately.
- 8:46Speaker 1: That's amazing. So you get the clean, readable brevity of Python,
- 8:50Speaker 1: but with the rock solid compile time safety of Java
- 8:53Speaker 1: or c sharks exactly, and the visual result is really striking.
- 8:57Speaker 1: The book is examples of defining a tuble just by
- 9:00Speaker 1: operating values with a comma like let player tuple equals
- 9:03Speaker 1: player name comma twenty one. So clean, yeah, or using
- 9:07Speaker 1: pattern matching, which looks like this vastly more powerful switch
- 9:10Speaker 1: statement that can unpack data structures on the fly.
- 9:13Speaker 2: And because you strip away all that explicit typing and boilerplate,
- 9:17Speaker 2: you actually start writing declarative code instead of imperative code.
- 9:20Speaker 1: Okay, let's break that down, because imperative versus declarative is
- 9:23Speaker 1: a massive mental hurdle for a lot of people.
- 9:26Speaker 2: It is. Think of imperative code as focusing on the
- 9:29Speaker 2: how it's low level mechanics. Declarative code focuses on the
- 9:33Speaker 2: what you declare your intent, and the framework just handles
- 9:36Speaker 2: all the mechanics for you.
- 9:38Speaker 1: The book uses a really great example for this, filtering
- 9:41Speaker 1: a collection to get only the even numbers. Can you
- 9:44Speaker 1: walk us through the c sharp imperative wave versus the
- 9:48Speaker 1: f Shard declarative way.
- 9:49Speaker 2: Sure, so in imperative C sharp you kind of have
- 9:51Speaker 2: to build the entire machine yourself. First, you allocate memory
- 9:54Speaker 2: by instantiating a temporary list of iNTS.
- 9:56Speaker 3: To hold your output scandard boilerplate.
- 9:59Speaker 2: Then you write a fortune to manage the iteration state.
- 10:01Speaker 2: Inside the loop, you write an if statement checking if
- 10:04Speaker 2: the number modulo two equals zero. If true, you call
- 10:08Speaker 2: dot ad to mutate the temporary list, and finally you
- 10:11Speaker 2: return the list. You are managing state iteration and memory
- 10:15Speaker 2: allocation completely manually.
- 10:17Speaker 1: So you have to read like six lines of mechanical
- 10:20Speaker 1: plumbing just to parse the business logic, which is basically just, oh,
- 10:24Speaker 1: we want the even numbers exactly.
- 10:26Speaker 2: Now. Contrast that with the declarative f Shard version. It
- 10:28Speaker 2: is a single line, one line, one line, Let get
- 10:31Speaker 2: even numbers equals sect dot filter, and then you pass
- 10:34Speaker 2: in a small function saying number modulo two equals zero.
- 10:38Speaker 2: You don't manage a temporary list, you don't write a loop.
- 10:41Speaker 1: You just pass in your core business logic.
- 10:43Speaker 2: Right, the mathematical definition of an even number, and the
- 10:46Speaker 2: sick filter function orchestrates the iteration and memory allocation under
- 10:50Speaker 2: the hood.
- 10:51Speaker 1: That makes total sense, and this naturally leads into how
- 10:54Speaker 1: F shar developers compose larger applications.
- 10:57Speaker 2: Right.
- 10:57Speaker 1: You don't build giant, deeply nested class hierarchies. You glue
- 11:01Speaker 1: these small declarative functions.
- 11:03Speaker 2: Together exactly like lego bricks.
- 11:05Speaker 1: The book specifically highlights two operators that C shar developers
- 11:08Speaker 1: really need to understand. The forward pipe operator, which is
- 11:12Speaker 1: a vertical bar and a greater than sign and function composition,
- 11:15Speaker 1: which is too greater than signs.
- 11:17Speaker 2: Ah. Yes, this is where the magic really happens.
- 11:20Speaker 1: I love this part.
- 11:21Speaker 2: The ford pipe operator is all about data flow. It
- 11:24Speaker 2: takes the data on the left and pushes it into
- 11:27Speaker 2: the function on the right. Okay, in C sharp, if
- 11:29Speaker 2: you want to filter a list, then square the numbers,
- 11:32Speaker 2: then sort them, you usually end up with heavily nested
- 11:35Speaker 2: method calls reading inside out or changed methods.
- 11:37Speaker 3: If you're lucky with lnq right, it gets messy.
- 11:40Speaker 2: But in F sharp, you take your data, pipe it
- 11:43Speaker 2: to the filter function, pipe the result to the square function,
- 11:46Speaker 2: and pipe that to the sort function. It reads top
- 11:49Speaker 2: to bottom, left to right exactly like a data assembly line.
- 11:52Speaker 1: And the function composition operator takes it a step further right,
- 11:56Speaker 1: because it doesn't pass data, it glues two functions together
- 12:00Speaker 1: to create an entirely new function. Yes, so you can
- 12:03Speaker 1: take a get even numbers function, compose it with a
- 12:05Speaker 1: square numbers function, and boom, you have a brand new,
- 12:08Speaker 1: perfectly testable lego break without actually writing any new logic.
- 12:12Speaker 2: And because these functions are immutable and stateless, you can
- 12:15Speaker 2: compose them with absolute confidence. You know they won't cause
- 12:19Speaker 2: bizarre side effects somewhere else in your pipeline.
- 12:21Speaker 1: Okay, this all sounds incredibly elegant, but I have a
- 12:25Speaker 1: very practical concern.
- 12:26Speaker 2: Let's hear it.
- 12:27Speaker 1: If f shark requires so much less boilerplate and you
- 12:31Speaker 1: aren't writing all those defensive unit tests to check for
- 12:33Speaker 1: state mutation, how do you actually know the code isn't broken?
- 12:38Speaker 1: Like if you drop this scaffolding, doesn't the building just
- 12:40Speaker 1: fall down?
- 12:41Speaker 2: Well, that brings us directly to the concept of the
- 12:44Speaker 2: pit of success and the sheer power of the f
- 12:46Speaker 2: shark compiler, which is known as SSC dot XE. Okay,
- 12:51Speaker 2: the compiler is doing vastly more heavy lifting than the
- 12:54Speaker 2: C sharp compiler Roslin. The type system is so incredibly
- 12:58Speaker 2: strict that it is physical difficult to compile code that
- 13:01Speaker 2: fails at runtime.
- 13:03Speaker 1: Let's talk about the biggest villain of runtime failures, the
- 13:06Speaker 1: null reference exception.
- 13:07Speaker 3: Oh. Absolutely.
- 13:08Speaker 1: Tony Horrer, who invented the null reference, famously called it
- 13:11Speaker 1: his billion dollar mistake. It's like the ghost in the machine.
- 13:14Speaker 1: Your application logic thinks and objects is there. You try
- 13:17Speaker 1: to call a method on it, and the entire app
- 13:19Speaker 1: crashes in production because the object was secretly null.
- 13:22Speaker 2: Yep, but in EKSHAV, the concept of nulls simply does
- 13:25Speaker 2: not exist for f shark types. You literally cannot assign
- 13:28Speaker 2: null to a record or a let binding.
- 13:30Speaker 1: Wait really, so how do you handle a genuine scenario
- 13:34Speaker 1: where data might be missing, like say, a user who
- 13:37Speaker 1: just hasn't provided a phone number.
- 13:38Speaker 2: So the f shark compiler forces you to use what's
- 13:41Speaker 2: called an option type.
- 13:42Speaker 1: An option type.
- 13:43Speaker 2: Right under the hood, this is a discriminated union. It's
- 13:46Speaker 2: a type that can only be one of a specific
- 13:49Speaker 2: set of cases. An option is either some containing the
- 13:52Speaker 2: data or none.
- 13:54Speaker 3: Okay, I follow, And here is.
- 13:56Speaker 2: The crucial mechanic. If a function returns an option, the
- 14:00Speaker 2: compiler forces you to use pattern matching to handle both
- 14:03Speaker 2: the sum case and the non case.
- 14:05Speaker 1: Meaning if I write the logic to extract the phone
- 14:08Speaker 1: number from the sum case, but I just completely forget
- 14:11Speaker 1: to write the logic for what happens If it's none
- 14:13Speaker 1: The code won't even compile.
- 14:14Speaker 2: It will throw a compiler error stating incomplete pattern matches.
- 14:18Speaker 2: The compiler mathematically proves that you have not handled every
- 14:21Speaker 2: possible state of your application, and it flat out refuses
- 14:24Speaker 2: to build until you do.
- 14:25Speaker 1: That is incredible, and the book highlights another brilliant example
- 14:29Speaker 1: of this strictness when it comes to domain modeling. Imagine
- 14:32Speaker 1: you have a core domain class, say a customer, and
- 14:36Speaker 1: the business decides they need to start tracking a new
- 14:38Speaker 1: piece of data like a loyalty tier.
- 14:40Speaker 2: Okay, classic scenario in C sharp.
- 14:42Speaker 1: If I add a new property to that class and
- 14:44Speaker 1: hit build, it compiles perfectly fine, right.
- 14:47Speaker 2: Even though you haven't initialized that new loyalty to your
- 14:49Speaker 2: property anywhere in your massive code base.
- 14:52Speaker 1: Exactly you deploy that code, a user accesses that uninitialized
- 14:56Speaker 1: field in some obscure branch the application, and bam, the
- 15:01Speaker 1: system throws an exception.
- 15:02Speaker 2: Yeah, and c shark. The compiler acts like a passive
- 15:05Speaker 2: aggressive colleague who sees you making a mistake, but just says, well,
- 15:08Speaker 2: they didn't ask me to check that, so I'll just
- 15:10Speaker 2: let it fail in production.
- 15:11Speaker 1: That's hilarious and so true. But if I add a
- 15:14Speaker 1: new field to a domain record in f shar, what happens?
- 15:17Speaker 2: Your project instantly breaks immediately Because SHAR records require structural initialization.
- 15:24Speaker 2: Wherever you create instances of that customer type across your
- 15:28Speaker 2: entire application, the f SHAR compiler throws an error demanding
- 15:32Speaker 2: that you explicitly provide a value for loyalty tier.
- 15:36Speaker 1: I use the analogy earlier of building a skyscraper. The
- 15:39Speaker 1: f shark compiler is basically a hyper strict structural engineer. Yes,
- 15:44Speaker 1: if you add a new load bearing pillar to the blueprint,
- 15:47Speaker 1: the engineer doesn't just nod and improve it. They halt
- 15:50Speaker 1: all construction, walk to every single floor of the building,
- 15:53Speaker 1: and force you to explicitly bolt that new pillar into
- 15:56Speaker 1: the existing framework before they let you pour into the
- 15:59Speaker 1: rounds of concrete.
- 16:00Speaker 2: That captures the workflow shift perfectly. You will absolutely spend
- 16:03Speaker 2: more time upfront arguing with the f shark compiler to
- 16:06Speaker 2: get your code.
- 16:06Speaker 3: To build, but the trade off is worth it.
- 16:09Speaker 2: Oh, it's a massive reduction in long term maintenance anxiety.
- 16:12Speaker 2: You spend your time defining business logic and the code
- 16:15Speaker 2: editor rather than spending countless hours in the debugger chasing
- 16:18Speaker 2: down run time exceptions.
- 16:19Speaker 1: Makes sense.
- 16:20Speaker 2: The book actually mentions a famous community joke. If your
- 16:23Speaker 2: f chart code compiles, there's a good chance it works.
- 16:26Speaker 1: That is wild, the idea that compilation actually equates to correctness.
- 16:31Speaker 2: It's because the compiler has forced you to handle all
- 16:33Speaker 2: those edge cases that you'd normally write unit tests for
- 16:36Speaker 2: in C sharp.
- 16:37Speaker 1: Okay, I can hear the gears turning in your head
- 16:39Speaker 1: right now. You're listening to this, sitting at your desk,
- 16:41Speaker 1: thinking this sounds amazing. I want the pit of success.
- 16:45Speaker 1: I want declarative code that doesn't null reference. But I
- 16:49Speaker 1: work in a massive corporate environment.
- 16:51Speaker 2: Right the real world.
- 16:53Speaker 1: Yeah, we have millions of lines of existing c shark
- 16:56Speaker 1: code and this vast library of nugat packages. I cannot
- 17:00Speaker 1: abandon the entire dot net ecosystem to go learn some
- 17:04Speaker 1: academic language.
- 17:05Speaker 2: And that is the massive relief of the book's final sections.
- 17:08Speaker 2: You do not have to start over. F shark is
- 17:10Speaker 2: not an isolated academic language. It runs directly on dot Net.
- 17:13Speaker 1: How does that integration actually work under the hood, like physically.
- 17:16Speaker 2: Well, it comes down to the common language runtime, the CLR.
- 17:19Speaker 2: When you compile C shard code, the rosin compiler translates
- 17:22Speaker 2: it into Microsoft Intermedia Language or MSIL. When you compile
- 17:26Speaker 2: f shard code, the FSC dotxes compiler translates it into
- 17:30Speaker 2: that exact same MSIL bytecode.
- 17:32Speaker 1: Social the computer at runtime. It's all the exact same
- 17:35Speaker 1: machine code. The JIT compiler doesn't even know if the
- 17:38Speaker 1: original text was c shap.
- 17:40Speaker 2: Or fshav exactly, and because they compile down to the
- 17:44Speaker 2: same bytecode, the interoperability is completely seamless. Virtually every type
- 17:48Speaker 2: you use in the base class library with c shap
- 17:51Speaker 2: is directly accessible in f sharp.
- 17:52Speaker 1: That's a game changer, it is.
- 17:54Speaker 2: You can pull down packages from nugat. You can write
- 17:56Speaker 2: a new data processing engine in fshar, compile it into
- 17:58Speaker 2: a DLL, and then reference it from your legacy c
- 18:01Speaker 2: shark web application. Your c shark code just sees it
- 18:04Speaker 2: as a standard dot Net library.
- 18:06Speaker 1: So for developer wanting to try this out today, they
- 18:08Speaker 1: don't have to download some obscure command line only toolchain.
- 18:12Speaker 1: They can just use visual studio.
- 18:14Speaker 2: S shapp has been a first class citizen in Visual
- 18:16Speaker 2: Studio out of the box since twenty ten. You can
- 18:18Speaker 2: create console applications, class libraries, or web APIs right from
- 18:22Speaker 2: the standard file New project menu.
- 18:24Speaker 1: But the author does give a few specific tips for
- 18:27Speaker 1: optimizing Visual Studio for x shap right because, as we mentioned,
- 18:30Speaker 1: the language relies heavily on white space instead of curly braces.
- 18:34Speaker 2: Yes. Specifically, if you are on an older version like
- 18:38Speaker 2: Visual Studio twenty fifteen, you must go into your text
- 18:41Speaker 2: editor options and ensure insert spaces is turned on. Mixing
- 18:45Speaker 2: tabs and spaces in a white space significant language will
- 18:48Speaker 2: cause massive compilation headaches.
- 18:50Speaker 1: Tabs versus spaces the eternal war finally settled by the
- 18:54Speaker 1: FSHR compiler. Right.
- 18:56Speaker 2: The book also strongly recommends installing an extension all the
- 19:00Speaker 2: Visual f Sharp Power Tools or VFPT.
- 19:04Speaker 1: What does that do well?
- 19:05Speaker 2: Because you aren't explicitly typing out your types, having proper
- 19:08Speaker 2: syntax highlighting, tooltips and refactoring tools is crucial for navigating
- 19:12Speaker 2: large codebases. The power tools provide code formatting, folder organization,
- 19:17Speaker 2: and a linting tool that gives you best practice tips
- 19:19Speaker 2: on writing idiomatic F sharp right there in the editor.
- 19:22Speaker 1: It sounds like the ultimate trojan horse. Yeah, you can
- 19:24Speaker 1: slowly introduce shar into an existing corporate architecture, maybe start
- 19:27Speaker 1: with a small test project or a specific micro service,
- 19:30Speaker 1: all without disrupting your overarching dot net infrastructure.
- 19:34Speaker 2: Exactly, you have the full power and safety of the
- 19:36Speaker 2: Microsoft ecosystem, but you get to write in this highly expressive,
- 19:41Speaker 2: mathematically sound language. However, the author ends with a very
- 19:45Speaker 2: serious warning about the mental transition.
- 19:47Speaker 1: Oh what's the trap?
- 19:50Speaker 2: The biggest challenge isn't learning the f chef syntax. The
- 19:53Speaker 2: biggest challenge is unlearning the dogma of object oriented methodology.
- 19:58Speaker 2: On learning the dogma, Yeah, things like for loops, mutable,
- 20:02Speaker 2: state heavy, class inheritance. They are so deeply ingrained in
- 20:07Speaker 2: how we are taught to solve problems that C sharp
- 20:09Speaker 2: developers instinctively try to recreate them in f shop.
- 20:12Speaker 1: So you start writing c shark code using f shop syntax,
- 20:15Speaker 1: which totally defeats the entire purpose.
- 20:18Speaker 2: Exactly. You can write mutable, class heavy f shart code,
- 20:21Speaker 2: but it will feel unnatural, it will be clunky, and
- 20:24Speaker 2: you will miss out on every single benefit we've discussed today.
- 20:27Speaker 1: So you really have to let go.
- 20:28Speaker 2: You have to approach it with a clean slate. You
- 20:30Speaker 2: have to trust that modeling your domain with immutable records
- 20:32Speaker 2: and pure functions is just a fundamentally different and often
- 20:35Speaker 2: simpler way to build software.
- 20:37Speaker 1: Well, let's summarize this journey. We started with the realization
- 20:40Speaker 1: that the exhausting rigor of traditional object oriented design patterns
- 20:44Speaker 1: isn't necessarily a badge of honor, right. It's often just
- 20:47Speaker 1: a defensive reaction to a language that makes it easy
- 20:50Speaker 1: to make state mutation mistakes.
- 20:52Speaker 3: Exactly, we explored.
- 20:53Speaker 1: How fshar shifts the paradigm to functional first, using idiomatic
- 20:57Speaker 1: defaults to make immutability and expressions the path of least resistance.
- 21:03Speaker 1: We dove into how it's clean declarative syntax focuses on
- 21:06Speaker 1: the what instead of the how, using type inference to
- 21:09Speaker 1: keep code readable. And we saw how the strict ftart
- 21:11Speaker 1: compiler acts as this unyielding structural engineer, using tools like
- 21:15Speaker 1: the option type to force you to handle edge cases
- 21:19Speaker 1: ensure you fall into the pit of success before your
- 21:21Speaker 1: code ever reaches runtime. Beautifully summarized, and finally we saw
- 21:25Speaker 1: that all of this is seamlessly integrated into the existing
- 21:27Speaker 1: dot net and visual studio ecosystem you already know.
- 21:30Speaker 2: Honestly, shot isn't just a new syntax. It's a way
- 21:33Speaker 2: to genuinely elevate your standard of software quality while actually
- 21:36Speaker 2: enjoying the process of writing code again. And you know,
- 21:39Speaker 2: if we connect us to the bigger picture, it leaves
- 21:41Speaker 2: us with a truly fascinating question to consider.
- 21:44Speaker 1: Ooh, I love a good lingering thought. Let's hear it.
- 21:47Speaker 2: We've just spent this entire session discussing how the strict rules, constraints,
- 21:52Speaker 2: and default behaviors of a syntactical environment can fundamentally rewire
- 21:56Speaker 2: how a developer approaches logical problem solving.
- 22:00Speaker 1: By changing the tools, you literally change the way the
- 22:03Speaker 1: brain structures a solution.
- 22:05Speaker 2: So this raises an important question. If a programming language
- 22:08Speaker 2: can do that, how might immersing yourself in a radically
- 22:11Speaker 2: different system of thought, even one you never plan to
- 22:14Speaker 2: use in production or even outside of software engineering entirely,
- 22:17Speaker 2: how might that permanently alter how you approach complex decisions
- 22:21Speaker 2: and problem solving in your own life or career.
- 22:23Speaker 1: Wow, that is a brilliant thought to end on, because
- 22:26Speaker 1: sometimes the restrictive scaffolding we rely on isn't just in
- 22:30Speaker 1: our code, it's in the way we view the world,
- 22:33Speaker 1: and occasionally you just need to step into a completely
- 22:35Speaker 1: different paradigm to realize a stronger, simpler structure was possible
- 22:39Speaker 1: all along. Thank you so much for joining us on
- 22:41Speaker 1: this deep dive into s shard. We hope this exploration
- 22:44Speaker 1: at to functional first thinking gives you a new perspective
- 22:46Speaker 1: to apply to your own projects. Keep questioning your defaults
- 22:49Speaker 1: and we'll catch you on the next deep dive.