Discussion Locked

What's the best way to learn programming??

0 helpful
38 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hey all, I have some quick questions I'm hoping I can get advice on. I primarily deal with support and networking, but I want to start learning how to program. The problem is that I have absolutely no background in it. I've never taken any programming courses (was not required for my degree) and the only exposure I've had is very little VB.NET for an ASP.NET application.

I want to learn VB.NET and possibly C# (can't decide which) but I don't know where to start short of waiting until I can take some courses at a community college. I've bought several books on VB.NET but I have a very hard time sitting down and reading them because I feel the silly little examples they use to teach doesn't demonstrate anything useful; I prefer to learn by having a case study and working to build that up, not doing a bunch of independent examples that I feel don't teach me anything.

Maybe I'm going about it the wrong way? I'm just confused by the prospect of it all and have a difficult time comprehending what I do, probably because I have had no classes on theory and logic.

So, is there any way that I could get myself into the right mindset and try to learn this.. I want to make myself as diverse as possible, plus the little programming I have done is enjoyable, I just don't know enough to do anything useful yet. Are there any good books that teach in the way I described (i.e. includes a case study of some kind that allows you to learn by developing a 'real world' type application and/or has one as the final chapter to let you use what you've learned already), or is this a lost cause and I should try and take some courses?

Many, many thanks in advance!

38 replies

by gralfus

Different people can have starkly different ways of learning that are most effective for them. When I wanted to learn VB, I got a variety of books and tried their examples. Some worked, others didn't. If I got to a point that wouldn't work, the book usually didn't have any way to direct me about what I was doing wrong (occasionally the book was wrong).

I found that by studying other people's programs at work, I was able to learn quite a bit. I also took intro classes to gain a foundation of the "right" way to approach VB programming. It is very complicated for the person who has never programmed before, but once the pieces start to make sense, you can put the tools together to serve your designs.

Perl was another language that I taught myself, mostly by reading the O'Reilly books on Perl, and by doing very short programs that demonstrate a variety of commands. I kept a binder filled with these short programs so I could reference them. I also commented heavily within the programs so I wouldn't forget what the code was supposed to do.

So all in all, I'd recommend some intro classes and then puruse Amazon.com for books that others found useful. I still have a VB for Dummies book on my shelf, because it has simple information that other more advanced books assumed I already knew.

by stress junkie

There are certain principles that can be applied to any kind of programming. You aren't likely to learn these from any particular language reference book. These are the kinds of things that are most likely to be learned in a classroom. General software design principles include things like:

well known data structures
well known algorithms
database design principles
avoiding spaghetti code
using flow charts
top down programming
bottom up programming
organizing huge amounts of data
and a bunch of other good programming practices.

My college curriculum was focused on software design so I learned programming techniques before I had developed too many bad habits. I believe that learning programming techniques is like many other skills. If you start on your own you may develop bad habits that will evenutally hinder you in the future. On the other hand if you start by learning good techniques they will appear burdensome at first but in the long run you will be better off.

So check your local college. See if they have classes with names like 'Data Structures and Algorithms' or the like, and give them a try. Once you learn these techniques you can pick up any programming language by using a language reference.

by tony hopkinson

I went from self taught, to a structured course in Pascal. Unlearnt more than a few things. Good programming practices I learnt like everyone else, either by shooting myself in the foot, or on occasion through another developer's poor attitude to firearms safety.

If you want to learn programming, look for course / books called learning programming with , not learning programming in .
Personally if you want to learn programming theory, you should learn Pascal or C, Pascal enforces a much better discipline in technique than C. VB.NET & C# are at a much higher level, they do more things for you, without you having to know how they work. If you learn at that level, you'll struggle to figure out why your code doesn't work because you where never taught how it does.
C# for instance does include pointers, but it's most powerful features are implemented with them.
All depends whether you want a quick start as a drag an drop programmer, or you want to learn the basics and then use drag and drop tools to program.

by apotheon

You're right, that good programming practice is fundamental and not something you learn as part of a language. A programming language and good programming practice are separate skills, but they're skills one must learn essentially in parallel: learning each depends on learning the other to some degree. I disagree that you need classes to learn good practice, though. There are a number of quite excellent books out there that can help you learn good fundamental programming techniques.

Some classics of the field, seminal works of programming practice, exist and for the most part have little or nothing to do with your choice of language. Among those probably most applicable to learning the fundamentals are [u]The Pragmatic Programmmer[/u], [u]Advanded Programming in the Unix Environment[/u], [u]The Mythical Man-Month[/u], and [u]The Art of Unix Programming[/u]. Two of those are more geared toward unices than other environments, but the principles they address are universal and valuable. [u]The Art of Unix Programming[/u] is available for free online at http://www.catb.org/~esr/writings/taoup/ and is more than worth the cover price to have a copy of your own. I'm told [u]Design Patterns[/u] is excellent as well, though I can't swear to the sources from which I recall having heard this. I plan to pick up a copy, eventually, and find out for myself.

Disclaimer: I have not read all of the books I recommended, but people whose judgment I trust have read those I have not.

by tony hopkinson

You're unlike to find many good books on programming theory for VB.NET or C#. You need to learn that in a 'lower level' language.
Choose C or Pascal.
Brian W Kernighan, by himself and with co-authors has produced some very good books on programming as a discipline in both the above languages. Once you've got the basics.
Applying them to the languages you want to market yourself with and any other will just a matter of translating.
As far as examples go you are right you need a project.
Anything from something as mundane as maintaining your cd collection, to writing a board game.

You'll find lots of snippets and examples on the net to do bits of your project (or nearly). Understand how they work apply them to 'your' problem.

All programming is, is taking a 'complex' task and breaking it into simpler steps. The size of the step, the way they are arranged and stated depends on the langauge.
Theories and techniques are ways people have successfully done it in the past.

by apotheon

Other good languages for learning to program include Lisp, SmallTalk, ObjectiveC, and Perl.

Perl is good because it has a very low bar to entry and encourages regular use by being very accessible, providing a very shallow learning curve. A shallow learning curve is important, of course, because it doesn't discourage the user, and Perl is a good programming language for ease of learning where something like C# isn't because Perl doesn't depend on drag-and-drop development to make the learning curve shallow (nor is it a mess of nasty the way VisualBasic is). Despite being shallow, though, the learning curve goes on forever. There's always more to learn.

SmallTalk is good because it's essentially the canonical object oriented language. If you want a relatively entry-level language to learn, but want it to be object oriented, SmallTalk might be for you. The downside to SmallTalk, of course, is that nobody uses it for real world applications. This isn't because there's anything wrong with SmallTalk: quite the contrary, SmallTalk would be excellent for many things. It just didn't get the hype that things like Java have gotten, so it has largely fallen by the wayside.

Objective C is a good language to learn for a number of reasons. For one thing, it's one of the best implementations of object oriented programming available. It essentially grafted SmallTalk-style object oriented programming onto the C language. The more common OOP language based on C is, of course, C++, but C++ is a messy kludge with some very schizophrenic issues. It's still a darn sight better than Java in many ways, though. In any case, Objective C also benefits from being a direct extension of C, rather than a reworking of C like C++ and C# are, so that even though it is not nearly as widely used as C++ it still teaches you a language (namely, the C programming language) that is fundamental to everything. The kernels to Linux, Windows, and MacOS X are all written in C, and it's hard to beat skill with C with the added benefit of a good schooling in object oriented programming. Additionally, pretty much all application programming for MacOS X is done with Objective C (using the Cocoa IDE). There's also a Linux implementation (called GNUstep) of the Objective C environment on which MacOS X is (in large part) based as well. This, along with Perl, is one of my favorite languages.

The Lisp family of languages is exceedingly good for learning programming because it is based on very elegant, well-structured design. In this manner, it is somewhat similar to Pascal, though there aren't too many people who would call Pascal "elegant". Lisp has more focus on the elegance, and Pascal on the structure, I suppose: both are quite valuable. Learning how to program in Pascal teaches you how to structure your programming, and learning how to program in Lisp teaches you how programming should look when it's done well. It's very difficult to get the point across without just telling you that you have to experience the difference for yourself, I guess.

There are people who swear by Python as a good starting language, but I disagree. It teaches structure better than Perl, I suppose (since Perl is the Swiss Army chainsaw of languages: you can do anything and everything with it, including patching your kernel in five lines of code, or lopping off your own leg with one misstep). Perl allows you to use or not use structure as you wish, and thus places the burden of learning good programming structure on other sources (like a good book about programming practice). Python teaches structure, but it teaches the structure of Python specifically, which for my tastes at least is worse than learning no structure at all. If you want a starting language that teaches structure, go with Pascal instead.

PHP offers one of the lowest barriers to entry to the language, and one of the shallowest learning curves, of any language worth learning. I say "worth learning" because something like JavaScript or VBscript is [b]not[/b] really worth learning: what you need to know about either in any given circumstance you can figure out while you're doing it, if you have programming skills in general, and you can safely forget it the next day. PHP is nearly that simple, but much more powerful, and as such is a lot more suitable for use as a first language than something like JavaScript. I wouldn't recommend it as a first language, though, because it is essentially guaranteed to teach you bad habits that you'll later have to unlearn. Take it from someone that has made the mistake of learning more PHP than anything else: unless PHP is pretty much all you'll use, ever, you should definitely learn something else first. It's quick and easy, but these are not always the best characteristics for a language to have.

Keep in mind that I'm not exactly a guru with any of these languages. I don't consider myself a programmer at this time: I just have programming skills. I know quite a bit about the theoretical benefits and detriments of various languages, though, as I do about a lot of other things, because I've spent more time learning the principles and capabilities of technologies than I have about the specific implementations of these technologies. This is the way of life for a dedicated consultant.

by tony hopkinson

Lisp and Objective C I haven't used. My language of choice is Pascal/ObjectPascal because I like the imposed structures. C I use because it's hard to move more than 2 inches in any direction in IT without bumping into it, but I'm glad I learnt pascal first it cuts out a whole swathe of bad habits particularly obfuscation.
PHP, I've been picking up as I go along and it certainly is preferable to Javascript or VBScript. Writing your code on cooked spaghetti with a magic marker in boxing gloves is better that either of them.
Even after 31 years since I started learning programming I wouldn't consider myself a guru, because I still am. As far I'm concerned you've grasped the principles a lot better than those who are happy to describe themselves as such. Once bumped into a guy who described himself as an ADO Expert, laughed my t1ts off.

by brentalansmith

Apotheon, I just wanted to take the time to thank you (and register at techrepublic for that matter), for posting this.

I found it extremely helpful and well thought out.

Cheers.

by inet32

"You need to learn that in a 'lower level' language. Choose C or Pascal. "

I disagree because those are procedural languages and C# is O-O. He's going to have to unlearn too many things. Also, if he starts off with Pascal or C then even writing "hello world" in a Windows environment is about 80 lines of code (to use the Petzold example). Or he's going to be stuck in a command-line mindset in a GUI world.

I suggest starting off in C# and biting the bullet by actually cracking the book!

Real programs ARE made up of lots of little parts and DETAIL, so if he insists on only doing grand-vision stuff and not little exercises then maybe programming isn't for him.

by tekillaah

Learn the ropes.. Improve your Logic.. Programming will be easy for you if you know how to design your software....the simplier the better.....Try HTML first ... or VB 6 ... dont use .NET .. although most sysntax are thesame...... www.w3schools.com <---------- This site could help...... I always think Python is a good start.... From thes you ca jun\mp to ASP ... Etc............

You cannot study all programing languages but you can understand some of it.. .nET is where the money is but u must learn the basics first.. Good Luck.......... Always put a remark on your codes... GOod programmers practice that everytime...

by tony hopkinson

Writing simple code is not about using a simple language. It's about not making it complicated for a laugh, and unreadable out of laziness.

Not VB6. You'll never learn good programming with that. Bleedin' terrible language. HTML is n't even a programming language. If you are talking scripts that's a bad way to go as well.
If you want to learn programming, choose a language where you have to declare your variables to be of a type. Get good coding habits and then move on to wysiwyg/scripted coding environments.

Do it the other way round and you'll at best struggle, when you want to do something that's not simple.

As for remarks.
They are only useful if they tell you something, and they are up to date. A wrong comment is worse that none at all.

A variable/object naming standard, meaningful names and making each function/subroutine only do one thing are a 1000s times more valuable than a comment.

Public Sub DoMonthlyInvoices(ByVal InvoiceMonth As Long, ByVal SelectedPrinter as Long)
' Extract Invoices for the passed month and output on the passed printer.
Dim InvoicesToPrint as colInvoiceList

Set InvoicesToPrint = New colInvoiceList
Call InvoicesToPrint.GetInvoicesForMonth(InvoiceMonth)
If InvoicesToPrint.Count > 0 Then
Call InvoicesToPrint.Print(SelectedPrinter)
End if
End sub

You could even argue that the one comment is unnecessary.

by montgomery gator

Tony's comments are right on target. I would only add that indentation makes it much easier to read the code, along with spacing to separate subsections of code.

by apotheon

You're talking about self-documenting code, and I agree: this is essential for good, maintainable code. Far more useful than heavy commenting is good self-documenting coding practice. This is, in part, what drove the development of the COBOL language -- it's the most self-documenting language in existence, I think. Unfortunately, that is basically all that COBOL has going for it, and I'd avoid it as a first (or second, or third) language.

You're also correct in your estimation of VisualBasic. It's terrible. It is absolutely the WRONG language to use for teaching yourself programming. It is a mess of bad habits, and it effectively enforces bad habits, to say nothing of the fact that the Visual Studio design environment basically everyone uses for doing VisualBasic programming hides almost everything you would need to learn to become a good, effective programmer.

I've made some comments elsewhere in this discussion about why I'd recommend against Python as a first language. I'd take Python over VisualBasic any day of the week, though.

by tony hopkinson

also where you bracket compound statements
if condition then {
Blah Blah
}
vs
If condition then
{
Blah Blah
}
prefer the latter myself but that's the way I've always done it.
Some people can get positively anal about it, though insisting on a number of characters.
Avoid these two as well
if condition then ... else ...
does not help when debugging

and the classic confusion of
if condition then
if condition then
...
else
...
Different compilers have different rules for which if the else belongs to, even if you know when you write it you're not likely to remember.

s = (((a*(v*v))+x)/(m/y)-h)
well no comment required again, apart from the door's that way.

In Programming like XML terseness is not a requirement, in fact it's a major handicap.

by montgomery gator

I too prefer

If condition then
{
Blah Blah
}

Easier to match up the curly braces.

I have also noticed how posting on Tech Republic removes indentation, even if entered by space bar.

by tony hopkinson

Some more tips.
Come up with some standard names.
e.g. If I write a class/component that loads it self from a store (database or file) the method that does it is always called Populate....
Any form that then displays the data in the class has a method called DisplayData. Simple conventions like this can save bucket loads of time. Either in a team environment or just in 3 months time when you re-visit the code. 99% of the time in a GUI, you want to change the way the data is displayed and or change the way you load it. The more familiar the environment the quicker you pick it up (again) and the more confident you feel about what you have to do to solve a problem.

by apotheon

I definitely prefer using braces on separate lines from code (as I did in the pre tags post), as well. In fact, it sorta drives me up the wall when I see code with the opening brace on the same line as the beginning of an if statement. It's much uglier formatting to do it that way (I tend to call it the "Visual Stupido" approach because the people I see doing it most are Microsofties that only know how to program in Microsoft's IDEs), at least in my opinion, and much more difficult to follow.

by jck

I'm a VB.NET programmer...and when I write C or C++, you'd never see the opening or closing brace on the same line as the code it encloses.

Of course, I was trained on Unix boxes in college :)

by tony hopkinson

but I prefer them on their own lines. Even with a decent syntactical editor they can be very hard to see and thats if you are a polite person who doesn't go past the edge of the window.
Do the the same with Begin & End in pascal, just much easier to see what belongs to what.

if condition statement, to save bracketing it is not one of my big favaourites either.

Don't like inline comments, you eyes keep bumping into them.
Another one of my pet hates is with statements. As for any one who uses compound ones well ...

What exactly is wrong with using a paste shortcut anyway.
Most of these things are simply to save typing. It's barely excusable in a script in a compiled environment it's just plain stupid.
99% of code maintainability is code readability.

by apotheon

It works better
[pre]if (you use)
{
pre tags
}[/pre]
to format your code. It's just like the HTML


, but you use brackets rather than greater-than and less-than.

by tony hopkinson

Unfortunately when you don't know the right questions you can get some very wong answers with Google et al. If you're really lucky the example won't work.

Wot No Pascal !!!

Not sure what that site was trying to do but FireFox crumpled it up quite badly for some Adware type stuff. Silly Extra window, with no status bar and no content before it raised the one I presumably was asking for.

I could run it in IE to find out I suppose.

by tony hopkinson

I hate documentation, so I try to write code that does not need much documentation.
I couldn't agree with you more on VB, it burns in so many bad habits in a developer you begin to think it was designed with that in my mind. Took me ages to learn how to write robust(ish) code with it, couldn't find many examples for some reason.
You can use the object before it's created.
Pardon ?
Remove bugs from your code, don't declare your variables.
<<< Rewind, don't think I heard you right their Bill...
A list of sins so long not even the late John Paul would have forgiven.

by apotheon

You learned the Unix way, not the Microsquishy way.

You should have a look at [u]The Art of Unix Programming[/u]. If you really learned the Unixy programming philosophy, that book will help you figure out why you do the things you do, and will help you figure out how to do them better in the future.

It's available online (from the author) at http://www.catb.org/~esr/writings/taoup/ for your convenience.

by jck

(I'm not sure exactly, because I have 8 bookshelves full) I think I have that book, or owned it when I was in college. Here at the office, I still keep a copy "A User Guide to the Unix System" on my shelf cause we have a Unix box our billing database runs on.

I also have standards like the Nutshell books on Unix, Unix System Administration, and other books I had to have for classes and that made good references in college.

I've still got "Stimulatings Simulations for the Commodore 64" if anyone is interested in some good BASIC programming reading ;)

by tony hopkinson

for the Commodore 128.
Still a good book if you want basic geometry and matrices for transformations in 2 & 3D
Danny Thorpe's Delphi Component Design, but that's rarer than a truthful politician and no ones having mine.
Bookcase of SAMMs and WROX stuff as well, and Harold's XML Bible which isn't hard to get hold of but very worthwhile.

by jck

jeez...what quality books do I have?

"Compilers" (I think that's the name), by Sethi, Aho and Ullman (The Dragon Book)

"The C-64 Anthology", by Jim Butterfield (*THE* definitive tome on C-64 internals)

"Unix in a Nutshell" - The single best reference I found on Unix that didn't take 2 days to find something in...not totally comprehensive, but had good stuff.

"The Computer Encyclopedia" - had everything I ever wanted to know about computing when my dad was a kid.

"Repairing and Troubleshooting Your Computer Monitor" - a great book for learning what to do and if you read it fully what not to do when working on a CRT.

"TCP/IP Illustrated Vol. 1, 2 and 3" - great stuff for learning and referencing TCP/IP info.

that's just a few...got tons of Novell 3-5 cert books, MS Win 95-2000 cert books, network architecture books, and programming language and OS books out the wazoo.

Maybe I should open up a library? hahaha :)

by apotheon

That was an amusing post, Tony. Heh. Thanks for the spaghetti analogy and the funny anecdote about the ADO expert.

by tony hopkinson

he pipped me to the post for a nice contract as a client/server developer. His expertise in ADO was cited as the reason. Like employing a journalist because he's good with a pencil sharpener.

by tony hopkinson

a good system for fines on late return though, and full cost on damage or loss.
Took my Perl Cookbook into work, one day I looked in my draw it was gone. Found it in another team's bookshelf. Thieving b*ggers !.

by oldbaritone

One cannot but remember the dialog between Alice and the Cheshire Cat in Alice in Wonderland: "Would you tell me, please, which way I ought to go from here?" Alice asked. "That depends a good deal on where you want to get to," said the cat. "I don't much care," said Alice. "Then it does not matter which way you go," the cat said, and he disappeared.

My own "steps in programming" are: concept, planning, development, coding, test and debug. Notice how far down the list is "coding."

So, to turn your question around: "What would you like to do (and think you can do) with VB.NET and C# that makes you think you should learn them? (Or, to qoute the Cat, "That depends a good deal on where you want to get to.")

It's obvious from the way you phrased the original question: you already understand that coding a few simple (and probably pointless) exercises isn't going to help much. As you said, "the silly little examples they use to teach doesn't demonstrate anything useful." JUST SO!

But if you start with a concept of something you'd like to do, then work toward that goal, you can define some requirements and make an informed decision about which programming language would be most useful for the task. Define the requirements in REAL WORLD terms so that you can see whether a particular language is useful to you or not.

Start a "case study" of your own, and study something that interests you. Try to solve a problem you perceive. If VB.NET's capabilities meet those needs, just go for it! Start working on your project, one step at a time. Or maybe you'll find that your problem is something that could be better handled by another language.

Another tip for programming, and not just while you're learning: use "stub" routines that return a result, without actually calculating it. You might have a routine like "Verify_user(username)" and you haven't figured out how to do it yet. That's OK, just write a "stub" that returns Yes or True or whatever. You can keep working on other parts of the program while you figure out how to verify the user. In essence, you're just "assuming the user is verified..." and keep going. Sometime, you'll need to figure out how to verify the user, but the "stub" prevents that one piece of the picture from stopping your entire project. It also makes good modularity for your coding, because you must define, in general terms, what needs to be done; in this case, "verify the user" - whatever that means to you.

When you're stumped on something, hit the blogs and find someone who has worked through the same problem. Code snippets are everywhere. Find two or three, analyze what they do and how, and work the ideas back into your own project.

But most importantly, remember that there's a lot to be done BEFORE the first line of code is written! It's easy to tell who "did their homework" by looking after-the-fact. You'll quickly see differences between modular coding and/or OOP, as contrasted with "Spaghetti Code." Most beginning programmers create a lot of the latter, because they're more concerned about "programming" than "problem solving."

And I bet you'll find that programming - in ANY language - is a LOT easier if you figure out "what you are trying to do" ... BEFORE you try to do it. (and you'll create a lot less spaghetti!)

Otherwise . . . "Then it does not matter which way you go," the cat said, and he disappeared.

by holod

Well, the most important is your desire. If you really want, after reading different tutorials and training, you'll know as much as passing rates. But the second way is to learn programming under the guidance of professors :)
It is individual for everyone what order of programming languages to choose to learn.
f.e. I tried to learn Java, but the first time I did not succeed. Only after many C + +, JavaScript and php tutorials, I begin to understand this language.

by kupolinka

On my opinion it is neccessary to find good online tutorials to learn programming successfull. I know good example of such tutorials for example: php tutorials.

by thomdd

learing computer programming.

Learn how to think first, language later. Use a higher level language with complex primitives for learning and avoid getting bogged down in syntax. Thats how we learn in real life. Language is for communication. We learn proficiency with languages later. We do not need to know that a variable must be declared of type string to understand how to think like a programmer. Afterwords we can learn the syntax and semantics which has absolutely

nothing to do with the fundamentals of programming concepts or design patterns. Thats how MIT does it, thats how people smarter than you or I do it, and thats the smart way to do it. I've gone through the same situation as you.

Use a high level language with complex primitives. Learn in Python.

This should help http://www.greenteapress.com/thinkpython/thinkCSpy/thinkCSpy.pdf

Best to start from the beginning

by ibcnunabit

Get a version of Scheme or Racket (formerly PLT Scheme), and a copy of The "Little Lisper", or if you can handle it, "Structure and Interpretation of Computer Programs" (SICP). PLT Scheme/Racket has some good materials in it as well, such as "How to Design Programs" (HtDP). You can also download MIT's courseware videos on Scheme (free downloads).

Scheme has virtually no syntax to learn (what there is can be learned in thirty minutes), which leaves purely PROGRAMMING to learn. It's a super-powerful language that allows you to build up any language construct(s) you like, want, or need as you see fit (and easily), and yet it has a large pre-existing (and powerful) set that can do anything you would need for some time. It makes it easy to create a minilanguages that perfectly fit your problem domain. All this allows you to explore advanced concepts far earlier than is likely in other languages. This will deepen your understanding of any language you learn in the future. It's in the Lisp family of languages, so metaprogramming is there, as are macros, as is lambda and continuations, and lexical scope, and a lot of other good things that make your programming more powerful.

After Scheme/Racket, you could move on up to Common Lisp, or Python--or whatever strikes you.

This discussion is closed to new replies.