How'd you like to listen to dot net rocks with no ads? Easy?
Become a patron. For just five dollars a month, you get access to
a private RSS feed where all the shows have no ADS. Twenty dollars a
month will get you that and a special dot net Rocks patron mug. Sign
up now at Patreon dot dot net rocks dot com. Hey Carlin, Richard
Here, as you may have heard, NDC is back offering their incredible in
person conferences around the world, and we'd like to tell you about them.
EDDC Oslow will be made twenty first through the twenty fifth. Go to Ndcoslo
dot com to register. NDC Copenhagen is happening August twenty seventh through the thirty
first. Go to NDC Copenhagen dot com for more information. NDC Porto is
happening October sixteenth through the twentieth. The early bird discount for dc Porto ends
July twenty first. Go to Edcporto dot com to register and check out.
The full lineup of conferences is at NDC Conferences dot com. Welcome back to
dot net Rocks. This is Carl Franklin and this is Richard Campbell and we
are in our respective home offices. Although it doesn't sound like it, does
it. It sounds like we're like together in a studio that costs millions of
dollars. Yeah, we fool people all the time with that. Can you
remember when we used to use the phone line to synchronize our audio files?
The tels one plus one? Oh yes, the t los? Yeah.
Yeah. If we went through like a laundry list of all the gear that
we've had to use throughout the years, and now it's evolved, thousands of
dollars worth of gear. Two those t loses were not cheap. Yeah you
want to buy one? No? No thanks, all right? Last one
I had cooked off and went to the e waste recycler. How is Vancouver
this time of year, Richard? Frozen? It's like negative six. A
couple of weeks ago it was like fifty degrees fahrenheit here, and then the
next week it was like ten below, right, what's what the hell?
Hell? And California froze too, froze. Yeah, yeah, we call
that climate instability. Oh, it's terrible. Well anyway, we'll tell terrible
for you, okay for me, But man, I would wish it would
be over. Yeah, before this show comes out, I will have jetted
off to New Zealand for a few days, Ain't you lucky? I am
officiating a wedding again. Richard had a little lamb, a little ham,
a little spam. All right, let's get it going with better no framework?
All right? Man? What do you got? This came across my
desk such as it is um from somebody I think it was on Mastodon,
and it's called code made, code made dot net doing our developer dirty work.
What an open source of visual studio extension to clean up and simplify C
sharp C plus plus F sharp VBPHP, PowerShell, R, json, zam
mlshtmails as less SCSS, JavaScript and type script coding. That's a lot.
Yeah, I I have a few customers that need this badly interesting. Let's
just say that. I mean, how do you how do you? How
does the tool clean up code without damaging it? Oh, removing unused using
statements, sorting them, adding unspecified access modifiers, removing empty regions, adding
blank line padding, removing blank lines next to braces, just like formatting,
you know. I mean when control E control D doesn't do the trick for
some reason, this. This kind of thing works, and there's been you
know, tools like this um throughout the ages, but this is kind of
the state of the art. So I'm told I don't particularly think my code
needs it, but somebody did. That's what I shared it with. Means
somebody thought your code needed it. Okay, yeah, yeah. It's kind
of like when your friend gives you some deodorant as a yea, or you
know, hands you the pack of tick tacks, did like, yeah,
here, No, I don't want those. Yes, take as many as
you want, please, all right, my friend, that's what I got.
Who's talking to us? I love it. Grabbed a comment off a
show seventeen sixty one, the one we did with Mads back in the fall
of twenty twenty one, talking about c sharp ten that was right before within
weeks of the twenty twenty one Really did fall, didn't it? Well,
there was a fall. It was cold, yeah, okay, And this
comment comes from Maurice Peters and he says, I just wanted to respond to
the remark from Mads. It's great to hear the c sharp team is listening
to the community and they take the time to design a feature like discriminating unions
by trying to find out what it is the community actually means when they say
they want discriminating unions. And I remember this conversation, right, and we've
talked about exactly that. So what do you mean when you say that Mad's
ads to this remarket And I am paraphrasing, perhaps crudely, but when no
community wants to have an F sharp like discribuinating union, they should probably use
F sharp. Yeah, dun, dunt du Now I understand his remark,
and I would love to use F sharp at my day job as well.
However, it is often not feasible to switch to a different programming language.
There are lots of reasons for this, one of them being that it's hard
to attract a larger number of developers with knowledge of F sharp or any other
functional language for that matter. And C sharp is a very enjoyable language to
work in, So don't forget that part. I totally agree with you,
and I think we said as much on the show. Yeah, and I
think we also suggested to that if possible, you know, you can create
a class library and F sharp just to do the f sharpie things. Yeah,
it's still and then use that at c sharp. Your employer kind of
needs to know you did that, right, like somebody does have to maintain
that. It can't be only you. And a feature like discriminating unions kind
of is a fundamental thing. So it's gonna is, It's going to be
in everything, And so Marie wraps up. I say feature is usually associated
with functional languages like discriminate unions have a lot of value, for instance,
designing type driven domain models, and he plugs Scott Woslin's book Domain Modeling Made
Functional here. The earlier in the development cycle we are able to catch air
as a domain model, the cheaper it is to fix them. So I
guess that means as early as possible in the inner development loop if you ask
me specifically what you would like to achieve the functional programming paradigms like in c
sharp in general, and I like to think I'm not the only one would
like him to expand my options to explicitly enclode a domain model by exploiting the
type system and the compiler. Thanks for a great show. Yeah, well,
thank you, Maurice. I have good thoughts that I'm sure Mads will
contribute to them when we let him speak because currently he's tied up in a
closet and a copy of us to codbuy is on its way to you.
And if you'd like him copy of us to code by, write a comment
on the website at dot net rocks dot com or on the facebooks where reread
every comment, and if I read on the show, we'll say your copy
mused to codebuy, and definitely follow us on Mastodon. I'm at Carl Franklin
at tech hub dot social, I'm Rich Campbell at Mastodondon Social. Send us
that too. I know the mastadon things, it just doesn't even to be
gaining any momentum. Maybe in your world not. But I find better engagement
on Mastodon with my you know, one percent of my followers sure that I
have on Twitter, I find they are more intentive and more interested in what
I have to say. And I think Twitter is not as big a dumpster
fire as you expected, honestly when you saw the layoffs, I you know,
I've done enough a large scale infrastructure stuff to think if he really got
rid of all those guys, he's got a week. But apparently he didn't.
The system is stayed up. Obviously, there's funny things happening, like
getting rid of free sms. Yeah to FA. Yeah, that's a great
idea. It turns out it wasn't free. That there are questionable telcos in
the world that were running bots that would create accounts on Twitter set up MFA
just to collect a few cents that they would get for every text message.
Interesting, Well, you can always use an authenticator too, and that's that's
what you should use, and arguably should Yeah. Absolutely, I think they
would have had a better PR statement and just said, hey, we're getting
rid of SMS for authentication, should use a real authenticator rather than say,
hey, you could pay us, but if you want to send us a
tweet. I'm at Carl Franklin. He's at Rich Campbell. Yes we are.
All right, let's bring on Mad's that's who you're here for. Mads
Turguson is the program manager for the c sharp language at Microsoft and runs the
c sharp design meetings. Prior to joining Microsoft in two thousand and five,
he was an associate professor at the University of our huss Is that right?
Oh yeah, that's close enough, doing programming language research. Welcome back.
Can't wait to hear what you have to say. Sir, thank you.
It's great to be bad. I feel like this. I've been here so
many times. This would be like my second or third time or something like
that, something like I should probably count them up. There's probably a few
more that I was gonna. I was in Sweden not long ago, and
the conversation came up above just how many language designers come from Denmark. It's
kind of staggering. Yeah, this is your sixth show, by the way,
sixth oh six. Yeah, there you go. More than any other
language designer, more than any other Daniel language designer. Yeah, it comes
up a lot, and I don't know what it is that. I mean,
there was a whole lot of interest in programming languages and compilers all the
way back in the sixties, you know, right, we we built alcohol
compilers in Denmark. Someone like Charles Simoni worked in Denmark for a while working
on an alcohol compiler. Might be the herring and sour cream, don't you
think maybe first said not a Danish thing. I mean, we have both.
Yeah. I gotta wonder if it was just certain professors and I wouldn't
know their names, that cultivated an environment where it just sort of became known
as a place where you work on programming languages, and so the folks that
wanted to do that tended to go there. It was the best place to
do it in Maybe. Yeah, I think there's definitely something to that.
I mean object going to programming famously was invented in not in Denmark, but
in Scanning Navy in no way. Um, one of the two inventors spent
a lot of time in anymore, you know, Hush, and I bumped
into him many times while I was there. So there's been a culture for
longer than I've been alive. I don't know if it's still going. Actually
I don't. I don't have I don't have that much of a connection anymore.
It's been seventeen years plus since I was there full time. But there
definitely was sort of like an environment in academic circles in particular. Yeah,
so you're not a good alumni of the university, you're not staying in touch
making regular visits. I would imagine they'd love to have you do a presentation
or two there. Oh, I've been back a few times. Yeah,
it's not that I completely lost touch. Um, but um, yeah,
it's probably half a decade between each visit. Well, we have had a
two half your interruption on just about everything right that too. Yeah, but
it doesn't sound like you guys have stopped at all C sharp eleven. Well
along in development, I see preview one of the framework dropped. I think
there was a language stuff in there as well. That's actually twelve C sharp
twelve sharp twelve we're talking about. See I told you twenty twenty one fell
Yeah. Yeah, there isn't any language stuff in the first preview, at
least as far as I'm aware. Okay, that'll start in preview two.
I think we'll see Um, I'm betting we'll see primary constructors and maybe a
few other things there, and then things will start seeping in. Okay,
what's a primary constructor, oh, carlitz Um. It's sort of a generalizing
a thing that we already did with records. You know, for a record
in C chart, you can put um constructor primeters directly on the class name,
on the type name when you declare one, and you can also pass
along base constructor argument on the base class of a record of a record class.
But it was sort of limited to records, and in records, it's
very like it does a lot of things. When you do that, it
generates public properties for each of the parameters and so on. It's sort of
like a um it's sort of like a a way to try to mimic functional
records a little bit, a very terse way of describing you a data model
in one fields, and that's a little much for other classes, because you
know, records are specifically like when you want to describe very straight up data
with a clear structure and public properties and so on. But it can still
be very useful to to allow you to specify like a main constructor that where
the parameters are on the class itself, so that instead of doing the work
of stashing the incoming data somewhere in private fields, protected fields or whatever,
they're just they're just in scope. They're just capture them, just like at
lambic can capture things from around it. And so so there is a more
and more limited form of primary constructors coming out on ordinary classes and starts,
And we've tinkered a lot with the exact semantics and and everything, but we
think it's there now. We think it has a really good first design.
There are some optional things we could do to it that we haven't done yet
and we probably do the usual thing now that we're shipping every year and just
ship the basic version and see what people climber for. You know, there
are kinds of ideas for, Hey, you could do this that type scrip
does, or you could do that that F sharp does, or you could
do this third thing that no one does or and we're just like, yeah,
but here, we know this part is good, so let's ship that
and then let's see what you all say that the annual cadence. That must
be really empowering, because you know it's only a year and there will be
interim releases. Yeah, no, it's it's it's incredible. And the more
we we've sort of leaned into it, the more we've gotten used to it,
the more we use it. Like, um, we have many feature
sets that we drip out year after year because then we can take much more
fine grained quote unquote advice from from the community, from from us. It's
not just the people who engage before the original feature comes out, but the
people who are who are on the forefront enough that they use new features and
tell us when they think something is missing and give us the scenarios and so
on. But they're also self selecting, Like you used to do this back
in the before open source days, but it was software design reviews, Like
you had to get an invitation to come in and sit with the team and
they'd show off the features and it was a kind of a prestige sort of
thing, like you're just splent a lot of time to get your foot in
the door of an SDR in the first place. Now it's like if you
can get to GitHub and you care, you can participate. Yeah, and
it's important for us to have these different kind of circles of engagement, right.
Obviously we've had we've had this program called the MVP program for a long
time, and we had that that was even around when I when I joined
these many years ago, and that was a way to have a certain group
of people that you could share your secrets with and get early design advice.
And then yes, there were the design reviews and so on. But it's
almost like guaranteed that that will not be a representative set of people, right,
but you're selected from that for that kind of thing, then you are
special in some way. Uh yeah, I remember Steven Sudovski gave me the
best admistration i'd ever seen this to the RDS when they were talking about I
E. Nine, which was not out yet, so that was such a
the time frame forward. He says to the room, there must be one
hundred and fifty of us. How many of you here use bookmarks? In
the entire room puts up its hands. Yeah, yeah, would you like
to see the doctor walks in data for bookmark usage? It's two percent,
right, you're talking to the people that use the product more than anybody else.
That's right, and in a much different way. And I also appreciate
that, you know, you have the really two groups of people who are
who don't want to maybe change everything to use the new language features because they're
maintaining old code and that would you know the it's a cultural disruption. It's
not a backward compatibility issue. It's a cultural disruption, right. And then
you have the people like like me who are just on the forefront to in
research every day and saying, you know whoa that that's really cool. Let
me show everybody how that works. So, yeah, there's a there's a
big difference between those groups. It's definitely a span and we yeah, we
want to have more circles of influence, so to speak, and we can
now that we're so open and now that we're shipping so frequent, right,
so we get so we get people on on GitHub helping us with the things
we haven't done, we haven't finished yet, and we have people um who
are adopting new features as they come out give us feedback in time for us
to um choose the right next steps for a given feature that's already shared.
I appreciate that you It feels like you guys, work on a given feature
until you say, okay, that now has value. Let's stop getting that
out in the field and see how they use it before we go any further.
Yeah, yeah, sort of. I mean it's not it's not enough
to achieve minimum value necessary. We'll go until we feel like, um,
it's we'll do the things that we're we feel certain are useful. Or is
it you get to a point, the fork in the road where it's like
there's now three ways to go, it's hard to tell which one's better.
Maybe this is the best place to stime. Yeah, it's often that kind
of thing. Yeah, Or you know, it's just it's just time because
or isn't that long? And so we're like this as far as we got.
But this, this is a coherent feature in and of itself, So
we'll ship that because I'm sure there's features that don't get put into the product
that we're worked on in that year, and it's like, this is not
there yet, it's going to slip a cycle. We'll go, we'll work
on it later. Absolutely, And that was one of the one of the
harder things actually with switching to a yearly cadence is to make sure you keep
doing things that take longer than a year. Yeah, right right, you
get hooked on that. I got to deliver this every year. You're only
taking you're making smaller things rather than bigger things, right, Yeah. It
has to be fine to work on something that is not about to ship interesting,
Okay, it has to be. Is that more about good for the
career or good for the product? Like that's a that's the issue. Balance.
It's like if nothing made it in the latest release, that would be
a problem. Also, that's true. I yes, so, But there's
definitely a balance there where you want and I think it comes sort of on
its own if you look for the right mix of features in general, some
of them will be small, some you know, quality of life features or
medium that we can relatively quickly take from idea to product and some and then
but then we also just have to keep those strategic lines in mind of we
really want to grow the language on this front, and we might spend several
years before people see the first even the first sort of down payment on a
given feature direction. Also, I imagine you've got groups of people, like
you have the ADHD people working on this year's features, and you have like
the old time or long term people who just want to work on code every
day, working on those things that are going to come out in a couple
of years. That might be how it pans out. I don't know about
who has ADHD and who doesn't. I know I do, but I still
do work on the long term features. Yeah, but it's a personality trait
too to folks who are great at knock it out quick things of bols and
enjoy a long duration we work at the same thing every day. Yeah,
that is that is true to some degree. I think that, Um,
I think that we generally have a culture of also not of letting people span
these different kinds of don't pigeonhole them either. Yeah, like you only do
short stuff. Yeah, don't actively pigeonhole people for sure, Like everybody should
have room to grow in a direction they're not strong end and um, and
I think that that works out pretty well. So it's not so much that
oh this, oh, this feels like a Bob feature and this feels like
a Katie features. That's not how I want do people volunteer for features?
Like how does this happen? Stuff comes in on GitHub conversations go on,
I see you generally in them. You know, it's a sort of shepherd
of the language. But how does that happen? Well? So, um,
there's sort of a there's the language to sign team, and then there's
the compiler team and other teams that also do some work language related work.
So first first there's the language designed team, and that is sort of that's
the thing I lead. That's I'm the only dictatorial power I like to exercises
that I get to decide who's on that team. Right, So that's a
that's a virtual team of people from different parts. They're all work at Microsoft.
It's not like a community forum. That's it. It's it's one Microsoft
employees, but they're plucked from various parts of the product and from various um
disciplines and backgrounds and generally the ideas people who are passionate about c SHARP,
who have great ideas, and who are collaborative, and who collectively represent a
bunch of different viewpoints. Right. So you want folks from the compiler team
there, and you want folks that focus on the frameworks there like that have
all those different views, but I also have a passion for the language.
Yeah, that essentially have enough passion for the language that they want to invest
essentially extracurricular time um in making CHR good and working actively on its future.
So um so that's where things go first, essentially, because there's so much
coming in on the I don't think anyone reads everything that comes in on geth
hubs. It's unbelievable, it's vast, right, So we um so we
have a system, a championing system that we've essentially stolen from academia, when
from academic conferences. Um that for a feature to reach discussion, make it
to discussion in in in the design team, someone on the design team needs
to have champion ins they like I want to discuss this. That gets it
on the agenda. Then, which we are shit, so to speak.
See if it if we have a feeling that it has legs and there's and
there's a path forward. There are many good features that fall at this stage
because we just like that that would be great, but a we don't know
how to do it or be um, it's well, it would be great.
There are these many things that are greater. So I'll have to write
so that. It can be frustrating if you're out there trying to you know,
get our attention. But it's just we need some kind of filtering mechanism
and this kind of everybody can scour and then champion if there's something there that
they think we should discuss, and I you know, it's not necessarily that
you want that we want that feature, it's that it warrants discussion. I
got championed several features that I I probably at the end of the day what
at least initially didn't feel like was the right thing. But it was bringing
up a good discussion that we should have. Right, but it's awful.
It's just as powerful to have conversations about the language shouldn't do as what the
language should do. Yeah, right. It does help put parameters around things.
I had to go look at the rosal And repository and it's like fifty
minutes ago another issue opened and it's sixty seven thousands. At thirty eight there's
eight thousand open and twenty two thousand clothes. Is like, this is a
lot of stuff. Bads holy Man. Yeah, Well, the Rosslyn repo
is where the compilers built, and so we started out having our language design
go on in the same repo. But we we branched it out fairly early
on because it so we have our own repo for the lengths design parts char
B blang, right, which is which doesn't have code in it as like
the the the source in there is is all documents, right, So we
separated out the language design workstream. It was it was two kind of semi
separate audiences and it was a mess to kind of have it all together.
So when did you separate it out? Oh, it's it's a long time.
It must been a few years. Yeah, yeah, I mean it's
at least five years ago. I would say it was pretty early on.
Like we first we were on what's it called code Plex for a bit,
ye didn't We cohabited co inhabited the Rosslyn repo for year or two. I
don't think it was longer than that. Okay, so that's twenty fourteen,
twenty fifteen. Within a couple of years you felt like you need to peel
it off. I don't disagree at all. And it's interesting to see.
I'm looking at them side by side, C sharp lying and Roslin and the
difference in the conversation, the kinds of topics of show but C sharp lying
are different. Yeah, And it's kind of like you want to be able
to talk about language without talking about compilers, because most people who have something
interesting to say about languages don't necessarily know how I shouldn't know how a compiler
works. Right. Part of doing language design, of course is is this
feasible to build? And you know it could ever be efficient? You know
that kind of thing, so you do. Some of us on the design
team do need to have compiler background, right, But that shouldn't be the
only thing. Yeah, right. It shouldn't be a thing that makes the
language design discussion less welcoming. It shouldn't be sort of a corner of a
compiler place. So that so this works really well that it means that people
can come in with much more of a user perspect on the thing. Yeah,
and al and just to pure language prospective, like I suspect some big
ideas come out of here that turn into this would be really hard to do,
but does this showed up value that it might be worth taking it on.
Where As soon as you get to boy, that's gonna be tough on
local piler. A lot of stuff's going to think yeah, yeah, and
you you don't want a bunch of people saying no, you want to at
least you want to balance it with another bunch of people saying but wait,
yeah, so yeah, having having breath they're both in the community and on
the design team is really very very useful. Nobody can kind of see all
the perspectives at once, so diversity just really is extremely useful. It spans
out like this vast space of opportunity. Well, this feels like a good
time to take a break because I want to dive into some of the new
features. But let's do that when we come back. We'll be right back
after this message. You know, amazon Aws is a great home for your
dot nem applications, whether you're looking to run apps as serverless functions, have
them running containers or you require the complete flexibility of virtualized hardware. You can
do it all on AWS. Dot Net toolkits and templates guide you through build
and deployment. Or you can use your favorite infrastructure as code and CICD tools
including Azure DevOps, GitHub Actions and git labs, CICD, loving, Visual
Studio, vscode, or Rider. There's an AWS toolkit for each of them.
Want to use familiar Microsoft sequelserver databases, you can with the Amazon Relational
Database service, which provides fully managed sequel server databases that offer automatic scaling,
failover, and snapshots. Once your dot net application is deployed, it can
use any of the over two hundred AWS services to extend its functionality. Interested
in AI, IoT, machine learning, video processing, or transcription, Your
dot Net on AWS application can do it all. To learn more, go
to AWS do, Amazon dot Com, slash Net. There is always something
new from our sponsor text Control. As a developer, do you need to
integrate PDF generation, document editing, or electronic signatures into your asp net,
corps or Angular applications, or you want to learn more about the differences between
electronic and digital signatures. Text Control is offering a free consulting service to educate
you about digital document processing and how text control products can help you add these
features to your applications. Go to text control dot com, slash contact and
request your free personal consultation. And we're back this Carl Franklin, you're listen
to Dot and Rocks. That's Richard Campbell. Hey, that's Mad's Tarkusen,
the MADS scientists on the c sharp team. And we've been talking about sort
of the culture around how Microsoft, you know, decides what comes in what
goes out, and let's talk about some new features. It looks like there's
a lot of really cool small features, you know, default parameters and lambdas
and things like that, but maybe we can talk about some of the bigger
things that you know that that people may not know about. Yeah, I
mean, we we shipped UM. We ships Chever eleven in November of twenty
twenty two, and that's when we ship every year UM and there were there
were some very big things in there and some medium big things. A huge
thing that is an example of a multi year effort that that culminated in this
release is UM that the language part of it is static virtual members in interfaces.
So that's that sounds a little gnarly, um but the the the it
has several potential use cases that essentially, um are you know, new new
abstractive power if you will. Sure, But the one that we really doubled
down on as the first as a use case for it, the one that
kind of drove it home that we are supporting in the framework is generic math.
So the ability to have massive code code with operators and so on be
abstracted over the type that it's working on. So the from a language point
of view, the feature is that an interface can now have that the virtual
interface members can now be static. Right. You can say a class that
implements this interface must have this static member must have for instance, this must
have a plus operator, okay, and or it must have this static property
you know zero. So you can imagine now interface is dictating the shape not
just of the the instances of the classes that implement them, but also the
classes themselves. And that is that's sort of the key new abstractive power,
if you will, And it has it has a number of really cool use
cases. One of them, of course, is what I mentioned, like
you can now you can abstract over math and we build a whole set of
interfaces that represent different math capabilities, essentially different sets of operators and stuff.
And we implemented those interfaces on all our own Mathew types, and now people
can plug into those interfaces as well with our own Mathew types and that,
you know, just imagine doing abstract composition. Like you have a matrix type,
and you can say matrix of T or TS element type of the matrix,
and now you can require that T implements the interfaces that represent the math
operations you need in order to implement the math operations on the matrix, like
the if you want to do matrix multiplication, for instance, well the elements
need to be able to be added and multiplied and they they're you know,
if you if you want to build an identity matrix, you need to have
some representation of zeros and ones, right and so on, and and you
can now abstractor over all of that. You can say matrix of T,
where T has these capabilities and the interface is actually looks like it's implementing the
math, right yeah, yeah, which is weird. That's that's not an
interface, that's a base class. That's what my brain is telling me.
I'm fighting against it. The interface isn't implementing the math. It is just
specifying the math, right, and then types that implement the interface will implement
the math. So the only it's not the interface is not playing a different
role, and it does. It's still just like a contract, right,
But it Okay, I see I'm looking. I'm looking at them the docs,
and was looking at the implementation, not the interface. The interface public
static of t like midpoint is the thing that returns the midpoint of two double
numbers. But the yeah, the the interface doesn't actually do it. Yeah,
right, it's very cool. I mean you can have you can have
default implementations of these things, just that you can of other things nowadays.
But um, yeah, the main thing is that that you can, um
you can specify a contract that is about these static members. Yeah, but
there are other users for that as well. And one of the coolest I
think is abstract static factories. Right there, as these two design patterns,
you have static factories, which are up until now being static methods that produce
instances of the class they're on or a subclass or whatever they so they they
sort of they abstract over constructors in a way. They're like the details about
how this update is constructed. But that can't vary down a type hierarchy,
right, the static it's a method that's non virtual. Or you can have
abstract factories which do vary by the type of the thing they produce, but
you kind of have to have a parallel hierarchy of factories that implement the abstract
factories for some other type hierarchy, and which is like a pretty gnarly pattern
to do with this. You can just smoosh them together. You can say,
everything that implements this interface has a factory that takes these specific elements and
produces itself produces that type that implement. Right. So so an example,
for instance, is a think about an eye possible. We actually have added
such an interface as an eye possible as a new interface in that I possible
of T that has a static method parts that it takes a string and returns
a fresh instance of the type the interface is implemented on of tea. Right,
And so so all of a sudden you can say you can get the
symmetry between the If you think serialize and de serialize, right. Serialized is
an instance method on an object of a given type, and de serialized now
can be a static method that is that is implemented specific to the specific type
that it's working on, but abstracted up in the same interface. So interesting,
some beautiful things come out of that, and I'm I can't wait to
see what else people do with this, because this is sort of like it's
very rare that we add this kind of new abstractive power to the language,
to the very core of the language, Like it's in the run time and
everything. It's like, this is new expressiveness. This isn't just syntactic sugar
or it's jenuine new expressiveness. And it's fun to do that kind of feature.
It's fun to see it, to see what people do with it.
How much energy do you put into looking at what people are doing with it?
Like I don't know how you'd go about that, but it's surveys or
something just to see, you know, people experimenting with this new feature.
Well, we probably don't have enough like systematic looking for it. We sort
of say, if you do something fun with it, please tell us and
then you know. And we have enough kind of interaction with customers and various
in various fura that we do get some examples of things. But but honestly,
we probably don't do enough of kind of Once the features in and it's
too late, it might still be good to do more to see is it
actually being used the way we thought or at all? Right, well,
an inster stantime to sugar you could have after the fact and later versions to
make it easier to use too. I mean, we've had this conversation before,
but we've had abstract EDA factories for a long time, and there are
hard waste implemented. Like you said, gnarly code. Yeah, if you
like that pattern. We've had approaches to serialization, deserialization that exists. Like
to me, it always seems like the hardest thing about C sharp eleven is
all the C sharp six out there. That's true. There's certainly the well
we already have these patterns, so too bad for us, you know.
Yeah, that's often that thing that we have to think about for a language
feature. If it fundamentally changes something that everybody already does in a certain way,
including our own core libraries, well it might not be worth doing.
Even if it's like you can be like, oh I wish we had done
this from the start, the whole world would be better. I can't I
can't imagine how many times you say that, right, you can't get maybe
you can't get from here to there in any like now you'll just have the
old way in the new way coexisting forever. Yes, um, which is
actually a very an interesting um. Like you read that comment in the beginning
about discriminated unions, that's that's exactly like one of those challenges where well they
benefit in really well with what's already there. It can't be just this new
way of doing things, because then how will it work with everything that's already
there? Sure, so you have to think about those things. Yeah,
Because discriminated union, I mean, it's it's coming from F sharp. It's
about function passing like architectural. It's a different thing. So it's not going
to work well in C sharp. You don't want to make C sharp into
F sharp, right. I mean there are versions of discriminated unions that can
work well in C sharp, but I think by and large they are ones
that are very closely integrated with the data modeling capabilities we already have. They're
sort of like records to classes. Is like records are not a new thing.
There are kind of thing. They are a vary end of classes that
that can be treated as in most ways just treated as classes, but they
just do some extra things for you. And it's if you can do have
that kind of relationship, then it's it becomes less of a whole new like
sublanguage and more of a fine grained choice like here, I want to do
this particular little hierarchy as a discriminated union because that would give me these these
certain benefits. Becomes that kind of thing. It's much more, much more
fine grain and much more local than oh, everything should have been discriminated unions
instead of time. You're crazy, like you never you can't do anything about
that, right. The install base is the install base. And how often
do you ever introduce breaking shages in the language these days? I can't think
of anything. Well, we very much don't want to. Yeah, um
and but but it's funny you should bring it up, because we do.
We are starting to have a little bit of an itch there. Um.
So we definitely don't want to ever like remove a feature from chart or something
like even we hate the most. I'm sure there's a list of ones you'd
love to remove, except for all the loud screaming that would cur afterwards.
Yeah, well you'd just be breaking a bunch of code that works just fine
today. How to make people angry in one easy step, the one.
So I actually don't believe that. Well, the size of the language is
a bit of a problem, like we grow it, but we never shrink
it. But I don't think the solution to that is to start removing things
from the language. We are we are working towards. Bill Wagner recently started
a project in the Docks Repo that um that is starting to kind of very
gently point out what I probably what we call everyday c sharp you know,
right, pople Given that you're starting a new project and you don't have like
a certain codebase or culture that you need to abide by, what are the
things that the ways that you should probably do things nowadays? So it's kind
of like a very soft bound to we around. You're not going to say
best practices because that's rude. Yeah, you're really going to say, hey,
here's the set of approaches that really take advantage of the what the current
compiler can do for you. Yeah, yeah, it's I mean, because
we add new features because we think they do things better than than before.
Right, that's a whole point. So, but and we need to have
some sort of counterweight to the to the the just the sheer weight of old,
old advice that's out there now yeah, to say nowadays, well you
can actually do this instead. So so that I think is we're trying to
create a much softer counterbalance to that that you can go and see, well,
okay, I want to I'm open minded. I want to try using
c Chhart the best it can nowadays in my next project or my team wants
to do that. Well, this is where this is a good place to
start. And I love that it's Bill doing that because he is everybody's granddad.
He didn't have a knacker putting his arm around your shoulder, you know,
metaphorically and say it's going to be okay, let's go, let's take
a walk and we'll figure this out. That's exactly right. Yeah, he
has a lot of compassion for developers, like regardless of how leaning into new
features they are and whatnot. And he's a really good person to drive striking
that balance. But there is one other problem with the back compat, and
that is that occasionally it is when we add a new feature, it is
limited in very annoying ways because of some because of some you know, old
code could accidentally occasionally or whatever, like already look like this, right,
So we want to introduce a new keyword in a certain context or whatever,
Well, there could be available with that name or a type with that name
somewhere, and we have to bend over backwards to accommodate those old cases,
even if they're relatively rare, and so on, And it does make the
language more narly. And people know, I mean people know a var right
var. When we introduced var, in order not to break people, we
had to take into account the fact that somebody could have a type called var
with lower case V right, And so the language is is more gnarly than
it would have to be. We could just have said, well, sorry,
this is a keyword, or in the type decision, this is a
keyword. We would have broken a few people, but not very many.
Instead, what we have is this awkward rule that if you declare something called
var in scope, then the feature var is put out of like it's just
turned off, right, And that is that actually sucks for everyone, except
there are a few people don't like var who actually declare a type called var
and just so that they can a piler out, they can force for other
people on the team not to use a variable named var. I look on
you with the same disdain that I looked on basic programmers that had a dollar
sign in b dollar sign for variable places you know so far, Oh boy,
that's that's great. And I think the best example in recent years is
discards. I mean you can go almost everywhere. You can use a discard
to mean like a throwaway variable that I assigned to and I don't care about
the result, and that I can pass us an out parameter when I don't
care about the result and that kind of stuff. Right, It's just a
variable without a name that you can never get back to, except that underscore
is already a valid variable name, and so that in some places, in
some places underscore is a variable and in some places it's a discard, depending
on whether it could have meaning before this feature was introduced. And that is
just nuts man, And they get it's like, what do you do in
name in something underscore like stop it? Well, actually a bunch of people
did, because they were simulating. They were using that to signal that they
wanted that was a discard. So most of the people who do actually probably
would be fine, yeah breaking that and just using a real discard, But
there are a few that use it for other things for whatever reasons. You
know, yeah it was there, it was available. Can you tell me
why somebody would use discard? I mean discard first of all, is like
when you say underscore equals and then some function that returns something that you don't
care about, but you could still call that function that returns something without having
a return value. Why do you need that discard in that case? Well,
there are functions you can you can call a function as a statement.
It's not everything you can do as a statement. So essentially, if you
want to do something, you want to do something that can't be a statement,
so an express like you want to add two things just to see if
your conversions work out right or whatever. I don't know why. There are
a bunch of things that aren't allowed as statements in short, but there's also
there are things that require a variable. For instance, um, so a
couple of good samples are out parameters. We're just like, yeah, I
don't care about this one, I do care about that one. So now
you can pass a discard for one of them. And you can actually declare
a variable in place with an outbars inside step seven and whenever that was also
deconstruction. Um. Yeah, this thing returns to two pole of four things.
I care about the three, but the fourth I don't care about.
Why do I have to declare a dummy variable and call it dummy variable to
receive that fourth thing? Why don't I just put an underscore and say to
say, don't care okay, right, and make it clear to anybody reading
it, I don't care about this exactly. Yeah, maybe that's it,
Richard. It's more readable. Yeah, it's a legibility. It's a strong
and very brief signal that you know, don't care about this, don't care
about But and it's a wonderful feature and the only thing not wonderful about.
And I think I don't have evidence for this, but I'm sure that it
has harmed its adoption to some degree. Is that it's so gnarly that and
occasionally it's not a discard. When you see an underscore, it's not a
discard. And that is just navigating those rules for developers just silly. Yeah,
it's like the English language, all these exceptions to obvious rules. Yeah,
and so all this is to say, that is something where I think
we're we have an active discussion now and it'll you know, we'll probably get
it out and get introduce it as a breaking change. I get something down
that we can have sort of like a very a very light breaking change in
those situations. Its like enough to push existing features over in a few scenarios
as so that we don't have to do a stupid design of the new one
for the sake of everyone's future. Yeah, it's got a hurt to introduce
a new feature damaged by the past, especially if it's a past that isn't
that important. That's a simple So if there's a simple little fix that even
we could automatic we have to do a new feature, it'll break a few
things. That's a simple fix that we can just you know, if you're
in an ide, we can just say, hey, this is going to
be broken. Just want to fix all of them. You know, say,
if you have a if there's a field somewhere all called underscore, do
you want to say this stood underscore instead? Do you want to rename this
to to understood one rename k yeah, yeah, yeah. This is this
gets into that conversation about the tooling helping the language. Yeah, that's true.
But at the same time, you can't really assume that everybody's using in
a rich ide like visual studio. Yeah, you know, no, that's
completely coore. So we so, um, we have to be and that's
the devil is really in what is the what is an acceptable experience? Like
a what is an acceptable level of break has to be small? Um,
has to be really well justified, um, and be what is an acceptable
experience when we do do it, and that this may all very well come
to nothing because there is no good sweet spot there. Um. We're just
starting to poke at it, and we'll try to write up some things and
put out in the community. It might already be be out by the time
this publishes, and where they may not, but try to get more community
input on what is an acceptable experience here? That doesn't really that doesn't boil
the ocean for this in some other way. Yeah, I appreciate that.
The You and I've talked a number of times both online and offline about the
whole how do we get folks using the new features? Like the side effect
of twenty plus years of development of a language is all that stuff and people
you know, I joke about people coding like it's two thousand and five,
but I'm sure they're folks that are doing that. And you said many times
like it's the tooling. We see these large language models showing up everywhere.
Do you look at leaning on that kind of technology to help people write more
moderncy sharp? I that's it. Oh, that's an interesting kind of um
cross discipline question there. Yeah. I mean, and you're not the visual
studio guy, but Visual Studio seventeen point five and twenty twenty two seventy point
five, you could see some of this stuff starting to appear. Immediately,
think, are you going to help me write better C sharp? Because I'd
like that by C sharp not that good. I'd still like to ask for
it though, Yeah, and I think there's um yes, the answer is
yes, And you're already seeing it, and you see things like a pilot
and in telecode and so on, like you're already seeing AI based things creep
in and I and they're very localized, but you could definitely you will see
this keep growing. And does it impact the language creation to think about the
tooling U Yes, to some degree, but more in a more traditional way
like that that has nothing to do with AI per se, but we um
it impacts us. We've certainly for many years focused on being able to create
a good idea experience, not so much able to in a can we implement
a kind of sense? But is it doesn't flow naturally all the way think
all the way back to query expressions in link, which if you think about
it, they're based on sequel queries for their structure, right, But in
in sequel you say select from where, and in C sharp you say from
where select. So the order of that is. The change in order is
so that you're introducing your variables first, so that the subsequent parts of the
query can use inteli sense. So if you're in a type of head mode,
the things that you're projecting out at the end actually are at the end
by the time that you've established what they are and what they look like.
So that was clearly driven by having a tooling perspective. Yeah, so the
order of things in syntax, well, you talk about regrets for language designers.
I bet the sequel folks load the fact that they put select ahead of
from you know, like they because it's so apparent. Now it's like to
find the sources of data then what you request. I personally think it makes
more sense. Well, it reads more like English. Yeah, and it
also it also is from very general to very specific, right, which is
what compilers like. Yeah. One question that I have I've come across in
my travels a desire to serialize link expressions. Not the implementation, so to
speak, but just like a link expression, you know, like we were
just talking about from X and this and select and all. That would be
very cool to turn that into some JSON, send it over the wire,
and then allow an API, let's say, to execute it. What do
you think about that? I think there are several instances of it out there,
none of already. That's probably true. That's not my fault though I
don't know. But well, the thing is if you if you take a
link query and um, you start with a data source that is I queriable
rather than innumerable, that is, in other words, that is expression tree
based, Well, then the query does in fact become a data structure,
right, The query itself is a data structure, um, and you so
that means that you can you can find a way to serialize that. Now
there's still um if the query is all written out in text, Well,
every every single part of the expression becomes part of the expression tree, and
it's fully like scrutable whatever. The opposite of inscrutable is um an abstraction around
it. But it kind of hurts because you have to take into account every
data type and then every operation for you know, you know, less than
greater than starts with events with like all of those things have to be uh,
you know, it's a great big switch statement. But yeah, I
didn't say it was going to be easy. You can't do it. I
mean, you're you're basically decomposing and deconstructing a select statement and into its constituent
parts and then turning that into data. But h and of course we do
various forms. I mean, if you think about it, uh, something
like endy framework is sort of that. It's just that the serialization format if
you will sequel right right, yeah, very good. So is there anything
new for pattern matching coming in C sharp twelve or do people not even know
what's there in eleven? Um? I think people are still discovering what's there
in eleven. That might be a little more in twelve. We don't have
that much plan in twelve pound matching, But I can't talk about both briefly.
Yeah, I think that's what one of those features that C sharp programmers
are kind of like, huh yeah, that's kind of a head scratcher.
When do I need that? You need pattern matching when you have logic to
select which way to go? That is getting gnarly and hard to hard to
keep in your head. What what pattern matching does, and in particular switch
statements and expressions with patterns do is that they can give you a very neat
list of that under these circumstances. To do this under those circumstances, do
that that is highly kind of like readable um, straight line and readable so
um patterns? Can you know? There are various kinds of patterns. We
only there were only a few patterns when we introduced the overall feature and C
seven and then we've been it's one of those features that we've just been able
to say, Okay, what is the next what would be the next useful
pattern? If you look at a language like f shark, it has a
bunch different patterns. The sort of classic example of a of a pattern in
a functional language actually is a list pattern um where you um, you match
a list, you can match an empty list in one case, and then
you can match um a list that has an element and some remaining you know,
arrest um in another case, or various ways to match a list and
then do different things depending on the shape of the list, very much tailored
to linked the lists and that kind of UM classic functional approach to that UM
And so for a long time we've been mulling what is the Is there like
a non linked list specific counterpart to that that we could add to see shirt
And that's what became list patterns into sharp eleven. So we have a really
good syntax now and patterns to say to you know, you get something in
you say, um, well it's the first element is this and the last
element is that, you know, grab the rest into this variable and then
execute this branch and you know, so um, it's um. It's just
yet another way to decompose your input in a very sixcinct readable way and you
know, check its shape and decompose it at the same time and use the
bits that you drag out of it if you if you indeed match the shape
of the thing. I can imagine like a boolean method is sorted. Yeah,
right, that would be a good UM A good thing to use list
pander matching on UM rather than having to go iterate through everything and determine if
it really is sorted. It could possibly be. Yeah, I'd have to
think about how to how to do that, but yeah, it's it's quite
possible that you could use that in the implementation, certainly if you're doing some
sort of divide and conqueror. I guess, I don't know. It depends
right UM. And so for C sharp twelve, we don't have big new
plans. We we're probably going to expand the reach of list patterns a little
bit to more kinds of types like to innumerables for instance, aren't covered today
UM, and a few other things like allowing the same variable to be used
in multiple disjoint parts of a pattern so you can you know, it's just
various kinds of little optimization. I don't think that's going to be a big
thing in pattern magic. Any other great big wamping features that you want to
lay on us for twelve UM, Well, there are some things that we
would really like to do in twelve. M One is actually the feature that
that triggered us talking about back compat again is UM is what we call field
access in auto properties. So you know, an auto property is a very
tercht int act that just generates a backing field for the property and the getter
and the setter public string food, get set Yeah exactly. Yeah. And
you know, immediately after we added that and we knew that full well,
people will start to climber for a well, can I just do this as
well? And can I just do that as well? And that is sort
of like and we've added little things to auto properties over the years, but
it sort of represents the fact that there's really a cliff where and there still
is where if I wanted to just one tiny little thing, then I have
to expand this out to a full property implementation and a private backing field that
I'm manually declared, or like, can we smooth out that cliff? More
so? The idea here is that if you're if you're writing a property and
inside of an access or, you know, if you don't if an accessor
is not implemented, then okay, that means this is an auto property and
there's a backing field and the access is automatically implemented for you. But you
could also actually have an access or implementation on both could you could pride an
implementation and inside of that implementation, you can reference a generated back you know,
backing field with the with the variable name field. So we've got to
introduce the variable name field variables all over my code. What are you doing
to me? Yeah? Yeah, so that's so that's why we need to.
Um, like, if you were if you were in certain if your
domain is particle physics or agriculture or whatever, you know, field might be
a common common simulator. Yeah, oh yes, yeah, yeah, that's
another one. Um. So that's a kind of feature that we can we
really want to introduce it. There's no like, we could try to come
up with a more obscure keyword instead of field. But who are we helping
if we may get super obscure. Yeah, and this is a this is
exactly the feature that it was so lovely for people to have. But there
are a few places where you will just have to say stut field instead of
field when you're inside, when you're inside of an accessor or property act.
Okay, and that's if you think about it. We already have value in
properties. Value is such a variable, right and people just know that.
Okay, if I have a fuel coal value I can I can have a
fuel coal value, that's fine. But if I want to get at the
field, I just say this stud value instead of value because value is shadowed.
Right, it's not no mystery and it won't be mystery in the future
either with Field if we do it the right way. The only mystery is,
you know, how can I make sure that all the places where I
don't say this dut field today don't get broken in some kind of nasty Yeah.
So, yeah, that's one that we're really eager to do. We
wanted to do it last release, and then this particular issue came up that
we're like, we're about to do it the wrong way. Let's not,
let's try to see if we can do it the right way. And I
suspected you. You only realize that fairly far down the path. It's like,
there's going to be a right and wrong way to do something. Well,
we knew all long, but we because we have that kind of brains,
have been conditioned to work like that, So we knew very early on
that, yeah, this is gonna be a problem. But we were just
reaching for a standard solution quote unquote, which was, well, we'll just
contort ourselves till it fits right, Star of my Life. Yeah, all
right, man's man, it's been great. The hours flown by and that's
that always makes for a good show. So thanks for coming back and keep
us informed. Thanks for having me. It's been a pleasure as always,
all right, and we'll see you next time on dot net rocks. Dot
net Rocks is brought to you by Franklin's Net and produced by Pop Studios,
a full service audio, video and post production facility located physically in New London,
Connecticut, and of course in the cloud online at pwop dot com.
Visit our website at dt n et r ocks dot com for RSS feeds,
downloads, mobile apps, comments, and access to the full archives going back
to show number one, recorded in September two thousand and two. And make
sure you check out our sponsors. They keep us in business. Now go
write some code. CNX time Van