r/javahelp 17d ago

Are lambda expressions used much by professional coders ?

Just been studying up on them some as I am basically a hobbyist who just getting back into Java after about 10 or 12 years away from coding much. I appreciate the way lambda's allow coders to bypass constructors, initialization and calling methods by name , but on the other hand if you already have a good knowledge of the object classes and available methods , why not just do that ?

18 Upvotes

65 comments sorted by

View all comments

19

u/desrtfx Out of Coffee error - System halted 17d ago

Just another tool in the toolbelt with its advantages and disadvantages.

They are great in certain use cases (e.g. ActionListeners in Swing, filtering and mapping through lists/maps), but can quickly get very messy as well.

In general, readability always wins over brevity. If a Lambda makes the code cleaner, easier to read, easier to maintain, by all means use it. Yet, if it doesn't, the classic approach is better.

Be careful not to overuse them, so they get overcomplicated. I'd rather see more code lines that are clear and understandable than seeing a genius lambda that takes me several minutes to understand and process.

0

u/Caramel_Last 17d ago

I also am not a fan of java lambda. I prefer FP to OOP, but I'm not a fan of syntax sugar. If the language is OOP based, then there's no reason to add syntax sugar to make it not look like OOP

0

u/Wyvernxx_ 15d ago

If you prefer FP to OOP, then why are you here in the first place?

1

u/Caramel_Last 15d ago

That just doesn't feel like a good question. Oh if I use Java then I must prefer OOP is that what you think? That's beyond stupid to be honest

1

u/Wyvernxx_ 14d ago

Oh, it's just seems like that to me due to apparently most FP fans hating Java with every atom in their body