Live data from Hacker News

Official proposal for Type Unions in C#

github.com

161–170 of 315 posts

Re: Official proposal for Type Unions in C#

#161
post #4
post #3

Huh, I did F# for years with discriminated unions, and I guess I just assumed C# would have had them by now. I know not everyone likes them, but for typed languages I find it extremely hard to go back to languages without ADTs of some kind. I do Java for my current job, and Java is generally fine enough, but it's a little annoying when I have to do whacky workarounds with wrapper classes to get something that would b…

F# is so hard to walk back from. I wish Microsoft would support it better and actually push it, because it's such a perfect sweet spot. Most of the functional advantages without being shackled to pure functions and the like is so easy to develop in. Instead they've been, very slowly, turning C# into F#, which is even weirder to watch.

Looking at the syntax in the type union proposal, I hope they take a bit more from F#. It really needs some work.

Re: Official proposal for Type Unions in C#

#162

Earlier quoted context omitted.

You must really hate REPLs. You cling to your ADTs, I cling to my REPLs.

I've seen comments like this a few times, and I think there's a misunderstanding at play. I think people who are used to using REPLs look at people who aren't and conclude that, since they don't have a REPL in their toolbox, they don't have a tool in there that does what a REPL does. But I think most of the time, they are accomplishing the same tasks with a different workflow. For instance, I use throwaway files inst…

There's a really nice VS Code extension called Polyglot Notebooks that's great for running small C# "scripts"

Re: Official proposal for Type Unions in C#

#163
post #53

Earlier quoted context omitted.

Maybe I'm off, but to me the gist of the expression problem can be explained by contrasting how code extensibility is achieved in OOP/FP. OOP Approach with interface/inheritance: Easy: Adding new types (variants) of a base class/interface. Hard: Adding new functionality to the base class/interface, as it requires implementing it in all existing types. FP Approach with Discriminated Unions: Easy: Adding new functions.…

I think you've nailed the definitions. However the definitions make the 2 choices (adding new types vs adding new functions/operations) sound like a toss-up. It is the fact that I tend to find the FP/DU approach so much more frequently useful for my/my team's own code that makes me wonder if I'm missing something. Perhaps the important distinction I've been missing is in Wikipedia's definition: "The goal is to define…

What do you do when you are handed a DLL with publicly exposed types? You can't recompile someone else's DLL without the source, but the public non-sealed types are totally open to inherit from; it's just a question of how useful the inheritance would actually be if there's not a logical public interface (as provided by the original designer).

Maybe you can read all the public fields, but you can't actually modify them or create functions that modify the object. You then must wrapper around the instances and fight to bridge every little behavior between their code and yours.

This to me is evidence that one core tenet of OOP "Open to extension" is in-practice meaningless.

Re: Official proposal for Type Unions in C#

#164

Earlier quoted context omitted.

I've been writing C, C++, C# and some js/sql/ts/python for money. Lua for lulz. And *nothing* gets even fucking close in terms of productivity to C#. Great language, mature and robust ecosystem with sane compilation times and great tooling: package manager, test runner, strong debugger, one CLI with almost all tools needed. I wish C++ was half as enjoyable as C# is.

I'm a Linux user who prefers open-source tools. I not a fan of Microsoft's programs, tools, editors, etc. What would you suggest I do to be productive with C#?

It's remarkably disappointing to see this question downvoted. I had the same thought, but this makes me wonder if it's just a bad culture fit from the start. I've been Linux-only now for 15 years and haven't used an IDE in well over 10. I use vim (neovim now) exclusively. Given my characteristics, should I just squash my curiosity and do a pass on C#? Do C# people not see value in open source? Is there low tolerance in that community for people who have those values?

Re: Official proposal for Type Unions in C#

#165

Earlier quoted context omitted.

I've been writing C, C++, C# and some js/sql/ts/python for money. Lua for lulz. And *nothing* gets even fucking close in terms of productivity to C#. Great language, mature and robust ecosystem with sane compilation times and great tooling: package manager, test runner, strong debugger, one CLI with almost all tools needed. I wish C++ was half as enjoyable as C# is.

> And nothing gets even fucking close in terms of productivity to C#. C# gets compared to java a lot for a good reason, and yet the languages and ecosystems have since diverged in their priorities and abilities. This gets even more complicated when considering F# and Scala. Do you think Java would offer similar productivity, or are there aspects to the C# that are—in your personal experience—uniquely productive?

I wrote c# professionally for 8 years and now have switched to a codebase mostly in Java and some kotlin. I know some of this is learning curve but none of those things mentioned are anywhere close in JVM. Build systems, package management, close IDE integration for test runners, builds, etc. The ability for the IDE to even know what version of Java you want the project to run in even though it's defined in the project doesn't exist. Kotlin as a language does some nice things but even the syntax highlighting is better with c#. Async is trivial in c#. The orm makes it so you can write db queries in c# with Linq and not have to mess with SQL. SQL injection isn't even a thing I ever had to think about but now I have to write actual SQL inline with my code to do any sort of non trivial queries. Were using maven which is apparently older than gradle so maybe that is better but having to remember do clean then compile before any type of build required action has caught me with so many things. Like migrations or tests including non existent files. There are more things that drive me crazy but this post will get unreadable and it's ranty enough as is.

Re: Official proposal for Type Unions in C#

#166

Every time the question of preferred programming languages comes up, I'm usually in the extreme minority with my preferences being Rust (for small/fast) and C# (for productive and easy, where GC is acceptable), a combination that doesn't seem to appeal to too many people. But for the projects that fall right about in the middle where it could go either way and I could see either language working, I almost always pick…

I've been writing C, C++, C# and some js/sql/ts/python for money. Lua for lulz. And *nothing* gets even fucking close in terms of productivity to C#. Great language, mature and robust ecosystem with sane compilation times and great tooling: package manager, test runner, strong debugger, one CLI with almost all tools needed. I wish C++ was half as enjoyable as C# is.

Typescript is pretty competitive with C# on those factors in my experience. What do you find yourself missing there?

Re: Official proposal for Type Unions in C#

#167

Earlier quoted context omitted.

Nah, people continue to pick Java or Go when they want to build their enterprise systems if they're not already married to Microsoft. There's not a single widely distributed infra application in C# out there. When people want to build stuff like kafkas, kubernetes, consuls, they still go to Java/Go/C++.

> There's not a single widely distributed infra application in C# out there. Azure has entered the chat. Microsoft Orleans has entered the chat. ASP .NET Core has entered the chat. Ever played Halo online? Used StackOverflow? (very likely) Visited any website on Azure? (most likely) Microsoft Orleans (Virtual Actor framework) powers the Halo server infrastructure since at least 2011 if not sooner, which arguably the…

None of those are "widely distributed". They're all things that either MS themselves or MS-oriented shops run internally.

No-one's writing a database server or identity management system or source code repository or business intelligence tool or even something like a linter in cross-platform C#. Unless you're a Windows shop, it's just not a first-class ecosystem.

Re: Official proposal for Type Unions in C#

#168

It’s ironic when things like this get added back into C-styled languages that were intended to be easier than their predecessors. Seems more confusing than useful. Wish they’d stop adding onto this ever expanding language. It’s like these people get bored of plain old functions and objects, read an academic paper and go “i think I’ll add that next”.

> Seems more confusing than useful.

Are you suggesting that these design decisions make it through the entire process and into the language without the feature bringing a clear advantage in its use case? What would you say are the worst two or three of these C# features approved in the last decade?

Let’s assume for the sake of argument that you are correct though. The Roslyn compiler diagnostics are second to none, and pretty much any of these features will have corresponding analyzers to help remove some of that confusion, with documentation links being automatically provided if used incorrectly.

These guys aren’t writing feature proposals the way you write comments.

Re: Official proposal for Type Unions in C#

#169

Earlier quoted context omitted.

I'm a Linux user who prefers open-source tools. I not a fan of Microsoft's programs, tools, editors, etc. What would you suggest I do to be productive with C#?

It's remarkably disappointing to see this question downvoted. I had the same thought, but this makes me wonder if it's just a bad culture fit from the start. I've been Linux-only now for 15 years and haven't used an IDE in well over 10. I use vim (neovim now) exclusively. Given my characteristics, should I just squash my curiosity and do a pass on C#? Do C# people not see value in open source? Is there low tolerance…

Strong advocate of open source here.

That said, in an enterprise setting, for all of Microsoft's other faults, C# is damn near bullet proof. Some enterprises, like mine, can't rely on community supported tooling for life-critical systems. If something breaks, we're near instantaneously on the phone to a dedicated support rep to fix the problem.

I learned C# and Java years ago during my IT degree but had long since forgotten them. The enterprise I work in uses C# a fair bit.

Only started to pick up C# again in the past few months, and holy heck, I forgot how pleasurable it is to work in C# again.

If the third-party components used in some software I help maintain supported JetBrains Rider, I'd use it in a heartbeat.

Visual Studio (not Code...) is okay, though I'm not tripping over myself to use it. PyCharm and IntelliJ have spoiled me.

Re: Official proposal for Type Unions in C#

#170
post #167

Earlier quoted context omitted.

> There's not a single widely distributed infra application in C# out there. Azure has entered the chat. Microsoft Orleans has entered the chat. ASP .NET Core has entered the chat. Ever played Halo online? Used StackOverflow? (very likely) Visited any website on Azure? (most likely) Microsoft Orleans (Virtual Actor framework) powers the Halo server infrastructure since at least 2011 if not sooner, which arguably the…

None of those are "widely distributed". They're all things that either MS themselves or MS-oriented shops run internally. No-one's writing a database server or identity management system or source code repository or business intelligence tool or even something like a linter in cross-platform C#. Unless you're a Windows shop, it's just not a first-class ecosystem.

No linters in C#? That’s a good one.

C# as a language has always been cross-platform.

Though the last few versions have made incredible gains in performance optimizations. You won’t get the flexibility of C++ but the performance comes close to it in most cases, when written optimally.

And you don’t have to deal with arcane, bullshit build systems with a learning curve that is worse than the language, and breaks down on every OS major version update (or its own version updates).

Post reply on HN