Skip to Content
author's profile photo Former Member
Former Member

Can we please stop talking about classes?!?

Hi all,

i dont't get, why the official documentation of SAPUI5 and a lot of users in this forum use the term "class" in association with JavaScript. JavaScript isn't a class-based language but a prototype-based language.

Douglas Crockford's comment this issue in this way:

The most controversial feature of the language is the way it does inheritance, which is radically different than virtually all other modern languages. Most languages use classes – I call them ‘classical languages’ – JavaScript does not. JavaScript is class free. It uses prototypes. For people who are classically trained who look at the language, they go: well, this is deficient. You don’t have classes, how can you get anything done? How can you have any confidence that the structure of your program’s going to work? And they never get past that. But it turns out…

So i am of the opinion that, that we should use the correct term "prototypes" and not "classes"!

Regards Michael

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jan 06, 2014 at 03:06 PM

    I believe you're splitting hairs or exerting energy in the wrong direction.

    JS is a prototypical, loosely-typed language, yes, however many rightly chose to follow conventions of object-oriented principles such as inheritance, interfaces, private/public members, an so on. We could debate how JS isn't 'secure' with data encapsulation or it violates some OO-paradigm on a technicality, it's treated as OO all over the globe, not just SAP.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Jason,

      yeah, of course it's right, that many established OO paradigms from other languages can also be used in JavaScript. But i think, it's not a good approach to twist the natural characteristics of a programming language into something else, only because programmers feel more familiar with it.

      When i hear the word JavaScript, i have to think at closures, functions, prototypes and Duck-Typing. First you understand these concepts, you can gain all advantages of this language.

      But hey, that's just my personal opinion. Maybe i'm just a fanboy of prototype-based languages🤪...

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.