4 ms·
> How do we choose the right tool? A good rule of thumb is that your code should be as close as possible to a plain-English description of what you want the co
by csande17 7y ago
> How do we choose the right tool?
A good rule of thumb is that your code should be as close as possible to a plain-English description of what you want the code to do.
So if you're trying to write a program like "When you click the button, it turns grey, and then sends the message, and then turns blue when the message is done being sent", imperative programming is probably your best bet. If you're writing "find all the posts that contain the word 'donut'", something like SQL or functional programming is probably a good fit. You can usually tell when you made the wrong choice when you end up needing to think really hard about how to fit the behavior you want into your paradigm, or when you have to write a big long comment saying, "This isn't very clear from the code, but here's what it's trying to do..."
And as GP says, there isn't any one paradigm that's good for everything, so well-written programs will often use a mix of them. If someone tries to tell you that one size fits all (all programs should be imperative C! all programs should be object-oriented Enterprise Java Beans! all programs should be functional TypeScript!), that's usually because they aren't a very good programmer.
- jplayer01 7y agoExcept there's no book or course or whatever that can teach somebody these things. Instead, everybody has to figure it out on their own, and usually they just don't. Engineering disciplines don't work this way. I don't understand why it's okay for software development.
- locoman88 7y agoVery well put, that's why I cringe every time a fellow soft dev considers himself an engineer
- fanf2 7y agoThere are books and courses that try, eg https://www.info.ucl.ac.be/~pvr/book.html https://www.info.ucl.ac.be/~pvr/book.html
- jplayer01 7y agoThis looks great, thanks. Definitely gonna give it a read.
- csande17 7y agoUniversity curricula often try to expose students to a wide variety of programming paradigms. I'm not sure how you could walk out of Berkeley's CS 61 series thinking that there's One True Way to write all programs, for example.