News for hackers. Stuff that matters.
Re:.NET 8 by Thaxll on Tuesday November 14, 2023 @11:39AM (#38265664)
Big difference is that Go is stable and conservative, net core keep adding a billion features every release. Looking at some net core 2/3 stuff and now to see how many things changed.

Good luck with your code base in 5 years when someone decide to add all the new stuff.

Re:.NET 8 by chrisandchris on Tuesday November 14, 2023 @12:02PM (#38266047)
I don't know Go that much, but the part about .Net is so untrue. First, C# was published in 2001, while Go was released in 2009. So there's 8 years of "more stuff".

Also (see in comments too), upgrading .Net is very easy. There are man not-to-small codebases can be "easily" upgraded from .Net Core 3 to 8 without any hassle. Backwards comptability was always baked into Microsofts thinking.

.Net 7 and 8 did also (IMHO) not contain that many groundbreaking features, just some "smaller" stuff.

Re:.NET 8 by Thaxll on Tuesday November 14, 2023 @02:45PM (#38268538)
Do you want to compare the number of features added between go and c# in the last 15 years? Just a single major release of C# added more stuff than probably the last 15 years of Go.

I'm not saying Go is 100% right in that, but it's much more conservative about stuff added into the language.

Re:.NET 8 by HackerThemAll on Tuesday November 14, 2023 @03:29PM (#38269264)
Of course, they conservatively added the most idiotic way of formatting dates as strings (while knowing other methods exist). And, while the whole bunch of other languages would call a method string.startsWith("a"), they use hasPrefix. This language is a mix of half-baked concepts and utter trolling. If I have to learn a lang with an awkward syntax, I'd prefer Rust, Julia, Erlang, Elixir or Haskell. Go is no-go. It's not even widely used at Google, its creator. So no, thanks.
Re:.NET 8 by WorldMaker on Tuesday November 14, 2023 @04:47PM (#38270261)
Also, why would force error returns without also including some sort of nice Monadic do-notation or Monad-inspired combinator syntax sugar in the 2020s? We've known for decades now how do that better.

I also think that Go looks like a practical joke that escaped some INTERCAL-like satire committee in the 1970s.

Re:.NET 8 by hollerith on Tuesday November 14, 2023 @04:55PM (#38270378)
You probably mean sum types and convenient syntax for testing and de-structuring sum types.
Re:.NET 8 by WorldMaker on Tuesday November 14, 2023 @05:32PM (#38270771)
No I specifically meant what is often called the Either or Result Monad. These are often implemented as Sum types, but they also follow the Monad laws and supports things like monadic binding/transformation/combination and benefit from syntax sugar like Haskell's "do-notation"/OCaML family's "computation expressions"/the "async/await" pattern of so many other languages now.

Good sum types destructuring would probably also be useful in more languages like Go, but many languages today provide "async/await" pattern syntax benefits without anything at all like "proper" sum types. Sum types are "merely" a possible implementation detail of the Monad and it's the Monad laws that empower some things beyond just sum types.

Re:.NET 8 by hollerith on Friday November 17, 2023 @01:10PM (#38307505)
Why pick on Golang, then? Rust doesn't have a monadic interface to side effects and "errors" either. Nor do the vast majority of the other newer languages.
Re:.NET 8 by WorldMaker on Friday November 17, 2023 @01:55PM (#38308210)
Rust uses a sum type for most errors (Result<T, Error>) and there are common macros such as "error-chain" that apply a monadic approach to binding/combining them (or chaining them, as the preferred nomenclature in that case).

Exception-based languages don't look monadic at first blush, they definitely aren't Sum types, but try/catch is one of the earliest and oldest of the monadic binding/combining approaches, even if it isn't often thought as such (and is barely considered more than goto/switch). It's far more obvious when you start to realize the intersection of async/await and try/catch is a working monad (and how that is reflected in Task/Promise monad instances).

Golang is the obvious odd one out where every other line of "best practice" code is `if err != nil` and the only other advice is "well you could just ignore errors". try/catch doesn't ignore errors, it just looks like it. Rust error chaining doesn't ignore errors, it just looks like it. Golang gives you the choice between micro-managing errors or BASIC-style "ON ERROR RESUME NEXT" and I cannot get anyone to convince me why this isn't either a practical joke or an intentional throwback to writing code like it is the 1970s all over again (even VB6 had better options than "ON ERROR RESUME NEXT", even if they maybe weren't used as often as they should be in some legacy 1990s/2000s codebases).

Re:.NET 8 by hollerith on Friday November 17, 2023 @08:31PM (#38313702)
>every other line of "best practice" code is `if err != nil` and the only other advice is "well you could just ignore errors".

You have a valid point there, but it hurts my ears a little for you to use the word "monadic" or "monad" to make the distinction between how the way Golang handles errors differs from how other modern language do it. To me, for a language to "have monads" requires the type system to give the programmer the ability to distinguish between a value type, e.g., an integer, and a computation that produce a value type. Haskell's type system for example uses `Integer` to refer to the former and, e.g., `IO Integer` to refer to that latter. And clearly by that definition, Rust and most other modern languages just don't have monads, i.e., don't have monadic types (and consequently don't support a monadic programming style) -- unless perhaps Rust's macro system can be used in some complex way to define the monadic-computational types, but I've never seen it used that way. BTW, I'd actually go further and say that to get the benefits of monadic style, the IO monad or whatever the language calls it must be the only way to perform side-effecting computations (though there is a little wiggle room on the definition of side effect here).

To be more precise, the terminology I prefer is that a monad (in the context of programming languages) is a type that obeys the 3 monad laws: https://wiki.haskell.org/Monad_laws. Although there are other ways besides a monad for the type system to distinguish between a value and a computation producing a value. Explicit continuation passing is one such way: whereas in Haskell you'd read a character from standard input with `main = getChar >>= \char -> do something with char`, in a language that uses explicit continuation passing, you'd write `main = getChar (\char -> do something with char)` where in this language getChar takes one argument, which happens to be a continuation argument. But all the languages I know about that let the programmer use the type system to distinguish between a value and a computation producing a value happened to use the monadic style to express that distinction (rather than something like explicit continuation passing) so I tend to use "monad" and "monadic" to refer both to the specific thing that obeys the 3 laws and for the deeper programming-language property.

Re:.NET 8 by WorldMaker on Friday November 17, 2023 @10:33PM (#38314749)
I suppose one of the biggest parts of confusion here is that I'm mostly referring to the monadic programming here in the perspective of the compile-time representations inside of a compiler rather than in the exposed type systems of the languages that they compile. A compile-time representation of computation is a type that represents computation. Not every compiler author themselves think of their work as monads and build them in a way that follows the monad laws/use monad operators directly either, but the overlap should be obvious and a lot of classic and modern compile-time transformations (generators, try/catch, async/await) can be thought of as monadic transformers transforming from one class of monad to another whether or not they are actually implemented that way.

That's one level of confusion in this conversation so far. However, the other problem is that monads don't just mean "computation". (Arguably the Lambda Calculus is way closer to the metal and more accurate to describe as the abstraction of "computation".)

Monads are useful for describing "computations as values" but that's not what the abstraction is entirely for and thinking of monads only as "computations" is how you fall into the easy mistake to make that IO in Haskell is the only "real" monad. There are lots of monads in the wild (Maybe, Either, Promise, List, ...), some of which don't really describe computation at all. We love to mock it, but the technical definition of a monad is "a monoid in the category of endofunctors"; nothing about that is "computation" specifically. Computation is a handy shorthand, of course, but its confusing one of the trees for the rest of the forest sort of thing, mostly because Haskell's IO was the first time monad escaped as a term of art for the deep abstraction that it is.

There is an importance to the monad laws and the two monad "operators", more importance than "computation" as a shorthand for thinking about monads. These operators are called "multiplication" and "identity" in raw Category Theory, but in programming "identity" is usually called "return" and "multiplication" is often called "bind", "bind" is interesting because it also has a dual generally called "join" and "join" is sometimes called "flatMap" or "SelectMany". (Yes, that does point out that most list structures in every modern programming language provide monad operators and obey the monad laws. Lists are a monad.)

A dumber, better shorthand for monads may be "glueable". Monads bind things together in a way that two binds of the same type of monad results in just one monad. (flatMap two lists together and get one list back.) The power of monads is that you can keep gluing things together. Whether by "executing side effects" in a "computation runtime" like the stalwart IO monad or in all the "boring" ways of Lists and Promises and Maybe and Either (that mostly have nothing to do with "computations", except Promises, sort of). The big useful bit is that the Monad laws imply that you can do all this "gluing" in a stable way. That stable way also makes room for the means to transform from one type of Monad to another (Monadic transformers).

Monadic transformers are where some of the real power of the IO monad as an abstraction lives (and other monads in terms of compile-time representations): the idea that the "notation" doesn't matter so much as the end "glued" result. Imperative looking do-notation is the same sort of "glue" as a lot of individual calls to the Monad operators bind and return, transforming from one form to the other is "relatively" "trivial" because the Monad laws say everything should be fine.

There is a usefulness to the IO Monad in Haskell and it is an interesting way to "describe side effects to perform", but the whole of monads and monadic binding is a lot more than just the IO Monad and if you are defining monads to only mean "the IO Monad" you are missing some of their other usefulness.

Re:.NET 8 by hollerith on Tuesday November 21, 2023 @02:58PM (#38369198)
>if you are defining monads to only mean "the IO Monad"

Show me one place in my writings where I imply that the IO monad (or state monads generally) is the only monad.

Re:.NET 8 by jen20 on Tuesday November 14, 2023 @05:34PM (#38270801)
The real problem was upgrading from .NET Framework, or Mono, to .NET Core, which has been stable since.

That comparison is not a fair comparison to Go, which has a much stricter guarantee around source and library compatibility within the 1.x series.

Re:.NET 8 by Capricorn2481 on Tuesday November 14, 2023 @12:07PM (#38266105)
People can write dumb, inconsistent code anywhere. A stable library will not protect you from a lack of PR reviews
Re:.NET 8 by pjmlp on Tuesday November 14, 2023 @12:08PM (#38266121)
Thankfully .NET folks are confident that their audience has the skills to manage those features.
Re:.NET 8 by The_Colonel on Tuesday November 14, 2023 @12:12PM (#38266192)
.NET / C# seems to be following C++ by including... everything. I wonder if they're just not worried about feature bloat or what's their thinking...
Re:.NET 8 by Metasyntactic on Tuesday November 14, 2023 @12:49PM (#38266765)
Hi there, C# Lang Designer here. :)

We're always thinking about the bloat concern when it comes to language development. However, our philosophy on it is that bloat primarily comes when you add replacement systems that are expected to supersede the previous mechanisms, not compliment them. So we try to do the former sparingly. In the history of C# there are very few times we've actually done this, and we do view those times as unfortunate cases where we likely rushed a feature too early and then regret having to live with those features forever.

To help combat this, we tend to go through long periods of design and experimentation, where we propose features, create prototypes of them, and then interact with a large set of diverse community groups to try things out. The feedback from this is tightly bound into our design process and allows us to refine (or even jettison) designs rapidly.

We also normally will both break up work into lots of smaller pieces (composing large language changes into small orthogonal, complimentary, composable blocks), and do designs over many years if appropriate. We think this approach has helped us create a language that is 25 years old, while being both very rich, and still very cohesive. There are a few mistakes we've made along the way ("anonymous-delegates", i'm looking at you), but we're very happy that our ratios here are very good given our continued investment in this space.

Re:.NET 8 by terandle on Tuesday November 14, 2023 @02:50PM (#38268633)
The new array literals seem to supersede some previous syntaxes like new[] { 1, 2, 3 } goes to [1, 2, 3] in a lot of cases. But overall they are a _great_ addition to the language playing around with them now so bravo.

Still not really sure how I feel about class primary constructors on the other hand, will give them some time to marinate.

Re:.NET 8 by oaiey on Tuesday November 14, 2023 @03:19PM (#38269099)
Share the exactly same worries. Let us see.
Re:.NET 8 by WorldMaker on Tuesday November 14, 2023 @04:54PM (#38270374)
Having moved to writing records by default in many places such as models and "DTOs", primary constructors are a very useful "transition" tool in those cases of "this started as a record, but now needs to be a mutable class for X reasons" and means a little bit less code to entirely rewrite in the first pass. It's also useful for even just "I aesthetically like for my class 'View Models' to mirror their record 'Model' definitions a little closer".
Re:.NET 8 by Smaug123 on Tuesday November 14, 2023 @05:45PM (#38270900)
Class primary constructors have always been the default thing in F#, and I found it deeply annoying not to have them whenever I had to write C#, for what it's worth!
Re:.NET 8 by zengid on Tuesday November 14, 2023 @01:29PM (#38267392)
C# has been able to add new features while simultaneously making the syntax more ergonomic and elegant, while C++ hasn't.
Re:.NET 8 by Kwpolska on Tuesday November 14, 2023 @12:17PM (#38266251)
.NET is stable, they very rarely remove things. Code written for .NET Framework 2.x will probably work fine on .NET 8 (unless it uses the things that didn't make the jump, like WCF, but there are libraries that provide SOAP support.)

Can a single developer remember all of .NET? No, but that applies to most languages/ecosystems. But if you encounter something you've never seen, you can always check the docs.

And the thing hasn't been named ".NET Core" for 4 consecutive releases now.

Re:.NET 8 by merb on Tuesday November 14, 2023 @12:29PM (#38266452)
Actually most wcf code does run on .net 7+ they open sourced it into corewcf. (At least a lot of the things) Webforms however is dead.
Re:.NET 8 by starik36 on Tuesday November 14, 2023 @12:31PM (#38266501)
> Code written for .NET Framework 2.x will probably work fine on .NET 8

WebForms would like a word.

Re:.NET 8 by Kwpolska on Tuesday November 14, 2023 @03:23PM (#38269180)
Hence “probably”. WebForms should die in a dumpster fire.
Re:.NET 8 by WorldMaker on Tuesday November 14, 2023 @04:48PM (#38270289)
I worry that Blazor is that dumpster fire sometimes.
Re:.NET 8 by custard42 on Tuesday November 14, 2023 @08:24PM (#38272222)
I'm curious, why do you say that?
Re:.NET 8 by WorldMaker on Wednesday November 15, 2023 @11:07AM (#38278226)
The mixture of client-side and server-side code that Blazor can allow in the same files gives me a very gut instinct feeling that "those who have forgotten the WebForms history, or worse the ASP Classic history, are doomed to repeat it". It's obviously different from both WebForms and ASP Classic and its use of Wasm is certainly a brand new idea that WebForms only wishes it had access to. It seems like a brand new mistake to me, because I still remember debugging ASP Classic and WebForms and Silverlight and "now even the client side JS of ~~WebForms~~ Blazor is no longer JS but a mini-.NET runtime in a Wasm box" doesn't sound like a good time in the long term maintenance future to me when Blazor apps become legacy apps. But some of that gut instinct may just be cynicism at this point.
Re:.NET 8 by papichulo2023 on Tuesday November 14, 2023 @12:47PM (#38266737)
Ehh, that is the thing about Go, most Go developers know most of the std (compared to other languages at least)