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

The example given in the article is not compelling -- there are only two arguments in play, so passing two arguments directly instead of passing an object holding those two things isn't painful.

To me the big win of classes isn't inheritance, it is that functions and related data live in a common scope.

If you write your code as a bag of data structures and a bag of functions that you pass those ad-hoc data structures to, it is less clear which things play together.



I would say that is simply down you you not being experienced with writing code this way.

Once you begin writing functional code more regularly, you will get much the opposite way of thinking. Today I find it frustrating that I need an object first. In my mind, I already know what action I want to do. I know what function I want to call. I start with that and look at what arguments it takes in.

OOP programming is frustrating now, because instead of going straight for the function I have to locate the appropriate object first. That is like a big detour.

> If you write your code as a bag of data structures and a bag of functions that you pass those ad-hoc data structures to, it is less clear which things play together.

Noting suggest you need to write code like that. People who write functional code tend to have a lot of well defined data types. I use well defined data types in Julia. Haskell and OCaml developers use well defined data types. We are not using using dictionaries or something.


This is exactly how I felt after learning Elixir and then coming back to Python. Object orchestration is painful.


Not only that, but the second example is object-oriented, he's just doing it "by hand" rather than taking advantage of the built-in language syntax (which, in spite of his insistence to the contrary, does make it clearer what's actually going on).




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

Search: