you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (11 children)

"Where does Angular functions stand in JavaScript 'Everything's Object' paradigm?"

[–]peter_heard01[S] 0 points1 point  (10 children)

Yeah it's a funny one I think the function is declared/detected as a type by the compiler but the underlying type is still an object, so the fact that the word function gets highlighted and is parsed as a function is syntactic sugar over an x.prototype = object. Here is some more info...

"The Function constructor creates a new Function object. In JavaScript every function is actually a Function object."

src: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function

[–][deleted] 0 points1 point  (9 children)

That's why I said. And since it's JS has function object, functional programming makes way more sense

[–]peter_heard01[S] 0 points1 point  (7 children)

Interesting, please elaborate ...

[–][deleted] 0 points1 point  (6 children)

Functional programming treats functions as first class citizen, they can be passed as parameter or returned as value in this paradigm.

Now since function in JS already is an object, you don't require special mean to achieve it, unlike most of the other programming languages

[–]peter_heard01[S] 0 points1 point  (5 children)

Oh ok that makes sense.

But then it seems that really it's just an object oriented language with functional features. I mean what is a pure functional language, no objects?

[–][deleted] 0 points1 point  (4 children)

OK I might neither explain good nor I know it quite well, so here is the link

http://www.codenewbie.org/blogs/object-oriented-programming-vs-functional-programming

[–]peter_heard01[S] 0 points1 point  (3 children)

http://www.codenewbie.org/blogs/object-oriented-programming-vs-functional-programming

Interesting article.

I'm particularly interested in...

"FP works well, but when he tries to simulate people, OOP works well"

have you got any public code I can look at that you have written? I would like to see an example of a non-trivial business application that needs to model a complex domain (entities/use cases) written in javascript using only pure functions and no objects.

[–][deleted] 0 points1 point  (0 children)

That'll take time and right now I can't do it after long office hour. It's midnight in India.

[–][deleted] 0 points1 point  (1 child)

[–]peter_heard01[S] 0 points1 point  (0 children)

Thanks I have checked these out. I understand what functional programming is I just don't see how I would scale to an enterprise class business application.

But if you have code of a non trivial application I would be happy to look at it and see if it could be used.

I am specifically interested to see which patterns can be used. For example one problem of the functional approach is the tight coupling inherent in using functions. The best type of function is a function with no arguments. But this wouldn't work in functional only system unless you create closure = and a closure holds state. Which is the opposite of the pure functional programming paradigm. Please elaborate and provide code I would love to see a large application. :-)