News for hackers. Stuff that matters.
Re:Compilers: Incrementally and Extensibly by mrkeen on Saturday April 05, 2025 @12:44PM (#43594754)
I grew up with "easy" languages. Pascal, VB, C, C++, Java, C#. And frankly I'm getting real sick of them.

I'm porting Dijkstra's algorithm over to C# at the moment, and in the last several hours here's the two most clownish things that have happened:

1) I have:

  if (node is null) {
    ..
  }
My IDE is telling me "Expression is always false according to nullable reference types' annotations". Nevertheless it enters that section every time.

2) I have:

  SortedSet<int> nums = [];
  Console.Out.WriteLine(nums.Min);
You know what this prints?

  0
The minimal element of a set which has no elements is 0.

Yes, every language has its warts, and anecdotes like this aren't going to change anyone's mind. I only wrote these up because they're hitting me right now in one of those languages that companies use "because anyone can learn them". I like harder languages better than easy languages, because they're easy.

Re:Compilers: Incrementally and Extensibly by tester756 on Saturday April 05, 2025 @02:37PM (#43595629)
2)

In general I'd recommend using Min() (from LINQ) which works as expected

But this property has this remark: "If the SortedSet<T> has no elements, then the Min property returns the default value of T."

1)

Feels like you used compiler hints incorrectly

Re:Compilers: Incrementally and Extensibly by neonsunset on Saturday April 05, 2025 @01:06PM (#43594914)
This is possible if you disregarded compiler warnings and assigned null to a non-nullable location.
Re:Compilers: Incrementally and Extensibly by nextaccountic on Sunday April 06, 2025 @10:36AM (#43601690)
Feels like this should be a compiler error. Or saying otherwise, this location isn't very non-nullable if you can assign null to it
Re:Compilers: Incrementally and Extensibly by neonsunset on Sunday April 06, 2025 @11:23AM (#43602101)
Just add <WarningsAsErrors>nullable</WarningsAsErrors> to the project manifest.