Live data from Hacker News

Which programming paradigm had the most impact on you as an engineer and why?

news.ycombinator.com

1–10 of 91 posts

Re: Which programming paradigm had the most impact on you as an engineer and why?

#4
Functional programming. I learned OOP in school, and always thought it overcomplicates things, why can't this comparison operator in one page of Java just be a function, I thought. How can you make the state of objects manageable, especially if it's private, how do you test, without opening up too much of the API, couldn't we just make this a set of functions with an explicit state so it's easier to understand? How do people understand a method that is spread over a hierarchy of 15 layers of inheritance.

For years I thought there must be something I don't grok about OOP. Some point where these design patterns click and make sense. Until I set out to learn OCaml, switched to F# because I was on Windows, and found https://fsharpforfunandprofit.com. All these concepts had really foreign sounding names, but they clicked right away. I finally found that there are people that think like me.

I'm happy functional programming is slowly taking off, influencing almost every modern language. So I guess I should have just trusted my intuition.

Re: Which programming paradigm had the most impact on you as an engineer and why?

#5
YAGNI, unlearning OOP, embracing simple languages, accepting that the requirements/hypotheses about external world is the most important signal.

Before: I was endlessly creating useless abstractions and going for cute and "elegant".

After: Simplest possible code.

The downsides:

1) One has to know good code from bad to evaluate if "simplest possible code" is not too simplistic and won't cause you problems a month, a year or 5 years later;

2) One is always bombarded by the "cute", "elegant", or plain meandering and unclear code. Unless one is at the top of technical peeking order of the company all the attempts to keep sanity will be in vain.

Re: Which programming paradigm had the most impact on you as an engineer and why?

#6
'Fail early' and 'throw exceptions in exceptional circumstances'. You need good top level error handling and logging of course. I still work with engineers that try catch exceptions and return some sort of more 'graceful' error, for problems that can't really be handled in any other way but to let the system fail. This practice makes it clear when problems arise and where they come from.

Re: Which programming paradigm had the most impact on you as an engineer and why?

#7
Minimizing and isolating state. Not eliminating it, keeping state is often useful, but not everything needs statefulness, and keeping track of state is _hard_ (hi yes I'm backend, have fun FE folk). The loose pillar of functional programming to keep state and behavior separate means that the problem space for objects and functions goes down quite a bit, and reasoning about things becomes much easier.

I don't think it'd be anything you could obviously point at in my code, but it's a day-to-day consideration that I have.

Re: Which programming paradigm had the most impact on you as an engineer and why?

#8
Not so much a paradigm, but learning TDD from the engineers at Pivotal Labs really changed the way I approach problems.

I spent a few weeks constantly pairing and doing TDD with them, and while I don't think I could pair forever (maybe 2 days/week), I was amazed at how TDD could shift my approach to a problem. These days I'll still use it, even on personal projects (usually only integration tests), as a great way to reduce unnecessary complexity and increase my confidence in my own code.

Post reply on HN