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. The Lounge
  3. Is there a programming language...

Is there a programming language...

Scheduled Pinned Locked Moved The Lounge
questioncsharpdatabasecomtesting
72 Posts 26 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.
  • R Rob Grainger

    Don't know if your familiar with Haskell at all, but its a wonderful thing. One day I'll undwerstand it well enough to use on a real world project. The example given is relatively simple. I particularly like being able to derive properties (type classes) like Ord (a bit like comparable), Num (numeric), Eq (equatable) and Show (convertible to string) automatically for many types. Be aware that "type classes" are not classes in an OO sense at all. More like interfaces. Even more like "concepts" in C++ (when they finally make it into the language). I think I've learned more from learning Haskell than any language since I learned Smalltalk.

    "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
    #58

    Rob Grainger wrote:

    Don't know if your familiar with Haskell at all, but its a wonderful thing.

    Nope, but I've been reading up on it since your previous post!

    Rob Grainger wrote:

    I think I've learned more from learning Haskell than any language since I learned Smalltalk.

    Interestingly, I learned more about the principles of programming from this book[^] than I ever have from any actual comp-sci book. I kid you not - biology and programming have a lot in common. Marc

    R 1 Reply Last reply
    0
    • R Rob Grainger

      Actually, most people would consider that numbers are as real as most human concepts, if not more so due to their universal applicability. By your logic trees don't exist because "tree" is purely a label we've conjuured up to describe the commonality of all trees. Colours do not exist because "colour" is a word we use to describe colours of all objects. So if anything exists then numbers are as real as anything else - just because they have no physical form does not render then nonexistant. If you reject naming things, then you reject language and symbolic systems as a means of communicating. Good luck with that. I'd suggest Wittgenstein's Philosophical Investigations for a more thorough consideration of this area. More interesting questions he tackles are of the form "what is a game" - now that really is hard to tie down.

      "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

      9 Offline
      9 Offline
      9082365
      wrote on last edited by
      #59

      But trees don't exist and 'tree' is indeed a label we've conjured up not to describe the commonality of certain plant species but to generalise sufficiently to deal with the fact that there is very little commonality in reality but life is way too short to demand strict accuracy in language. I'm surprised that you find anything to the contrary in Wittgenstein (although I appreciate that interpreting Wittgenstein depends very much on what mood he was in at the time of writing!) And where do I reject symbolic systems and naming? I simply accept Kant's logic that we never do and never can know what is really there. In other words the fact that you can name something or fit it perfectly into a logical system does not make it an ontological necessity. The ability to speak of 'number' or 'trees' and use those concepts in the most complicated yet logical manner does not mean that number or tree actually exist. Even the most rigorous of ontological 'proofs' will always fall prey to the fact that they are a product of the logical system in which they operate and therefore require an unjustifiable acceptance of that system. Of course, for the conduct of everyday life I bandy terms like tree and 34 about without the slightest embarrassment. It keeps one out of mental health institutions for starters! But that doesn't require commitment to the notion that they connotate anything real. If Hume could play billiards and at the same time believe that there was no such thing as cause and effect a little duality of thinking can't do any harm!

      1 Reply Last reply
      0
      • M Marc Clifton

        Rob Grainger wrote:

        Don't know if your familiar with Haskell at all, but its a wonderful thing.

        Nope, but I've been reading up on it since your previous post!

        Rob Grainger wrote:

        I think I've learned more from learning Haskell than any language since I learned Smalltalk.

        Interestingly, I learned more about the principles of programming from this book[^] than I ever have from any actual comp-sci book. I kid you not - biology and programming have a lot in common. Marc

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

        I am not surprised. Alan Kay has stated that biology heavily influenced the invention of OOP. I think he touches on that in This interview[^]

        "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

        G 1 Reply Last reply
        0
        • M Marc Clifton

          ...that works "easily" with semantic types? For example, I may have: int age = 51; which completely loses the concept that 51 is an age (in years). What I want is something like: AgeInYears myAge = 51; and yet still be able to specify that I can perform, say, arithmetic operations on "myAge". For example, in C#, I could write:

          class AgeInYears
          {
          public int Value {get;set;}
          }

          ... implement operators on AgeInYears

          But that gets messy real fast - every "semantic type" needs these operators, etc. Furthermore, the unit of measurement is still not handled very elegantly. So, as the question states, are there programming languages out there that are more expressive of semantic types? Marc

          Day 1: Spider Database Navigator Unit Testing Succinctly

          M Offline
          M Offline
          Member 4608898
          wrote on last edited by
          #61

          You could use C/C++ typedef int AgeInYears; AgeInYears myAge = 51; No need to define operators etc. You could even use Ada type AgeInYears is new Integer; type AgeInMonths is new Integer; myAge: AgeInYears; yourAge: AgeInMonths; Ada won't let you type myAge := yourAge / 12; unless you cast it.

          1 Reply Last reply
          0
          • M Marc Clifton

            ...that works "easily" with semantic types? For example, I may have: int age = 51; which completely loses the concept that 51 is an age (in years). What I want is something like: AgeInYears myAge = 51; and yet still be able to specify that I can perform, say, arithmetic operations on "myAge". For example, in C#, I could write:

            class AgeInYears
            {
            public int Value {get;set;}
            }

            ... implement operators on AgeInYears

            But that gets messy real fast - every "semantic type" needs these operators, etc. Furthermore, the unit of measurement is still not handled very elegantly. So, as the question states, are there programming languages out there that are more expressive of semantic types? Marc

            Day 1: Spider Database Navigator Unit Testing Succinctly

            A Offline
            A Offline
            aschmahmann
            wrote on last edited by
            #62

            An interesting language for doing this type of thing is Julia (http://julialang.org/[^]). In Julia you can A) Use typedefs to indicate that AgeInYears is a typedef for Int or B) Make a new type AgeInYears that is a subtype of Integer and implement a converter function (these are a standard Julia concept) from Int to AgeInYears so that age::AgeInYears = 5 will resolve correctly.

            M 1 Reply Last reply
            0
            • M Marc Clifton

              greydmar wrote:

              I believe that this threshold "semantic" is outside the domain of a programming language (commonly, it is a "system domain" concept),

              Yes, that's what makes it interesting to look at. :) Marc

              G Offline
              G Offline
              greydmar
              wrote on last edited by
              #63

              Well, lets consider the following task: Imagine the same issue when your development includes (for example) some SQL tables with some (or a lot of) semantic fields (unit of measure, complex number, currency, etc.) and you decides (of course, you are a "programer"!! ;P) performs some calculations using SQL dialects (T-SQL; stored procedures, udf, package, PL/SQL)... So, it's a kind of art do ordnary operations (conversion, arithmetics) without "semantic types", no?

              1 Reply Last reply
              0
              • R Rob Grainger

                Stroustrup has written somewhere on implementing SI measures in C++ using user-defined literals and simple classes. That would work well, but should really be part of the standard library.

                "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                G Offline
                G Offline
                greydmar
                wrote on last edited by
                #64

                Rob Grainger wrote:

                "If you don't fail at least 90 percent of the time, you're not aiming high enough."

                Well. Try this with your employer! (it's a joke)

                R 1 Reply Last reply
                0
                • R Rob Grainger

                  I am not surprised. Alan Kay has stated that biology heavily influenced the invention of OOP. I think he touches on that in This interview[^]

                  "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                  G Offline
                  G Offline
                  greydmar
                  wrote on last edited by
                  #65

                  Rob Grainger wrote:

                  Alan Kay has stated that biology heavily influenced the invention of OOP

                  Ancient Greeks established paradigm of capture world events into models (abstract concepts schemes) without cares with empirical verification... Biology and statistics with your main concepts (store, compare, infers!) had heavily influenced since Medicine up to Mechanical sciences working from a diferent perspective: World evidences first (facts, events, observations). Model concepts later. An interesting book about this, available only in portuguese (BEHIND THE SCENES OF SCIENCE - Resistances Scientists to Scientific Innovation) it's a very enlightening

                  1 Reply Last reply
                  0
                  • A aschmahmann

                    An interesting language for doing this type of thing is Julia (http://julialang.org/[^]). In Julia you can A) Use typedefs to indicate that AgeInYears is a typedef for Int or B) Make a new type AgeInYears that is a subtype of Integer and implement a converter function (these are a standard Julia concept) from Int to AgeInYears so that age::AgeInYears = 5 will resolve correctly.

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

                    aschmahmann wrote:

                    An interesting language for doing this type of thing is Julia (http://julialang.org/[^]).

                    Reading the docs, that looks very very interesting! Thank you for pointing out Julia! Marc

                    1 Reply Last reply
                    0
                    • G greydmar

                      Rob Grainger wrote:

                      "If you don't fail at least 90 percent of the time, you're not aiming high enough."

                      Well. Try this with your employer! (it's a joke)

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

                      I still feel that would be an improvement on some of the folk whose footsteps I'm following (see various entries in The Wierd and The Wonderful) - at least I'd succeed 10% of the time ;-)

                      "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                      1 Reply Last reply
                      0
                      • R Ron Beyer

                        I hate myself for typing this:

                        namespace TestApp1
                        {
                        using AgeInYears = System.Int32;

                        class Program
                        {
                            static void Main(string\[\] args)
                            {
                                AgeInYears myAge = 10;
                                AgeInYears oldAge = 50;
                                AgeInYears timeUntilOldAge = oldAge - myAge;
                            }
                        }
                        

                        }

                        Yes, that's perfectly legal C# code. Its technically an int, works the same way that #define does in c++ to replace types. It only works in single code files though.

                        E Offline
                        E Offline
                        etkid84
                        wrote on last edited by
                        #68

                        isn't that akin to a typedef?

                        David

                        R 1 Reply Last reply
                        0
                        • E etkid84

                          isn't that akin to a typedef?

                          David

                          R Offline
                          R Offline
                          Ron Beyer
                          wrote on last edited by
                          #69

                          Kinda, as I said in a different reply, typedef has valid uses (defining a BOOL for example) that actually creates a new type and can be universal, whereas "using" alias is more like a #define replacement in a single file.

                          E 1 Reply Last reply
                          0
                          • R Ron Beyer

                            Kinda, as I said in a different reply, typedef has valid uses (defining a BOOL for example) that actually creates a new type and can be universal, whereas "using" alias is more like a #define replacement in a single file.

                            E Offline
                            E Offline
                            etkid84
                            wrote on last edited by
                            #70

                            I suppose typedefs get type checked at compile time and #defines do not. Is that correct? so maybe the typedef equivalent is the safer way to go?

                            David

                            R 1 Reply Last reply
                            0
                            • E etkid84

                              I suppose typedefs get type checked at compile time and #defines do not. Is that correct? so maybe the typedef equivalent is the safer way to go?

                              David

                              R Offline
                              R Offline
                              Ron Beyer
                              wrote on last edited by
                              #71

                              #define will be checked at compile time just like typedefs because the preprocessor will run through and replace all instances of the #define name with the value before compiling. If typedef had an equivalent c# construct that would certainly be the better way to go, but it doesn't. So the only real way to redefine types as a different name is to use the "using" or to create your own value type that derives from the equivalent type.

                              1 Reply Last reply
                              0
                              • M Marc Clifton

                                ...that works "easily" with semantic types? For example, I may have: int age = 51; which completely loses the concept that 51 is an age (in years). What I want is something like: AgeInYears myAge = 51; and yet still be able to specify that I can perform, say, arithmetic operations on "myAge". For example, in C#, I could write:

                                class AgeInYears
                                {
                                public int Value {get;set;}
                                }

                                ... implement operators on AgeInYears

                                But that gets messy real fast - every "semantic type" needs these operators, etc. Furthermore, the unit of measurement is still not handled very elegantly. So, as the question states, are there programming languages out there that are more expressive of semantic types? Marc

                                Day 1: Spider Database Navigator Unit Testing Succinctly

                                B Offline
                                B Offline
                                b leclerc
                                wrote on last edited by
                                #72

                                // In C langage (or C++) you could write : typedef int years; typedef unsigned years ageInYears; ageInYears myAge = 50; // is not that enought ?

                                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