As someone who spends time programming, I of course find myself in conversations with people who aren’t as familiar with it. It doesn’t happen all the time, but these discussions can lead to people coming up with some pretty wild misconceptions about what programming is and what programmers do.
- I’m sure many of you have had similar experiences. So, I thought it would be interesting to ask.
I found it useful when explaining programming to lay people to try to put various programming paradigms in everyday terms.
Imperative programming is like a cooking recipe. You need specific ingredients in certain amounts and you need to perform actions in a very specific order, or the recipe won’t turn out right.
OOP is like a bicycle. Lots of pieces interconnected and working together, hopefully interchangeable and standardized. It can also be used to explain unit testing to juniors. Clock mechanisms or engines can also work but people tend to relate better to bicycles.
Declarative programming (SQL) works like ordering at the restaurant. You still need to know how restaurants work and about meal courses and how to read the menu etc. but you don’t need to know how the sausage was made, only if it’s good or not.
SELECT food FROM menu WHERE name LIKE ‘Fried %’;
Lemme
cat menu | grep Fried
real quickYou don’t want to order from the cat menu.
grep -i fried < menu
grep -i fried menu
Of course! It’s amazing how this stuff just flows from the keyboard when you’re typing in a shell window, but feels awkward when typing in a Lemmy comment.