Introduction to Topics and Guest
00:00:00
Speaker
Welcome to the Codeplay Culture podcast where we discuss tech, gaming, health, and the world around us. Welcome back to Codeplay Culture podcast. Rui Logan back at it again. Today we have a new friend joining us. Dan, welcome. How are you today? I'm doing good, doing good. How about yourself?
00:00:23
Speaker
Very good. Dan is joining us as an application developer to talk about all things F-sharp if we can stay on topic.
F-sharp vs. C-sharp: Features and Functionalities
00:00:34
Speaker
I personally have no experience with or very little experience with F-sharp. As we've been working together and coding periodically, just learning about how
00:00:48
Speaker
all the new C-sharp features, like F-sharp had it, had it first. It's a little bit more, and even discriminated unions was more easy
00:01:00
Speaker
or easier in F sharp when they brought it to C sharp. It's like certain things just work better from a functional perspective. And a lot of the C sharp things are going that way with the new switch expressions and all of that stuff. So first off, like how did you fall into getting like a deep wealth of knowledge on F sharp?
Dan's Journey into F-sharp
00:01:23
Speaker
That really started just as a personal side project. It's kind of the things where you're
00:01:29
Speaker
You're driving along and you see this thing under the corner of your eye in technology and you're just like, oh, what is that? That kind of interests me and, you know, what's this thing all about? I think it started with the, you know, functional programming in general.
00:01:47
Speaker
there's a lot of similarities between, uh, it and, um, you know, just the way you think about making your compiler and I was kind of good at that stuff and, and, and school and things like that. And a lot of other things that they were touting kind of hit home. Um, so I just kind of explored it and it was kind of like, I don't know this, let me just learn it as, as a thing. It's kind of like just set myself a challenge. Um, that was kind of the goal.
00:02:17
Speaker
There was like other ones from Microsoft that fell by the way words. I'm not lumping F-sharp into that. Obviously it didn't, but there was like J-sharp. This was all back in like 2002, Iron Ruby, Iron Python, like all of them were just like, hey, we
00:02:38
Speaker
This one was supposed to be OCaml, which is a functional language, but in .NET. How can we apply this language to .NET?
Influence of F-sharp on C-sharp
00:02:49
Speaker
I think it's good for the space because it makes the
00:02:53
Speaker
Um, not the C-sharp languages developers really think about things, but it can go down like a different, a lower level into IL. Um, cause I think if Don Sime didn't work on F-sharp in those things, you wouldn't have generics in.
00:03:09
Speaker
in C-sharp. Some really .NET 1.1 and 2.0 things, those foundational pieces, you wouldn't really see or they would have a really different effect because forcing you into the different paradigm makes you think of different programming in a different way and you'll have different underlying structures that are available and stuff like that.
Language Preferences: F-sharp, C-sharp, Kotlin
00:03:36
Speaker
the tunnel vision limited foot. You don't know what else is out there. How could you say that you love? I would slurp the soda of a C sharp shake from some shifty shyster in a heartbeat. But if you're not actively trying out different languages, how do you compare and contrast and take the best of those worlds and apply it? I heard that
00:04:02
Speaker
I think it's called Kotlin, which is like that newer Android instead of Java, it's whatever. But apparently C-sharp developers, like Nick Chapsis on his channel, he said that, hey, to forget the guy's name, but if you like C-sharp, you definitely like Kotlin. But yeah, like Ru, you have a lot of this, like different languages and when you like. Yeah, absolutely. I've dabbled in many different languages. I like to dip my toes in
00:04:31
Speaker
in many different pools, so to speak. On that note, what was the purpose of, I have a question, what was the purpose of JSharp? Was that some kind of failed experiment like mimicking Java? Is that what that was?
00:04:49
Speaker
say before my time. Um, I, I saw the book in chapters as like J sharp for dummies, but like that's the book I didn't open. Um, so J sharp is, is for dummies or is that, I'm just kidding. It's like trying to make a pun, but it didn't work.
00:05:04
Speaker
There was a Dummies book I had in my office one time. It was just on my shelf. And it was back when you had to go in to work. So there was a manager that he really thought I was, him and I are still friends. He's like, hey, Logan, you got to turn that book around. I just glanced by your office. Right above your head, it says,
00:05:25
Speaker
Microsoft access for dummies, right? I had an arrow pointing down. Yeah. And then like some like floating emoji arrows, like pointing is like, how are those things like floating? Right? So, um, uh, do you think that F sharp, sorry, F sharp.
00:05:40
Speaker
a J-sharp became C-sharp because
F-sharp's Typing and Design Principles
00:05:43
Speaker
the Java, they ripped off Java a bit, right? There was that kind of need to make a Java. That's why .NET exists, right? It's because they were trying to latch on to like, okay, Java is really popular. Let's do it at Microsoft. Can we switch our Visual Basic guys into a different Microsoft thing that's a little bit newer or whatever? Let's get off the D6.
00:06:08
Speaker
Yeah. Well, they did it better. That's for sure. They did it much better. Yeah. It's just a personal opinion, but people love Java, right? But it does. You did raise a good point, Marie. It's kind of the thing where it's it's kind of like a disease where I was C sharp for a good portion of my career, like learn a couple of things in school, but, you know, land on dot net and kind of stuck there. But once I learned F sharp,
00:06:39
Speaker
There were so many other languages and patterns and practices that you start dipping your toe in and you find out these things that exist out there. And so like continual learning and stuff like that. It's like, um, was I ever going to look at Haskell and like category theory and all this math stuff? I don't understand any of it, but like I can dip my toes and like know these things exist. Um, right.
00:07:07
Speaker
Yeah, it's kind of like you're sheltered from the world because it's really uncomfortable. But once you actually realize that these things exist, yeah, learning all these different languages or at least different communities exist and different ways of thinking. Right. And I think that's kind of what opened my eyes up when I started learning F sharp is just like,
00:07:28
Speaker
I now think differently and can think differently about different patterns and practices and development techniques. F sharp has really, because of the strict discriminated unions, they have a really, really good grasp on domain driven design, such to the fact that
00:07:56
Speaker
It's not a thing where you need to go and I forget the guy's name, but like the guy who wrote the book on domain driven design, um, I'm not reading his book because it's just so ingrained into the language. I don't need to go, you know, uh, do that, that piece kind of thing. Um, that'd be a better book for like vb.net developers or something like that because it's not so baked into like,
00:08:20
Speaker
It's ingrained into the way you feel about the language and interact with the language that it just becomes second nature kind of thing. So like the first thing an F sharp developer will do will be they'll write out their domain and what are their, what does their program do? What is the core things and core that just start describing the things or they'll describe their API is like, what is your API? Well, it's a get request that accepts this parameter, this parameter, and you get out this thing and you have your,
00:08:49
Speaker
your domain of whatever it is that you're working at. The one thing that blew my mind was when you said that essentially it's like a strongly typed or more strongly typed Python, where if you don't want to use Python, you could just use F-sharp. Python synonymously to F-sharp is JavaScript to C-sharp or TypeScript.
00:09:18
Speaker
Is it a direct replacement? Let's say I'm a .NET developer and I live in a bubble and I don't want anything else other than .NET to enter my love life, would I do F sharp instead of Python?
00:09:33
Speaker
Actually, there is a really good presentation done by one of the former head F-sharp guys at Microsoft, Philip Carter. He was like, we've got to stop doing F-sharp is a better C-sharp. We're never going to convert the two orders of magnitude of developers to convert over F-sharp. But it's more like, friends don't let friends learn Python.
00:10:04
Speaker
It's like the JavaScript recovery class where like, hey everybody, I do JavaScript. My name is Logan. Hi Logan. You know, it's like I got my blue chip.
00:10:13
Speaker
I'm not trying to dunk on Python developers. It's a good language and you get a lot of worth from just the sheer volume of community. But as a .NET developer, type safety is one of those things that probably you've latched onto and it's your safety net. If I have these classes here and I design it this way and these are protected and these are public, if it compiles,
00:10:43
Speaker
I run it once and I might have to do a couple things in debugging and stuff like that, but generally my type safety will solve me this thing.
The Advantages of Type Safety in F-sharp
00:10:53
Speaker
I'm programming in F sharp, it's the same thing.
00:10:57
Speaker
If it compiles, it works in F sharp is like the little tagline for F sharp because it's just the way you're defining your domain. And also the funny thing is you also have heavy type inference. So not only do you have the type safety, like this is a string, you're only working in strings, you're not trying to switch strings to int, you got to be explicit. You also have the type inference where you don't have to write out the types anywhere.
00:11:27
Speaker
Like you don't have to write out, this is a string. This is an IE numeral bowl of an eye dictionary of a whatever. You just say, this is my variable. Like there's like, like a bar in C sharp kind of thing. Um, it's gonna, um, because of the strong typing system, um, it is able to figure out based on how you're using it, what the thing actually is. So if your method is generic,
00:11:52
Speaker
it's going to say it's generic. If your method is using specifically these things, it's going to work that way. Nice, like a variant. Exactly, exactly. No, it has its restrictions, though, to get those benefits. That's the thing I'm saying.
00:12:10
Speaker
So I've never programmed in it, and I haven't looked at some code in F-sharp in a while, but just thinking about it, is it just methods that return something? Is that all it is? When they say functional, what does that mean? Good topic. Okay, so C-sharp is a statement-based language. You hit that semicolon, that's your statement.
00:12:36
Speaker
F sharp. There is no semicolon, for one thing. It's like really, you did a new line. Did you need to do the semicolon and a new line? So it is tab sensitive like Python, but honestly, that's not a problem. It's only a problem for people who think it's a problem.
00:12:59
Speaker
Agreed. If you did a Venn diagram of the actual times and it actually is a problem, you find out it's very miniscule. Yeah. I'm sorry, what was I saying? Yeah, so it was like C sharp is a statement-based language. C sharp is a statement-based language. F sharp is an expression-based language.
00:13:25
Speaker
So which means if you type in one plus one, semicolon in C sharp, it's going to give you a compile error. If you type in one plus one in F sharp, it's going to give you the value two. If you write an if statement, if this is true, then five else, this is false and five, you can store that if statement into a variable just like absolutely everything is an expression.
00:13:52
Speaker
So the newer style of C-sharp for switch expressions could be like if everything's like that because it'll store back to a variable. Exactly. You always have to store it back into a variable. If you want to ignore something, you got to be explicit to ignore something. When you do it in that pattern, basically, you try and chain everything together,
00:14:18
Speaker
much like back in the Unix days where you were doing pipes in between. You pipe it from this thing into something else into the third thing. That is why the pipe symbol has been starting to explore out into different languages as well from F-sharp because it's a good way to program. That's like your fluent API where you would say dot
00:14:48
Speaker
then order by, or then it's like your chaining, like your fluent API chaining is the pipe. So you would say like one plus one pipe, two, and then that would return true.
00:15:11
Speaker
It's really good for data processing because the way you have to write it is the way you usually think. If you look at standard C sharp or JavaScript like code, it's always read from the inside out.
00:15:27
Speaker
you do five, and then you wrap it around two string, and then you wrap it around two upper, and then you wrap that around thing. But when you're actually trying to read it, you're trying to, okay, what is the thing on the inside that I'm trying to read? Then I keep on chaining out and out and out, and then the final step is the big statement. So the one plus one pipe A would assign the number two to the variable A?
00:15:57
Speaker
Something like that. It's kind of like. We're trying to figure out coding problems.
Benefits of Expression-based Programming
00:16:02
Speaker
Exactly. It's like some of this stuff. If we do it a presentation, I would actually like show things on the screen of actually writing these things out. But it's basically like you think your data manipulation steps all in a pipeline kind of thing. Cause you're like, okay, I have this array.
00:16:21
Speaker
and then I want to convert, step two, I want to convert the array and do some validation on it. Step three, I want to take those array values after doing that and then step three is like insert into the database and then notify the user by sending them an email and then I want to return a success to the screen.
00:16:43
Speaker
So the way you write in F sharp is literally like step one, pipe to step two, pipe to step three, pipe to step four. You can actually read it on the screen is just from top to bottom. This is what it's doing. If you did the same thing with C sharp or Java, you'd be like,
00:17:02
Speaker
Okay. The raise in the middle or in the center. And then I wrap that around the validation. And then I wrap it around with, I think it's why the builder pattern feels great because you're just like, Oh, like I don't have to figure out which happens first. It's just like, whatever read it top down, top to bottom. Um, and you're good to go.
00:17:25
Speaker
I think it's still like, uh, can you break up those different sections or I might be thinking about it in a C sharp mentality, but like, is it like, and we should probably should like stop ourselves from talking about something visually.
00:17:39
Speaker
like would just like go and look at it at the end of the day, go and look at it or whatever. But like in between the different pipes, like are those different methods or that just one statement or everything is a function. Um, if in F sharp, everything is a function. Um, you have an input and you have an output. Um, funnily enough, everything is also a one parameter function.
00:18:03
Speaker
And they will do little tricks to go and extend those things out. It's kind of almost like they've proven it exactly the same as dependency injection. It's like dependency injection for every single function that you have. And it's just baked into the language kind of thing.
00:18:24
Speaker
Even if you execute the statement on the database has seven parameters, you can start to build out little functions that just go, okay, the connection string is the same. My configured connection string for production equals connecting to the database with the production connection information.
00:18:49
Speaker
And then you just kind of build things on there. It's like, yeah. I do like how you can read, like if you can mimic how humans read with like a fluent API or something where you said like in C sharp, you would just use obviously static extension methods with like the this keyword, and then you just chain. So you're like, you know, var, I don't know, some variable.
00:19:15
Speaker
and then you do dot then to string, then to database, then you just keep on chaining these dot. I remember an MVC dotnet core before they went away from that and now everything's blazer. Web forums, everything became blazer is like you would have in
00:19:37
Speaker
.NET Core MVC, like when you're writing in views, this big long dot like fluent API, all the way is like this huge block of code that's just all chained with fluent like dot expressions. It's very synonymous to the piping. I'll make it really simple for you. If you like programming in the link, take a look at it.
00:20:03
Speaker
because the core of Link is functional programming. The core building blocks of Link, like Eric Merger and a couple of them, they're big Haskell buffs, big functional programming people. They put it in .NET many ages ago and just hit it away as like, oh, it's a new style of thing where it's functional programming at its core.
00:20:31
Speaker
you get the inherent like, yeah, select star from database where this and order by and they all happen in steps and they all read from top to bottom. And then it's kind of the thing where you're like, um, what if I could do that same thing, but with my own coat, um, is that, that level of power and feeling of just being able to, you know, go through your code like that is, uh, is really powerful.
00:21:01
Speaker
Yeah. Link is a good example for people that if they like Link, then go to try F sharp. I haven't done too much of that stuff where you can actually have this and then a funk of T or something, and you can actually start
00:21:23
Speaker
Lambda, get into Lambda hell where you can actually start chaining different lambdas like not EF core style of, you know, expression tree builders and stuff like that. Some of that stuff's like pretty
00:21:34
Speaker
One guy on an EF Core stand-up where they got the whole state of the unicorn thing, he was showing how you can do tenant IDs that are in Entity Framework Core. It's like a query in EF Core that's precompiled, but then it's like a precompiled expression tree.
00:22:02
Speaker
but every time you call to this table, it automatically appends global query filters. So he built out this thing that appends tenant IDs, global query filters, and it's one thing he said on the pod. He's like, here's the expression tree builder for the tenant. And he's like, I know when you look at it, no one can understand it, but it works very well. No, it's good.
00:22:28
Speaker
You kind of touched on why link is powerful. It's because it's an expression tree. Oh, it's expressions. So if you have an expression-based language, then your whole thing kind of flows like that. It does come from a couple other languages, like Haskell, where everything is lazily evaluated.
00:22:51
Speaker
where a good pattern is basically you describe what your program is supposed to do with your workflow. And then you wrap that around with one thing that's going to be the context for how that feels kind of thing. So like you'll describe your async workflow and all the steps that are going to be performed. And then you wait until the last step before you go, okay, now run the async thing.
00:23:18
Speaker
Up until then, it's just basically an expression tree of the things that you're going to try and perform. Nothing actually happens until you do that last statement of make it real kind of thing. Have you ever used the type lazy of T?
00:23:35
Speaker
Yeah, I just I just I've never used it. I just kind of want to use it. I just but I I can't I can't actually. This is not a dad joke like coming in or whatever, but I just I haven't gotten around to like trying out to use lazy of tea. I'm like and like I'll research lazy of tea, but I'm like I'll do it some other time. It's not like an inherent joke, but like where would you use like? Because you said F sharp is very like the expression tree is like lazily that kind of stuff like we're.
00:24:06
Speaker
Because is it with the, how does it work? Is it at build or at, do you get runtime errors or you won't get build errors if it's like expression trees? Well, that's the thing.
Interactive Coding in F-sharp
00:24:20
Speaker
You basically, programming in F sharp is very interesting because
00:24:26
Speaker
Remember C-sharp interactive, it's probably something that you haven't used quite enough. They added that a couple of years ago because F-sharp has it and it feels okay in C-sharp. There's a couple of things that it doesn't really do very well because in F-sharp basically,
00:24:50
Speaker
The way you're developing, you're trying to develop in chunks and bite-sized pieces, much like Python. Python is the same thing with their redevelopment loop, their interactive session. You write a section of code, you test it right away, and you kind of interact with it as you're playing around with it. OK, it works. I'll go on. Because it's an expression-based language, you just kind of get the results in the little window at the bottom.
00:25:20
Speaker
You're not trying to manage an object with state and stuff like that. You're just like, run a function. Look, here's some input to a function. Go look at the output. And it's very easy, quick cycles for going in, testing something out, seeing if it works, and then running it.
00:25:42
Speaker
Again, like this is something that we had live demos and stuff like that. You can just see the different flow that people go through as they're trying to build out stuff. It's a whole like hot reload, reducing the amount of cycles for developers to go through.
00:25:58
Speaker
whatever the inner loop for the development loop, you do want to have that as tight as possible because it should only be the developer that's trying to think that slowing it down, or not slowing it down, but you want your hardware to work for you, not against you. Have you seen a big solution, .NET solution, bunch of C-sharp, whatever, functions, all the stuff, and then a project inside there that's F-sharp?
00:26:25
Speaker
and what does it use for, is it? Yes. Can you mix both languages in a single project? It is all .NET. Yes. It compiles to CLR, which compiles down to IL. Exactly. It is all .NET. You can take F sharp. You can take F sharp.
00:26:45
Speaker
and decompile it in C-sharp to see what they're doing. What you'll notice is 15 lines of code in F-sharp will be about 800 lines of code in C-sharp. That's a lot of bytes too.
00:27:03
Speaker
Like functional programming, because of this style, it is, you got to double check what you're doing. They do have, I don't even remember from school, like tailor recursion and stuff like that. Like, so it won't like create stacks and it will just like automatically go in. So you won't get that bloat of like actual recursion. Yeah.
00:27:27
Speaker
But there are a lot of defaults in the language and it's basically, that's the way the language was designed was just like sensible defaults. So if you follow the sensible defaults, you try and fall into like to pit of success. So like everything is immutable by default.
00:27:48
Speaker
Okay. My VPN is conking out here. Everything is immutable by default. And what that does is it basically makes it so that everything works with asynchronous really effectively right out of the box. And you don't have to worry about somebody changing your state as you're, you know, enumerating through a list kind of thing.
00:28:13
Speaker
So you get all that performance benefit too with immutable objects, because you're not dealing with stack versus heap versus whatever. You just destroy and create a new object based on the other object. So probably records as a concept minus the syntactic sugar was an F-sharp thing maybe kind of first.
00:28:36
Speaker
20 years ago, yeah, it's like one of the first things, because that's how it's just like, I have some core data structures, they're immutable, you can't change them, you can only create them. There's good things where just like, it feels good to go and modify them and play around with them. And there's some hidden pattern, like functional patterns that
00:29:01
Speaker
like lenses and stuff like that of if you actually went down into like the math of it and and that stuff it's like oh what am I doing in all these other programming languages of like setting individual properties when it's just like there are some core fundamental things in programming but it's like it's not Alan Turing it's
00:29:24
Speaker
Alfonso Church or whatever. It's like, it's the different camp. They had a fight back in the fifties about which one was better. And it turns out they're both right. That's the weird thing. Yeah. Sensible defaults in the language to make things so that you don't shoot up nulls.
The Advantage of No Nulls in F-sharp
00:29:43
Speaker
Here's another one. Nulls. You guys ever have to work with nulls? Yeah. Yeah. We, we, we bane of our existence of like, yeah.
00:29:53
Speaker
billion dollar problem, right? F sharp? No nulls whatsoever. I love that. I mean, I got to get on this F sharp stuff because like I've had the C sharp stuff like going to me via IV and I've just been completely
00:30:10
Speaker
cloak over the eyes kind of thing. No nulls in F sharp. The only time you have to worry about it is when you have to deal with C sharp developers or C sharp coming into it. When you have to walk over the other side, that's when you have to deal with it and make it feel better for the other side and pay attention to these things. This must be one of the few programming languages that have no nulls because
00:30:38
Speaker
As far as I know, they all have nulls, right? And it's the problem that only shows up in runtime, right? You're not really going to see it. That's the other thing. You probably enjoy with the switch expressions where they do the exhaustive-ish matching, like, hey, you missed one. Yes.
00:31:03
Speaker
In F-sharp, because you're usually creating your own discriminated unions, you'll say payment method. Payment method will be we accept money, we accept credit cards, and we accept these things. And Ethereum, and small bits of string. Exactly. We only accept these three.
00:31:25
Speaker
you create this domain in your FSHOP program and then everywhere else, it will tell you all of the places that you, oh, you added in a new payment method and it will light up everywhere that you missed the thing because you're creating your own domain. So it's like you go through, you fix all your warnings and you're good to go kind of thing. It will tell you all the places that you're not hitting all the cases that you possibly could be.
00:31:52
Speaker
So you probably get a more bulletproof, less buggy application because of that, right? Exactly. Obviously no nulls. I mean, I'm like very pro no null, like to the point where, you know, back, you could be pretty badly, you'd be like, you know what, from this controller, I'm going to return nulls. I'm going to return exceptions. I'm going to return, you know, maybe an empty list, or I'm going to return the list that's populated.
00:32:20
Speaker
the point where I'm like, no, I'm just gonna.
00:32:23
Speaker
try catch and return default. At the end of the day, I don't want someone using this function to null check it. You're going to get something reliable if whatever. Nulls are like if you don't check them correctly, so many times people check if the list is, if the count, list.count is whatever, but then they'll get a null error exception because they didn't check if it's null first.
00:32:53
Speaker
So like, so many different objects, you have to check nullability differently. It's like, if you have a language from the ground up that doesn't have, like, if it has no nullability, then it's all for the better. Sorry, my cat just got shaved, so he's like demanding warmth. And like, I'm like trying to get him to, you know, go away in the nicest possible way. But I'm like, at the end of the day, just, you know, stay warm, another,
00:33:21
Speaker
We have to put heating pads on because they've become these pretentious prima donnas where they're like, I cannot regulate my own body temperature without a heating pad. I'm like, maybe I shouldn't have bought that cat backpack. You know what I mean? But yeah, I hate nulls.
00:33:44
Speaker
So exceptions are the other thing. So this is more of a style of programming thing in F sharp. So it's kind of like you're designing an API. You're designing how people are going to interact with your code.
00:34:00
Speaker
And you've probably done the thing in C sharp where it's like, okay, I have to make a decision. Do I return a negative one? Do I return a null? Do I throw an exception or do I do something else? Because of the advent of like discriminated unions in F sharp and just being that's how you describe what your domain is. Discriminated unions really are just enumerations that can have data with them.
00:34:31
Speaker
So they're just enums, but it's like a credit card with a credit card number associated with it. These are my three cases of all the payment methods that I accept. This one has a little bit of data associated with it. This one has a little bit of data associated with it. And it works with all the pattern matching.
00:34:49
Speaker
So for those things, it's kind of like, would you rather a method or function throw an exception, or would you rather it return you a successful result, a validation result, or an error result? And the guy who receives this, he's just like, oh, I call the function.
00:35:12
Speaker
it returns me three cases, I just have to execute those three cases. If you go down the exception route, it's just like, oh, I have to know that this guy throws an exception, and maybe I'll handle it, but maybe there's argument null exception, or divide by zero exception, or a random exception that I'm not expecting, because it's in some sort of like core.net library that I didn't like propagate up or handle,
00:35:42
Speaker
Exceptions feel bad sometimes because it always bubbles up three levels higher than you actually intended it to. Then you have the yellow screen and ASP.NET or Blazor, and your whole application failed. In Blazor, they have this thing that they haven't promoted since they came out with it in .NET 6 or 7,
00:36:09
Speaker
it's some block of code that a component that they cherry-picked from all the different spa frameworks, but it's some exception handler component, and then it'll show two different UIs, one if there's an exception, one if there's not, but I'm thinking more on a human psychology level, if you're going into an application and you see a bunch of errors, you're going to be like,
00:36:38
Speaker
This application is buggy as hell, but you know what I mean? There's a whole thing of like, do you actually bubble it up? Sometimes people are like, if development show the whole stack trace, if production continue. Because you don't want to damage credibility of like, look at all these bugs, right? Even the word bugs are like negative connotations. Why does your application have bugs?
00:37:02
Speaker
Like it's so buggy. Why are you fixing bugs? Should it not have bugs? I'm like, like that kind of stuff. But the exception handling in C sharp specifically also has a lot of resources assigned to those exceptions are not very performant to throw. Yeah, no. And.
00:37:22
Speaker
Yeah, exactly. It breaks the stack. You have the bubbling problem. You also have the human element of developers who don't want to do the thing and they'll just wait until like, oh, I'll just make sure that I have a global exception handler. And that global exception handler will handle everything.
00:37:41
Speaker
That way I don't have to handle this specific error. When it's this case, like, no, you're processing a credit card, like handle the error here in the business side of it, so that you actually can, you know, do your retries or, you know, do the things. I'm saying these are the only three things. It can either work, it didn't work, or there's a validation measure. Like these are the three things. Like these are the only options coming out of this function. There's no other cases that you have to handle.
00:38:10
Speaker
Yeah, I do like the reliability of that. I'm like, you know what? At the end of the day, you're going to get back these three things, you know? And if you're not, there's no way, like unless the service is down, but at that point if like, whatever, we don't have to talk about that, but like the whole credit card thing of like this is atomic, you know, like Azure SQL ledger of like.
00:38:31
Speaker
No, there was something written there. Everyone agrees. The ledger has been validated. It's like a blockchainable ledger of reliability, right? Like that whole thing of like, you just want to call something and get something and never worry if it's...
00:38:48
Speaker
you know, been mutated and it's always not null and all that stuff. It's like reliability is really important with functions and all that stuff. People develop this trust over time when like, no, it'll, it'll happen. It went into some kind of queue or, you know, whatever it's there, whether it be processed or not. You know, how's the memory management in F sharp compared to like, say C sharp is it operate the same way?
00:39:17
Speaker
It's all the same. It is only the patterns that you're using when you're programming. FSharp is functional by default, which means that you can use classes, you can define classes, you can do procedural programming if you really want to. It's basically going to be the times that you need to care about it are
00:39:46
Speaker
going to be the times that you would actually spend time to look at the data structures that you need to work on the thing and do a thing. If you have an array of 100 items, are you going to care that it takes 100 picoseconds versus 110 picoseconds?
00:40:02
Speaker
No, but if you have like a billion items, you're probably going to have, you know, seven, eight engineers around a table and figuring out the minutia of the thing. If you just have that like a hundred items, then you're just going to write it in the easiest way it's going to be to debug the statement kind of thing. Yeah. Sorry. You're getting back to that one thing we didn't loop on is the same project.
00:40:29
Speaker
and you mentioned that you added one in. What was it for? Testing? Was it for a Python level? This is perfect. Perfect segue. F-sharp has something called type providers. It's like the code generators in C-sharp, just with a different flavor. At their core, they generate code.
00:40:56
Speaker
And they generate compiled codes. So they actually generate things that the compiler will do. You can do anything with type providers. They're really amazing. The best use of type providers that I've seen for code generation are the ones that I use to make myself look really good at work.
00:41:16
Speaker
So you can point a type provider at a Excel document, a piece of data, a database, some sort of metadata, and it will generate a class based on that metadata.
F-sharp's Type Providers and Data Conversion
00:41:33
Speaker
I have a type provider that I did for database conversion. And this is one of the primary uses I would always use F sharp, where they gave me a set of data that they needed to do data migration from one system to another. And we don't have any ETL stuff, extract, transfer, load stuff here installed or things that we can use. So the only thing was the data is small enough, just create a script for it or whatever.
00:42:03
Speaker
So F sharp, you point the type provider at the CSV, the JSON file, the whatever, and it's just like a one-liner in your project. And then you go and load the data and it will give you a class that looks exactly like your JSON, a class that looks exactly like your CSV or your Excel document that you have or your database table.
00:42:30
Speaker
and it will pull back the things of like, oh, we looked at the first 100 rows of your sample. This column is a date time. This column is a string. This column has missing values in it, so it's an optional string or a nullable string. Then you go and program with it and you're like, oh, go insert it into this table. You have another type provider pointed at the database.
00:42:59
Speaker
The database will come back and look at the metadata of the database and say, oh, this column is not nullable. These two types don't match up. You're trying to put a not nullable thing and a nullable thing does something in the database that's not nullable. You're going to have to handle that and gives you like a red error message in your database. So I was working through the sample
00:43:27
Speaker
of 100 records or whatever, and it was time to do the real thing where you have 100,000 items or whatever. It is time. It is time. From Lion King, it is time. And then you actually have to hit prod and do this whole like, okay, here we go. Right? Okay.
00:43:47
Speaker
You put in the live sample into the type provider. It goes back. It regenerates your class structure and whatever from the sample. This is all while you're compiling. So if you replace the file on your thing, or you might have a version one to version two sample for your JSON, you're targeting a different piece of the API. And all of a sudden, the compiler lights up things where it's like, oh, I know for the first 100 records in your original sample,
00:44:16
Speaker
Like the middle name was all filled out But guess what for like a couple of random samples in the middle where you had some bad data Guess what your entire name is optional here so it's highlighting your compiler that you have like issues with your data because now instead of like
00:44:36
Speaker
Um, this should have been a date time, but somebody decided to put a string in here and then an integer in here and the columns all get shifted. It highlights in your, um, compiler that like, Hey, there's an issue with your data. Your, your data doesn't match how you're trying to use it kind of thing. This is no longer a string. Yeah. There's no longer an integer. There's some string values in here.
00:44:58
Speaker
So if you were tasked to provide some integrations between, let's say your ultimate destination is whatever database vendor, and you wanted to program a bunch of integrations, Oracle, Postgres, JSON, any kind of open AI, I don't know,
00:45:20
Speaker
any flavor of data in like SSIS style, would you do what you did in F sharp, like kind of make this ETL data integration package? For this weird one, yes. Because not only did they switch up or have like injected bad data, they switched database providers midway through.
00:45:45
Speaker
And when they did that, it was like, oh, this column was an integer in this one, but it's a byte in this one. That does bite. So that's like highlighting something like,
00:46:03
Speaker
So all I did was change the connection string for the type provider. The type provider takes over in the compiler and does the code generation in the background. And all of a sudden, it's starting to light up all the things where like, oh, hey, by the way, dude, when they did the conversion of the database from MySQL to SQL Server,
00:46:23
Speaker
Like they changed all these columns. This column doesn't exist anymore. This column is now a byte instead of an integer. You probably have to go and look at that. And then you just have to walk through and go like, oh, does this actually make a difference? Okay, how am I actually going to handle each of these things? Fix all the compile errors, you run it, it's good. Right. Have you used SSIS?
00:46:47
Speaker
No, like we don't have most of these tools. Fair enough. Yeah. So like I did it back in the day and just imagine a visual editor where you have this table and then a line drawn to it like a UML diagram and then it goes to here. So destination and source.
00:47:04
Speaker
And then you have along the way, conversions, this call of maps to this. But you wouldn't really know if it'll ever work until you actually run it. And then it'll be running. You're like, oh, why did it fail? I don't know. So obviously, there's not much Microsoft push to evolve SSIS. There's other things. And I'm drawing a blank on their Azure variant of that. I think it's
00:47:25
Speaker
data studio. There's like so many, like by the time you learn something in Azure, oh, that's deprecated because now it's not even called Active Directory. It's called Entra or some like, okay, you guys slow it down like a bit, you know, you guys are good, but we're still catching up. But that sounds like a strongly type version of like SSIS or
00:47:47
Speaker
So yeah, to getting back to the question, what would you, or was it just like, this was a perfect project for it. This is a perfect project because it was like, we don't have the tools to do the ETL or like they switched cloud, they switched from a public cloud to a secure cloud.
00:48:04
Speaker
so the tools wouldn't have been available anyways. Or they're like the requests on the side of your desk were just like, hey, can you like convert this to like do this thing with this data? I don't want it in this format. I want it in this like other format. When it's like, oh, you wouldn't have an ETL for that. It would just be like, oh, you just need a developer to like chunk through or do some data processing. Totally would recommend that kind of stuff for that.
00:48:34
Speaker
going through and mucking around with data and series of data also feels really good in the language. And the whole ETL tool thing you're talking about, like, well, yeah, also, those cost money.
00:48:49
Speaker
And they're all based on things like F-sharp doing whatever anyways. You might as well go low level if you're trying to... I was talking to you before about the huge Azure bill that just got hit because we're using a bunch of open AI services. Yeah, they're great, but Microsoft's marking them up a little bit. And if you're not expecting a $2,000 Azure bill this month, that hits hard sometimes. So you're like,
00:49:15
Speaker
Dial it back, now call open AI directly and then save, you know, two cents on every call or whatever it is, right? Am I going to learn Azure Data Factory?
00:49:28
Speaker
Or am I just going to use like the thing that's not like it's a one time thing. It's a yeah, it's never a one time thing, but yeah. Yeah, there's also the low level, right? Yeah, like if you're going to do it multiple times, then maybe, or if there's other teams and considerations for OK, they use it, so we might as well do it. But as soon as you go super low level, you're going to get the perf like Steve Gibson, who's like on security now podcast with Leo Laporte and he's like.
00:49:57
Speaker
super genius level, builds all sorts of crazy time machines and things he can't talk about. But he built this hard drive recovery tool called Spinrite in assembly. And he's said why? Because he just, it's not that he needed that, it's just that he knew in assembly he could build a perfect program.
00:50:21
Speaker
It's just that he said windows, these are toy operating systems. They're not built perfectly. If you go super, I'm not saying like, build your Blazor, Maui hybrid apps in assembly. That's a lot of work. We build these layers on top like Data Studio way up here. But if you go a couple layers lower, you're going to get all the perf benefits of
00:50:47
Speaker
an F sharp or you might not know why it's taking long in Data Studio. It could be their code. You don't want to go too low that you're like, let's rewrite C sharp or let's rewrite the CLR. That's like, okay, it's okay. We don't get to rewrite that, but people have gotten used to things being super quick and if they're not,
00:51:17
Speaker
Thank you, TikTok. Thank you, Google. Thank you, five gigabit up and down ethernet. Or spoiling my kids to make them pretentious enough to be like, I think I was like playing a Nintendo Wii game on like a, you know, 47 inch flat screen. They're like, why does it look like that?
00:51:38
Speaker
I'm like, seriously? I'm like, they're like, it's old. I was like, this is, this is a Nintendo Wii, right? This like, yeah, it's not HD, it's like 480p, right? I'm like, guys, really? Like, yeah, I'm like, they're used to like, you know, 4K, 60 frames a second, Dolby Atmos, Dolby Vision. And like, I'm like, and it's lightning quick. It's like, why is it taking so long to load?
00:52:06
Speaker
You should be able to make the same thing. We knew at the time that this wasn't as good as the PlayStation and the Xbox, but we still bought into it because of the thing that it did with the handheld. We already know it's bad. It's fun. We like to top vegetables. In Metroid, it was cool. You put in a thing and then you turned it. It's like a key and you pulled it out. I still remember that.
00:52:31
Speaker
You know, that's a good segue. I'm thinking like F sharp is probably more efficient for writing Unity scripts instead of C sharp. I wonder if that's your name. You can use F sharp with Unity. Yeah. I think people are trying to rewrite Doom again. Oh. Yet another thing. In F sharp? In F sharp, yeah. Doom sharp. You'll get a performance.
00:52:58
Speaker
It does. The thing is, it's a performance boost for the developer, I would say, especially for writing these scripts and stuff like that. It definitely is because you do get a lot less code and you don't have to learn another language like Python, which feels really good for scripting. When you're learning a new
00:53:20
Speaker
language, there's usually two things you gotta learn. You gotta learn the language and then you gotta learn the environment. And then you learn the IDE usually. With F sharp, all your, if you were a C sharp developer, the only thing you have to learn is the language. So you already know how, you know, system.collections.generic works. It's the same thing. The only thing you have to learn is like the little language you want. So if all you need is like a little scripting language,
00:53:50
Speaker
Just give it a shot and try it because it's going to be less code. You're just going to read it top to bottom because that's how the language flows and stuff like that. Because of the way you program is just interactive, like you write a section, you run it immediately, you get the results. You're always testing and playing around with it. You don't have to hit F5.
00:54:16
Speaker
wait a couple of minutes for it to compile and load up the console program, have the console program run start to finish and then read the same, right? It's very interactive to work with the language. Nice. Yeah, I think I'm going to try F sharp for, I have a thing that will run pre-build or post-build on a component library I built and it builds out all of these
00:54:44
Speaker
sample pages for each of the components. Like you have a text box. Here's all your permutations of this Blazor component. And it's a CLI for building out those Blazor pages and stuff like that. And it just runs top to bottom. It's a script. I'm just going to see if I can fork that. It's very small, like as a POC for F sharp. And I'll just be like, hey, this is going to be another thing that runs pre-build. And then just, would it be good for that, you think? Oh, totally. Anything?
00:55:13
Speaker
Anything scripting based is a good way to like, add yourself into. We're definitely like, I usually do use like the same exact program. I've just rewritten it's how like, I know this hobby, it's my thing. It's, you know, could be like fantasy football or whatever, where it's just like,
00:55:32
Speaker
This is the thing I'm interested in and then I write the thing and then I rewrite it. I need to learn this other thing. I'll rewrite it again and add this other module and now I know how Azure Cloud works or this graphing library works or whatever. You just keep on rewriting the exact same problem. You're not having to learn the problem, you just have to learn the specific language thing.
00:55:54
Speaker
Yeah. Now I'm thinking about it like when I'm asking chat GPT-4 for like, hey, how could I do this in this scenario? And they're like, and it's like, blah. And I'll be like, can you give it to me in F sharp? And it'll be like, okay. Exactly. It'll just allow you to see it. I'm like, wow, is that two lines versus 20?
00:56:15
Speaker
And then so last question here before wrapping up, if you're if you're first time tuning in, or just, you know, you've found this on Spotify, Apple Music, anywhere, and you're kind of interested in getting into F sharp, you know, Dan, what would you recommend for that, like you coming from that area where I'm going to experiment, try it out, like
00:56:34
Speaker
Now that you've gone through the gamut of falling in love with a language, just really embracing it and it being the gateway drug to Microsoft's mule of options.
Advice for Aspiring F-sharp Developers
00:56:47
Speaker
What would you recommend for developers getting into it? In addition to that, give us some info on the marketability of F-sharp. Marketability of F-sharp is a fun one.
00:57:03
Speaker
hard to find F sharp developers because of just the sheer order of magnitude of C sharp developers. But if you do find an F sharp developer, they are very valuable because they're the guys who go outside of the fringe and have the extra ideas to learn those new languages. Like if I came to you with a guy who knew like Closure and Haskell and
00:57:29
Speaker
Scala and C sharp and like a list laundry list of things is like oh you're doing that for your hobby like programming is your hobby and That's the kind of culture that I want here. Yeah It kind of doesn't have to be f-sharp. It's just those are the kind of people you'd be looking for and then if you give them see f-sharp work You can just pay them don't mind. They will just do the job because they enjoy it That's the whole thing
00:57:59
Speaker
F-sharp has a certain number of spaces that feels really good for data science, working with data and stuff like that. If you don't want to introduce that whole other platform of the whole polygot thing of .NET and the Python is over here and we're using this other thing over here, F-sharp transpiles into all of those other languages anyways. Even if you have to interact with those things,
00:58:29
Speaker
I never have to write JavaScript. I never have to write Python. I can write a React application without actually knowing how to use React.
00:58:40
Speaker
Like it translates into so many other language. I didn't even talk about that side of things in this podcast. Those are the strengths. The podcast front end, front end F sharp, F sharp for front ends. And it'll be F like front ends with like a sharp symbol at the end, but I'll be V2. And then getting into it for new devs. I'll do some call outs to some things that really helped me out. There's obviously the try F sharp,
00:59:10
Speaker
stuff online, it's got tons of good resources. Some of the things kind of require you to be already into it, so I won't go into those ones, but there's one that is called F-sharp for fun and profit. There's a guy named Scott Washington. He does some really good explanations on it, even down to like
00:59:33
Speaker
the difference between C-sharp and F-sharp. And he basically walks through the entire presentation of like, oh, by the way, did you really need those curly braces? Let me just remove those curly braces. Did you really need public? And then you'll show the entire progression from one language to the other language. And he's really good at underlying those. A good series on something called railway-oriented programming.
01:00:01
Speaker
It's always kind of like hidden functional meanings, but kind of just makes sense F sharp for a friend and profit is really one that I'd suggest starting out with If you can send that to us, we'll make sure it's included in the show notes So people can just scroll down on whatever plot their favorite, you know platform YouTube whatever there'll be a link to that kind of stuff it's available on YouTube or like all of that stuff or
01:00:29
Speaker
Yeah. So I'll send some good resources and stuff like that for getting your toes into it. And then just as for learning stuff, I would suggest advent of code.
01:00:49
Speaker
It's something that runs in December where they just give like different math problems or different computer science problems and you go through the whole December unlocking each one and it's a good way to learn new languages. It should be starting up in a couple weeks. So they do like the traveling salesman problem is like day 18 and
01:01:13
Speaker
usually have like a challenge step of like you'll be able to do the basic example but you'd have to actually kind of think of it to do the advanced example because it would like you know add too many cities or to one minute too many recursions and if you didn't like think about it it's a good challenge for programmers to learn a new language kind of thing.
01:01:34
Speaker
Cool, yeah, that sounds good. We'll have to make sure that we release this episode before December so people can take advantage of coding. Awesome. Ruby, any last words before we walk the plank and go back into the madness that is the love of our life, which is programming, coding, gaming, getting back to the grind of helping people every day? Any last words before that? No last words, maybe a few last words.
01:02:03
Speaker
I'm generally interested in F sharp now. I feel like this was a good resource. Dan, I want to thank you for being here.
01:02:11
Speaker
And absolutely, I'm going to take up that dev challenge and see how that goes. What is it called? Advent of programming, right? Advent of code. Advent of code, yeah. Advent of code. I have the memory of a fish, sorry. Exactly. And it's like for whatever language you're trying to do. It's like language agnostic. Can you post your results and it'll give you new challenges every day. Yeah, that seems interesting.
01:02:35
Speaker
Right, well, thank you, Dan. It was a pleasure. We'll have to do a V2 on F-sharp for front ends. Thank you, Rui, and we'll see you guys next time. Thank you. Okay, thanks a lot.