4 ms·
Why would I use C# over any other language though?
by shepherdjerred 2y ago
Why would I use C# over any other language though?
- CharlieDigital 2y agoIt's very productive and kinda nice. Especially for big backend APIs: https://typescript-is-like-csharp.chrlschn.dev/ https://typescript-is-like-csharp.chrlschn.dev/
- jayd16 2y agoC# has a strong high level feature set and lower level tools to keep performance up. The language itself is well designed and consistent. Its able to mix functional and OO features without being dogmatic, leading to better dev-x over all. ASP is actually very good these days and feels cleaner than Spring Boot. There's less choice but the available choices are good. It has arguably the best gRPC implementation. It's just a nice experience over all.
- deleted 2y ago[deleted]
- hu3 2y agoLINQ alone is unmatched.
- CharlieDigital 2y agoAddendum: having `Expression`[0] type representing the expression tree is a really killer feature. I've been doing a writeup comparing how ORMs work in TypeScript vs ORMs in .NET and one thing that is magical is that having the `Expression` type enables a much more functional and fluent experience with ORMs. [0] https://learn.microsoft.com/en-us/dotnet/csharp/advanced-topics/expression-trees/ https://learn.microsoft.com/en-us/dotnet/csharp/advanced-top...
- fireant 2y agoLINQ in EntityFramework certainly isn't perfect, but frankly it's so far ahead of anything else available in all other languages. It was a brilliant idea to add expressions type into the language AND to create a standard set of interfaces that enable collection interop AND to to then create universal clients for local and remote collections that use all this machinery to deliver first class DX.
- int_19h 2y ago"All other languages" is a stretch IMO. Any language that has proper macros (e.g. Rust, Clojure) can do something LINQ-like as well as C#.
- CharlieDigital 2y agoCan you post some examples? Having been working in TS with Prisma for a bit, what stands out is how a Prisma query is effectively trying to express an expression tree in structural form An example on TS with Prisma: const loadedAda2 = await tx.runner.findFirst({ where: { email: 'ada@example.org' }, include: { races: { where: { AND: [ { position: { lte: 10 } }, { time: { lte: 120 } }, { race: { name: { contains: 'New' } } } ] } } } }) (Other query tools like Kysely end up using strings (though with the support of TypeScript at dev time)) And the same in C# with EF and LINQ: var loadedAda = await db.Runners .Include(r => r.RaceResults.Where( finish => finish.Position <= 10 && finish.Time <= TimeSpan.FromHours(2) && finish.Race.Name.Contains("New") ) ) .FirstAsync(r => r.Email == "ada@example.org"); The difference being that the C# code is actually passing an expression tree and the code itself is not evaluated, allowing C# to read the code and convert it to SQL.
- int_19h 2y agoTS does not have macro facilities. Proper macros operate on AST, which it to say, it is exactly like the Expression stuff in C#, except it can represent the entirety of the language instead of some subset of it (C# doesn't even fully support the entirety of System.Linq.Expressions - e.g. if you want LoopExpression, you have to spell the tree out explicitly itself).