Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Irfan Ullah
Irfan Ullah
6,869 Points

What type of Paradigm language JavaScript is ?

Please can any body tell me what type of paradigm language javascript is? I know it support prototype base inheritance. Is it single paradigm or multi paradigm language ?

4 Answers

James Barnett
James Barnett
39,199 Points

> Multi-paradigm: scripting, object-oriented (prototype-based), imperative, functional

source: https://en.wikipedia.org/wiki/JavaScript

JavaScript is a bit of a mongrel, to be honest. Don't get me wrong, it's my favourite programming language, but due to the fact that it was pretty much built in 10 days, it's all over the place.

Yes, it's multi-paradigm. It's object-oriented more than most languages as everything is an object. The inheritance is prototype-based, pretty much based on Self (a dialect of Smalltalk). It's functional, supporting first-class functions. Functions are objects so they can be passed around. It's imperative with a Java-like syntax. See? A mongrel.

Brendan Eich (the creator of JavaScript) always listed Self, Scheme (a dialect of Lisp), Java and C as the main influences for the language.

Note that the next standard of JavaScript (ECMAScript 6) will support classes so in some ways it'll become a "real" object-oriented language, whatever that means. :)

I've found it most helpful to think of JavaScript as a functional language, the rest is just a bonus. That way of thinking always allows me to find elegant solutions for problems.

Also, it's nice to note that the scripting part of JavaScript depends on where it's being executed. Chrome's V8 compiles JavaScript (2 times, in fact, the second one doing optimisations) to native machine code. Mozilla's SpiderMonkey also features JIT compilers for the language, as does Chakra (IE). Safari's Nitro also compiles JS into native machine code.

Irfan Ullah
Irfan Ullah
6,869 Points

Thank you very much guys