4 ms·
So I guess we've had 'JavaScript but like C#', in the form of TypeScript; so I suppose now we get 'C# like JavaScript'? I must admit, I find this amusing. I su
by ddek 5y ago
So I guess we've had 'JavaScript but like C#', in the form of TypeScript; so I suppose now we get 'C# like JavaScript'? I must admit, I find this amusing.
I suppose this raises two questions: "Why use C# like this in place of express or koa on node, which idiomatically similar?", and "Why use C# like this instead of C# like that (the way all other AspNetCore apps do it)?"
- nodejs_rulez_1 5y agoThey neither broke the type system to make it weaker nor did they stick a browser engine where it doesn't belong.
- andix 5y agoYou still get C#/.NET, with it's superior performance and type safety, but just without all the OOP bloat.
- LAC-Tech 5y agoWait, you think this is not OOP? var app = WebApplication.Create(args); app.MapGet("/", () => "Hello World"); app.Run(); You're creating an object and calling methods on it..
- andix 5y agoThis is more functional. C# is an multi paradigm language. There is not a big difference between an FP module and an OOP static or single instance class.
- LAC-Tech 5y agoI think the word OOP has lost all meaning and just means "crusty old code I hate".
- andix 5y agoIn the OOP way you create controller classes. In the FP way you pass lambdas/functions. So yes, it’s not 100% functional. But probably 80%?
- LAC-Tech 5y agoYou're creating an instance of an app class, calling methods on it, and passing objects in that method (string and lambda are objects). I just feel like the term OOP can't win here. If it's concise people will just claim it's FP.
- andix 5y agoOff course there is still OOP involved. Also most FP languages support objects to some extent. Also records and their modules have some similarities to OOP. And even FP can be never completely pure, there always has to be state. But this approach is just more functional than the one before.
- arethuza 5y agoAlso MapGet seems to be changing the state of the WebApplication object... which doesn't seem to be very functional?
- jeswin 5y ago1. The web server component could be fronting a middle-tier written in C#. There are numerous advantages to doing this in .Net over Node. 2. Performance. 3. Native AOT is coming in 6.0. Meaning, you get a native platform specific app which can run without the framework - like golang. But with GC, so not like C/C++/Rust.
- GordonS 5y agoI've been using C# since it was released, and I'm a huge fan. But I can almost guarantee that native AOT doesn't appear with dotnet 6 - they've been promising it for several years, and it's become Microsoft's Duke Nukem Forever,
- merb 5y agoyeah and the sad thing without NativeAot there won't be the WebAssembly things which we would like. the way it works now is way too lazy for anything real world. (compiling the runtime to wasm and loading dll files...)
- ripley12 5y agoNativeAOT is supported in more places in .NET 6, there has been a tremendous amount of work to ensure that libraries are trimmer and linker friendly. But I believe ASP.NET’s targeting .NET 7 for that.
- stevefan1999 5y agoI don't get it why people always hated (tracing) GC. Unless you are working on a hard real time systems such as DSP or audio synthesizer, having some kind of GC is always the boon. Not only you can run code faster in some case (by suspending GC in some critical code and just do plain allocate and resume GC at a later time, and this is also how you make it more real-time compatible), it can also help curb fundamental security issues such as dangling pointers and use-after-free. GC is also not the blame to the bloated size of your app, Nim [1], for example, is a language with GC/runtime while being lightweight. Another honorable mention would be Haxe [2] for gamedev, where it can generate much more compelling C++ code that the binary size is just slightly bigger to what you normally do with C++ while having much less lines needed to code. And it has a tracing GC. So I do think GC-enabled language can be like C/C++/Rust. Even if there is a binary and performance difference, it won't be huge. But the way it makes your program safer by a huge margin and your programmer less mentally pain, makes having GC a huge difference. By the way, even smart pointers/move semantics and ownership are one kind of GC (by leveraging linear/affine logic to ensure resources will not drop out of its controllable/life phase commonly called lifetime), so most of the time what I refer to GC is more specifically tracing GC where mark-and-sweep algorithms that usually need to stop-the-world is indeed a fundamental problem in GC design especially for multi-core platform which is going more and more popular nowadays. [1]: https://nim-lang.org https://nim-lang.org [2]: https://haxe.org https://haxe.org
- stevefan1999 5y agobecause you dont want to work with a broken module system? im talking about you, ESM, for all the headaches you induced me on TypeORM and NestJS. I really miss the proper Java packages and dotnet namespaces design
- flohofwoe 5y agoThe same can be done in pretty much any other language, it's just a HTTP server wrapper which maps specific URL paths to callback functions which return a HTTP response. E.g. in Go: https://gobyexample.com/http-servers https://gobyexample.com/http-servers, or in Python via Flask: https://flask.palletsprojects.com/en/2.0.x/quickstart/#routing https://flask.palletsprojects.com/en/2.0.x/quickstart/#routi...
- kevingadd 5y agoI think the fact that this maintains type safety, IDE integration and other useful traits of modern C# like zero-allocation primitives gives it a leg up over TypeScript/JS in some cases.
- oaiey 5y agoIt is about attracting new developers to .NET. Boilerplate does not help. So it boils down what the cool kids consider simple: Express + node.js => ASP.NET Core Minimal API. Evolve or die. When you see the releases in the last 5 years, C#/.NET tries to evolve and stay relevant. Do we need to like that: No. Is it necessary for .NET: Yes.