Re:The memory safety problem isn't bad coders
by scarface74 on Tuesday February 12, 2019 @08:54PM
(#19149659)
You also included information about “constraints” like is it a positive or negative number and string length. That wouldn’t be encoded in the type. Why would I go look up the types either way? I’m using a strongly typed language, the IDE would tell me that anyway. While I am writing code, I see a red dot showing me immediately if I’m using the type incorrectly. Any assumptions that were incorrect, I would get immediate feedback.
Re:The memory safety problem isn't bad coders
by gmueckl on Tuesday February 12, 2019 @10:34PM
(#19150148)
Not necessarily. Is Age unsigned or not? This constrains the possible range of values. In other contexts, there is a lot more information inferred by the integer type used.
Re:The memory safety problem isn't bad coders
by maxxxxx on Tuesday February 12, 2019 @09:46PM
(#19149914)
Do you actually work with C#, LINQ and generics?
Re:The memory safety problem isn't bad coders
by gmueckl on Tuesday February 12, 2019 @10:14PM
(#19150047)
Yes. I am quite familiar with them.
Re:The memory safety problem isn't bad coders
by maxxxxx on Tuesday February 12, 2019 @10:30PM
(#19150115)
Then tell me how you can model in C# a type where a property can’t be negative or a certain length.
Re:The memory safety problem isn't bad coders
by gmueckl on Tuesday February 12, 2019 @11:55PM
(#19150530)
class Foo {
public uint Bar { get; set; }
private char[] _baz;
public char[] Baz { get { return _baz;} }
public Foo() { _baz = new char[5]; }
}
This is cheating a bit on the array part. But the length of that char array is set in stone and cannot be changed from the outside. However, the Bar property uses a standard C# datatype.
Re:The memory safety problem isn't bad coders
by maxxxxx on Wednesday February 13, 2019 @06:27AM
(#19152249)
I honestly thing that you haven't done any real work with LINQ or you are imagining problems that don't exist. The char array is not usable as string or we have to go back to 0 terminated strings like C.
Re:The memory safety problem isn't bad coders
by gmueckl on Wednesday February 13, 2019 @02:27PM
(#19155968)
I am not imagining problems that don't exist in the application domains I work on.
If your environment is so relaxed that aspects like signedness of an integer don't matter, so be it. But then you are also far removed from a domain where software correctness is non-negotiable.
Re:The memory safety problem isn't bad coders
by scarface74 on Thursday February 14, 2019 @09:40AM
(#19162151)
It’s not aspects “like signednes” that’s the only constraint that you could embed in your defined POCO and still use as a select projection that would survive a LINQ expression that was turned into an expression tree. Your data store would enforce the other constraints. Your C style character array as a string wouldn’t work with either LINQ nor any of the standard library.
Are you really trying to go back to the bad old days with Microsoft C/MFC/WIN32/COM where you had over a dozen ways to represent a string that you had to convert to and from depending on which API you were using?
Re:The memory safety problem isn't bad coders
by scarface74 on Wednesday February 13, 2019 @12:51AM
(#19150773)
And your class wouldn’t work as part of the LINQ example. EF for example wouldn’t know how to translate it.
Yet, any code using its result will contain implicit assumptions about that data. Therefore, in order to maintain type safety, the expected type of the return value must he stated.
That type must also be independent from whatever LINQ does internally to produce that return value. Otherwise, the LINQ providers wouldn't be as exchangeable as you claim.