This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

How Do You Teach Yourself Programming?

14 posts · 11510 views

Hi all,
I never had a formal education in computers, let alone programming. A short while ago I started to teach myself programming through Common Lisp, the first language I’ve ever tried. I know that one of the best ways to teach yourself programming is “simply to do it – pick projects that are personally interesting to you and a language that intrigues you and just go for it,” as one prominent Lisper put it. I’ve tried to follow this advice and largely it’s working. Possibly some of you have successfully taught yourselves programming. What advice would you give to someone who’s trying to follow your path?
hmas

Re: How Do You Teach Yourself Programming?

Keep your ambitions low at the beginning, and start to slowly increase them. For example, start with a few simple one-command-applications, and then "generalize".
I myself (and I know others do) tend to have an idea for some Program I want to write. But then, thinking about it, I get more and more Ideas how to extend the possibilities of the Program and how it could be generalized, how to create a generalized API for what it does to make it embeddable and create some kind of Plugin-System or so... But even though every single further Idea would only lead to a few more lines, the whole bunch of Ideas can lead to a Project that is too tall to finish it - which can be frustrating.
Thinking "inductive" is therefore the best way, I think - create something small, make it work, and then, if you still want, extend it.
Sorry for my bad english.
Visit my blog http://blog.uxul.de/

Re: How Do You Teach Yourself Programming?

IMO, the best way to teach yourself programming is:
  • Choose a language to learn. I would start off with Lisp or Scheme first. I think you'll be better prepared for all the other languages you may ever meet.
  • Choose a book that describes the language. If you choose something like Scheme, I'd start with Structure and Interpretation of Computer Programs. You can find an online copy here, http://mitpress.mit.edu/sicp/, or you can buy a paper copy here.
  • Choose a problem to implement. Make it something small enough that you have a reasonable shot at doing it. The first computer program I ever wrote was a simple craps game that just simulated rolling a couple of dice, and then implementing basic pass-line rules for the game (7 or 11 on the first roll wins; 2, 3 or 12 on the first roll loses; otherwise the number becomes the "point" and you continue rolling until you re-roll the number, at which point you win, or you roll a 7, at which point you lose). I happened to write that program in BASIC on a Commodore PET in a computer store one afternoon in 1979 or thereabouts. And yes, I lost the program as soon as they kicked me out of the store for the evening. I was 12 at the time.
These days, you don't have to hang out in a computer store until they kick you out. :)
Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/

Re: How Do You Teach Yourself Programming?

Hello everyone,

I’m also teaching myself how to program without any formal background. I have no clue how to go about doing so, but I’m having a lot of fun.

I started out by getting “Common Lisp: A Gentle Introduction” and “ANSI Common Lisp”. I’ve been doing every exercise in A Gentle Introduction and using ANSI mostly as a reference text. I’ve found that I learn a lot more if I never look up a solution to a problem until I’ve come up with a working program on my own, no matter how crude.

About halfway through Gentle, I took a break to write two simple programs I had thought up myself. I’m glad I did....I learned a lot. When you’re working problems in a textbook, you know that you’ll be using the concept you just learned, so it’s easy. To start with only an idea and figure out how to begin and then follow it through to the end is difficult at first.

I’ll finish A Gentle Introduction soon, and then I figured I’d go through Structure and Interpretation (which I learned about on this post – thanks!). There’s an endless amount of texts and information online if you’re persistent...just keep digging.

I’ve found that the more I program, the less money I spend. So, I don’t have to work as much, and I have more time to program. I wish I had figured that one out ten years ago.

Re: How Do You Teach Yourself Programming?

Heh, I'm half way through Touretzky's book as well, but I think you are progressing faster than I am. For reference, I use the Hyperspec. There are some useful chapters from "Practical Common Lisp", but the example programs are pretty advanced though. I think a better book after Touretzky's book is "Paradigms of Artificial Intelligence Programming" by Peter Norvig. Some of the material will be reviews, but hey, it's better to review Lisp in a new book than the same book. :-)

Re: How Do You Teach Yourself Programming?

speech impediment wrote:I think a better book after Touretzky's book is "Paradigms of Artificial Intelligence Programming" by Peter Norvig.
Thanks a lot for the suggestion Speech Impediment. I'll definitely take your advice and choose that as my next text. I could really use a little review as well.

I recently started doing a few of the L-99 Lisp Problems. They're a good change of pace, and go well with Touretzy's text.

Re: How Do You Teach Yourself Programming?

I've been thinking about this sort of thing a lot recently. Not so much the very basics of learning to program, but.. well, I've been trying to write a series of articles for people who have been programming for a while. maybe even professionally, but have no real background in computing. This turns out to be harder than it sounds because you can't assume anything...

Anyway, I agree that PAIP is a really great book. SICP is also a great book, but it has one flaw, I think (well two, if you count the fact that it's in Scheme rather than CL, but I digress ;) .) It asks for a certain level of mathematical maturity in some of the early chapters. Not a really high level, but the golden section stuff threw me a bit when I first read it (a long time ago now.) I've gotten better at that sort of math since then, partially because SICP convinced me that I ought to (and some of Gerald Sussman's other work was even more persuasive on that front) but I had a hard time with it at the time. That might not be an issue for you. I floundered a fair bit with math involving numbers at one point- I actually never passed a grade of school past 6th so I found myself a bit out of my depth in that respect when I eventually went to Uni.

Beyond that I'd really suggest that you start reading actual code now. There's a lot to be said for fumbling around trying to figure out how to do things like sort a few numbers. I think people do too little of that these days. But there's also a lot to be said for looking at how good programmers do things. Paul Donnely said, in a nother thread, soething I've said many times. People don't learn to play music without ever having listened to music. They don't learn to write without ever having read good writers. Of course programming is a bit different because- well almost everyone winds up with the background knowledge neessary to at least hear music, if not analyze it. The same could be said for writing.

Anyway, I'd suggest that in addition to reading books about CL you start looking at the simpler libraries. You may find that you don't understand everything you see, but that's OK- learning to program is a process of iterative refinement, IMHO. If you come back to the same library in a month or so you'll understand it better. Anyway, just my two cents, make of it what you will.

Re: How Do You Teach Yourself Programming?

duncan wrote:I'd suggest that in addition to reading books about CL you start looking at the simpler libraries.
Thanks so much for your help. Is there a library in particular you would suggest? I don't mind researching them on my own, but if you could point me in a general direction, that would be great.

Thanks again :)

Re: How Do You Teach Yourself Programming?

Which library to pick also depends on what interests you.
Here are some:
Beginner/Intermediate (nice, pretty small libraries)-
(1) anaphora - anaphoric utilities for common lisp. For example,
(aif (getf list 'a) (print it)). The return value of (get lst 'a) is bound to the variable it.
http://common-lisp.net/project/anaphora/

(2) cl-op - a partial application library (check out url and scroll down for example under documentation! It's pretty cool)
Main Page: http://code.google.com/p/cl-op/
Blog/Announcement :http://blarneyfellow.wordpress.com/2009 ... ry-for-cl/

Intermediate/Advanced (if you want a real challenge; i.e. probably one would only try to determine how it works if one were attempting to expand library; i.e.
some are quite large) -

(1) cl-store - "CL-STORE is a package written by Sean Ross for serializing and deserializing CL objects from streams" i.e. persistent lisp!
http://common-lisp.net/project/cl-store/

(1) cl-opengl - uses the foreign function interface ability for lisp (allows one to make bindings to c libraries). Binds to the OpenGL graphics library.
http://common-lisp.net/project/cl-opengl/
You'll notice that this library requires darcs to download from repository! Fun! :shock:

(1) cl-mpi - cffi binding to MPICH1.2 and MPICH2 library. Allows utilization of multiple cores by running x lisp programs at once (i.e. sbcl.exe, clisp.exe, etc)
and using the MPI protocol to communicate between each process. Well, sort of anyways.
http://code.google.com/p/cl-mpi/

(2) mudballs - easy loading of lisp libraries from internet (some implementations) and from system files.
http://mudballs.com/

(2) cl-ppcre - " Portable Perl-compatible regular expressions for Common Lisp"
http://weitz.de/cl-ppcre/

Re: How Do You Teach Yourself Programming?

ebie wrote:
duncan wrote:I'd suggest that in addition to reading books about CL you start looking at the simpler libraries.
Thanks so much for your help. Is there a library in particular you would suggest? I don't mind researching them on my own, but if you could point me in a general direction, that would be great.

Thanks again :)
Well, to begin with you might want to take a look at some of the libraries in cl-utilities. A lot of them are pretty compact, self-contained, and not hard to understand. Split-sequence is written bit differently than I probably would have chosen to write it, but it's nice and short and provides a good introduction to loop ;). Pretty much any library you can find that's both very short and used widely enough that you can be sure it works is probably worth reading at first.

In terms of larger libraries, all of Edi Weitz's libraries that I've looked at have been well coded. Unfortunately a lot of them are too complicated to start with, particularly if you haven't been programming for that long. PPCRE tends to get mentioned as good reading, and it does some very interesting things with closures, but it requires a fair amount of background knowledge. Cl-who is quite short though, and it illustrates a few things quite well. It's worth noting how it uses a bunch of regular functions to build up the facilities necessary for the transformation it implements and then uses a few very short top-level macros to get the convenient syntax that's desired.

Other things about Edi's code that are worth looking at, IMHO, are: A fair bit of what he's written needs to be pretty efficient. He tends to do the right thing here, writing efficient code without doing extreme and marginally useful stuff. He also makes use of special variables in a nice idiomatic way. In a lot of languages global variables are best used very sparingly, but CL's special variables avoid a lot of the problems with globals, and they can make code significantly cleaner when used well. They don't get as much press as, say, macros, but they're a nice feature. And in general what he writes tends to exhibit "good taste." So after you've read some shorter libraries you might want to move onto some longer ones. If you're interested in clients, and servers, and protocols (oh, my!) you might find drakma and hunchentoot interesting.

Metatilities also looks like it has some pretty interesting stuff in it- I haven't read through it, but cl-containers looks as if it might be particularly interesting. One thing about programming in a language that comes with a fair number of useful built-in data structures is that it's pretty easy to not learn how data structures are actually implemented in that language. Since there are a number of good open source CLs largely written in CL you can always go and look at how, say, hash tables are implemented in one of them, but if there's a lot of dependence on internals that can get a bit hairy. Some of the other metatilities utilities are likely to require a fair bit of background though (like a good working knowledge of the MOP.)

I see that while I've been writing this Harnon has also responded, and his (?) suggestions are also good.

Re: How Do You Teach Yourself Programming?

About cl-opengl: glut has some limitations regarding keyboard/mouse input. (And maybe some other stuff too) It might be better to use lispbuilder-sdl. I don't know what cl-opengl has, but lb-sdl has handy macros such as with-init, with-events, with-primitive.

You also might want to learn C or assembler to learn how the machine and pointers work a little. Make your own little singly linked list or something with it.

Re: How Do You Teach Yourself Programming?

I really appreciate all the helpful suggestions. I hit a wall and had to put my head down and push through it, so I've been slow to respond to your posts. Up to that point I found lisp fairly simple and easy to learn. All of a sudden, I got overwhelmed by....I'm not sure....I just couldn't wrap my mind around some of the implications.

I finished Touretzky's text and, following Speech Impediment's advice, started on PAIP. I'm finding it a perfect a followup. It's filling in the gaps and answering a lot of the lingering questions I've been having.

I downloaded some of the simple libraries that were suggested in your posts. A lot of the code is slightly beyond me, but I'm slowly able to figure it out. It's helpful to see 'real' programs as opposed to those with just a purely instructional aim.

On a slightly different topic, something surprising happened to me recently. I was looking at a simple algorithm implemented in C, and I actually understood it! I've never seen any C code before. I sat down and, using it as a reference, was able to write it in lisp. It actually worked! I'm chalking it up to beginners luck.

Re: How Do You Teach Yourself Programming?

I don't remember how I taught myself programming... probably a good thing, since I almost certainly did it completely ass-backwards. Here are the blundier blunders I wish I could undo:

1) Learn the science ASAP. It's not hard to get a list of the important algos and data structures, and look them up on Wikipedia. Implementing them in the language of your choice is good practice.

"Practice makes permanent, but perfect practice makes perfect." The sooner you grok the science, the less time you'll spend writing bad code. Ideally.

2) Get involved in FOSS. Writing documentation is a good place to start because it requires you to read someone else's code, and understand what it does. On top of that, it gives you a chance to network and learn from more experienced developers.

If you're going to be involved in FOSS, then learning some sourcecode management systems is essential. The learning curve tends to be steep at first, but even if you only want to work on personal projects, you'll be glad to have access to the project at earlier points in its development. Learning the GNU tools— grep, sed, awk, diff, etc— are great for productivity and go hand in hand with SCM.


For Lisp in particular, I'm enjoying Paul Graham's On Lisp. I'd already read halfway through Peter Seibel's Practical Common Lisp, and they're both good books, but On Lisp was the one that got me excited about this language, and rekindled my mania for programming. In fact, this:
eble wrote:All of a sudden, I got overwhelmed by....I'm not sure....I just couldn't wrap my mind around some of the implications.
...happened for me around chapter 6. ;)
"If you want to improve, be content to be thought foolish and stupid." -Epictetus

Re: How Do You Teach Yourself Programming?

I never really analyzed the process before, but first I should explain why I'm not sure how much programming I've taught myself. I took a Webmastering class in high school which introduced me to HTML, CSS, and maybe a little inline JavaScript. It wasn't a great class; everything was laid out with tables and W3Schools was the supplemental reference. Around the beginning of it one of the other students showed me *real* JavaScript and I started writing it, and enjoying it a lot more than CSS or HTML. I'm not sure when I started asking questions on the W3Schools forum (which is a lot better than the site itself), but I think I immediately found some questions I could answer. That forum is where I ironed out just about all my JavaScript misconceptions.

The next year I took Computer Science, which used Java. I was still a novice programmer at this time, as this paragraph started somewhere in the middle of the last one. By the end of the year I had placed 5th in the state CS competition, but unfortunately it was my senior year. I didn't know it at the time, but I thus started out with two traditions in my head, along with two methods of learning. And I think I'm glad it worked out that way, because I was introduced to very different concepts but basically the same syntax. The two methods of learning have since maintained their priorities, because I'm generally able to learn something online much sooner and more easily than I can register for a class.

Over that summer I read a C++ tutorial and then received online certificates from the local community college for learning PHP/MySQL and C++. At first I didn't see much use for PHP; I thought I could do it all with JavaScript. Boy was I wrong. After a while of answering questions on forums for JavaScript, PHP, and HTML, and then asking questions on a C forum, I enrolled in a physical C# game-programming class at the community college. I did learn C# then, but we were going to program Xbox 360s which didn't work out because the book used an old DirectX version. I think the next semester and summer are when I learned Python from the official tutorial. One more semester later I'm now taking Python game-programming, C# XNA game-programming (better this time), and AI programming for games. I'm really not particularly interested in games, but those are the classes they offered and I don't care very much what I program. (And I know these classes probably won't transfer to a university, but oh well.)

So all in all, standard education has a claim to teaching me at least part of every language I know. And yet, in about every language except Java and C# (which are about the same thing - C# never really felt like a new language), most of my education has come by independent means. But to answer the question, it's really about the projects you're interested in building - as stated above. I obviously use forums heavily to complement and direct that motivation toward best practices, but I''ve spent much more time reading language references (and specifications) than asking questions on forums. Although many of my ideas for what to program have started as questions asked by others.
I'm off my grokker.
- Chris