Live data from Hacker News

New in C# 10: Easier Lambda Expressions

dontcodetired.com

81–90 of 111 posts

Re: New in C# 10: Easier Lambda Expressions

#81

Earlier quoted context omitted.

Err.. I'm too drunk to check, bit I'm fairly sure C# has had operator overloading for like ten years? Having worked recently in it, I found Java to be relatively (as a language, not for tooling) backwards compared to C#.

C++ had operator overloading in the 90s. Mostly we decided it was a bad idea. Every generation must learn this for themselves though.

Operator overloading has been traditionally overused, especially in C++ (shift operators for iostreams, C++ iterators). Java was the peak of the push-back against that. C# has operator overloading, but forbids many things that were possible in C++:

  * `operator=` and `operator ,`
  * `operator new` and `operator delete`
  * `operator +=` overloaded differently from `operator +`
  * `operator &&` and `operator ||` overloading works differently in C#, so that it preserves the short-circuiting behavior
  * `operator ++` only can be overloaded once in C#, with the compiler automatically handling the difference between pre- and post-increment
But more crucially, the C# standard library uses operator overloading only for types like `decimal` and `BigInteger`. C# programmers can go years without ever overloading an operator, while still profiting from it whenever they use `BigInteger`. It's very different from the C++ culture where

  * everyone needs to learn about how to overload `operator=` (for memory management)
  * the standard library encourage abuses of operator overloading such as shift operators for iostreams
It should be unsurprising novice programmers abuse operator overloading when the C++ language teaches them exactly that.

Re: New in C# 10: Easier Lambda Expressions

#82
post #25
post #18

Earlier quoted context omitted.

You’re going to love Kotlin, it really is a fantastic pragmatic language. You’re also likely to discover that while C# the language is amazing, the CLR runtime looks frankly minor league when compared to the JVM.

> the CLR runtime looks frankly minor league when compared to the JVM. This is comically backwards from my experience. I often see near-native optimized performance on C#/CLR, where I see similar code (SIMD friendly loops) literally hundreds if not thousands of times slower than it should be in Java.

Very true, Java was late in the game in term of SIMD loop optimizations compared to C#.

Oracle engineers did the first implementation for Java 7, more recently it's mostly contributions from Intel, AMD and ARM [1].

[1] https://cr.openjdk.java.net/~vlivanov/talks/2019_CodeOne_MTE...

Re: New in C# 10: Easier Lambda Expressions

#83

Earlier quoted context omitted.

Err.. I'm too drunk to check, bit I'm fairly sure C# has had operator overloading for like ten years? Having worked recently in it, I found Java to be relatively (as a language, not for tooling) backwards compared to C#.

C++ had operator overloading in the 90s. Mostly we decided it was a bad idea. Every generation must learn this for themselves though.

Operator overloading in a language in which memory management is all manual would be more challenging. That doesn't really tell us about its suitability in a language with automatic memory management. We've had about 20 years of C# with operator overloading, and it's been totally fine.

Re: New in C# 10: Easier Lambda Expressions

#85

C# 10 didn't introduce many new features. I hate they delayed the introduction of Algebraic Data Types again. Maybe they will appear in C# 11. Using ADT in F# makes it a breeze to do domain modeling.

Record classes and pattern matching get you 90% of the way there thankfully. Not perfect, but good enough. It's funny how much of a difference being able to write each case in a single line and have equality and all that stuff automatically taken care of makes. Honestly that's more important than the exhaustive pattern matching you get with ADTs. I can live with "default: throw".

Re: New in C# 10: Easier Lambda Expressions

#86
post #73

Earlier quoted context omitted.

Exactly my experience. Coming from C# around year 2014s to php then nodejs (due to company setup), typescript is the best of both worlds. Won't be back to static typing for a while unless I'll need higher precision and higher reliability module.

Damn, I’m missing Union Types in C# so much! Typescript make it so simple to compose types.

Indeed. Union, intersection types are godsend. Furthermore arguments don't need to be class instances / explicit type, object with fulfilled properties are enough. It's much much easier to work especially during templating / developing engine.

Re: New in C# 10: Easier Lambda Expressions

#87

Earlier quoted context omitted.

Ever since LINQ, maybe even before that, I feel Java is a more boring C# clone. C# keeps innovating their language (borrowing a lot of times from other languages, of course), and then java seems to look and wait and do a half-assed implementation of a lot of tried-and-true C# language features some years later. Java had two tech advantages over C#: It officially ran on platforms other than Windows and ran well, and t…

JVM's garbage collectors are at least a decade worth of effort ahead of CLR. I am talking out of my ass here, but from reading people working on large projects JVM has no problem chewing through multi-terabyte large heaps. The recently introduced collectors (Shenandoah and ZGC) even keep the same pause times (something like 99 percentile within 1 ms and 99.9 within 10 ms). The largest heap you might be able to use un…

You know C# has records too right? "With" and all.

Re: New in C# 10: Easier Lambda Expressions

#89

A couple decades ago everyone was on static types. But then people got sick of the boilerplate, and in what I think was a backlash, dynamic languages like JavaScript, Python, Ruby, etc. took the world by storm. With the raised bar of developer expectations when it comes to agility, static type systems were forced to innovate, and now type-inference and related features are coming to all static languages and bringing…

Haskell has been quietly doing this since the 90s though. I guess being a research-first language it isn’t held back by trying to have mass appeal (eg to be C-like to be familiar)

Haskell is held back by pushing category theory into their tutorials. Want to do IO? Great, first learn about monads.

Re: New in C# 10: Easier Lambda Expressions

#90
post #89

Earlier quoted context omitted.

Haskell has been quietly doing this since the 90s though. I guess being a research-first language it isn’t held back by trying to have mass appeal (eg to be C-like to be familiar)

Haskell is held back by pushing category theory into their tutorials. Want to do IO? Great, first learn about monads.

That's not true and never has been. Want to do I/O?

    main = do
        putStrLn "Who are you?"
        name 
There. Do you really need to know something about monads to understand that example? No.

Do you need to know how do syntax and the assignment operator <- works? Sure. But that has nothing to do with category theory. That's just syntax.

Post reply on HN