Page 9 of 12 FirstFirst ... 7891011 ... LastLast
Results 81 to 90 of 118

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

  1. #81
    Join Date
    Sep 2012
    Posts
    358

    Default

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

  2. #82
    Join Date
    Jul 2011
    Posts
    368

    Default

    Quote 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?

  3. #83
    Join Date
    Sep 2012
    Posts
    358

    Default

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

  4. #84
    Join Date
    Jun 2009
    Posts
    28

    Default

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

  5. #85
    Join Date
    Sep 2012
    Posts
    358

    Default

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

  6. #86
    Join Date
    Jan 2013
    Posts
    1,461

    Default

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

  7. #87
    Join Date
    Jan 2013
    Posts
    1,461

    Default

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

  8. #88
    Join Date
    Sep 2012
    Posts
    358

    Default

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

  9. #89
    Join Date
    Sep 2012
    Posts
    358

    Default

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

  10. #90
    Join Date
    Jul 2011
    Posts
    368

    Default

    Quote 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 at 03:56 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •