Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    911
    Thanks
    302
    Thanked 2 Times in 2 Posts

    Question Does JavaScript Support OOPs?

    I have heard from many and have read a lot that JS does not support OOPs. Then how come mootools claim that their framework supports Object-Oriented JavaScript ?

    Someone Pls throw some light on this.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,174
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    Depends on how you define OOPS. Where the "S" (System) gets the most emphasis.

    I would say that JavaScript is one of the few *TRUE* Object Oriented Programming Languages in existence. Truly, the Object is the basis of everything in JS!

    JavaScript is *NOT* a Class Oriented Programming Language. It doesn't support the whole concept of classes. (Yes, I know, readers: There are ways to make JS behave AS IF it had classes. Sorry, but it is still not "Class Oriented".)

    And many books that talk about OOPS expect that the language in use does support classes and all that goes with them.

    It's interesting (to me): At one point in my life I was working on a team that created a combined Java and C++ programming system. You really could code one class in Java and another in C++ and they would automatically be aware of each other. You could even have a base class in C++ with a derived class in Java and then a class derived from the Java class back in C++. Wonderful system. *sigh* ANYWAY...we discussed for a long time adding truly dynamic *OBJECTS* to both C++ and Java in that system! In other words, just as you can do in JavaScript, you could have AT RUNTIME added methods and properties to an individual object without modifying the class it was an instance of. Now *THAT* would have been an OOPS in any meaning of the term that you want to apply.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    Dormilich (05-25-2012)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,174
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    The argument about the definitions of all of these terms has been going on for more than 20 years. I don't expect it to end soon.

    A long time ago, I started calling Java/C++/C#/et al. "class oriented" just to be able to distinguish them from "object oriented". But iBall's definitions are shared by just as many as those who might agree with me. And then there will also just as many (or probably more) who won't agree with either of us.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,174
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    But you forgot the ones who agree with both of us! And mostly you forgot the 99.7% who either have never heard of OOPS or who don't give rat's patootie. <grin/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,174
    Thanks
    75
    Thanked 4,339 Times in 4,305 Posts
    Ah, no...YOU assumed that the options given constituded the universal set!

    Read again (with added parenthetical content <grin/>):
    But iBall's definitions are shared by just as many [2 people] as those who might agree with me [2 people]. And then there will also just as many (or probably more) [397 people] who won't agree with either of us.
    The only "absolute" number in there is the number of people who agree with me. And since I can only definitively name two other persons who use the same terms I do...

    [Well, I think there are more than 2, but I can't prove it. <grin/>]
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    The great advantage of being on iBall's ignore list is that he cannot seize on something in one of my posts to start a pointless and belligerent argument.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by iBall View Post
    I see javascript as Object Based as opposed to Object Orientated given that OOP = Object Orientated Programming
    just for my information, how do you define "Object Based" and "Object Oriented"?

    Edit: personally, I go along the definition given in Wikipedia:

    Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs.
    Last edited by Dormilich; 05-25-2012 at 07:37 AM.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #8
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by iBall View Post
    Object Based to me means it has functionality similar to, but not including all the concepts and functionality behind a programming object.
    that leads to the question: what are all those concepts?

    again, I would go along the definitions mentioned by Wikipedia:
    Fundamental features and concepts
    [...]
    Similarly, in his 2003 book, Concepts in programming languages, John C. Mitchell identifies four main features: dynamic dispatch, abstraction, subtype polymorphism, and inheritance. Michael Lee Scott in Programming Language Pragmatics considers only encapsulation, inheritance and dynamic dispatch
    all those mentioned concepts are fulfilled in JS.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #9
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,619
    Thanks
    0
    Thanked 645 Times in 635 Posts
    JavaScript is a prototyping language - since OOP is a subset of what a prototyping language can do you can of course use OOP with JavaScript but it can result in the code being longer and more convoluted than it might be if you were to use the full power of the language.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #10
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    I just wanted to know your definitions, because this whole discussion is all about them (and that’s why it goes on since 20+ years). (I am aware that we will never have matching definitions of OOP)
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #11
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    the only problem with that is that
    all the concepts and functionality behind a programming object
    are not (necessarily) known to me, as I am not a professional programmer. (ok, a citation would suffice)
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

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