News for hackers. Stuff that matters.
Re:TypeScript 5.0 by jdthedisciple on Thursday March 16, 2023 @03:19PM (#35186931)
Have you tried C#? Sounds like it would fit your needs perfectly, additionally benefitting form a huge ecosystem behind it.
Re:TypeScript 5.0 by rrishi on Thursday March 16, 2023 @05:21PM (#35188846)
How does the verbosity in C# compare to Java's? And are big C# codebases littered with annotations and "dependency inversion" Java Spring boilerplate-y crap?

I ask because I have never delved into C# only heard it's Microsoft's Java. And I am no fan of the original Java at all so C# gives me pause.

Re:TypeScript 5.0 by cutler on Thursday March 16, 2023 @05:42PM (#35189121)
C#11 defaults to nullability and has top-level functions giving it a big advantage over Java. The idiomatic Pascal case takes some getting used to but it's worth it.
Re:TypeScript 5.0 by rrishi on Friday March 17, 2023 @10:05AM (#35197219)
Thanks for the overview. Hopefully I can give the language a shot when time permits.
Re:TypeScript 5.0 by theshrike79 on Thursday March 16, 2023 @05:27PM (#35188922)
C# is pretty much Java done right.

Speaking as someone who started with Java 1.2 and saw all the crap that happened to it.

C# is currently lightyears ahead of Java in every way, especially now that MS is not Micro$oft to people on the internet any more =)

Re:TypeScript 5.0 by kaba0 on Thursday March 16, 2023 @07:04PM (#35190178)
> C# is currently lightyears ahead of Java in every way

Let’s not claim things that can’t be objectively proven. C# does have much more features than Java, but that is not necessarily a plus in case of a programming language. There are features that are definitely better, but I am not bought that the whole would be.

Plus, ecosystem-wise Java is much bigger and much more open-source. The runtime is also better on the JVM-side, though this is offset by C# expressing more low level details.

Re:TypeScript 5.0 by postdb on Friday March 17, 2023 @02:37AM (#35193951)
Also C# is really meant to run on MS servers (Azur). Yes you can compile C# asp core projects on Linux, but the hell of dll when the there are many projects in a solution is quit annoying. Development experience in C# without Visual Studio is quite cumbersome.
Re:TypeScript 5.0 by theshrike79 on Friday March 17, 2023 @02:45AM (#35194010)
Nope. This is the M$ == bad era thinking.

I've been doing C# on a MacBook with JetBrains Rider for years. Some code runs in Linux containers, some on AWS Lambda.

Re:TypeScript 5.0 by pjmlp on Friday March 17, 2023 @04:31AM (#35194602)
Nope, see you're using Rider, because VS4Mac and VSCode only offer a subset of Visual Studio capabilities for .NET development.

I rather do .NET than Java, but the FOSS story isn't as Microsoft sells it, hence why on our agency .NET is mostly used on Windows projects, and usually loses against Java or node in UNIX like RFP, even after .NET Core reboot, because of dependencies and existing enterprise tooling.

Re:TypeScript 5.0 by tester756 on Thursday March 16, 2023 @06:43PM (#35189942)
We don't do annotation-oriented-programming in C#

DI is almost always in web, but via constructor instead of annotations.

Re:TypeScript 5.0 by WorldMaker on Thursday March 16, 2023 @07:00PM (#35190146)
Recent versions of C# have expressly been working to minimize/eliminate verbosity. Things like namespace statements (rather than { } blocks), global usings, top-level statements, record types (by default structurally compared, immutable data structures defined often only by their constructor and nothing else), and much more.

Similarly recent libraries such ASP.NET have been working hard to use more of these things to eliminate their own boilerplate. The latest ASP.NET templates use top-level statements and some global usings and are getting very lightweight in terms of starter-level code.

.NET does have annotations and dependency inversion, but those too tend to avoid boilerplate more than create it. Few annotations are "required", depending on your domain and which libraries you are expecting to use. .NET now has a single, mostly standardized dependency injector that almost everyone has agreed to use (Microsoft.Extensions.DependencyInjection) at this point. It intentionally only supports a bare minimum of Dependency Injection needs and is nothing like the Kitchen Sink approach of something like Java's Spring. (For instance, zero out of the box support for wiring Dependency Injection via XML files. .NET's DI is always code driven, often in a Startup.cs, Program.cs, App.cs, or Main.cs file.)

I've been increasingly finding in C# that I'm writing new code with zero templates and almost no snippets-expansion. (There will always be plenty of legacy code out there with much more verbosity, of course.)

The easiest suggestion is to try it for yourself. The `dotnet` tool is cross-platform, generally an easy install, and its `dotnet new` command will help you try many easy template types. You can relatively easily work entirely in VS Code today (as opposed to older versions of C# often "needed" the full bulky Visual Studio install for templates, language servers, and other stuff).

Re:TypeScript 5.0 by rrishi on Friday March 17, 2023 @10:03AM (#35197207)
Thank you for such a well written and detailed response. Gave me a fair representation of C#.

I do hope to try it maybe in recent future.

Re:TypeScript 5.0 by MrJohz on Thursday March 16, 2023 @05:32PM (#35188991)
C# doesn't have algebraic data types and pattern matching though, right? I'm not the same person, but at least for me that's one of the big advantages of Rust, and it's one of those features that outside of Rust you only really find in ML-family languages. I know it's possible to simulate it partially using sealed classes in some languages, but that's always seemed like a lot of boilerplate in comparison.
Re:TypeScript 5.0 by roebk on Thursday March 16, 2023 @05:56PM (#35189332)
Pattern matching was recently added to C#. I can't say quite how well it's been embedded into the language. I always hear great things about F#, ADTs, pattern matching, nice type system and it integrates nicely into the rest of the .NET ecosystem.
Re:TypeScript 5.0 by physPop on Thursday March 16, 2023 @06:03PM (#35189426)
F# is great. Simple, small, straightforward, great interop with .NET
Re:TypeScript 5.0 by spion on Saturday March 18, 2023 @09:35PM (#35215081)
Also, the requirement to manually order the compilation units (files) in an XML file to ensure the compiler doesn't get confused.

They had me at features, lost me at manual compilation ordering.

Re:TypeScript 5.0 by WorldMaker on Thursday March 16, 2023 @06:05PM (#35189446)
C# has a lot of pattern-matching support today, including an expression-switch form: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...

C# can fake algebraic data types in some ways/some cases. Though if you are expecting to do a lot of it you are still better off in F# or C#/F# hybrid projects. (F# of course being a proper ML-family language.)

Re:TypeScript 5.0 by virtualwhys on Thursday March 16, 2023 @06:19PM (#35189620)
> it's one of those features that outside of Rust you only really find in ML-family languages

Or in Scala, technically not an ML, but is as close as you'll get in a nominally typed language.

    enum RGB:
      case Red, Green, Blue

    def log(x: RGB) = x match
      case Red => print("red")
      case Green => print("green")
      // error, not exhaustive
Obviously Scala can do a lot more, including GADTs, which Rust will never have until HKTs are supported.

Ton of powerful languages to choose from these days, good times...

Re:TypeScript 5.0 by spion on Thursday March 16, 2023 @06:24PM (#35189682)
I did, and I should've listed it. Its my third favorite typed language. At the time I was trying it, its type system wasn't as expressive as TS is today (no algebraic data types, no Result<T> error modelling in the type system etc), but LINQ with its clean syntax and ease of use is something I've missed in every language since (scala `for` syntax looks really awkward by comparison).