Hacker News new | comments | show | ask | jobs | submit login
Ask YC: Learning to hack...
29 points by rjett 3331 days ago | hide | past | web | 51 comments | favorite
One of the common pieces of advice given by the hackers on this site to the non-hackers is to "learn how to hack." In the past few weeks, I have come to the realization that I, too, would like to "learn how to hack." Here's the problem: Not having an extensive technical background, this piece of advice seems to be quite vague. With which languages should one start in order to learn to hack? I sent a similar version of this question to PG about a month back and he referred me to the creators of Appjet, a YC startup he said was working on this very problem. After looking at the site and receiving an email from one of the founders, the answer I gleaned was to start with learning Javascript. I would like to know from this community whether I'm on the right track to "learning to hack."

Your best bet is to get a project and make something. It doesn't matter what the project is or if anyone besides you will ever use it.

There will obviously be a lot of debate (and possibly some downmodding) over this, but I would say that the language doesn't matter. I think the important part will be finding resources that you think will be helpful for you (a book, a tutorial you find on google, a friend who knows programming). In your case you want to spend as much time coding and as little time on set up and administration as possible.

Figure out how to do something easy, then see if you can start tweaking it and adding small things. You'll be a regular hacker in no time

For all intents and purposes, you will need to learn (at least) 2 technologies, one for the client and one for the server.

On the client, you have 2 primary choices: HTML,CSS, & Javascript or Flash/Actionscript. I would definitely opt for HTML,CSS, & Javascript because it's open source and it's everywhere.

On the server, you have many more choices for languages and databases. One of those languages is Javascript, although not too many people use it on the server.

I think you're on exactly the right track. Learn how to build web pages first with HTML, CSS, and Javascript. Then when you're ready to "connect" to the server, ask the next question, "What is the best language/data base to use on the server." But stand back because sparks may fly from your terminal screen as we hackers fight with each other trying to answer that one :)

Good luck.

"For all intents and purposes"

Not quite - there are other applications of programming than web and web services...

Right. I was just making a few assumptions and trying to keep it simple and helpful.

One thing I would like to point out, that you probably won't like to hear ..

If your purpose is to learn how to "hack" to the point where you can make real webapps, you should be aware of two things.

1. You will never become a good hacker if you are only doing it for the money or for the recognition. You have to be able to love the code for the sake of the code itself. You have to be able to see the beauty in the code. Otherwise you will never really understand it. It is the difference between being able to copy a poem out of a book and being able to write a new poem. 2. Assuming you are a true genius, the process will still take you many years. Working hard will not be enough. You will have to learn how to work smart to learn all the stuff you will need to know.

If your purpose is to understand hacking to the point where you can better understand technical people so that you can work with them better .. that is a much more realistic and reachable goal. For that I would recommend you start with Ruby or Python and try to make a full-scale production webapp, and from that experience you will learn a lot that will explain how a technical person thinks.

I really agree. I think there's probably a lot of people out there who read about Gates and Brin and Page and Zuckerberg, and say, "omg I want to be a haxor it wud be fun and I can make $$$!". I hate to say it, but if you really wanted to hack, you would have done it before you read about how much money haxors are making. You would have started like us, in QBASIC, because you were exhilarated at the thought of controlling that computer screen...

I think I understand the underlying reasoning behind the question. If like me, you have read a lot of the posts on this site, and the essays of Mr Graham, and have a desire to somehow start a start-up, or become your own boss etc., you search for ways to achieve this/these goals.

Most of the advice is fairly general, and I was often left with the feeling that many people just repeat the mantra: 'learn how to hack', 'do something you want, and users will like' etc etc. All good advice I may say, but nothing too concrete on how you actually start!

As hackers, most people will say: "you need to code, and business people, although relevant aren't required straight away."

I sort of agree and disagree. What does not work though is doing nothing, or procrastinating(in the wrong areas).

For me, I decided to at least do SOMETHING. I came from a systems engineering background (read:good Microsoft/Cisco techie, and reasonable sales/presentation sort of guy) - not a hacker though.

So, I decided to attempt to learn Java about a year or two ago. I have done OK with this, but unless you use a language in anger most days, you don't get very far. My latest attempt is Python. I like Core Python Programming 2nd edition by Wesley J. Chun.

What I guess I am trying to say is, you need to work out where you want to be (successful business), and take small steps towards it. That maybe learning business stuff, and it maybe learning to hack. Whatever. Just do something that is a step towards where you want to be, and continually re-evaluate how it's going.

Good luck.

Learning the essence of programming is more important than learning a specific language, once you master one of them it's very easy to pick up the rest. So I'd pick an easy one such as PHP and use online resources like w3schools.com to get me started.

Also, I find it very effective to learn by looking at examples on line first and create similar problems to solve. That way, my head remain active to think through the problem solving process. It also helps memorizing the syntax because you see the purpose of the code instead of just passively taking it all in.

You are trying to learn how to program, but many people are suggesting that you should pick a language based on what you plan on doing with the language. I don't think that should be your primary consideration. The primary consideration should be the quality of introductory material in that language. I think you'll find most material to be in Java, followed by C++ and Python.

Assuming you want to do web programming, I would suggest you start with Python as your first language. It has quality introductory material[1] and is widely used for web programming, as well as many other tasks. There is less complicated syntax that you have to ignore while learning how to program compared to Java and C++, and is generally regarded as a Better Language. Even if you weren't planning on doing web programming, Python would still be my suggestion for a first language. I'd only suggest anything different if your main concern was getting a generic programming job, in which case Java would be a better idea.

I feel like JavaScript would be a particularly poor choice as a first language since most introductory JavaScript material isn't trying to teach how to program; it typically teaches how to manipulate web pages. As a new programmer yourself, it will be harder to judge what texts you should pick from those that are available.

If you start out trying to learn how to program web applications instead of learning how to program in general, you'll be selling yourself short. Your code will be worse and it will be more difficult to figure out how to solve atypical problems that a web framework hasn't solved for you. Don't do it.

[1] Or so I hear. I haven't read introductory material in years, and then it was C++. Try How to Think Like a (Python) Programmer: http://www.greenteapress.com/thinkpython/

I've always liked Eric Raymond's advice:


BTW, it's notable that Eric used to recommend Java as a second programming language, and that he no longer does.

The only thing I'd add to his recommendations is a pitch for Ruby. I think it's a really good first language.

Teach Yourself Programming In Ten Years http://www.norvig.com/21-days.html

The nice thing about the Javascript recommendation is that by using the "View Source" option in your browser, you can get lots of real-world examples to read. Reading code is a great way to learn how to hack (and the way we used to do it, back in the day, when access to computers was very limited).

I'd suggest the following: find a web page that interests you, view the source, and try to understand what the source code is doing. Start with getting a vague overview, and keep drilling down into each layer of abstraction, asking questions repeatedly, until you truly grok every line.

When you can do that, you'll be well on your way.

You might want to add that the "View Source" option is only in Firefox once the Web Developer add-on is installed. Now that you mention it, I would suggest installing this add-on for many reasons, but I found personally that the way a majority of code is presented in books and the way it is actually implemented in the real world are two different things. This hurdle has been the greatest for me with regards to CSS. Books, at least the ones I have been exposed to, tend to fail at actually showing the real world applications of those principals. The most progress I have made in that past has been through getting your hands dirty and digging through other individuals code.

To the author, I would suggest finding a website that you feel accomplishes something you would like to create (I would start small, like a personal blog just because the amount of code might be overwhelming with larger sites). Borrow their code using the add-on, and change certain features to see effect the change makes to the product. I would continue the process for a while until you get a feel of how all of the code works together. Only after this point I would suggest going into books. Maybe you will learn differently that I do, but reading a book without actually being able to have hands on experience with what I am attempting to grasp has a hard time sinking in.

> You might want to add that the "View Source" option is only in Firefox once the Web Developer add-on is installed.

No, it's a standard part of Firefox. "View Selection Source" is too, which can be useful.

I agree that Web Developer (or similar plugins) can be a great way to learn.

Web Developer and FireBug for FireFox are the best way I know of to discover the inner workings of a web page.

FireBug even has a javascript REPL built in!

you should find some small thing you need to do for yourself : for example searching through all the images on your computer, and seeing which one is of a particular format (jpg, bmp for example) or which one was created/modified in the last couple of days. only then should you approach learning a programming language (i recommend python for starters, because it's sweet and has a lot of libraries, letting you concentrate on what you want to do instead on arcane problems) and then learning the techniques necessary to solve your problem (you'll see that most tasks you can solve programaticaly have a certain template).

It's important to start with a real task, and not only do the simple training programs you'll find in every manual/tutorial. I can't stress enough the difference between grasping a concept and actually being able to apply it in the field.

Second, after you learn your first language, don't ever think of sticking only to it. Learn your second, learn your third and your Nth language and never stop learning them. Sure, most of them are similar (python is like ruby, perl, lisp, c is like c++,c#,java) but there are some oddballs like prolog and haskell which will make you a better programmer just by knowing that they exist and what they're about). Thus you'll have a tool for every job.

Also, after a while, learn assembler (x86) and some hardware theory (how a computer works, what's in a CPU or a GPU etc.).

Finnaly, have fun! Don't feel pressured to know anything you don't need or don't think will make you a better programmer. Don't learn Java and it's assorted libraries because every job wants you to know it. Don't learn LISP because the cool kids are doing it, and don't write programs you won't use.

Saying you want to learn how to hack is incredibly ambiguous and in the strictest sense of the word pretty difficult to achieve. A "hack" is essentially a clever solution to a programming problem or a solution to a problem that's outside the norm and requires extensive domain knowledge. Judging by the comments it seems the term has been diluted to pretty much be a synonym with "programming" or "coding."

If you want to learn how to code, the first question is what do you want to code? Do you want to make websites? Create PC games? Create mathematical algorithms? Use math to create images... the possibilities are endless. Learning Javascript would be useful if you want to create websites, obviously, but outside of that it's not a general enough language with enough (any, really) general applications to be a good place to start. It's essentially an odd combination of Object Orientation and Functional programming which is cool in that it introduces you partially to two separate kinds of languages simultaneously. It can also be confusing for the same reason.

If you want...

A multi-purpose language that will let you rapidly prototype programs and is both extremely readable, easy to understand, and has modules for just about everything: Python

A language that forces you to learn about more fundamentals of programming and doesn't keep you from royally screwing up: C

A language with extremely high-level features, infinite flexibility and power: Lisp

A language that lets you create extremely stable applications built for concurrency: Erlang

A strictly web-only language with a huge supported base in the online hosting business and about 1,000 frameworks: PHP

The latest craze in web development: Ruby with obligatory framework Rails


I could go on and on and on... hopefully one of these descriptions scratches your itch. Keep in mind these are merely suggestions and there are many other languages that would fill any of the descriptions I gave.

EDIT: I am a firm believer that regardless of your end goals to really learn programming one must start at the beginning. Learn about computer architecture, how CPUs and memory work; learn the pain of programming Assembly and managing memory bit by bit even though you'll never do it again. Then move onto C; learn how even the most fundamental of abstractions made programming possible for lesser mortals. Keep moving forward and come to comprehend that features such as garbage collection, while taken for granted, are in reality really freaking awesome and will help you keep your hair longer.

Move up the ladder, rung by rung, until you have the confidence and knowledge to use a language that is highly abstracted and has all the "batteries included," like Python. At this point the language/interpreter/compiler will do most of the work for you but you'll have the experience necessary to understand, more or less, what's going on behind the scenes. From there, if you want to specialize, choose a language created for the domain that interests you; PHP, Erlang, Matlab, etc.

A brief 5/10/20 years later, you're a hacker. Nobody will give you a diploma, though.

"I am a firm believer that regardless of your end goals to really learn programming one must start at the beginning."

Absolutely - I've never met a hacker who didn't know the fundamentals.

I definitely agree with this -- although maybe not that you have to start at the beginning. I started with lots of python/Java, but then dropped down to where I had been staring at enough assembly that moving back up to C was a huge relief.

I think it's nice to get to learn programming and just get going with something like python, where you can take advantage of all the libraries like other people have mentioned, and maybe have more fun right away and avoid being turned off by it all -- before learning all the lower-level stuff -- not that you shouldn't learn it though!!

Right. I guess the real step one is to find out if you even enjoy programming. You're correct that it's much easier to determine this realistically if you start by playing with one of the higher-level languages you will eventually end up using.

Good call.

I suggest _why's lovely Hackety Hack (http://hacketyhack.net)

Reasons why H-ety-H is a good choice: 1. Ruby - Ruby is a beautiful, easy to learn, modern language that's both powerful and easy for beginners. 2. Hand-Holding - It walks you through all of the interactive examples 3. Community - Hackey Hack encourages users to share their programs with others

Besides, if eigth graders can do it, so can you!

Learn JavaScript, Python and PHP. It will take time but eventually it will pay off. Moreover, once you learn/master any language please always pay attention to everything that comes with the package. In linguistics, the ultimate goal is to become proficient enough to start thinking in a language. Being a non-native speaker, I know how hard it's for me to start thinking in French and English (despite knowing a few things). Develop a sense of dissatisfaction. Always find ways to optimize things. Build something that lies between "Hmmm, I guess I cannot build it" and "Well, I guess I can do it given I spend time doing it" (read: Psychology of Flow). Do a product, albeit small. I've observed that you hack with altogether a different mindset when you're developing a product with a belief that it can some day pay you back somehow. And please once you're an expert JavaScript programmer always capitalize the S in JavaScript ;)

What is it that you want to hack? What do you want to make?

For me, I was a kid and I started hacking basic on an Atari 400 with a whopping 2k of ram. I was trying to make a dungeon crawl game. I learned about variables, conditionals and looping. Then I learned about I/O.

Your environment is, of course, vastly different than mine was, but the process is the same.

Frankly, I would advice against learning Javascript. When you try to interact with HTML, it's very inconsistent, and it's difficult for you to get a grasp of the rules and what is supposed to happen where.

I would suggest starting with Java. Java is a modern language, you can get a free compiler and IDE, there are tons of excellent books, and you will learn all the concepts of object oriented programming without having to deal with the 'interesting' parts of the machine.

Set yourself a goal, for example to create a GUI app that organises your MP3s or so. Then work on that as your way of learning Java.

After you know Java, the other imperative languages are mostly about syntax. There are no real new concepts to learn.

Now, I do not use Java personally. I use C++, and I started with VB. It's useful to learn C++ early, but only attempt this if you are a dedicated and patient person.

i hadn't noticed Eric Raymond keeps updating "How to become a Hacker". No mention of the in-vogue ruby, haskell, erlang, scala, scheme, smalltalk, OCAML, etc, but good stuff.


learning html and javascript could be a good place to start since you can make things right away with those.

i think that is very important when you start, to get instant feedback, making stuff is fun :)

for this reason i would recommend python as your first language. it is very highlanguage and have extensive libraries. it has clear sparse syntax and is very easy to write and read.

but that doesnt mean it is a weak language, ont he contrary it is a very powerful language that is used by a lot of big companies and small startups.

so not only is it a good language to start with but it is also something you will have great use for in general as a skilled hacker.

while paul graham and a lot of others rave about LISP(right fully, its a powerful, flexible language with some very special features) i wouldnt start with it. it lacks a standard and you start working on a higher level of abstraction right away, there is not a lot of libraries that you can just install and start having fun with right away as you can with python. i definitely think you should learn it later on but not at the start.

with python you can add the pygame library and start making simple games right away, it is very easy. you can write webapps with webpy/django without much knowledge needed.

then as you evolve you should pick up something like the art of programming(or a similar book that has code in a language you know) and learn about all basic algorhitms and datastructures. if you want to be a serious hacker you need to know the theory.

python however lets you create cool things right away without knowing that much.

while this is a rant for python it is not fanboyish, i just think python is very suited for programmers of all skillevels. there was an article on here some days ago about pythons suitability as a beginners language.

there are other options obviously, ruby for example his fairly similar to python in a lot of aspects but when python tries to keep things simple(there should preferrably be one obvious way to do things) rubys philosophy is there is more than one way to do it.

you could ofc learn java(java and javascript only have the name in common) which is wide-used language that you will run into sooner or later anyway. on this board youll probably find that it often gets critisized for being a language for average programmers though. it is fairly verbose and in some peoples opinion too objectoriented and dont offer any options.

the downside with python and ruby are that they can be pretty slow but that isnt an issue for most applicatiosn and certainly not for the apps youll write a s a beginner.

ruby also has a very popular webframework called rails(ruby on rails).

c/C++ are probably the fastest(executionwise, not developmentspeed) and are also good to learn but are a little more difficult to start with and c is fairly low-level. good to know but wouldnt recommend it to start with. devc++ is a good development environment if you do though.

Good place to learn JavaScript: http://eloquentjavascript.net

Good place to learn Python:


Not for a non-hacker. That book is great for programmers who want to learn python, but someone new to programming would need something more like "Wade Into Python."

Good point. I stand corrected.

"Beginning Python - From Novice To Professional" is good starting point for a newbie. Very clear and smooth.

For a complete newbie, the Zelle book is probably even better. I think it is called "An Introduction to Computer Science Using Python." MIT and a few other schools use it now, but it is a very gentle introduction.

HTDP.org is also really good if you go the Scheme route instead.


Imp is right, that's a terrible book for someone just getting started. I'd recommend "How to Think Like a (Python) Programmer" available on the web here: http://www.greenteapress.com/thinkpython/

O'Reilly's Learning Python is also an excellent learning tool for the language.

I was about to recommend How to Think Like a Computer Scientist (http://openbookproject.net//thinkCSpy/), which is what I've been using and thoroughly enjoy, until I realized that it's the original version of How to Think Like a (Python) Programmer. Glad to know the new version's out. Hope this clears it up for anyone else wondering why TCSpy hadn't been mentioned yet.

Also, Lisp lacks a standard? Huh? Care to elaborate on that?

I mean sure, CL's standard is older than some dinosaurs, and Scheme's standard is currently rather controversial, but both have standards. Especially in the case of CL, there's little to complain about.

And which CL would you recommend the Padawan Hacker use? Oh, that's right there isn't a majority view on this... hence no standard CL to point people towards.

You guys are talking past each other.

One of you is talking about a standard in the true sense (such as an ANSI Standard, which Lisp has in spades) and one of you is talking about a canonical/standardIZED IMPLEMENTATION (which Lisp doesn't technically have.) So, everyone can follow the actual ANSI Standard for CL. And if you're looking for a standardized open-source implementation, you should just choose SBCL ;-) Either way, you should be Lisping instead of arguing.

Like schtog said, I think python is a great choice. You can easily write programs that actually _do_ things without having to get too deep into the ugly details.

Most of all, write programs that are fun. For my third year software engineering class we wrote a 3D implementation of bomberman. It was a blast to write and I still hack on it now and then to add crazy over the top powerups.

Also, it looks like you've found a good place to get your news from. Being aware of cool new projects / languages / ideas is always a good thing.

Adding to what everyone else said, you need a framework for the programming. These are skillsets & you can only pick them up if you practice extensively. You need something to practice at.

Install ubuntu 8.04 & explore the add/remove apps. Install netbeans & write a hello world app. Install quanta & edit some saved web pages. Get mediawiki working & use it for notes. Install a simple mediawiki extension. Edit it, or write your own.

this is a good thread for me to read. i have found it difficult just to realize what i need to know to start working on projects that i have in mind. i have so far been working with html css and some java script to design static web-sites but am really unsure as to where to go to make a simple web-app with a database to store user information that produces a dhtml page.

i was thinking of picking up a mysql book for dummies yesterday but decided to put it off till i finish the one on javascript. though even then im not sure if that's what i need to know or if its the right choice

with so much buzz about rails everywhere i was contemplating picking up something on that but then there is python too, and i havent a clue what exactly they do. then there is the new google app engine. will that help me? i signed up, but am yet to fully delve into exactly what it does for a developer. i guess there is alot of ways to cook an egg. but this forum really helps alot.

See http://news.ycombinator.com/item?id=135494 for a previous discussion on this topic and http://news.ycombinator.com/item?id=135575 for my previous recommendation.

It really depends on the domain you want to work in. Do you want to create a web service? Do you want to create systems? Do you want to create a tech start-up? I assume the answer to the last is yes, but even then it is not necessary for every founder to be a hacker, but it certainly does help.

Ruby and Python seem to be in vogue for web applications. I'm a Ruby guy because I got tired of reading through flame wars and decided to pick one of them randomly.

as a novice, but language bigot it depends a lot on what you want to make.

Low level, kernel, command line C is king. Python for slightly slower but faster coding.

For an GUI program use C++ (qt is a good toolkit).

For Web Pages learn html/css and then add javascript. After that I would say mysql (or postgresql. I like postgresql better) and php. you can trade php for perl/python/ruby if you like.

Web means learning a lot of languages but to me seems the easiest.

angel tech is a good book

Good knowledge of OS is a must..then some C, Perl will some handy...If you know unix shell programming, u can become a master in hacking...

and also, if you are a DB guy like me, then even with ordinary SQL, u can hack a lot of stuff...

[comment that looks archaic once parent is modded up]

Which is to say a hacker also needs a taste for recursion.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact