Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Insider News
  4. Use stronger types!

Use stronger types!

Scheduled Pinned Locked Moved The Insider News
question
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kent Sharkey
    wrote on last edited by
    #1

    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?

    Sander RosselS E M J 4 Replies Last reply
    0
    • K Kent Sharkey

      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?

      Sander RosselS Offline
      Sander RosselS Offline
      Sander Rossel
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • Sander RosselS Sander Rossel

        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

        K Offline
        K Offline
        Kent Sharkey
        wrote on last edited by
        #3

        Yeah, but from a C++ dev's perspective. And you know what they think of .NET :)

        TTFN - Kent

        N 1 Reply Last reply
        0
        • K Kent Sharkey

          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?

          E Offline
          E Offline
          ed welch
          wrote on last edited by
          #4

          Umm, in his example you don't need "strong types" at all. Just check that the properties have meaningful values when they are loaded.

          1 Reply Last reply
          0
          • K Kent Sharkey

            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?

            M Offline
            M Offline
            Marc Clifton
            wrote on last edited by
            #5

            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

            R 1 Reply Last reply
            0
            • M Marc Clifton

              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

              R Offline
              R Offline
              Rob Grainger
              wrote on last edited by
              #6

              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.

              M 1 Reply Last reply
              0
              • K Kent Sharkey

                Yeah, but from a C++ dev's perspective. And you know what they think of .NET :)

                TTFN - Kent

                N Offline
                N Offline
                Nemanja Trifunovic
                wrote on last edited by
                #7

                Kent Sharkey wrote:

                And you know what they think of .NET

                ;P

                utf8-cpp

                1 Reply Last reply
                0
                • R Rob Grainger

                  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.

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • K Kent Sharkey

                    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?

                    J Offline
                    J Offline
                    Joe Woodbury
                    wrote on last edited by
                    #9

                    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.)

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups