Learning to Program
Posted on 20. Jun, 2009 by Terry Reinert in Engineering, Software
Jason, the man behind Canon Blogger, asked me earlier via Twitter how someone can get started in programming. This got me thinking a bit about how programming has aided me in my photography and Adobe Photoshop pursuits. Believe it or not, there is a lot of cross correlation between the two! For starters, I tweak the coding behind my WordPress blog theme constantly to change things up, make it more efficient, or add new features. Then there is the fact that I am currently in work on a web application that will benefit a lot of photographers in the near future (at least I hope so or else I am wasting a lot of my time). Let’s not also forget that you can write plugins and much more advanced Photoshop and Lightroom actions using their programming / scripting interface. So yes, there are many ways that programming can be incorporated into your photography profession.
Decide What You Want to Program
The first step in learning to program is not picking a language. This is where a lot of people make a fundamental mistake… they hear something cool about a specific programming languauge and dive in. The first thing that a person should do is to determine what it is they actually want to program. There a few main categories to this…
- Low-level embedded applications that run on microprocessors (the software inside of your digital camera).
- Desktop applications that run on a PC, Mac, or Linux desktop computer (software like Photoshop, Lightroom, Firefox, and such).
- Web applications that run… well… on the internet in some form or another (websites and WordPress are a few examples).
- Extending one of the above through the use of scripting.
Number 4 above may seem a little weird to be included there but I think it is important to group it as such because if all you want to do is write Photoshop scripts then you will take a whole different path than you would if you were doing any of the others.
Decide What Language You Want to Learn
Once you determine what you want to program you can now choose a language to learn. There are many different languages available to you and I am not about to cover all of them. What I will do is give my opinion on what languages you should look into for each of the categories above… now I know that there are people out there who will disagree with me on my recommendations and they are free to write their own blog about it…
For programming low level embedded software like what controls every aspect of your digital camera you are going to need to learn Assembly and C/C++. Java has been making waves in embedded programming (pick up almost any current day cell phone and you see Java in action) but I come from a hard real-time embedded OS background and you’d get laughed at and fired if you even hinted at using Java in that environment.
If you are looking more at programming desktop applications then you’ve got a little bit more variety to choose from. The big players on desktop applications are C++, Java, and Objective-C (Mac / iPhone only). I’ve done a lot of programming in both C++ and JAVA and I think I like C++ a bit more than JAVA. But to be honest, I would recommend Java for a beginner to desktop programming. First off, it is easier to learn in my opinion. Secondly, Java is very easy to make cross platform (meaning you application will work on Windows, OSX, and Linux without changing the code).
Web programming is where the world really opens up as there are a ton of languages available to the web programmer. Regardless of what you are going to do you will have to learn HTML, CSS, and JavaScript. Those three languages are seen on every web platform. Then you can move on to a more powerful language for generating dynamic content and web 2.0 applications based on what server you will be running your application on. If you are running on a windows server you’ll want to look into ASP. The lesson to learn here is to not run a windows server. Just my opinion of course. If you’re running on a Linux server then you’ll want to learn PHP. If you’re running on a Java based server (like Glassfish) then you’ll need to dive into J2EE which is made up of many different technologies and all combined make up the most powerful of the whole bunch. You will also want to learn a bit about database technologies like SQL or MySQL.
I think the most useful for the photographer audience, in terms of web application languages, would be to learn PHP and MySQL. All the big name open source web applications (WordPress for example) are mostly all PHP and MySQL. Oh, and HTML, CSS, and a form of JavaScript called AJAX too…
Ok… at this point your head is probably spinning because of all the acroyms and stuff I have been throwing at you. Jason said he wants to learn how to program desktop applications and web applications. So my advice to him is to start with the core Java language. This will include JavaScript since it is usually always taught near the beginning of Java courses / books anyway. Once he gets the core language down then move into J2EE which will teach JSP, JSF, Beans, Web Services, and other technologies that are very useful for web application programming. I would also recommended learning PHP and MySQL along with J2EE just because of how common it is on the web. In addition, Photoshop scripting can be done in 3 different languages likes I said above but only JavaScript will work on both Windows and Mac… so in my opinion writing Photoshop scripts in JavaScript is the only way to go!
Another reason I would recommend Java to a beginner is because there are some great free IDE’s (Integrated Development Environments) for Java that really help make programming easier. An IDE is an application that you use to write your code in. The IDE is coupled to the compiler (what turns your code from what you wrote into 0′s and 1′s the computer understands) so writing, building, and testing your application is a simple process. Eclipse is one of the free IDE’s that a lot of people swear by. I use NetBeans a great deal which comes in the Java download package.
Book Recommendations
I would recommend any of the “How To Program” books by Dietel / Dietel for whatever language you want to learn. These books are used in a lot of colleges and they are what I learned C++ and Java from. They provide a lot of examples on each learning topic and discuss each line of code in the example so that you fully understand what they are talking about. I also like the Core Java books by Sun Microsystems for learning Java. I think the Dietel books are better for absolute beginners though as they walk you through getting things set up and configured properly in a lot more detail.
Conclusion
Programming seems like a very complex and tedious task. Sometimes it is. Sometimes it isn’t. I think it all depends on the person. I started programming when I was 5 years old on a Commodore 64… back in the very early days of MS-DOS and BASIC. Yeah, I am lucky… I just missed the old punch card days!! Once my family got its first PC I moved on to Pascal and then to C. Now I cannot even count how many programming languages I know… it just comes second nature to me… I know I was going to be a computer programmer when I was a young kid… well, my top pick was a F-16 Fighter Pilot but getting glasses in 9th grade kinda ruined that one. Long story short… programming isn’t hard… just take it one step at a time and build a strong foundation in the core part of the language before moving on. You won’t be making super sweet applications with bleeding edge user interfaces anytime soon… but you have to start somewhere!
Related posts:







akayla
20. Jun, 2009
I agree with this . I think it is useful.
Yasky
20. Jun, 2009
Very well done. I never thought of programming this way though I have already gone in depth.
But you completely threw Microsoft out of the picture when you were talking about programming languages for Desktop applications. What happened to C#?
It’s a very informative post still.
Terry
20. Jun, 2009
You bring up a very good point. I did forget to mention C#. I have never programmed in C# but I do not want to take away from its validity since it is a widely used programming language. However, it is not really ideal for a beginner simply because of the freely available resources for it. I know you can get Visual Studio Express for free but it doesn’t have the optimized compiler and some other features of the full IDE. With Java, all of it is freely available. But you are right… I did leave out C# and that was an oversight on my part. Thanks for the catch!!
Jason
21. Jun, 2009
As “the man behind Canon Blogger”, let me just say thanks for such a useful information set. I can’t tell you how often I’ve been the one to just dive into a language and give up after a few days because I couldn’t make heads or tails of it. At least I know how to think about it now, and how to approach things in the future…thanks Terry! (Oh and props for the mention over on RC’s blog at Layers TV re: the HDR content – quite awesome!)
Terry
24. Jun, 2009
Hi Jason… I had a C++ book for years before I actually learned how to program in C++… so I know exactly what you mean about diving into a language just to give up after a few days. I think we’ve all been there before. Glad that this helps though. I love programming and love to share the passion for it. There are a lot of cool things you can do with little learning. There are some REALLY cool things you can do with a bit more.
Stick with it… you will be glad you did in the long run! And thanks for the props!
Jason
24. Jun, 2009
Happy to oblige, and I see you got another nod today on SK’s blog – did not know you assisted Robert Vanelli – yet another impressive feather. All in a days work for you though probably!
Void
08. Jul, 2009
I do a lot of programming in C/C++, and I think that, even beyond the Dietel books which are quite good, C Primer Plus and C++ Primer Plus are all around the best books to learn these languages from. They are organized a bit better and most importantly have many more examples. They are also much better reference books for when you are done learning and need to look stuff up.
You mention JAVA as your cross platform language, but when I want to do something cross platform I go to PYTHON. I find JAVA to be quite obtuse (in fact, I only know a little bit of it, because every time I try to do something in it I end up in C++ or python because they are more practical), and I wish they would not teach it as a first language to so many people. My semantic dislike aside, the main reason I don’t like it as an introductory language is that too much is taken care of behind the scenes. By the way, I also think that to a much lesser degree with python, however it is more tolerable later. I think people should learn on C++, then move up to more automated languages. Learn with minimal abstraction and then gradually add it.
Terry
08. Jul, 2009
I think it really depends on what the person is going for in the long run. Does a desktop level programmer really need to know what is happening at the chip level? No. It might help at times but it is not essential. JAVA is a different way of thinking than C++ but it isn’t bad if you know it. Besides, Python seems to be one of those languages that does a lot of stuff behind the scenes as well. Not only that but with technology going the way it is, semantic based languages are the real future. In the end it is really personal preference.