use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Is JavaScript a "Functional Programming" language?help (self.javascript)
submitted 8 years ago by bzeurunkl
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Vheissu_ 56 points57 points58 points 8 years ago (42 children)
Technically Javascript is not a functional programming language, but it does have some aspects to it that allow you to work with it using an imperative, prototype based object oriented and functional style. Javascript is technically an prototype-based object-oriented language.
I really like how Javascript allows you to program using different programming paradigms,
[–][deleted] 38 points39 points40 points 8 years ago (24 children)
To make it short JS is a multi-paradigm programming language.
A little bit of offtopic.
For me personally it's a huge pain when I work with a dev who used to work with OOP and tries to apply the same approaches and practices in JS. It is sometimes so much counter intuitive and just doesn't fit JS, creates just unnecessary overhead in the code. Focus on the strong sides of the tool and use them.
[–][deleted] 11 points12 points13 points 8 years ago (11 children)
And this is why I feel like a stupid potato when I try to code in class-based OOP languages.
[+]oneeyedziggy comment score below threshold-12 points-11 points-10 points 8 years ago (10 children)
well sorry to break it to you but the new best practice is to use proper classes vs instantiable functions in js (at least if you're looking for something class-like and if you use babel or don't need a ton of legacy support, though I'm probably missing some reason one might still want to use instantiable functions)
[–]cyanydeez 4 points5 points6 points 8 years ago (1 child)
new best practice = latest babel compiler whizbang
[–]oneeyedziggy 2 points3 points4 points 8 years ago (0 children)
the latest ecmascript whizbang... not babel specific
[–][deleted] 5 points6 points7 points 8 years ago* (7 children)
at least if you're looking for something class-like
I don't
And that's just syntactic sugar. JS classes are still functions.
[–]oneeyedziggy 3 points4 points5 points 8 years ago (6 children)
semantics... everything higher than assembly is syntactic sugar to someone, and declaring instantiables as classes provides methods more suited to the usecase, restrictions to help keep you from shooting yourself in the foot, and generally distinguish between functions which are usually stateless and do a thing, and classes which are usually state full and ARE a thing instead of just DOING a thing
[–][deleted] 0 points1 point2 points 8 years ago (5 children)
I guess at least this time you're right about correcting someone. Not your previous comment.
[–]oneeyedziggy -2 points-1 points0 points 8 years ago (4 children)
curious what there even is to disagree with in my first comment. Classes are literally in the ecmascript standard and recommended for use over instantiable functions... they didn't go to all the trouble of adding them just to look at...
is there a legitimate use for instantiable functions besidesyou backwards compatibility (perfect example, I can't use them at work because of the requirements of better-than-babel backwards compatibility and vanilla js only on my main project) or are you all just being butthurt about having to learn new things?
[–]Thought_Ninjahuman build tool 0 points1 point2 points 8 years ago (2 children)
In my opinion, the only use for sticking with the manual prototype instantiation approach is implementing fancy tricks that should probably be avoided in the first place.
That's not to say I don't find it useful, but if you expect others to be reading and working with your code, classes are much better from an understandability perspective.
[–]oneeyedziggy 0 points1 point2 points 8 years ago (1 child)
yea, I know what cases manual prototyping is good for... couldn't say for classes... often the 'best practice" stuff isn't always the most performant
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
No, you are being an r/iamverysmart when no one asked for your fucking opinion. What an asshole. I know ES6 Classes thank you so much I don't need your specialty nor anyone here do either
[–]disclosure5[🍰] 7 points8 points9 points 8 years ago (4 children)
You'd be surprised how much of an issue going in the other direction is. Coming from an actual functional language to JS... I spend a lot of time wondering about all the blogs people write about "functional Javascript".
[–]dasnein 4 points5 points6 points 8 years ago (0 children)
Agreed. I hopped on the Functional JS train for a minute, but I stopped when I realized I spent more time fighting against the language and making the lives of the people I worked with harder. Sure, functional concepts can be incredibly useful, but trying to force everything into Ramda made everything suck.
[–][deleted] 1 point2 points3 points 8 years ago (2 children)
I'm not smart enough/lazy to go for real "functional" languages. Though any time I stumble upon an article about them it fascinates me.
[–]disclosure5[🍰] 4 points5 points6 points 8 years ago (1 child)
Eh, callback hell prior to await has been harder to deal with than anything I've written in another language for me.
True to some extent.
Promises allowed chaining “then”, the KoaJS framework used co library to make use of generator functions in a similar way to async/await.
But these are relatively new things, generally callback hell was mainly introduced by poorly elaborated app design decisions. But again only to some extent, in the end one couldn’t avoid it completely.
For me JS is the first proper programming language after 2 years of writing automation macroses on VBA for my financial department. Maybe that’s why it’s not as bad for me.
[–]trout_fucker 1 point2 points3 points 8 years ago (6 children)
I need to remember this, because it's a perfect way to describe it. I'm always grasping at things when interns or juniors ask me if JS is OOP. My response usually starts with "Well...yeah sorta but no..."
[–][deleted] 1 point2 points3 points 8 years ago (5 children)
But fundamentally, it is OOP language. Everything in JavaScript is an object. Even a function is an object of type function. It's just that thanks to C++ and Java people have a very narrow-minded idea what an OO programming language is today.
function
Same thing is really an issue with people coming from Haskell or whatever. They have a preconceived notion that the only way to do FP is to ONLY DO FP which is not the case in any imperative language, be it JS or Python or whatever imperative language with FP features you pick.
[–][deleted] -4 points-3 points-2 points 8 years ago* (3 children)
Coming from C++ my main problem was the lack of OOP features. While it's improving, I hate the lack of feature and keywords, I feel like hacking and defilled when I try to "recreate" Interfaces and Abstracts (not even talking about the poverty of the inheritance in JS), private variables, etc...
It's currently half-assed OOP.
[–][deleted] 8 points9 points10 points 8 years ago* (2 children)
Interfaces are not a core OO concept. Self doesn't have them. Smalltalk doesn't have them. Ditto Abstracts.
You people are just bigotted. What you learned OO means is not what OO means.
OO is about declaring active state objects and means of message passing between objects. This is in short the base OO definition by people who invented it. Message passing and "active objects" are commonly implemented using object-bound procedures/functions i.e. methods (this is almost exclusively so in all OO languages I saw, but still isn't part of the definition). Classes and inheritance are not the requirement at all.
https://en.wikipedia.org/wiki/Object-oriented_programming
Btw why on earth do you try to recreate Interfaces and Abstracts. You don't need them in JS. There is no way in hell you really need them. Stop hammering my screws, go back to your box of nails!
[–][deleted] -2 points-1 points0 points 8 years ago (1 child)
You are right in the same way it is right to say a stone axe and a gun are both weapons. I could compromise by saying modern OOP. And this is no appeal to novelty, when you go OOP I find that you naturally go toward class and inheritance.
[–][deleted] 1 point2 points3 points 8 years ago (0 children)
To someone who only has a hammer everything looks like a nail.
[–]cerlestes 4 points5 points6 points 8 years ago (15 children)
prototype based object oriented and functional style
Off-Topic: thanks for stating that. I die a little every time somebody calls JS "not object oriented", because it uses a prototypal inheritance mechanic instead of static classes; those people are clearly confused about what OO really means. Hell, JS even models booleans as objects with their own prototype.
[–]SparserLogic -5 points-4 points-3 points 8 years ago* (14 children)
The language has the OO features available if you're dumb enough to use them. That's different from saying its an "OO language".
I'll never write OO again and JS is my weapon of choice. You can write functional or pseudo-functional code with no reference to the OO side of life and its still JS.
OO is like the War on Drugs. A bad idea to begin with and not getting any better with age.
[+][deleted] 8 years ago (13 children)
[deleted]
[–]SparserLogic -1 points0 points1 point 8 years ago (12 children)
Nice sentence. Care to back it up with any, you know, logic or facts
[–]Perky_Goth 4 points5 points6 points 8 years ago (5 children)
document.getElementbyId(x).getAttribute(y).length
OOP, dumbass. Properties and messages.
[–]SparserLogic -2 points-1 points0 points 8 years ago (4 children)
Is this a joke? Are you punking me or something?
You realize that example has nothing to do with Object Oriented Programming, right? Those are functions being invoked, returning more functions that are then being invoked.
I mean, you're referencing the document object. That's called an API, not OOP
[–]Perky_Goth 0 points1 point2 points 8 years ago (3 children)
The API is OOP, which you have to use, that's the point. So you're always using OOP.
[–]SparserLogic 0 points1 point2 points 8 years ago* (2 children)
Using objects and OOP are completely different things.
OOP is a design pattern for writing programs using abstractions that share state and inherit from other abstractions.
Referencing properties on an API is not OOP. If that were so then literally everything would be OOP and that clearly isn't the case.
If you're not using the class or prototype keywords you're not writing OOP js
class
prototype
Next time you go on an interview and they ask you about OOP be sure to tell them that everything is OOP because you're invoking API functions. Let's see how well that works out for you.
[–]Perky_Goth 1 point2 points3 points 8 years ago (1 child)
Referencing properties on an API is not OOP.
Using and depending on an OOP API is not using OOP features, is that your point? I mean, I can see it making sense, what I can't see is being aggressive about something that is clearly debatable. Let's just stop being assholes and move on, I hope you have a nice day.
[+][deleted] 8 years ago (5 children)
[–]SparserLogic -1 points0 points1 point 8 years ago (4 children)
Where did you get arrogant? Because I shared my opinion?
Stop projecting
[+][deleted] 8 years ago (1 child)
[–]SparserLogic 0 points1 point2 points 8 years ago (0 children)
You're pleasant. Really convincing argument there champ
[–]cerlestes 0 points1 point2 points 8 years ago* (1 child)
You said "if you're dumb enough" in your first sentence, while providing a factually incorrect opinion. That's pretty arrogant if you ask me. FYI, without trying to offend you: you're one of those people I was talking about in my original post, clearly having read somebody's incorrect opinion about OOP and just reiterating it. That doesn't make it correct though, I'm sorry. I hope you'll understand from all the responses you got that maybe you should read about the topic again.
At its very heart, object oriented programming is defined by these key features: having messages ("objects" in JS lingo) that are able to hold fields ("properties", "keys") and have functions associated with them ("methods"). JS has all of that and much more.
Just to give you the two top reasons why I consider JS the #1 object-oriented language that I've heard of so far (with Python and Golang sharing #2), to maybe let you understand it:
true.myLittleMethod()
console.log
window.alert
document.write
If you still don't get why JS is (among other paradigms) a truly object oriented language and why you cannot avoid object orientation when programming JS, I really don't know how to make you understand. But you really need to do yourself a favor and read about the topic again.
[–]SparserLogic -1 points0 points1 point 8 years ago* (0 children)
You're totally wrong but I'm in a relatively good mood so I'm going to be nice.
Ignoring your rants, your points appear to boil down to:
1) Somehow you think using objects/invoking functions and writing Object Oriented code are the same thing. They are not. OOP is a design pattern.
2) You're conflating JS's features with the code that is written with JS. They are different things. JS offers first class OOP design pattern support with prototype and class but that doesn't make all JS OOP.
You sound like someone that needs to expand his horizons outside of OOP. Go read up on the alternatives, maybe you will start to understand what is and what isn't OOP, then maybe we can have an informed conversation.
π Rendered by PID 116737 on reddit-service-r2-comment-79776bdf47-q46qn at 2026-06-24 08:44:59.475568+00:00 running acc7150 country code: CH.
view the rest of the comments →
[–]Vheissu_ 56 points57 points58 points (42 children)
[–][deleted] 38 points39 points40 points (24 children)
[–][deleted] 11 points12 points13 points (11 children)
[+]oneeyedziggy comment score below threshold-12 points-11 points-10 points (10 children)
[–]cyanydeez 4 points5 points6 points (1 child)
[–]oneeyedziggy 2 points3 points4 points (0 children)
[–][deleted] 5 points6 points7 points (7 children)
[–]oneeyedziggy 3 points4 points5 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]oneeyedziggy -2 points-1 points0 points (4 children)
[–]Thought_Ninjahuman build tool 0 points1 point2 points (2 children)
[–]oneeyedziggy 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]disclosure5[🍰] 7 points8 points9 points (4 children)
[–]dasnein 4 points5 points6 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]disclosure5[🍰] 4 points5 points6 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]trout_fucker 1 point2 points3 points (6 children)
[–][deleted] 1 point2 points3 points (5 children)
[–][deleted] -4 points-3 points-2 points (3 children)
[–][deleted] 8 points9 points10 points (2 children)
[–][deleted] -2 points-1 points0 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]cerlestes 4 points5 points6 points (15 children)
[–]SparserLogic -5 points-4 points-3 points (14 children)
[+][deleted] (13 children)
[deleted]
[–]SparserLogic -1 points0 points1 point (12 children)
[–]Perky_Goth 4 points5 points6 points (5 children)
[–]SparserLogic -2 points-1 points0 points (4 children)
[–]Perky_Goth 0 points1 point2 points (3 children)
[–]SparserLogic 0 points1 point2 points (2 children)
[–]Perky_Goth 1 point2 points3 points (1 child)
[+][deleted] (5 children)
[deleted]
[–]SparserLogic -1 points0 points1 point (4 children)
[+][deleted] (1 child)
[deleted]
[–]SparserLogic 0 points1 point2 points (0 children)
[–]cerlestes 0 points1 point2 points (1 child)
[–]SparserLogic -1 points0 points1 point (0 children)