
How do I think like a programmer? - chpp
I&#x27;m a network engineer who has dabbled in Python for some automation, PHP for random fixes on the many php sites I throw on my LAMP, bash for, well, various systems stuffs.<p>I recently got into Corona SDK and Lua and am just trying to release a project. My biggest frustration comes from not the syntax or IDE, but figuring out how and where to write and call functions. I feel like my brain doesnt think like a programmer, so I am constantly hitting a wall and starting over.<p>Any advice?
======
lorenzobr
The best advice in my own experience is don't buy books and learn by doing.
Grab some open source piece of software from GitHub or anywhere else, have a
poke around, get inspired and then try to build your own project from scratch.
But above all...break things! The best way to learn programming is trying to
do things, break them, understand why they don't work and go on.

Besides that, programming can be just like painting. Each of us has its own
style and, even if there are some common patterns e.g.:
[http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93cont...](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller),
generally there aren't really written rules on how and where to write and call
functions. Just try, eventually learn some patterns and then just do what you
feel is better for your own project following your own style.

Once you've done this everything will be easier and doing things will be
awesome. In the end, you will be even capable of jumping from a language to
another on the fly. Don't be frustrated, keep trying and have fun! ;)

~~~
chpp
Thank you for the advice

------
kazinator
If you're trying to change someone else's code, this requires special skills
in addition to thinking like a programmer. You have to be able to think like
the other programmers who wrote the code, which is often different from the
way that you think. Plus, you are unfamiliar with the code. These are
additional difficulties, which is why the way programming is taught in
schools, tutorials and books takes the point of view that you're always making
something new from scratch, even though everyone knows that much real work
isn't like that. The underlying hypothesis is that if you develop enough
experience cranking out complete programs from scratch, you have a good base
for jumping into other programs, which is plausible.

Knowing what function to call and where in a big, unfamiliar program, requires
cunning: more so than in your own program where you know everything.

Find out if the program has a regression test suite, and learn how to run it.
Then when you make changes, execute the suite. If anything breaks because of
your change, find out why; by answering the question "I cannot do it this way
because ..." you will quickly get some fairly deep insights into the program.

~~~
chpp
Thank you for the advice!

------
runjake
As others state, the best way to think like a programmer is to program, but
also seeking a senior programmer as a mentor helps. Also, browsing code on
sites like StackOverflow and Github but you kind of need to develop a quick
sense of good vs bad code. There is a lot of both on those sites.

~~~
chpp
I have this issue with learning guitar right now. Finding a competent mentor,
on recommendation, is surprisingly difficult.

I spend a lot of time on git reading code, shamelessly stealing function and
seeing how they work in my code. I am glad that there is benefit to what I am
doing. Thank you for the advice!

------
juliangoldsmith
You can only really think like a programmer by programming. Just keep at it,
and you'll get better at it.

I have heard that going through SICP can help you better wrap your head around
functional decomposition and that sort of thing, but I haven't gone through
yet it myself.

~~~
chpp
Thanks for the SICP recommendation! Great bed time reading.

I am slowly chiseling away at my 10k hours :)

------
brudgers
Leslie Lamport's _Thinking for Programmers_ :

[http://www.youtube.com/watch?v=4nhFqf_46ZQ](http://www.youtube.com/watch?v=4nhFqf_46ZQ)

~~~
chpp
Thank you!

------
thegenius
I've often wondered what made Steve Jobs say that "Programming teachers you
how to think" and here's what I've come up with. Programmers think in terms of
orders of magnitude and have a strong ability to branch out.

Here's a good example:

My friend has a business selling essential oils (Eucalyptus, Lavender,
Sandalwood) on Amazon. This turns out to be a pretty decent business for one
simple freakonomics'ish reason I believe. Let me illustrate:

You can sell 10ML of oil:

[http://www.amazon.com/Lavender-100%25-Therapeutic-Grade-
Esse...](http://www.amazon.com/Lavender-100%25-Therapeutic-Grade-
Essential/dp/B002RSCP9W/ref=sr_1_12?ie=UTF8&qid=1412100447&sr=8-12&keywords=essential+oils)

For nearly the same price as you can sell 3 times the amount:

[http://www.amazon.com/Woolzies-Lavender-100%25-Pure-
Essentia...](http://www.amazon.com/Woolzies-Lavender-100%25-Pure-
Essential/dp/B00IXPC50W/ref=sr_1_9?ie=UTF8&qid=1412100447&sr=8-9&keywords=essential+oils)

I think the reason for this discrepancy is people can't do conversions between
milliliters and ounces in their head, and since they can't hold the oils in
their hands and only have a picture for reference, they use the price itself
to determine the value of what they're getting.

Now back to thinking like a programmer: Upon hearing this, a programmer's
first instinct wouldn't be to start a competing line of business but rather
would be to come up with a systematic way of scouring Amazon's entire
inventory for a multitude of such arbitrage opportunities. He'd branch out to
using weight in addition to volume.

In addition to exploring the details, programming gives you practice in seeing
the big picture and branching out at all levels of the system.

~~~
chpp
Thank you for the interesting insight :)

