News for hackers. Stuff that matters.
Re:DHH: How do I learn to program? by jrockway on Wednesday September 22, 2010 @11:36AM (#1716450)
This is more a description of "how to type in code that appears to solve today's problem". But that's not programming, that's code monkeying.

To learn how to write real programs, you need to read real programs. Is Emacs bugging you? Open the source and see how it works. Web server crashed? Read the source and fix the bug. Not sure how to configure cron? Take a look at its config parser!

Many "programmers" spend their entire life treating everything as a black box. Take a look inside the box! That's how you really learn to program.

Re:DHH: How do I learn to program? by jacquesm on Wednesday September 22, 2010 @11:54AM (#1716529)
To tell someone new to programming to open the emacs source and start reading it is not really friendly.

I'd start with something considerably lighter than that, but I do agree that reading code is a really important part of really learning how to program (well).

As for 'code monkeying' not being programming, I disagree with that, programming is the creation of specific instructions in order for a computer to reach a certain goal and I couldn't care less what the goal was or the way in which you arrived at your program. I'd definitely not go so far as to demean anybody that got in to coding that way, just like not everybody can be Michaelangelo we can't all be Peter Norvig.

From Excel to LISP and everything in between, it's all programming.

Re:DHH: How do I learn to program? by danilocampos on Wednesday September 22, 2010 @02:23PM (#1717050)
It's funny you mention Excel. Without actually meaning to, that's where I started programming.

I ended up building all of my reports using MVC, before I even knew what a design pattern was.

Re:DHH: How do I learn to program? by jacquesm on Wednesday September 22, 2010 @02:26PM (#1717061)
I know several people that started their programming career in excel spreadsheets, it's actually quite scary how far they got with their stuff before they ran in to the limits of excel. The natural follow up to that was visual basic and then more and more 'mature' environments.

One of them got so successful with his VB program formerly spreadsheet that he ended up making a very impressive fortune with it.

Re:DHH: How do I learn to program? by ojbyrne on Thursday September 23, 2010 @12:22AM (#1718559)
One of my earliest jobs involved Lotus macros. When I got to port them to VBA-Excel it was a joyful thing.
Re:DHH: How do I learn to program? by nickpinkston on Wednesday September 22, 2010 @02:50PM (#1717127)
Haha - yea me too. I've actually wanted a gEdit plug-in to text highlight for huge cells. I actually love programming in Scheme because the parenthesis are so like Excel's sort-of functional style.
Re:DHH: How do I learn to program? by eru on Wednesday September 22, 2010 @03:41PM (#1717253)
Excel is the world's most popular functional programming language. To bad it's only of zeroth order.
Re:DHH: How do I learn to program? by JoeAltmaier on Wednesday September 22, 2010 @02:09PM (#1716999)
No, I agree. Looking at a large program can be a college education. Looking at toys is what the article complained about: you learn how to make toys.
Re:DHH: How do I learn to program? by jacquesm on Wednesday September 22, 2010 @02:21PM (#1717044)
You can't begin to understand something the size of emacs before you've taken a bunch of steps in between, and looking at 'toys' makes you understand how toys are put together as well as gives you the skills you need in order to appreciate what makes stuff tick one 'level' up from there.

When I was a kid my 'toy' programs would be a few hundred lines of assembler or basic, rarely beyond that. Then the first time I hit a thousand lines (a score editing program) I realized that my old techniques didn't work any more and I discovered structured programming. This worked well for a while until the limits of organization for a single file were reached and I had to start splitting up the code in to large chunks that 'belonged' together in separate files and so on.

And that's just the organizational stuff, never mind the actual code or data structures.

To throw someone in on the deep end of that and saying 'Swim!' is not going to work except for a very few people that are genius level. The GGP might be one of those but for the rest of so (let's say ordinary mortals) that's not how you learn the fastest.

Of course, once you're ready for a 'big' program (say 50K lines and up) it really will be a great step forward, once you've mastered to read (and work on) a program of that size it will be a huge achievement.

I've never met someone that learned how to code out of the gate by studying emacs though.

And don't underestimate how much you can get done with 'toy' bits of code, libraries are so easy to tap in to that a few hundred lines will go a long way if all you want to do is solve some problem.

Check out some of the more involved 'R' programs that float around here for good examples of that.

Re:DHH: How do I learn to program? by jrockway on Wednesday September 22, 2010 @02:24PM (#1717054)
I disagree; you don't need to understand all of Emacs to read the source code. You type "C-h k", press a key, and then the source code for the key you just pressed is displayed. It's written in a simple procedural style. Now instead of guessing how that works, you know.

You might be adventurous and read the rest of the file. Now you know how a whole major mode works.

Before you know it, you are applying those techniques to your own code without realizing it -- and now your code works like the rest of Emacs.

Show me any Emacs extension on the Internet, and I can tell you exactly how the author learned Emacs Lisp -- that's how different "I learned everything myself" and "I read the Emacs source code" methods of learning are.

Re:DHH: How do I learn to program? by jacquesm on Wednesday September 22, 2010 @02:35PM (#1717087)
You can change this now to be about a single small module in emacs, but originally you wrote:

> Is Emacs bugging you? Open the source and see how it works. Web server crashed? Read the source and fix the bug.

Both emacs and web servers are major programs, and analyzing them 'from the source' for debugging purposes is a different thing than analyzing how a single minor module works in it's normal environment. Debugging can have you rooting around in the basement fairly quickly, which is more than likely to overwhelm a novice.

Sure, emacs is built that way, but Lisp code isn't quite as easy to understand and debug as you make it out to be (judging by the number of people that hack around in emacs vs those that don't) and you have to keep in mind that you are very good at this, so it may be a bit hard to put yourself in the shoes of someone just starting out and maybe not at your particular level of genius.

What's easy for me may not be easy for you and vice versa, and hacking emacs as a start - at least to me - seems to be a bit much.

Plenty of people have trouble getting slime working, let alone hacking around on the guts of emacs without an experienced hand around to guide you.

Re:DHH: How do I learn to program? by jrockway on Wednesday September 22, 2010 @05:06PM (#1717532)
Both emacs and web servers are major programs, and analyzing them 'from the source' for debugging purposes is a different thing than analyzing how a single minor module works in it's normal environment. Debugging can have you rooting around in the basement fairly quickly, which is more than likely to overwhelm a novice.

If you say, "it's too hard", it will be. (You don't have to be productive on day one. But some day, you should at least take a look.)

Plenty of people have trouble getting slime working, let alone hacking around on the guts of emacs without an experienced hand around to guide you.

If they read the source code, the magic would become understandable. The problem that people have with things like SLIME or monads or pointers or classes is that they build a mental model that's a lot more complex than the real thing. Take a look at the real thing, and your mental model becomes simpler and more in line with reality.

Re:DHH: How do I learn to program? by jlmendezbonini on Thursday September 23, 2010 @10:42AM (#1719786)
>I'd start with something considerably lighter than that, but I do agree that reading code is a really important part of really learning how to program (well).

I am interested in well written code that falls into the light to read category. Can you provide examples?

Re:DHH: How do I learn to program? by run4yourlives on Wednesday September 22, 2010 @01:07PM (#1716786)
DHH is saying "do" rather than "try".

You can memorize every line of the emacs code base, but unless you have a problem with emacs itself that you'd like to solve, it isn't going to get you far.

On the other hand, if you can't find a web-app to manage projects that works for you, and you decide to code one, you will learn much, much more.

Re:DHH: How do I learn to program? by jrockway on Wednesday September 22, 2010 @02:21PM (#1717043)
I disagree. I would say I've learned about 40% of what I know about programming by typing stuff in and seeing if I like it. The other 60% I've learned by reading other people's code and stealing the techniques I like.

For example, I learned C by myself when I was in middle school. The memory management technique I developed independently was "the library allocates, the application frees". No errors in valgrind, and my app works.

Then I started reading other people's C code, and switched my technique to "the application allocates, the application frees". Now C is a lot easier to write!

Assuming that you're the smartest person on Earth only gets you to a local maximum. To get to the global maximum, you have to interact with other people.

The way you interact with programmers is with source code.

Re:DHH: How do I learn to program? by run4yourlives on Wednesday September 22, 2010 @02:52PM (#1717133)
I think you've possibly hit on a fundamental difference between learning styles that people have.

I've learned probably 95% of all my programming from doing.

I do take issue though with the idea that the learn by doing crowd is somehow less accomplished. It smacks of baseless elitism.

Re:DHH: How do I learn to program? by dlo on Wednesday September 22, 2010 @08:36PM (#1718098)
Isn't thinking that others have little to offer to you a form of elitism as well? It seems neither option is particularly humble.
Re:DHH: How do I learn to program? by spiffytech on Friday September 24, 2010 @12:27AM (#1722659)
It's not that others have little to offer, it's a different style of learning. Just like some people are visual or auditory learners, some are kinesthetic learners.

Seeing other people's code does little for me because I miss all of the reasoning that went into it's creation. However, when I've fought through the same problem myself, I understand very thoroughly the traps, pitfalls, and solutions the task entails. When I reach this level, I can read other people's code and clearly see why they did what they did, and how it's better or worse than my method. I have to take a crack at the problem myself first, though, in order to learn well.

Reading other people's code is, for me, a way to refine and reinforce my techniques, not to learn entirely new things. I learn much less effectively when I try that.

Re:DHH: How do I learn to program? by hello_moto on Wednesday September 22, 2010 @10:04PM (#1718282)
I read a lot of books, but tend to forget most of them as well.
Re:DHH: How do I learn to program? by helium on Wednesday September 22, 2010 @11:43AM (#1716484)
Actually, I don't believe that was what DHH meant. Everyone is going to write a spaghetti mess starting out. The only way to learn from that is to write more and more code(that you'll need to maintain) and teaching yourself what well designed code is and why it matters.
Re:DHH: How do I learn to program? by BrandonM on Wednesday September 22, 2010 @12:41PM (#1716706)
Definitely this. I got a BS in Computer Science and started along the path of Software Engineering while working towards my Masters. Learning some good fundamentals helps, but my code was still a mess. Writing code that you'll actually have to look at again is the best way to become a good programmer.
Re:DHH: How do I learn to program? by angrycoder on Wednesday September 22, 2010 @04:15PM (#1717369)
Just curious, how much bigger did it make your e-penis to type out programmers in quotation marks?

At the end of the day, it takes all types to make software. Those who build the boxes, those who peer into the depths and improve or maintain the boxes, and those who use the boxes all work together to make great software.

Re:DHH: How do I learn to program? by InclinedPlane on Wednesday September 22, 2010 @03:46PM (#1717272)
Learning to program well is a complicated bootstrapping process. You can't start out writing full-fledged, high quality apps (because you won't have the skills), nor can you start out by reading production code (because most of it'll just go over your head).
Re:DHH: How do I learn to program? by awakeasleep on Wednesday September 22, 2010 @11:50AM (#1716517)
You could disagree with anything if you tried to. But can you see any merit to the 'need a goal to guide your learning' point of view?
Re:DHH: How do I learn to program? by shadowsun7 on Wednesday September 22, 2010 @12:19PM (#1716633)
That wasn't the point of his counter-argument. That a stance has some merit does not raise it above criticism.
Re:DHH: How do I learn to program? by jshen on Wednesday September 22, 2010 @11:40AM (#1716475)
nice strawman.

If you have a real concrete goal, and your web server crashes, you'd try to fix it just like you say.