Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

All data types in those languages are objects.


I agree (generally speaking).

I'm not sure at what point MVC based design patterns became the definition for OOP but stranger things have happened.

People calling JavaScript the new HTML5 gets me everytime!

To be fair though the topic of discussion was semantics so if we are only talking about semantics it is correct as per the dictionary terminology to call JavaScript an FP or an OOP because it is both.


First you said that these languages are 'OO'. Confronted with evidence that, in fact, they are multi-paradigm languages and that includes functional style you changed your argument.

Now you're saying that those languages are not functional, because all the main datastructures in them are implemented as objects. Well, object models of JavaScript, Python and Ruby are vastly different and so I have to infer very wide definition of an object - that of data+methods - because there is nothing more that all three languages agree on in case of objects.

I have to tell you this - this kind of objects is not unique to OOP. The only difference between C, for example, and Python in this respect is that you call "methods" like this:

    list_append(my_list, my_element);
instead of

    my_list.append(my_element) # but note that you can write like this too:
    list.append(my_list, my_element)
My point is that every datastructure is an object. Every datastructure has some data (internal representation) and methods operating on them. LinkedList or HashTable is going to be an object no matter which notation you use to access them.

There is more to OOP than just objects, of course, but that does not matter. You can program in functional style using your language built-in objects without any problem at all. Take a look at PowerShell, for example of something even more exotic: turns out you can program in purely procedular language while using objects from .NET framework. On the other hand, there are bindings to wxWindow for Erlang; turns out you can program in purely (as in 'not supporting other paradigms'!) functional language using objects too.

I don't really know what you're trying to say, but JavaScript, Python and Ruby are perfectly capable of functional programming and can be used as languages supporting functional style. There is really no counterargument for this - or at least the fact that operations on main datastructures of these languages are implemented with syntactic sugar is not one.


My argument is still the same.

By having the data types exposed as objects, it doesn't matter what you do, because from the CS point of view you are still manipulating objects.

Even lambdas and functions are objects with some kind of invoke method.

So it is not possible to use those languages without OO, because OO is part of the language's type system.

Using CS language speak, you cannot do language semantic analysis without making use of the object semantics.


I think I don't understand what you mean. Why does it matter how lambda is implemented on the language level if it retains lambda semantics?

Also, it seems that only languages you think worthy of being called "funtional" are various (typed or not) lambda calculi implementations?

What is Scala, then? Not functional at all, too?

Could you maybe provide a few examples of languages you'd call "functional" or "supporting functional programming paradigm"?


Standard ML, Haskell, Miranda, Lisp, Scheme, OCaml, F#


Ok, thanks, now I understand what you mean.

Just note that F# is not functional by your definition, because all it's core datastructures (tuples, arrays, lists) are actually objects, with methods on them etc.


Regarding F# I was not sure if I should have mentioned it.

Still do not much about it or how its implementation generates code, as the MSIL supports much more than just OO constructs.


Yeah, but it's not possible (I think, but am not 100% sure) to reason about F# code without object semantics because of how it's implemented: it probably could be implemented on top of MSIL without objects, but (again, not 100%, but 95% sure :)) it isn't.

I thought about another language I think you'd call functional: Lua. It supports first- and higher-order functions and has no objects at all in the core language. What do you think?

Also, now that I understand what you mean I can agree with you, but you do realize that this is not very common definition of "functional", right? :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: