Language inadequacies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darren Oakey

    #31
    Re: Language inadequacies

    > It appears you are the one who is not up on the debate. You[color=blue]
    > seem like an old-time C++ guy who can't comprehend why people
    > wouldn't want to throw anything and everything including the
    > kitchen sink into a language and damn the people who think
    > it's messy, inconsistent and not standardized.[/color]

    hmm.. have to step in here, even though you were attacking someone else..

    a) const is hardly messy inconsistent or not standardized! It is a very
    defensive tool. Many people now are realising that as coding gets out of
    the cowboy corral that TESTING is more and more important - especially
    regression tests.
    Now, suppose you have the lines:

    Point x = new Point( 5, 3 );
    Point transformed = F(x);
    Test.Assert( x.Equals( new Point(5,3)), "check that X hasn't been
    changed");

    In non-const world - that assert will not guarantee to pass. In a const
    world... it will.
    I put it to you:
    without const (or some workaround, like const interfaces)
    it is impossible to test anything more than a trivial example
    with any degree of confidence, in any practical situation.

    While you are correct that there are some OO people argue who against const,
    OO is a good paradigm, but not the be-all and end-all of development. It is
    very good for modelling a business problem. However, other paradigms, such
    as functional programming, are vastly superior in almost every other way.
    I believe a synergy of many programming techniques is the optimal solution,
    as in MS's intentional programming model. In fact, we are already going
    this way - you use a UI to produce your forms, and a designer to produce
    your data types (datasets) - as time goes on, more and more people will
    use the appropriate tool to solve the appropriate problem. OO only solves
    one very specific part of the whole programming problem. (look up aspect
    orientated development/workflows/etc etc)

    C# is a general purpose programming language, so it handles simplistic
    paradigms like structured design or stack based programming very well. It
    also has been built with lots of OO features, so can be used for OO design,
    development as well. The single keyword, const would give you a lot of the
    benefit of a functional programming language! (In fact, iterators and
    Anonymous methods (can you say lambda? :)) give you most of the rest of the
    benefits.. (see
    http://www.gotdotnet.com/team/csharp...e/default.aspx)

    So - is const trivial? It almost singlehandedly brings a new tool to the
    programmers arsenal, and if you look at the debates between functional and
    other languages, one which is probably more important than the entire OO
    enablement of the language put together.
    I would say that any programmer not using at least a workaround of const,
    such as const interfaces or events on all modifiers could not consider
    themselves anything more than a beginner/intermediate coder.

    b) as for templates: what's more messy/inconsistent/standardized?

    Hashtable bad = new HashTable();
    bad.Add( 1, "red" );
    string theObjectIAmHop ingLikeHellWill ActuallyBeAStri ng = (String) bad[ 1 ];

    --- or ---

    Hashtable good = new HashTable<int, string>();
    good .Add( 1, "red" );
    string theValue = bad[2];


    and type safety is just one of a million different reasons good programmers
    who code using generics use far less code, take far less time, and produce a
    much more stable result than their specific compatriots.




    Comment

    • Chad Myers

      #32
      Re: Language inadequacies


      "Darren Oakey" <you@darrenoake y.info> wrote in message
      news:%23Hfj6i6Z DHA.1816@TK2MSF TNGP09.phx.gbl. ..[color=blue][color=green]
      > > It appears you are the one who is not up on the debate. You
      > > seem like an old-time C++ guy who can't comprehend why people
      > > wouldn't want to throw anything and everything including the
      > > kitchen sink into a language and damn the people who think
      > > it's messy, inconsistent and not standardized.[/color]
      >
      > hmm.. have to step in here, even though you were attacking someone[/color]
      else..[color=blue]
      >
      > a) const is hardly messy inconsistent or not standardized! It is a[/color]
      very[color=blue]
      > defensive tool. Many people now are realising that as coding gets[/color]
      out of[color=blue]
      > the cowboy corral that TESTING is more and more important - especially
      > regression tests.
      > Now, suppose you have the lines:
      >
      > Point x = new Point( 5, 3 );
      > Point transformed = F(x);
      > Test.Assert( x.Equals( new Point(5,3)), "check that X hasn't been
      > changed");
      >
      > In non-const world - that assert will not guarantee to pass. In a[/color]
      const[color=blue]
      > world... it will.
      > I put it to you:
      > without const (or some workaround, like const interfaces)
      > it is impossible to test anything more than a trivial example
      > with any degree of confidence, in any practical situation.[/color]


      Well, my point is that, I guess it's nice in a C world, but in a
      nice, mostly-pure OO environment like C#, it doesn't make a lot of
      sense. C# developers have come to expect that every language element
      will work 100% of the time exactly how it's supposed to work
      without any unintended side effects. Everything I've seen, read,
      and experienced with const is that it doesn't live up to that.

      There are several circumstances where const can be "gotten-around"
      and it seems that if you depend on const for something, you have
      failed in your design because you're trusting the runtime to
      validate everything which, like I said -- from what I've read,
      heard, seen -- cannot be done with const.

      It's one of those features that for every time you would use it,
      there's a better, and more elegant solution which doesn't use it.

      If you must be absolutely certain that X will not change in your
      example, and knowing that const can be cast away, why would you
      even use it? Why not copy X or make a read-only wrapper for X?
      [color=blue]
      > While you are correct that there are some OO people argue who against[/color]
      const,[color=blue]
      > OO is a good paradigm, but not the be-all and end-all of development.
      > It is very good for modelling a business problem. However, other[/color]
      paradigms, such[color=blue]
      > as functional programming, are vastly superior in almost every other[/color]
      way.

      Well, that's where the conversation must end. This is what I was
      talking about. Whenever there is a language feature debate with a
      Java/.NET guy and a C++ guy, the C++ guy usually brings up that argument
      that "OO isn't really that great" or "OO isn't the end-all be all".

      Well, if you make up that argument, then yeah, C++ is a great
      everything-and-the-kitchen sink language. But if you're mostly
      a purist and believe that OO should be 99% of what you do, then const
      is a fairly offensive notion.

      <snip>
      [color=blue]
      > b) as for templates: what's more messy/inconsistent/standardized?
      >
      > Hashtable bad = new HashTable();
      > bad.Add( 1, "red" );
      > string theObjectIAmHop ingLikeHellWill ActuallyBeAStri ng = (String)[/color]
      bad[ 1 ];

      C# Generics.
      [color=blue]
      > --- or ---
      >
      > Hashtable good = new HashTable<int, string>();
      > good .Add( 1, "red" );
      > string theValue = bad[2];[/color]

      C# Generics.

      You also conviently left out all the other abuses and misuses of
      templates
      that are very prevalent in the C++ world.

      -c


      Comment

      • Magnus Lidbom

        #33
        Re: Language inadequacies

        Another post with nothing but:
        "I've heard someone say ...<unsubstanti ated, vague attack on something>"
        and
        "You just want this because you believe in the wrong religion. The only true
        religion is pure OO"

        Not believing OO is the be all and end all of software development in no way
        implies that you don't know OO. Your continued assertions that C++ programmers
        don't understand OO, and hence all opinions of anyone who has ever used that
        language is to be disregarded, is nonsensical. Unless you're well acquainted
        with
        OO you're not a good C++ programmer, you may be a good C programmer, but
        definitely not a good C++ programmer. In my book you must be well acquainted
        with the paradigms a language primarily support to be able to claim to be any
        good with that language. If you're not, you're not even able to make an
        informed
        choice as to what paradigm is appropriate to solve a specific design problem.

        /Magnus Lidbom






        Comment

        • Harkos

          #34
          Re: Language inadequacies

          What I meant by proposing this ThrowsAttribute was a suggestion for
          Microsoft to implement on, possibly, .NET Framework 1.2

          []'s,
          Harkos

          "Günter Prossliner" <g.prossliner@g mx.at> escreveu na mensagem
          news:%23mIUPjzZ DHA.1940@TK2MSF TNGP10.phx.gbl. ..[color=blue]
          > I think the implementation in own classes (with Attributes) would be
          > possible, but IMO the problem is, that this MetaData is not available from
          > other classes like the Base Class Libray (BCL), or componets from other
          > vendors.[/color]


          Comment

          • Harkos

            #35
            Re: Language inadequacies

            Why don't you put something up the compiler where you can flag if you want
            or not to check these exceptions (like another cmd line param)? I've been
            giving thoughts about the attribute idea and believe it becomes useful once
            you can pick the exceptions list yourself from a MethodInfo.

            Another work-around could be to generate only warnings for non-treated
            exceptions, ignoring those signaled on the attribute. I agree with Hejlsberg
            but I also think there should be a way of telling our API users what they
            are to expect; allows us to create better applications.

            []'s,
            Harkos

            "Eric Gunnerson [MS]" <ericgu@online. microsoft.com> escreveu na mensagem
            news:ueoKTk2ZDH A.2404@TK2MSFTN GP10.phx.gbl...[color=blue]
            > I think this interview with Anders should answer some of your questions:
            >
            > http://www.artima.com/intv/handcuffs.html
            >
            > --
            > Eric Gunnerson
            >
            > Visit the C# product team at http://www.csharp.net
            > Eric's blog is at http://blogs.gotdotnet.com/ericgu/
            >
            > This posting is provided "AS IS" with no warranties, and confers no[/color]
            rights.[color=blue]
            > "Harkos" <harkos@uol.com .br> wrote in message
            > news:e4EsyByZDH A.2352@TK2MSFTN GP12.phx.gbl...[color=green]
            > > Talking about inadequacies, the only thing I really really really miss[/color][/color]
            in[color=blue]
            > C#[color=green]
            > > is the throws declaration on methods. Sometimes it is a real pain in the
            > > ass, but it sure keeps you from forgetting an exception.
            > >
            > > I believe they didn't include this because property declarations differ[/color][/color]
            a[color=blue][color=green]
            > > bit from methods (although they also throw exceptions). Then why don't[/color]
            > they[color=green]
            > > use these wonderful attributes they came with. It would be so easy.
            > >
            > > [Throws (typeof(Argumen tException),
            > > typeof(InvalidO perationExcepti on))]
            > > public void DoSomething(obj ect o) {
            > > // ...
            > > }
            > >
            > > It could get a little big but it should work. Somebody could come up[/color][/color]
            with[color=blue]
            > a[color=green]
            > > 3rd party compiler that could recognize these.
            > >
            > > []'s,
            > > Harkos
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Frank Olorin Rizzi

              #36
              Re: Language inadequacies

              [color=blue]
              >-----Original Message-----
              >"Frank Olorin Rizzi" <fkh1000@yahoo. com> wrote:
              >[color=green]
              >> ***** COULD WE PLEASE, please, PLEASE
              >> HAVE DEFAULT PARAMETERS ? ****[/color]
              >
              >I've worked around it like this:[/color]

              [..snip..]
              I know, I know... I do that all the times...
              ...but I just have an issue with things like:
              hmm.. I have a class with 10 private fields.
              When you instanciate an object of that class, you may know
              none, some, or all of the values you wish to stick in the
              10 fields.
              So, the naive approach, since we have no default
              parameters, is to have the following:
              myClass() {...}
              myClass(p1) {...}
              myClass (p1, p2) {...}
              myClass (p1, p3) {...}
              ....
              myClass(p1, p10) {...}
              myClass(p2, p3) {...}
              ....
              myClass(p2, p10) {...}
              myClass(p1, p2, p3) {...}
              myClass(p1, p2, p4) {...}
              and so on...

              The approach I am using lately is to provide *ONLY* one
              constructor, the "default" one:
              myClass() {...set up all the fields with default values...}
              and then provide setters for the fields, so that you can
              set them as you need.

              Is this elegant? nope.
              Is it "right" ? nope, it forces me to provide setters for
              all fields..
              Is it always feasable? nope, sometimes I have classes with
              fields that CANNOT have default values, and I am back to
              the "naive" solution (granted, with a smaller set of
              fields: only those that have no default)...

              ...but thanks for suggesting that, in case I had not done
              so yet :-)
              [color=blue][color=green]
              >> On the other hand, I ***LOVE*** Enums, but
              >> [...]
              >> I'd rather be able to do something like
              >> public enum myType
              >> {
              >> GOOD ("Good"),
              >> BAD ("Bad"),
              >> SO_AND_SO ("So and so")
              >> }[/color]
              >
              >I suppose you could simulate it with a hash table whose[/color]
              keys are enum[color=blue]
              >members, but that's not pretty.[/color]

              nope, and requires me to carry around a Hashtable...
              (ok, you make it static and public, and you have it from
              everywhere, instead of carrying it around, but
              nonetheless...) .

              I think that it wouldn't be an *incredibly* difficult
              thing to add, that's why I suggested it :-)

              Then again, I'm sure someone will say that it adds a
              complexity that is not needed :-)

              F.O.R.

              Comment

              • Chad Myers

                #37
                Re: Language inadequacies


                "Magnus Lidbom" <magnus_lidbom@ hotmail.com> wrote in message
                news:bi1smm$4bj ub$1@ID-204195.news.uni-berlin.de...[color=blue]
                > Another post with nothing but:
                > "I've heard someone say ...<unsubstanti ated, vague attack on[/color]
                something>"[color=blue]
                > and
                > "You just want this because you believe in the wrong religion. The[/color]
                only true[color=blue]
                > religion is pure OO"
                >
                > Not believing OO is the be all and end all of software development in[/color]
                no way[color=blue]
                > implies that you don't know OO. Your continued assertions that C++[/color]
                programmers[color=blue]
                > don't understand OO, and hence all opinions of anyone who has ever[/color]
                used that[color=blue]
                > language is to be disregarded, is nonsensical. Unless you're well[/color]
                acquainted

                blah blah blah.

                Look, at the end of the day, const is not good OO practice
                and C# is a strong OO language based on OO principles.

                If you don't like OO and you'd rather have const, then just
                stick with C++ and quit trying to ruin our OO utopia.

                We don't like const for a number of well argued reasons in
                the context of OO. If you disagree with OO, then you're arguing
                apples and oranges and we'll never get anywhere.

                Make a strong case for const in an OO environment, and then
                we have a discussion.

                -c


                Comment

                • Magnus Lidbom

                  #38
                  Re: Language inadequacies


                  "Chad Myers" <cmyers@N0.SP.A M.austin.rr.com > wrote in message
                  news:uIg00PEaDH A.1748@TK2MSFTN GP12.phx.gbl...[color=blue]
                  >
                  > "Magnus Lidbom" <magnus_lidbom@ hotmail.com> wrote in message
                  > news:bi1smm$4bj ub$1@ID-204195.news.uni-berlin.de...[color=green]
                  > > Another post with nothing but:
                  > > "I've heard someone say ...<unsubstanti ated, vague attack on[/color]
                  > something>"[color=green]
                  > > and
                  > > "You just want this because you believe in the wrong religion. The[/color]
                  > only true[color=green]
                  > > religion is pure OO"
                  > >
                  > > Not believing OO is the be all and end all of software development in[/color]
                  > no way[color=green]
                  > > implies that you don't know OO. Your continued assertions that C++[/color]
                  > programmers[color=green]
                  > > don't understand OO, and hence all opinions of anyone who has ever[/color]
                  > used that[color=green]
                  > > language is to be disregarded, is nonsensical. Unless you're well[/color]
                  > acquainted
                  >
                  > blah blah blah.[/color]
                  Such eloquence.
                  [color=blue]
                  > Look, at the end of the day, const is not good OO practice[/color]
                  Why?

                  <snip>
                  [color=blue]
                  > We don't like const for a number of well argued reasons in
                  > the context of OO.[/color]
                  What reasons? You've yet to name _one_..
                  [color=blue]
                  > Make a strong case for const in an OO environment, and then
                  > we have a discussion.[/color]

                  It allows a more precise specification of class interfaces by allowing a class
                  to promise that calling a get property, or a method, will not change the
                  observable state or behavior of the instance, it allows the passing around
                  of references to instances that the client must promise not to modify, and it
                  allows the compiler to verify at compile time that all these promises are
                  kept. It allows the programmer to make explicit parts of the contract between
                  a class and it's client that must be implicit without const, thereby
                  decreasing confusion, the number of times that the documentation must be
                  consulted, and preventing bugs.

                  How is this "bad OO"?

                  <snip>

                  /Magnus Lidbom











                  Comment

                  • Magnus Lidbom

                    #39
                    Re: Language inadequacies


                    "Chad Myers" <cmyers@N0.SP.A M.austin.rr.com > wrote in message
                    news:uIg00PEaDH A.1748@TK2MSFTN GP12.phx.gbl...[color=blue]
                    >
                    > "Magnus Lidbom" <magnus_lidbom@ hotmail.com> wrote in message
                    > news:bi1smm$4bj ub$1@ID-204195.news.uni-berlin.de...[color=green]
                    > > Another post with nothing but:
                    > > "I've heard someone say ...<unsubstanti ated, vague attack on[/color]
                    > something>"[color=green]
                    > > and
                    > > "You just want this because you believe in the wrong religion. The[/color]
                    > only true[color=green]
                    > > religion is pure OO"
                    > >
                    > > Not believing OO is the be all and end all of software development in[/color]
                    > no way[color=green]
                    > > implies that you don't know OO. Your continued assertions that C++[/color]
                    > programmers[color=green]
                    > > don't understand OO, and hence all opinions of anyone who has ever[/color]
                    > used that[color=green]
                    > > language is to be disregarded, is nonsensical. Unless you're well[/color]
                    > acquainted
                    >
                    > blah blah blah.[/color]
                    Such eloquence.
                    [color=blue]
                    > Look, at the end of the day, const is not good OO practice[/color]
                    Why?

                    <snip>
                    [color=blue]
                    > We don't like const for a number of well argued reasons in
                    > the context of OO.[/color]
                    What reasons? You've yet to name _one_..
                    [color=blue]
                    > Make a strong case for const in an OO environment, and then
                    > we have a discussion.[/color]

                    It allows a more precise specification of class interfaces by allowing a class
                    to promise that calling a get property, or a method, will not change the
                    observable state or behavior of the instance, it allows the passing around
                    of references to instances that the client must promise not to modify, and it
                    allows the compiler to verify at compile time that all these promises are
                    kept. It allows the programmer to make explicit parts of the contract between
                    a class and it's client that must be implicit without const, thereby
                    decreasing confusion, the number of times that the documentation must be
                    consulted, and preventing bugs.

                    How is this "bad OO"?

                    <snip>

                    /Magnus Lidbom











                    Comment

                    • Michael Mayer

                      #40
                      Re: Language inadequacies

                      "Frank Olorin Rizzi" <fkh1000@yahoo. com> wrote in message
                      news:0ed701c367 25$60c94580$a30 1280a@phx.gbl.. .[color=blue]
                      > On the other hand, I ***LOVE*** Enums, but I'd like to be
                      > able to define on the fly their ToString equivalents. For
                      > instance, if I have[/color]

                      You can use attributes. See this article:



                      <quote from article>
                      private enum MyColors
                      {
                      [Description("yu k!")] LightGreen = 0x012020,
                      [Description("ni ce :-)")] VeryDeepPink = 0x123456,
                      [Description("so what")] InvisibleGray = 0x456730,
                      [Description("no comment")] DeepestRed = 0xfafafa,
                      [Description("I give up")] PitchBlack = 0xffffff,
                      }

                      public static string GetDescription( Enum value)
                      {
                      FieldInfo fi= value.GetType() .GetField(value .ToString());
                      DescriptionAttr ibute[] attributes =
                      (DescriptionAtt ribute[])fi.GetCustomAt tributes(
                      typeof(Descript ionAttribute), false);
                      return (attributes.Len gth>0)?attribut es[0].Description:va lue.ToString();
                      }
                      </quote>
                      --
                      Mike Mayer
                      真人高清实拍女被破的视频,影音先锋熟女少妇,青青青国产最新视频在线观看,在线看人成呦呦视频影,亚洲永久网址在线观看,国产成人综合亚洲欧美,视频免费在线观看,国产精品欧美一区二区久久久

                      mike@mag37.com


                      Comment

                      Working...