I like functional programming. Yet I am afraid that when the community dogmatically jumps into it as functional = good, OOP bad we are not helping functional or the industry at large.

Doing this closes the world of possibilities. Perhaps using logical programming makes solving a problem easier. But we won't even consider it if we don't even know that it exists

@hugoestr Especially when object-oriented programming and functional programming are solutions to different problems, and are complementary.
Object-oriented programming is about structuration of data and code and separation of concerns. It answers the "where ?" question.
Functional programming is about how to write functions and methods. It answers the "how ?" question.

Follow

@Feufochmar @hugoestr

I have a very hard time to understand in what situations OOP such as found in Python (because that is the only PL with OOP I practice); how OOP is useful?

I am not a very knowledgeable about functional programming, tho. Furthermore, I do not think I am a functional fanboy.

OOP is overkill. Using functions is enough.

No need to into more complex abstraction such as whatever Haskell does (some of the things I understand are interesting, and useful).

· · Web · 2 · 0 · 1

@Feufochmar @hugoestr

I grow to understand what people call “functional programming” is in fact everything that is well thought, with decades of groundings.

Something is clear: the term functional programming, is not enough to describe the patterns, and practices that are less mainstream.

Whereas OOP is whatever mainstream PL do.

Do we really need to power up our PLs with metaclasses to be able to do DSLs? That is what Python does with the so-called declarative syntax.

@Feufochmar @hugoestr

> Perhaps using logical programming makes solving a problem easier. But we won't even consider it if we don't even know that it exists

+ 💯 that is what I am trying to explain to my boss. We keep staying in a mainstream comfort zone (ORM, Python, JavaScript, Docker, k8s, clouds etc…) without considering, and even less trying alternatives. Cargo-culting whatever news.ycombinator.com zealots toot and boost because it brings their way more cash.

@amirouche @hugoestr Sadly, from a manager point of view, it's preferable to stay in a mainstream comfort zone, as it's easier and cheaper to find people to maintain the code with widespread technologies, than to find people to maintain niche technologies.
However, it would be an error to not have someone to do technological watch for the future projects, or be future-proof for the current projects, especially as the block you use become unmaintained over time.

@Feufochmar @hugoestr

> it brings their way more cash.

Following the zealots bring even more cash to the zealots.

@Feufochmar @hugoestr

My scheme code is much bigger than a couple of hundreds of lines of code, and I use no niche algorithms.

@amirouche @Feufochmar Going off the mainstream path can be the business advantage that a small company needs

@Feufochmar @amirouche Mainstream OOP and probably mainstream functional are usually a procedural programming that does hurried attempt to adopt their practices.

A well thought out OOP system can give a huge productivity advantage to a small team. When you see one working well, it feels like magic.

I used to think that this was because OOP evangelists did a poor job of explaining what OOP was about. I still think there was a lost opportunity there.

Functional has many books and courses that teaches the principles well. Yet I am seeing the same mismatch between theory and practice.

@amirouche @hugoestr How large is the code base you maintain in your projects ?

Once your code base reach a certain size, you need to abstract the data you manipulate into datastructures and gather the functions that operates on those in the same place, so that the code is easier to maintain. Also, you usually want to restrict the visibility of functions to only expose a public interface for your datastructures, because some functions are just implementation details that are called from the functions of the public interface.
What I have described here is what object-oriented programming is about : organizing your code around abstractions, with a datastructure storing a state and functions operating on that state. A class just groups those two kind of elements in the same place, but you can do object-oriented programming without it.

Object-oriented programming is rarely overkill, unless your code stays under a few hundreds lines of code, or if you just write throwaway code. When you maintain a large code base for several years, you must think with abstractions, and not just at a class-level, but at a component-level.

@Feufochmar @hugoestr

🤔 I am not sure what you are saying?

> code base reach a certain size

As if it was easy with OOP

> abstract the data you manipulate into datastructures

who said otherwise?

> the code is easier to maintain

hopefully.

> some functions are just implementation details

who said otherwise?

> What I have described here is what object-oriented programming is about [...]

zealot talk? NB: What I know does it better than anything open or closed source I have read.

@Feufochmar @hugoestr

> Object-oriented programming is rarely overkill, unless your code stays under a few hundreds lines of code

Easy boy, look at my GitHub before speaking of a few hundred lines of code, please?

> or if you just write throwaway code.

You do not have enough experience with working on code that live outside the bubble of privateer company.

@Feufochmar @hugoestr

> When you maintain a large code base for several years, you must think with abstractions, and not just at a class-level, but at a component-level.

You are grand-fathering OOP.

Everything you wrote apply to what I know about Scheme code.

@amirouche @hugoestr Scheme was developped to explore and implement the actor model, which is also the basis of object-oriented programming (objects == actors, methods == messages). The principles of object-oriented programming can be applied more broadly than just the object-oriented languages, and can be applied to Scheme (having user-defined types and user-defined functions are the minimal requirements to do object-oriented programming, and most languages used today can do that).
Furthermore, unlike a language like C, Scheme gives you the primitives to write a meta-object protocol, so you can implement the primitives of the object-oriented languages at a library level (though it's usually overkill when you can use modules to limit the visibility of functions).

Sign in to participate in the conversation
social.hyper.dev

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!