How can I get addicted to programming?
stackoverflow.com
stackoverflow.com
When programming, I can stay on-task for 12 consecutive hours a day with enough caffeine, but after the first ~5 hours, I'm doing it by rote, and hopefully I've made good design decisions earlier in the day. After around 8 hours of it, I'm just a zombie. I'll be producing poorly factored and poorly tested code, I won't be considering the corner cases, and I there will be a lot more bugs. If I do this for enough days in a row, I'll start the day a zombie.
When playing Diablo II, I can easily spend 6 hours playing it in a row without noticing that my skin has gone pasty-white and I've ordered my second pizza ;) I may not be as intelligent towards the end, but the game is nowhere near as demanding as programming and it really doesn't matter.
Ideally I'd be updating documentation, running some tests, organizing a project at the end of the day. Although it rarely goes like this ofcourse.
If I run into a nasty problem when I'm way past my daily mental peak and there is time I'll just wait for the next morning. Experience has shown that nine times out of ten I see the solution the next morning so I won't be wasting time on it.
I think the key here is persistence. Recently, it took me over four days to solve a certain 3D animation problem. It was frustrating when it wasn't working, but because I threw all of my spare time at it, it eventually got done, which is very satisfying.
I don't know how to want to be persistent. I just am. Getting started each day is usually the hardest part. If I give in to the temptation of playing a game, it's almost a guarantee that I won't be getting anything done for a few hours, if at all.
It helps a lot to be very interested in the problem domain. If you're avoiding a task, try re-framing it to make it fun. For example (I'll use a gamedev example since that's my field), instead of writing a way to play a 3D animation, write a way to blend between a bunch of different animations simultaneously, then play the result. Sure, it's more challenging, but it's also more fun. That kind of "re-framing" is very valuable.
A perfect example was my project last week. I had to make 14 changes (including 3 major structural reworks) to an existing application to produce one additional output. This output was key for a fundamental shift in thinking about the use of the app.
My week was actually fairly predictable:
Monday was fun for a while, thinking about how it would work, what needed to be different, how the data has to be restructured, and how cool the new results would be. But things became drudgery when I had to lay everything out build my work plan.
Tuesday sucked, tearing apart code while trying to maintain an audit trail and balancing the new functionality with keep everything old still working.
By Wednesday, I didn't even want to work on it and spent a lot on time on hn, playing games, and surfing the internet. I struggled getting the final pieces in place.
On Thursday, my interest piqued when regression testing went almost flawlessly. But no matter, even if it didn't, being in "getting it to work now" mode always captures my attention.
Friday was bliss. I was cranking code, unit testing, regression testing, reworking, getting the results I forsaw on Monday, and doing a happy dance every 20 minutes or so. Time flew as I worked into the night getting all this cool stuff working. I wish every day could be like Friday, but I needed to pay my dues earlier in the week just to get to that point.
I wish I had an easy answer for collapsing the long hours of building the prerequisites and expanding the time spent "in the zone". The only suggestion I can make is get to the point of having something for output as early as possible. That's when the fun usually begins. Until you reach that point, just understand you're in "courting" mode. Just keep on working and the digital orgasms will arrive. Once they do, it'll be worth it. Don't worry, you'll be "addicted".
(NB I've always been fascinated by prehistory and how our ancestors experiences shaped our own behaviour).
"After the Ice: A Global Human History 20,000-5000 BC"
http://www.amazon.com/After-Ice-Global-History-000-5000/dp/0...
http://en.wikipedia.org/wiki/Mihaly_Csikszentmihalyi#Flow
Flow happens when you have high skill and are attempting things at the limit of your ability. The little mental rewards for achievement come quicker and propel you to the next step.
So the unfortunate truth is that he's going to have to spend a lot of time practicing and honing his craft, before he can truly get into flow. Perhaps it's better to try mastering simpler tools and simpler tasks and iterate from there.
There are programming methodologies that help you get into flow. Extreme programming is a silly name, but pairing with someone else really does help with focus. Also, building a skeleton system with lots of dummy classes or functions and "filling in the blanks" can feel extremely rewarding. A test-first practice can also help, where you set up lots of tests that all fail and make them pass, one by one.
I can second this, although I don't know if I could make the choice to do it voluntarily. I was unemployed a couple of years ago and working full time hours at Tim Horton's serving coffee. I found it really exhausting, both physically and mentally, and then when I got home all I wanted to do was program - I think I would have had to force myself not to do it. Maybe it's even something about being around the smell of coffee all day too!
It seems to me I was most enthusiastic about programming when it wasn't my "real" job. Maybe I just want to recapture those days.
Also, I had no idea how ignorant I was, which certainly helped.
That being said, I think his attitude of "If I can get hooked on programming like I am on gaming, I'll be in heaven" is totally wrong. You should know that there are other things in life. Read the classics. Fall in/make love. Learn how to make something with simple tools. Volunteer. Repeat.
This might just make me weird though ;-) I guess I like to think I'm working towards actually making an academic contribution to the world one day, rather than just doing something to earn some money - that's a big driver for me in terms of life ambition.
This is great. This sort of thing is very similar to a video game - I try to get high scores, and I can mark off the problems I've succeeded to see how well I'm progressing. Just yesterday, I think I spent a good 4 hours in flow while working on a problem. I barely noticed what was going on in my surroundings at all. It was awesome.
The difficulties in motivation start when I hit something 3rd party that I don't know very well.
There was a productivity tip on HN a while back about how you should always walk away with something incomplete so that it's easy to come back to. You know exactly what you need to do next.
But when coming back to programming means spending another hour or so reading documentation and playing with settings until it works, things get a lot more difficult I find.
Every day is different and some days I code because I love it, some days because Iam good at it, and some days I absolutely hate to code. Regardless of what mood I am in I think of the money....code pays my bills, I use this fact to focus my attention ;)
Let the ego trip begin and soon enough you feel like a god.
Once you feel like god, you are addicted. Hopefully, you can live in denial as long as possible until the real world decides to kick you in the ass.
There's really nothing quite like the joy of having a simple game come together and be fun enough that you play it yourself. Here's one I did in java. The source is available!
http://jonathanwatmough.com/jplanetoid/ptoidApplet.html
Of course, I write bigger programs now, but the same joy of getting something to work should always be there. If it's there, it should shine through in your code and UI, and people should love your software. Make people happy.
Just as an example, today's task that I got done, I managed to move some audio streaming code onto its own thread and get vastly improved performance in the UI of an iPhone app I'm building. It's just sooo addictive when a plan comes together!
And one other thing. Pick a programming language to write in that is fun and powerful enough to be addictive. Clojure is a wonderful language, and so is Objective-C. Both have enormous power, yet are relatively easy to write once you have the basics down. Many people will say similar things about Ruby or Python, or hacking things together in Perl. The important thing is to pick something where you say 'just 5 more minutes on this'.
Then you're addicted.
That's why they're so addictive, because they're so much "more" than reality.
The only solution is to reduce the consumption of them. Than reality will "bloom" again. I have been there before.
Unfortunately I'm currently again on the other side, and I know hard it's to reduce it.
Edit: The funny thing is, that reducing them makes them again more enjoyable.
So start slowly, solve a simple task, then ride the dopamine levels upwards by solving more and more, until you hit the flow.
Although, I do not understand why would anyone want to get addicted to programming. Trying to have something that can earn money while getting you high naturally is one thing, trying to imitate successful addicts in hopes of huge success is a cargo cult.
So the answer is that you can't get addicted to programming even if you wanted to but occasionally you will even if you didn't want to.