Use stronger types!
-
Arne Mertz[^]:
Is everything we use a string for really just a bunch of characters? Is everything we use an int for really just a number? Probably not. We can have stronger types than that.
Do your types even lift?
-
Arne Mertz[^]:
Is everything we use a string for really just a bunch of characters? Is everything we use an int for really just a number? Probably not. We can have stronger types than that.
Do your types even lift?
I believe he's trying to describe semantic types :) Introducing Semantic Types in .Net[^]
Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
-
I believe he's trying to describe semantic types :) Introducing Semantic Types in .Net[^]
Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability. — Edsger W. Dijkstra
Regards, Sander
Yeah, but from a C++ dev's perspective. And you know what they think of .NET :)
TTFN - Kent
-
Arne Mertz[^]:
Is everything we use a string for really just a bunch of characters? Is everything we use an int for really just a number? Probably not. We can have stronger types than that.
Do your types even lift?
-
Arne Mertz[^]:
Is everything we use a string for really just a bunch of characters? Is everything we use an int for really just a number? Probably not. We can have stronger types than that.
Do your types even lift?
Sigh. Strong Type Checking with Semantic Types[^] Introducing Semantic Types in .Net[^] Higher Order Programming[^] HOPE - Higher Order Programming Environment[^] Introducing Semtrex[^] Should I go on? Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
-
Sigh. Strong Type Checking with Semantic Types[^] Introducing Semantic Types in .Net[^] Higher Order Programming[^] HOPE - Higher Order Programming Environment[^] Introducing Semtrex[^] Should I go on? Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Unlike most of those though, in C++ the Semantic types have zero or close to zero overhead. Further, with user-defined literals, it allows natural expressions such as:
auto distance = 12_km;
auto time = 4_s;
auto speed = distance / time;Giving safe, statically checked, zero-overhead semantic types. (Edit - substituted distance for length)
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
-
Yeah, but from a C++ dev's perspective. And you know what they think of .NET :)
TTFN - Kent
-
Unlike most of those though, in C++ the Semantic types have zero or close to zero overhead. Further, with user-defined literals, it allows natural expressions such as:
auto distance = 12_km;
auto time = 4_s;
auto speed = distance / time;Giving safe, statically checked, zero-overhead semantic types. (Edit - substituted distance for length)
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
Rob Grainger wrote:
Unlike most of those though, in C++ the Semantic types have zero or close to zero overhead.
Oh, I'm not complaining about the C++ example, it's just, how exactly is this new and profound? I guess I was in a bit of a mood (more-so than usual, haha) and I do definitely wish C# had that feature -- it's supposed to be coming in C# 7.0 I think I read somewhere? Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project! Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
-
Arne Mertz[^]:
Is everything we use a string for really just a bunch of characters? Is everything we use an int for really just a number? Probably not. We can have stronger types than that.
Do your types even lift?
There comes a point when you have to stop designing code with the intent that it be maintained by idiots. (Especially since the idiots will probably get annoyed and remove all the strong typing, arguably making everything worse.)