by CharlieDigital · 2y ago · 0 comments
> After excel, probably the second best thing Microsoft has ever released. Turns .NET into a reasonable platform.
I feel like C# is quite underrated. Very productive language that's relatively easy to teach to anyone that is already familiar with JS or TS. Used in a variety of contexts from game engines to enterprise backends to desktop apps.A few fumbles by Microsoft early on stunted its growth, IMO, but it's a really good and relatively easy to learn general purpose language.
Microsoft really, _really_ missed out on a huge opportunity to rebrand .NET into something else when they did the Framework -> Core transition. Despite .NET being cross platform for over ten years and winning benchmarks left and right people still see it a the “slow enterprisey framework that only runs on Windows”.
I've met a handful of folks who used it in the .NET Framework days and hadn't kept up with the changes in Core (multi-platform, object-functional hybrid, minimal syntax for console and APIs, etc.).
https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/to...
(If there’s other syntax changes, I don’t know them, AFAIK it’s the same C# you write)
It's a beginner friendly and "demo mode" set of features to reduce boilerplate for small programs, such that the minimal "hello world" program is literally 1 line of code.
And a working minimal ASP web app with a http endpoint is not much longer.
C# and .NET was from day 1 designed for "programming in the large" so that large codebases can be sensibly organised.
This however causes some overhead, such that a person coming from Python might have looked at the standard C# "hello world" example with using statements, namespace, class and method wrapping the 1-line payload, and conclude that the language is impossibly clunky and cumbersome. My opinion is the opposite; managing e.g. 50K lines of code without those ways of organising code, is going to be impossibly clunky and cumbersome.
However, it is also true that demo mode is great for 1-file demos that get right to the point.
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/m...
Do these people I've never heard of outnumber the people who did upgrade but wouldn't have if it had been branded as a separate product?
Mind you, I’m not a coder, and more just a Linux homelab hobbyist.
How heavy of a dependency is it?
And is there a dependency hell situation, if different programs require different versions of .NET Core?
Size very much depends on what you actually use in the app, but on the order of tens of megabytes.
Pretty much yes. (there are also other ways to bundle it)
It's not even called ".NET Core" any more, it's just ".NET", which for version >= 5.0 effectively is the successor to cross-platform .NET Core.
.NET 9.0 will be out shortly - The annual release is expected November 2024, likely this week.
You may still find some JREs, which are created by some distributions that take the stuff out of the JDK to make classical JRE, though.
What should be "do a thing" is now design a thing to do a thing then call the thing-do-er IDoAThing.
Alone this would not be so bad but the problem is that you only have this. Extension methods? Fuck off (but don't take them away).
Roslyn is great though.
Also, extension methods are great. LINQ is amazing and that's partly from extension methods.
You can call it a hack but IMO you get the best of both worlds.
It's adding optionality and in fact, doesn't in any way break OOP at all; it is syntactic sugar.
There's reflexivity and path dependency but the culture is downstream of the values for the most part.
> C# culture is closer to enterprise Java than it is to Typescript
I mean, this really depends on what you're looking at.Here's a sample from the MongoDB client: https://github.com/mongodb/node-mongodb-native/blob/main/src...
Here's a sample from Storybook: https://github.com/storybookjs/storybook/blob/next/code/core...
Here's a sample from Prisma: https://github.com/prisma/prisma/blob/main/packages/client/s...
Here's a sample from Cal.com: https://github.com/calcom/cal.com/blob/main/packages/core/Ev...
These are all fairly mainstream repos so it's not a one off to see "enterprise" style coding in TypeScript.
It's rather the specific use case that determines the style of the code that's written. In the examples above, there's no need for the teams to choose JavaScript classes and inheritance to model the logic, yet it likely better fits the programming model of those modules.
Look at Nest.js as well: https://github.com/nestjs/nest/blob/master/packages/core/rou...
The whole codebase of Nest.js looks an awful lot like Spring or ASP.NET (controller syntax) probably because there's a lot of crossover in terms of what APIs need at scale and how to logically organize that logic.
It just so happens that most use cases for C# and Java favor applications at a larger scale. Another key difference being object scope and lifecycles -- something that rarely comes into play in the generally single-threaded Node runtime. This being one of the key reasons why dependency injection is a thing in C# and Java land.
I kind of think the best languages would be those that make creating layers of spaghetti indirection nearly impossible. In practice, it's usually much more specious. Names like "CreatorImplementer", "FactoryAbstrator", "DeviceAccessory" and a half dozen equally amorphous things calling each other as if Thomas Pynchon was writing software.
I think I've seen it in all languages I've worked on professionally. Maybe not in Perl.
I think that F# goes a long way to prevent this, by nature of being functional.
Are you taking about the popularity of the mediator pattern (via Mediatr)?
Additionally, Microsoft has an outsized influence on the C# ecosystem. As a result, they wrote quite a few architectural and style guidelines that, naturally, target themselves. It makes sense for a hyper-widely distributed library to consider things like binary compatibility as critical features, but the design rules that follow from that have zero utility for apps, and low utility for most libraries. The C# ecosystem also has an unhealthy veneration for MS provided code. While I'm sure most of the authors are quite competent, there's less experimentation and fewer hidden gems because the ecosystem is tilted towards being followers behind the framework providers path.
As a result, it's much harder to refactor code in that style than code in a less (runtime) flexible style, and it's worse when the libraries heavily used are frameworks that have so many extension points. There's a tradeoff between runtime flexibility and codebase flexibility, and the default .NET C# style heavily leans towards runtime flexibility, which isn't a good tradeoff for most software.
MediatR is part of the problem, yes. Way too much attribute/reflection magic there.
One particularly good example is: attempt to add full support (i.e. query text generation) for PERCENTILE_CONT to EF. That will give a good idea of just how bad the idiomatic C# style can get. Now take the EF style of code/architecture and apply it to an entire product codebase - which is completely a understandable mistake to be made (it's not unreasonable to assume that EF would be a good example of C# code). You know you have a problem when you throw in the towel and have ThingDependencies classes all over the place. The aspnetcore internals don't vary too much from the abomination that is EF.
"Just don't code like that," you might say. The problem with that argument is that pre-existing code exists, people don't code in isolation, and the cargo cult has a ton of momentum behind it.
> your comment about F# being different.
You'll struggle to write that style of code in a functional language. There is such as thing as healthy friction. F# has its own problems, but this is not one of them.
My experience is that it's "fire and forget"; never give it much of a thought at all and isn't much different from:
// some-module.ts
export const someModule = () => {
}
// other-module.ts
import { someModule } from "some-module"
Except that DI allows "importing" at different levels.That’s fair, I consistently underrate it myself. Last time I worked with C# was a big messy codebase written by mostly junior developers who didn’t understand what entity framework was doing behind the scenes. I came away from that experience with the impression that C# is a terrible language.
I say all this as someone who loves F# and would only take a C# job if I needed the money. But certainly a lot of the enterprise antipatterns can be clumsily implemented in F#, while a well-written C# codebase is usually pleasant and productive. In particular F# doesn’t totally escape problems like “the Nuget service locator is overengineered for our needs, but we are on a deadline and an excessive abstraction is better than hard-wiring everything.”
And line for line, F# is more effective at getting things done (and i would argue with less bugs)
What about Java?
IMO to be productive in F# code code tends to be simpler - many patterns that dev's valued learning in a OO context become a little obsolete or less needed as a whole. This is my anecdote but it is the C#/Java/etc crowd that tend to have the most negative immediate reaction to F# - they ask "where is X" and often I immediately say "X is bad, you shouldn't need X - think about why". They associate X with some kind of power/productivity gain, but don't realize there is many ways to do things. Kind of follows the paradigm of "frameworks/patterns are missing language features".
If they keep at it then it eventually clicks but there is almost a psychological "unlearning" that needs to be done which at least in the C# camp creates an almost tribal tension between the two camps - its just too unfamiliar. Whereas for example TS dev's seem to find it somewhat familiar in parts; even people only ever done JS previously I've found have become good F# dev's. Could be because the flow more suits the way you would code in a dynamic language while still being strongly typed (e.g. REPL's, type inference, static modules, functions over classes, etc).
Check out my small repo here showing how similar they are: https://github.com/CharlieDigital/js-ts-csharp