Sunteți pe pagina 1din 12

11/30/2010

Seven ideas for learning how to progra

TechRepublic : A ZDNet Tech Community

Seven ideas for learning how to program


Date: November 4th, 2010 Author: Chad Perrin Category: *nix, Code Writing, Databases, Macros, Programming Tags: Opportunity, Administrator, Smart Phone, JavaScript, Code, Web Browser, Programmer, Language, Plug-in, Programming Ancient Chinese philosopher Confucius is credited with saying a lot of things, from trite fortune cookie messages to patently ridiculous jokes like Man who stand on toilet is high on pot. One statement attributed to Confucius that is relevant to people learning to program is: I hear and I forget. I see and I remember. I do and I understand. Sitting in a classroom is far from the ideal way to learn to program for most people. Reading about the programming concepts at the same time might help, but it does not compare for practical skill acquisition with the effectiveness of reading and thinking about others source code until you understand it. Nothing really cements programming skills in the mind like writing programs of your own, however. Read a little, get taught a little, and start programming a lot. Find things you wish were easier, and make them easier by writing some code to automate them. Unfortunately, figuring out what to do can sometimes be the most difficult part of learning to program. The key, based on personal experience, seems to be to wish you could do something in one step instead of seven or eight, and to have a sudden epiphany where you realize you have an idea how to write a program to solve the problem. Because starting programmers typically have very limited knowledge on which to draw when looking for that kind of epiphany, it helps to stack the deck in your favor. Doing so, at least at first, involves figuring out what parts of your daily computer use routine most lend themselves to easy scripting. Once you have that sorted out, focus your early learning on programming skills that are particularly useful in those circumstances. To the extent such opportunities are lacking, you may want to make changes to your computing environment that will provide such opportunities. The most important thing to do is to find a way to motivate yourself to write code. Here are suggestions on how to learn programming by taking action.

1. DBMSes
Major, industrial strength DBMSes such as PostgreSQL, Oracle, Microsoft SQL Server, and Informix offer scripting capabilities via stored procedures or stored functions. Probably the most widely recognized language options are TransactSQL, used by Microsoft SQL Server and Sybase,
com.com/programming-and-develop 1/12

11/30/2010

Seven ideas for learning how to progra

and PL/SQL, which is used by Oracle. PostgreSQL offers a PL/SQL-like procedural extension to SQL called PL/pgSQL, but it also provides a range of other language options such as PL/Perl, PL/Python, PL/Ruby, and PL/Tcl. Such opportunities for programming are limited to a particular set of problem domains, but could prove very useful if you are a DBA or if your job involves developing database reports.

2. Plugins
Many new computer games offer the ability to write and load plugins. World of Warcraft, for instance, offers a plugin system that uses the Lua scripting language. Modern Web browsers also tend to offer flexible plugin systems, with Firefox being the most famous and widely used; in the simplest case, Firefox plugins are written using JavaScript. Open source browsers tend to attract more plugin development than closed source browsers, and among browsers Chromiums plugin system is likely to become at least the second most-targeted by plugin developers because of its high-profile marketing as Google Chrome as well as its permissive licensing. Many other applications have plugin and extension systems that can provide ample opportunities to build your burgeoning coding skills, including even some terminal emulators (see TechRepublic contributing writer Sterling Camdens urlpicker for rxvt-unicode for an example) and consolebased text editors like Vim. (In the interests of full disclosure: I have contributed a little bit of code to the urlpicker project.)

3. Practice problems
You can try to solve the problems offered by a generic list of coding tasks designed expressly for the purpose of providing programmer practice opportunities. One of the more popular, regardless of the programming language, is Project Euler, which is a series of challenging mathematical/computer programming problems. The problems are generally arranged from easiest to most difficult, and there are literally hundreds of problems in the Project Euler collection, so this can keep you busy for a long time. Other examples include RubyQuiz, which has been a popular attraction of the ruby-talk mailing list for years, and CodeKata, a somewhat smaller and shorter-lived project of Dave Thomas, one of the co-authors of The Pragmatic Programmer. These options are not as conducive to self-motivated exploratory learning as tasks that actually scratch your own itches, but if you find them interesting, they can serve the purpose of educational programming practice as well as anything else.

4. Smartphones
The biggest new craze in application development is smartphone applications. Such devices typically require the developer to use a specific language to their full capabilities as application platforms, at least to do so in an officially sanctioned manner. A burgeoning industry of smartphone development frameworks that allow developers to write their code in languages other than the native languages of smartphone platforms, that then translate the applications into those native languages, is on the rise. Web applications are also gaining traction as a means of writing smartphone applications that do not require learning the

com.com/programming-and-develop

2/12

11/30/2010

gaining traction as a means of writing smartphone applications that do not require learning the official application development language of any particular smartphone platform. Another option for using the language of your choice rather than of the platforms is to use a device like the Nokia N900, which runs a Linux distribution derived from Debian and can run a wide range of software including a lot of software that was not originally designed for smartphones at all. Books and online tutorials focused on myriad methodologies for developing smartphone applications are appearing in droves, particularly for Android and iPhone devices. Some thirdparty frameworks will compile code written in everything from HTML+JavaScript to Ruby or Python into native applications for multiple platforms, sometimes including not only smartphone platforms, but also desktop systems. Perhaps most exciting about this situation is that these frameworks and their associated IDEs do not tend to try to solve all programming problems equally well the way major frameworks and IDEs such as Visual Studio and the .NET Framework do. This makes it possible to simplify the development process significantly by narrowing options to an easily managed set of problem domains. The result is a style of software development that can be extremely approachable for beginners. The downside is that writing new smartphone applications is hardly something you are likely to do every single day while learning how to program. If your smartphones OS is a Unix-like system (like the N900), however, the same small tool development projects can be useful on workstations and servers.

Seven ideas for learning how to progra

5. Spreadsheets
If you use spreadsheet programs with a robust macro system, you have a quick way to read code someone (or something) else wrote and write your own code. First, record a macro for a task you perform a lot and that normally takes several tedious steps. Next, look at the macro source code, and edit it to make it better suited to general use. This is an extremely limited approach that will not take you very far, but it might help get you started on the road to feeling like simple scripting is second nature for you. The most common spreadsheet program for this kind of scripting is probably Microsoft Excel. Excel uses VBA, which is a miserable language, but if your daily work involves heavy use of Excel, this is probably a skill you should have anyway. OpenOffice.org uses a similar macro system that can be used in much the same way, as does its non-Oracle fork LibreOffice, that provides the same opportunities for early learning-oriented coding as Microsoft Office. In every case, there is a slightly greater barrier to entry for writing code than when writing simple command line shell scripts because of the menu options and buttons that need to be clicked to get started. The overhead for getting started is similar to that of starting a new project in one of the major IDEs on the market, but for significantly smaller projects. It would be a good idea to ensure this is not the only kind of simple scripting opportunity in your daily development environment, even if making use of it can be helpful.

6. Unix
If you use some kind of Unix-like system regularly, you have a huge advantage in finding ways to exercise your nascent programming skills. Unix provides more opportunity for simple scripting automation than any other general purpose operating system family, thanks to the extreme flexibility of admin scripting on the platform. In the least sophisticated case, an admin script might be nothing more than a series of shell commands saved in a file Opportunities can be extended

com.com/programming-and-develop

3/12

11/30/2010

be nothing more than a series of shell commands saved in a file. Opportunities can be extended from there with simple looping and conditional constructs, input and output handling, file reading and writing, and scheduled tasks. After getting comfortable with simple shell scripting, it is worth any Unix sysadmins while to learn how to write admin scripts in Perl, Python, and Ruby. Key skills for such languages in a Unix environment involve accepting text streams via Unix pipes and redirects, processing command line options, reading and writing files, and searching and operating on text with regular expressions. An admin will also want to know the common basics of programming like producing output, looping (or recursing in some cases), and using conditional constructs for programs that make decisions based on well-defined criteria. Writing command line tools for Unix is fertile ground for opportunities to write programs that make use of a lot of the capabilities of a scripting language. Because of the flexibility and minimalistic requirements of admin script development, writing such utilities can range from the simplest examples of useful tools to robust server processes, and even massively parallel task automation, load balancing, heuristic filtering, and other interesting problem-solving jobs that intrigue some of the worlds best programmers. While some admin scripting capabilities are available in just about any general purpose OS, and quite a few that are more narrowly purposed, some OSes are more equal than others. Unix stands head and shoulders above the norm in terms of its suitability for admin scripting, and because Unix-like systems such as the major Linux distributions and BSD Unix systems share the same basic operating environment design, they all benefit from this richness of opportunity for admin scripting and portability of script between platforms as long as you write them to be portable (such as by using sh or Perl instead of bash, and choosing standard sysctl values instead of the proc filesystem for data sources). This works for languages other than very high level, dynamic, interpreted languages as well. C, C++, Haskell, Objective-C, Objective Caml, and a plethora of other options fit neatly into the task of writing various types of simple Unix utilities. For many of these languages, a more extensive set of skills must be learned to tackle projects even as simple as small admin tools than for languages like Perl, Ruby, and the Bourne shell, but such tasks are still much less daunting to a beginning programmer using these languages than GUI application development, systems programming, and other tasks for which they are often used, especially on other platforms. In fact, given what the Unix philosophy has provided over the years in terms of a plethora of common utilities that each do exactly one thing (for the most part) and do it well, part of the value of Unix-like environments for the novice programmer is that leveraging the power of the Unix command line environment encourages the user to think more like a programmer than an audience.

Seven ideas for learning how to progra

7. Web pages
A dangerous recommendation to make is to learn programming by playing with JavaScript. This is not because JavaScript is a bad language, but rather because the Web is already cluttered with myriad abuses of JavaScript for a dynamic user experience, and unleashing an incautious new programmer on the Web might be considered irresponsible. There are positive uses for JavaScript on the Web, and the growing interest in the idea of writing what amount to desktop applications that run in the browser is giving us plenty of reasons to start learning JavaScript early in our programming careers.
com.com/programming-and-develop 4/12

11/30/2010

Seven ideas for learning how to progra

The fact that JavaScripts single most common use is for client-side Web scripting also means that JavaScript may be the easiest language to learn by reading others code. Find any Web page that has client-side dynamic elements, then right click and select the option to view the pages source, and you will likely find it littered with small snippets of JavaScript here and there. For more sophisticated dynamic pages, the (X)HTML page may even reference a separate .js file full of code. Be careful about the code you write before uploading it to a publicly accessible Web server; make sure it is good before you subject the public to what you have wrought. If you wish to start more locally with scripting that you find useful, browser extensions exist that allow you to apply arbitrary scripts to pages you view and that apply only to your personal browsing experience. Greasemonkey for Firefox is one example.

Solicit feedback about your code


Another great way to improve your programming skills is to solicit feedback from people who know more about the subject than yourself, and to learn from the wisdom they share with you. They may not always agree with each other, but if they are worth your respect as good programmers, what they have to say should at least prompt you to think about new ideas and to think about old ideas in new ways. There are many ways to solicit feedback. These are three possibilities: Start working in a language that has a strong, helpful community, such as the rubytalk mailing list for the Ruby programming language or the PerlMonks website for the Perl programming language. Join one of these communities (or something like one of them), and learn the culture, the best practices for the language, and how to get the most out of asking for help. Pair with another programmer. Pair programming is a fashionable practice that has gained respectability through the rise of the agile software development methodology. Two people get together to work on a project, but often only one of them is actually writing code at any given time. The pair of programmers switches off who is sitting in front of the keyboard, ensuring that both of them get substantial coding time, while the other basically reads over the coders shoulder. An ongoing dialog about the code can help ensure that the best way to approach a given problem comes to light and ends up being used. Anyone who has had an epiphany while trying to explain a problem to another person should recognize the potential value in pair programming. Get a mentor. Mentors can be found in language communities, among friends or co-workers, in open source software development projects, and at conferences and conventions with a heavy technological subject focus. School may be another good place to find mentors, in the form of tutors, instructors who take a shine to you, dorm roommates, and even study groups for a less traditional and more give-and-take mentoring relationship. Sometimes, a one-on-one relationship with a mentor can prove to be the single most valuable way to get feedback early in the process of learning to program. If you are lucky enough to get a good mentor, you should take advantage of that resource, and never take it for granted. Create a project on a code hosting site such as Bitbucket or GitHub. Tell your programmer friends, post about it to your Weblog or Twitter account, and generally encourage others to have a look at your code and offer feedback. Make sure that the issue tracker is turned on so that people can submit bugs or propose enhancements through the code hosting sites interface. Between practicing your craft and getting feedback from people who have insights to offer, you should be able to get well on your way to learning the basics of programming and gaining practical, useful experience at it. Now go forth and code.
com.com/programming-and-develop 5/12

11/30/2010

Seven ideas for learning how to progra

Related TechRepublic resources


Five tips for starting a programming career Three ways to gain programming experience Poll: How did you learn to program? Tips on choosing a programming language to learn Get IT tips, news, and reviews delivered directly to your inbox by subscribing to TechRepublic's free newsletters. Chad Perrin is an IT consultant, developer, and freelance professional writer. He holds both Microsoft and CompTIA certifications and is a graduate of two IT industry trade schools. Read his full bio and profile.

People who read this, also read...


How to create CSS style sheets for printing Three ways to gain programming experience Tips on choosing a programming language to learn Five tips for starting a programming career A skeptic's history of C++

Print/View all posts


Comments on this blog
Seven ideas for learning how to program apotheon | 11/04/10 Long ago, on a CRT far, far away... Palmetto | 11/04/10 getting started, part 1.1 apotheon | 11/04/10 Hmm cookbook approach could work. Tony Hopkinson | 11/04/10 "...outside of just strictly work-related purposes..." Palmetto | 11/04/10 PowerShell neilb@... | 11/05/10 re: PowerShell apotheon | 11/05/10 Almost exclusively for the latter neilb@... | 11/05/10 two problems I've seen apotheon | 11/05/10
com.com/programming-and-develop 6/12

11/30/2010

Seven ideas for learning how to progra

Being purely Winders, PowerShell came as SUCH an improvement neilb@... | 11/05/10 VBA Bashing gskur@... | 11/09/10 What languages? apotheon | 11/09/10 Was it all BS and posturing? apotheon | 11/14/10 VBA is good at what it was designed for? Tony Hopkinson | 11/09/10 They don't always deserve respect. apotheon | 11/09/10 Indeed not Tony Hopkinson | 11/09/10 They just don't know the language SinisterSlay | 11/10/10 Please explain. apotheon | 11/11/10 No, the opposite SinisterSlay | 11/12/10 okay apotheon | 11/12/10 Seven ideas for learning how to program brackobama | 11/11/10 Lovely AnsuGisalas | 11/12/10 LibreOffice currently solicits help TobiF | 11/04/10 unfortunately Jaqui | 11/06/10 That strikes me as uninviting. Palmetto | 11/06/10 I agree Jaqui | 11/06/10 I'm not exactly an OpenOffice.org fan. . . . apotheon | 11/09/10 it's the newest Jaqui | 11/10/10 egad apotheon | 11/11/10
com.com/programming-and-develop

No it's not normal apotheon | 11/09/10

7/12

11/30/2010

No, it s not normal. apotheon | 11/09/10

Seven ideas for learning how to progra

Inaccessible . . . ? apotheon | 11/09/10 yup Jaqui | 11/10/10 That's not what it's designed to do. apotheon | 11/11/10 Apart from a wee shudder at number 7 Tony Hopkinson | 11/04/10 Learning nwallette | 11/08/10 They've certainly a right to get it wrong Tony Hopkinson | 11/09/10 inflicting one's incompetence on others apotheon | 11/09/10 I would hope such a website would not be published to external servers SinisterSlay | 11/09/10 That's the problem. apotheon | 11/09/10 Doesn't need to be amateur stuff Tony Hopkinson | 11/09/10 that's not all apotheon | 11/09/10 Most of it is so poor, or so specific Tony Hopkinson | 11/09/10 Latest evolution; harmless. Palmetto | 11/09/10 That's what I was thinking nwallette | 11/10/10 What do you want me to say? apotheon | 11/11/10 I thought we were talking about beginners nwallette | 11/12/10 no, that's not what happened apotheon | 11/12/10 Don't forget LUG's. lastchip | 11/04/10 user groups apotheon | 11/04/10 How similar are programming languages to human languages? AnsuGisalas | 11/05/10
com.com/programming-and-develop 8/12

11/30/2010

Seven ideas for learning how to progra

Descriptive power is much better Tony Hopkinson | 11/05/10 Ambiguity is actually a strength in human communication... AnsuGisalas | 11/05/10 OO apotheon | 11/05/10 That's another reason I haven't attempted anything. Palmetto | 11/05/10 "everything is an object" and the problem(s) with VBA apotheon | 11/05/10 The limitations of VBA... Justin James | 11/06/10 They did that sort of crap in WMI as well Tony Hopkinson | 11/06/10 @Apotheon SinisterSlay | 11/08/10 @Justin SinisterSlay | 11/08/10 Iteration nwallette | 11/08/10 @NWallet SinisterSlay | 11/08/10 Increasing the dimension(s) Tony Hopkinson | 11/08/10 @Strongbad nwallette | 11/08/10 @Nwallet, I think I get it SinisterSlay | 11/08/10 @nwallette, @SinisterSlay Justin James | 11/09/10 datestamps and collections apotheon | 11/09/10 Ouch.. nwallette | 11/10/10 That was my question too. I just guess it assigns the current date SinisterSlay | 11/11/10 try this, o the ignorant one gskur@... | 11/11/10 re: OOP and VBA date formatting apotheon | 11/11/10
com.com/programming-and-develop 9/12

11/30/2010

To gskur Tony Hopkinson | 11/11/10

Seven ideas for learning how to progra

@Apotheon, Was your post directed at me? SinisterSlay | 11/11/10 onVBA: to apotheon gskur@... | 11/12/10 nope apotheon | 11/12/10 Why can't you automate Excel outside of VBA? SinisterSlay | 11/12/10 Double-negative nwallette | 11/12/10 Re: Excel automation Justin James | 11/13/10 @JustinJames gskur@... | 11/14/10 Batman: "I've tried to avoid all this, but I can't." apotheon | 11/14/10 Re: The Excel object model Justin James | 11/15/10 Interesting... AnsuGisalas | 11/06/10 That kind of expressiveness... Sterling "Chip" Camden | 11/06/10 Is it? Tony Hopkinson | 11/05/10 OOPsie apotheon | 11/05/10 Ha... Tony Hopkinson | 11/05/10 Think about it.... AnsuGisalas | 11/05/10 Well yes but that's where it all falls down Tony Hopkinson | 11/05/10 ugh, bad OO design apotheon | 11/05/10 Sure, we certainly agree on that. AnsuGisalas | 11/06/10 Well Child was an aggregate property Tony Hopkinson | 11/06/10 To AnsuGisalas Tony Hopkinson | 11/06/10
com.com/programming-and-develop 10/12

11/30/2010

Seven ideas for learning how to progra

RE: Seven ideas for learning how to program Sterling "Chip" Camden | 11/05/10 RE: Seven ideas for learning how to program Vladas Saulis | 11/08/10 Thanks, Yoda. No text. Palmetto | 11/08/10 This comment is useful how exactly? Tony Hopkinson | 11/08/10 I think I understand the intent. apotheon | 11/09/10 I think anyone with a reasonable level of intelligence Tony Hopkinson | 11/09/10 Consider free interactive fun learning of real IT skills with MIT's Scratch BruceAndShelly@... | 11/09/10 B&S, Palmetto | 11/09/10 modify the language apotheon | 11/09/10 Start small, make something that interests you and that you will use Duke E Love | 11/09/10 great example apotheon | 11/09/10 Hmm I've been writing sql to go the other way Tony Hopkinson | 11/09/10 Am I the only guy who's first program wasn't "Hello World"? Palmetto | 11/09/10 Last "first program" I remember AnsuGisalas | 11/10/10 Nope Tony Hopkinson | 11/10/10 Programmable calculator Glenn from Iowa | 11/12/10 Calculators cost a weeks wages Tony Hopkinson | 11/12/10 In college, jfuller05 | 11/10/10 Learning How to Program whitland | 11/10/10 "The Unix approach" TobiF | 11/10/10
com.com/programming-and-develop 11/12

11/30/2010

Seven ideas for learning how to progra

That's a hard one Tony Hopkinson | 11/10/10 TIP: Always evaluate the utility of isaacmjohnson@... | 11/11/10 I thought of something that might be fun! AnsuGisalas | 11/11/10 I'm not entirely sure what you're suggesting. apotheon | 11/11/10 Oh, couldyadothat? AnsuGisalas | 11/11/10 The role of Esperanto... TobiF | 11/11/10 It's usually English... AnsuGisalas | 11/11/10 Good idea. But must be somehow tagged TobiF | 11/11/10 Machine AnsuGisalas | 11/11/10 kinda apotheon | 11/12/10 these days apotheon | 11/12/10 Mapping intent AnsuGisalas | 11/14/10 translating code apotheon | 11/12/10 hallo jaba8 | 11/12/10 Two tips for you TobiF | 11/12/10 And a third Tony Hopkinson | 11/12/10

My Updates My Contacts Popular on CBS sites: US Open | PGA Championship | iPad | Video Game Reviews | Cell Phones About CBS Interactive | Jobs | Advertise | Mobile | Site Map 2010 CBS Interactive Inc. All rights reserved. | Privacy Policy (updated) | Terms of Use
com.com/programming-and-develop 12/12

S-ar putea să vă placă și