Announcement

Collapse
No announcement yet.

Ubuntu's Unity Written In Qt/QML For "Unity Next"

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #81
    Originally posted by dee. View Post
    Oh really.
    So prototype-based languages, like Javascript or Lua, aren't actually "real OOP"?
    They have equivalent.

    Comment


    • #82
      Originally posted by JS987 View Post
      They have equivalent.
      Which is the essential feature you don't have in C which prevent real OOP . Classes is only a name on a solution. What is the essential feature C lack?

      Comment


      • #83
        Originally posted by Akka View Post
        Which is the essential feature you don't have in C which prevent real OOP . Classes is only a name on a solution. What is the essential feature C lack?
        I already said which features C is missing.
        You can read docs about classes
        http://www.cplusplus.com/doc/tutorial/classes/
        http://en.wikipedia.org/wiki/Class_(...r_programming)

        Comment


        • #84
          Originally posted by JS987 View Post
          I already said which features C is missing.
          You can read docs about classes
          http://www.cplusplus.com/doc/tutorial/classes/
          http://en.wikipedia.org/wiki/Class_(...r_programming)
          OOP has actually very little to do with the "class" keyword. That's just a convenience. You can build powerful object oriented systems in C using function pointers. To harness OOP you basically just need to be able to implement polymorphism, which you can do in C using function pointers. The syntax isn't as pretty but it works.

          Similarly just because you're writing code using the "class" keyword doesn't mean you're writing an object oriented program. Many programs use "classes" as just modules to group related code not to create real objects.

          Comment


          • #85
            Originally posted by admax88 View Post
            OOP has actually very little to do with the "class" keyword. That's just a convenience. You can build powerful object oriented systems in C using function pointers. To harness OOP you basically just need to be able to implement polymorphism, which you can do in C using function pointers. The syntax isn't as pretty but it works.
            Similarly just because you're writing code using the "class" keyword doesn't mean you're writing an object oriented program. Many programs use "classes" as just modules to group related code not to create real objects.
            Function pointer isn't same as method. You can't do real OOP without methods.
            C++ supports also functional programming. It's your decision if you use OOP or not.

            Comment


            • #86
              Originally posted by JS987 View Post
              Function pointer isn't same as method. You can't do real OOP without methods.
              C++ supports also functional programming. It's your decision if you use OOP or not.
              A method is nothing but a function that gets passed an object reference, sometimes implicitly (as in C#, Java), sometimes explicitly (as in Python).

              There's no reason you can't create functions and pass references (pointers) to them as parameters in C.

              GObject is an object-oriented type system, written entirely in C. It's a C library. Then there's Vala, which is similar in syntax to C#, supports all the OOP features from C#, and it compiles to C + GObject code. You can try it yourself. Go on, write whatever small program with what you consider OOP, in Vala. Then compile it and look at the resulting C code. There's the same OOP code, but on a lower level, with all the abstractions showing as raw code.

              Comment


              • #87
                Originally posted by JS987 View Post
                They have equivalent.
                And no, no they haven't. Look up what prototype-based OOP is about. There's no classes, instead objects are made by cloning other objects (you create an object "prototype" that other objects are based on, hence the name). So no, classes are not necessary for OOP, they're just abstractions, a way of saying "this object creates other objects". Prototype-based OOP does away with the distinction between classes and objects, there's just objects that can make copies of themselves and those copies can be extended.

                Comment


                • #88
                  Originally posted by dee. View Post
                  A method is nothing but a function that gets passed an object reference, sometimes implicitly (as in C#, Java), sometimes explicitly (as in Python).
                  There's no reason you can't create functions and pass references (pointers) to them as parameters in C.
                  GObject is an object-oriented type system, written entirely in C. It's a C library. Then there's Vala, which is similar in syntax to C#, supports all the OOP features from C#, and it compiles to C + GObject code. You can try it yourself. Go on, write whatever small program with what you consider OOP, in Vala. Then compile it and look at the resulting C code. There's the same OOP code, but on a lower level, with all the abstractions showing as raw code.
                  C++ method is different from C function. Method is part of class namespace, but function is declared in global namespace.
                  In real OOP data are private and you have to use methods to access data. Direct access to private data in structure passed as reference isn't possible.
                  Vala compiler converts OO code to non-OO code. C code is never real OO code.

                  Comment


                  • #89
                    Originally posted by dee. View Post
                    And no, no they haven't. Look up what prototype-based OOP is about. There's no classes, instead objects are made by cloning other objects (you create an object "prototype" that other objects are based on, hence the name). So no, classes are not necessary for OOP, they're just abstractions, a way of saying "this object creates other objects". Prototype-based OOP does away with the distinction between classes and objects, there's just objects that can make copies of themselves and those copies can be extended.
                    They have dynamic/anonymous classes.

                    Comment


                    • #90
                      Originally posted by JS987 View Post
                      C++ method is different from C function. Method is part of class namespace, but function is declared in global namespace.
                      In real OOP data are private and you have to use methods to access data. Direct access to private data in structure passed as reference isn't possible.
                      Vala compiler converts OO code to non-OO code. C code is never real OO code.
                      Encapsulation? You can do it, the compiler don't help you obviously. But you can do it in c? Dee. has already said how. Structs with data and with functions with pointers to operate on the data and you have a simple solution.

                      I do not now any practical easy way to get inheritance (I'm sure you can do it?) but I don't think that is a requirement for OOP. I'm sure most of the basic OOP patterns is older than the OOP languages.
                      Last edited by Akka; 03-11-2013, 03:56 PM.

                      Comment

                      Working...
                      X