6 ms·
Follow @davidfowl on Twitter/Github and look at "Minimal API" code for beautiful C# code and examples for specific scenarios. C# is VERY different from even ju
by CyanLite2 4y ago
Follow @davidfowl on Twitter/Github and look at "Minimal API" code for beautiful C# code and examples for specific scenarios.
C# is VERY different from even just what things were 2 years ago. You can now build a full-on app with the same number of lines that a Node/Express/Flask app. Except the .NET runtime is about 5-10x faster than those runtimes.
- quickthrower2 4y agoI am a .NET dev not been keeping up admittedly but was blown away by the Blazor docs and what that can now do. HN comments are what made me look. Last time I looked it was a POC. I didn’t realize it had become a thing! It might convince me not to bother learning Phoenix.
- c7DJTLrn 4y ago>Except the .NET runtime is about 5-10x faster than those runtimes. I'm as guilty as anyone for using anecdotal evidence but any reliable numbers that prove this? Stats I recall from years ago showed V8 destroying the .NET CLR.
- SideburnsOfDoom 4y agohttps://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/
- olvy0 4y agoSpecifically, comparing Responses per second between C# and javascript web frameworks: https://www.techempower.com/benchmarks/#section=data-r21&test=query&l=zik0sd-6bj https://www.techempower.com/benchmarks/#section=data-r21&tes... One JS framework smokes, but most of the C# ones are above the JS ones. I don't know what's that "just-js" thing at the top though, I suspect it's not really a framework.
- nkozyra 4y agoPedantically, it's a framework but a very targeted one with its own runtime: https://github.com/just-js/just https://github.com/just-js/just
- CharlieDigital 4y agoAlso worth checking out the gRPC benchmarks: https://github.com/LesnyRumcajs/grpc_bench/discussions/284 https://github.com/LesnyRumcajs/grpc_bench/discussions/284 dotnet is up there with Rust.
- bob1029 4y agoThis is actually in the official documentation now: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0 https://learn.microsoft.com/en-us/aspnet/core/fundamentals/m...
- throwayyy479087 4y agoThis is remarkably different than it was 2012. This is absolutely fantastic news.
- pan69 4y agoThat looks very TypeScript/NodeJS-esque. I am not very familier with the .NET ech system. How do you write tests for some of these API examples? E.g. in the NodeJS eco-system we have e.g. Jest with Superserver and Nock (for mocking/intercepting outgoing requests). What does a typical test suite in a .NET core project look like?
- c0wb0yc0d3r 4y agoA basic example looks like: https://github.com/davidfowl/CommunityStandUpMinimalAPI/blob/main/TodoApi.Tests/TodoTests.cs https://github.com/davidfowl/CommunityStandUpMinimalAPI/blob... Some more documentation on integration tests: https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-6.0#basic-tests-with-the-default-webapplicationfactory-1 https://learn.microsoft.com/en-us/aspnet/core/test/integrati...
- CharlieDigital 4y ago> C# is VERY different from even just what things were 2 years ago C# and TypeScript are converging (both from Anders Hjelsberg). Small repo here showing just how similar they are syntactically: https://github.com/CharlieDigital/js-ts-csharp https://github.com/CharlieDigital/js-ts-csharp I'm surprised we don't see a bigger uptick in C# usage given the growth of TypeScript and how similar the two languages are. If you know C#, it's pretty easy to pick up TypeScript and vice versa.
- Scarbutt 4y agoI'm surprised we don't see a bigger uptick in C# usage given the growth of TypeScript Because why dabble in two languages/ecosystems when the project can get by with one(TS)?
- CharlieDigital 4y agoTS is great for the front-end where JS is inevitable, but I find not a great choice for backend work. Node runtime is overall more prone to security threats (prototype pollution attacks, rogue packages, etc.). See GitHub's 2020 State of the Octoverse report for details [0]. With the Node ecosytem, there is a very large dependency tree that creates a large surface area for security risks. Then you may be dependent on the community to find and and patch. With dotnet, at least Microsoft has professional, paid engineers maintaining a broad set of base class and first party libraries which provides a LOT more functionality out-of-the-box. For some workloads, having the higher throughput of dotnet is also a boon. [0] https://octoverse.github.com/2020/ https://octoverse.github.com/2020/
- auraham 4y agoThanks for the repo! I love to compare programming languages side by side as you did. For example, a few months ago I was learning about Java streams, but they looked a bit convoluted to me, especially the collectors. Then, I reviewed the same concept in Elixir and then it was clear to me why the collectors are needed.
- pan69 4y agoA programming lanaguage is only a relatively small aspect of making software. The eco-system is far more important, i.e. frameworks, libraries, tooling, etc. Personally, the majority of my day-today work is TypeScript/NodeJS and the reason I don't use C# is that I just don't want to be stuck in Microsofts eco-system.
- hbrn 4y ago> Except the .NET runtime is about 5-10x faster than those runtimes. Which is going to be irrelevant because your app performance will be mainly limited by network/database.
- CharlieDigital 4y agoWith asynchronous execution, it means that you'll get more throughput from a single node.
- generichuman 4y agoDepends on the network and the database. Measure, always. That assumption is harmful to people who don't know better.
- rhaway84773 4y ago5-10x faster usually also means that it makes far more efficient use of resources, so if you’re running something in the cloud, you can achieve the same throughput at a lower cost and are more resistant to spikes.