Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How to become a better programmer?
29 points by Paton on Dec 27, 2009 | hide | past | favorite | 62 comments
My questions is: what abilities are required to effectively build complex web apps and services?

My current knowledge is limited to PHP and MySQL, with no real understanding of OOP.

That said, what would you suggest my next step be? Should I take a stab at Ruby? Javascript? Python? Frameworks?

I would appreciate any suggestions.




Learn another language. Not just because PHP isn't a particularly good one (IMHO), but because learning new languages inevitably teaches you new ways of thinking about programming.

Ruby is good for OOP.


Since nobody mentioned yet... lisp is a great language to learn just to expand your horizons. Don't expect to actually develop websites in it (though clojure might be a good bet for more complex web apps), but it _will_ make you a better programmer.


"Don't expect to actually develop websites in it"

I just tried to develop a website with SBCL and Hunchentoot, and it works relatively well for small examples. There's pretty good MySQL support, and it's all pretty fast. I couldn't figure out how to get a long-running SBCL process to keep even on memory usage. I saw a talk from a guy who works at ITA software [1] where he said they blow away their SBCL instances and restart them on regular intervals, so maybe it's just not possible!

To anyone who is serious about developing a Lisp website, I'd spend a lot of time up-front evaluating different Lisps

[1] I can't find this talk anymore :<


It's about the tool for the job. Most websites just don't have that much server code to justify a bigger hammer. And lisps definitely take a stronger arm to swing.

Right now I'm re-learning PHP, and I'm shocked at both how prone to shortcuts it is, and how practical most of these shortcuts are. It's truly a tool for the job. I have yet to see if the cool toys like first order functions are actually usable, but I wouldn't be surprised at all if they were. All that's missing for most people is a feel of what can be done - and that's exactly what a couple of months of lisp can do.


Hey Paton,

The quickest way to become a better programmer is to take a real world problem and then to solve that with a technology that is as far removed from the ones that you are already familiar with as you can imagine.

Since you're already in to the imperative mode why not try a functional or a logic language for a change to see what the other side of the street looks like ?

The interesting bit in that approach is that when you return to your current languages you'll look at them in a completely new way.


more specifically, take a real problem that your having ("Scratch The Itch"). That'll provide the ample motivation to spend a lot of time you wouldn't normally. Just build something. If you need to create a blog or whatnot, instead of using a pre-packaged platform, writing it in whatever tech you want to learn. Then you'll benefit two-fold, even though it takes longer than installing wordpress.


It's important to differentiate between the technical ability to build web applications and the craft of programming. It seems you are interested in the former, in which case I would recommend learning a popular framework (Ruby on Rails or Django). While you are learning a framework you'll pick up the base language just fine.

If you'd like to learn the more general craft of programming, Peter Norvig has some excellent advice: http://norvig.com/21-days.html. You'll find some language recommendations in the appendix.


Between starting with Ruby on Rails or Django with Python, is one better to start with than the other?


Personally I tried Ruby on Rails and I did not like it. There was too much magic going on and it was confusing to a beginner like myself. I thought about Django but I got the impression that it is just "Python on Rails", so I stayed away from that too. I ended up going with web.py, and I enjoy it. I understand what is happening and what all the pieces of my program do.

It's not for everybody. There are fewer plug-ins for the framework and doing things like session management is a little harder than in Rails. The community is small (though the Google group is active). I had to spend 10 or 20 hours learning sqlAlchemy instead of having an DBORM handed to me out of the box.

But it is far easier to create a complex web app that breaks the Rails/Django paradigm. Reddit uses web.py.

There are some cool open source projects on Github that can get you started:

http://github.com/alexksikes

Please note that my experience may have been better because I already logged a thousand lines or so in Python before diving in (which reminds me of a great free book for learning Python - "Dive into Python").


i disagree a little with the advice above as a recommendation for the original poster. i'm not saying that web.py is better or worse than django or ror, but i think that as a "learning experience" it's probably better to go with one of the larger packages. learning to use a big package will teach you a lot. once you have that understanding, sure, go with web,py and cut your own path.


I was in a similar situation to you earlier this year, in that I was trying to decide between Rails and Django. I ended up going with Django, but I don't think there will be much effective difference to you regardless of which one you choose. Both platforms are good for building web apps and both languages will help you learn new concepts. I went with Django because of the wealth of documentation abailable online and the fact that I have personal resources to tap on Python (although I've used mostly online documentation for that as well).

If you end up going with Django, feel free to email me with questions. I'm sure I can help with some of the "simple" and "stupid" things that can trip up newbs for disproportionate amounts of time.


choose whichever your friends use, or whichever community you find friendliest, or whichever has the documentation you prefer. technically, either is fine.


Despite what a lot of people will tell you ;) Python isn't really a web app language (really, at all, in the slightest). Stick with PHP or learn RoR.

In all seriousness if a web app is your aim, and you have on in mind, then stick with what you know and get good at it - it will suffice :) at the end of the day there is no particular limitation with PHP that RoR or Python will solve - if you get the point of having to worry about scaling etc. then they all have the same issues/solutions :)

EDIT: if your going to disagree that's great! But lets hear some reasoning - there is no logical reason to pick Python to learn from scratch if you already know PHP and wish to start a web app. Seriously speaking it's a waste of time; python is a killer language (and by far my favorite) but PHP and RoR are much saner choices for a web app :)


Python is a mature language with solid implementations, top-class web frameworks, an above average user community, and hundreds of libraries that do pretty much any thing you want.

Ergo: it is fine to use with web apps.


But im not deriding Python per-se (indeed I believe it is a fantastic language and the vast majority of my code is in Python).

However when you consider it in the situation of a Web App (i.e. running under Apache or another web server) it loses most of the advantages. Not to make it worse - but if you know PHP there is no huge benefit for switching to Python :) Which is what the OP is asking "should I learn a new language to make a web app in". I'd say no, not if PHP serves you fine! :)

On the other hand if you want a general purpose language to hand then, yep, Python is ace.

(despite all that when programming for the web I still prefer PHP, because, well that was what it is designed for).


I wrote a PHP app back in the day. It was small and messy, had code strewn all throughout the HTML. Hell, I didn't even know how to run a PHP script without loading an URL in the web browser.

That's not necessarily a fault of the language, but the books available for PHP taught me how to code that way. And the community was in a perpetual state of newbishness. At least in 2005, the IRC channels were dominated by people (like me) who one day though "I have no programming experience but I would like to make a web app. I know! I'll use PHP!". PHP can be programmed well, but it was hard to find someone in the community to point you in the right direction.

Facebook proves that large, successful web apps can be built with PHP. But PHP was probably not Zuckerberg's first or only programming experience.

As for your contention that "Python isn't really a web app language (really, at all, in the slightest)", that's just straight stupid, and doesn't deserve a further response.


> As for your contention that Python is not good for web apps, that's just straight retarded and doesn't deserve a further response.

Im not sure that contends a good reverse argument ;) but anyway... (I do stand by the statement somewhat though; it was never designed to be a web language but as a general purpose successor for ABC, any web implementations are incidental and I still contend that it cant beat purpose built "for the web" languages :))

It's a difficult call all round. I used to code PHP that way - but one good book (I forget which) and some experience with Frameworks cured me of it. It's probably similar for other languages; the person I know best who swears by Django does pretty much the same thing (horrible code)

Not good for web apps is perhaps not the point I was making (it got confused in trying to be concise). More Im saying that if the OP is sat there knowing some PHP and wondering where to go next if his aim is to make a web app I would say: go make a web app in PHP. There is no killer advantage that makes Python better for the web than PHP (for me PHP is better for the web - but that is a somewhat subjective choice).

if his prime aim is to learn a new language - and he also wants to make a web app RoR is a good choice. Again because it is tailored for the web.

If he wants to learn a language and wants something general purpose which also will do him for web work Python is a great choice.

To make things even less clear; if you want to do something specialist Python is probably your "best foot forward".

The problem with Web apps is that the web server is by far the greatest leveller. It removes any clear advantage Python has over PHP :)

I am mid/high experienced in Ruby, Python and PHP and I personally would say PHP was the best choice for a basic web app with Python bringing up a very close rear :)


How is Rails "tailored for the web" in a way that Django is not? Marketing?


A lot of good programmers aren't fans of OOP.

Of course, before you can decide whether you're a fan or not, you should understand it. So I'm all for that:)


Agree. OOP is great for packaging libraries, but when it comes to software architecture it's way too easy to shoot yourself in the foot.

One common mistake, which I don't think is emphasized enough, is that modeling the problem and modeling the software are not the same thing. The problem can have a "User" actor, but this doesn't mean at all that the software should also have a User class. And yet you see User classes far too often.


Since nobody suggested it, go to college/university and learn about data structures, lists and processor architecture. It will help you become a much more insightful programmer.


This advice is so bad I think it just gave me cancer.

The OP is asking "what abilities are required to effectively build complex web apps and services?"

99.9999999999% of data structures in web programming are arrays and hashes. Look those up on wikipedia and read it, then you are done, now get to work.

Processor architecture??? Is that really to be taken seriously? Not only was it previously not relevant to the OP's question, but its becoming more irrelevant because virtual machines and the "cloud" paradigm.

OOP details are great if you are going to write your own libraries or plugins, but its not necessary for cranking out websites. Most of the time the OOP you are going to be dealing with you can fake.

Javascript is a must have, but you don't have to get so fancy with it. Just enough to drive a popular framework. I'd recommend jQuery, it seems to be the emerging winner.

Learn the CSS, broken browsers, and the box model, which will waste so much of your time.

If you just want to work for yourself try a few web frameworks and go with what works for you. Using anything from PHP to rails to Django, you could take over the world, they are all good.

Look into scalability. Its fun stuff to learn about, even if you never lucky enough to need it, here's a good place to start http://highscalability.com/

As part of scalability look into AWS like EC2, EBS and S3, they are game changers. You don't have to use them, but if you need them, they are there to save your ass.

Learn about "viral" marketing and how sites go viral.

Learn about database backup and recovery, and as part of scalability learn how you can scale databases.

Learn about unit testing, QA or even something like Selenium, figure out which works for you best and in which ways.

Learn to figure out what users want and what itch you need to scratch.

Figure out how to make interfaces that don't suck. And when you do, let me know how.


While I agree about your points I still maintain that a couple of courses in data structures and algorithms is a very good investment of your time.

In data structures you learn how to properly use a data-type. You learn how to implement a hash and a list. That is knowledge that is very valuable when programing high level stuff later on.

In algorithms you learn how to construct loops and programs that run faster than they would otherwise. For instance, think about how much faster it is to search for something in a sorted list than in a unsorted list (its log vs exp if its a nested search).

Processor architecture because you want to know where those bits go, if you dont, how are you ever to truly understand pointers, variables and data structures?

Your life will be soo much easier with these fundamentals in Computer Science in regards of scalability, performance and even user design. It's not for everyone and you can certainly do without it. But what you're advocating is basically "luck". Not everyone will write plentyoffish or twitter.


The guy wants to build complicated websites, not be a hacker snob, so I'm giving him the honest truth and getting modded down for it.

"While I agree about your points I still maintain that a couple of courses in data structures and algorithms is a very good investment of your time."

Maybe a good investment of your time, but not if you are going to just be building websites, that would not be a good investment, the returns on that investment would be small.

"In algorithms you learn how to construct loops and programs that run faster than they would otherwise. For instance, think about how much faster it is to search for something in a sorted list than in a unsorted list (its log vs exp if its a nested search)."

Do you even do any practical web programming? Unless you are hitting a amazing load on your server this would never come up. Also, if you are digging into these details you better have a good reason because there a good chance of creating bugs or overloading your web box. However if you keep it basic, and just scale horizontally, which you don't seem to understand web hosts can do, its a much better use of resources.

"Processor architecture because you want to know where those bits go, if you dont, how are you ever to truly understand pointers, variables and data structures?"

I've been in web development and scripting for 15 years, can you show me where these "bits" are, I must have misplaced them.


I'm 100% self-employed and build websites where I earn money from advertising/affiliate/sales-revenue. Been doing it fulltime for 7 years now, before that I was a student for a couple of years (where I learned that me and academics wasnt a match made in heaven..).

I used to have a site that carried 5m uniques/month, but I've also run sites that had has worse performance problems with much less users. I know of several instances where I got stuck and had help from academic books (to refresh my memory) or friends that paid more attention in class than I did :-)

My point, and as others point out, you just dont learn these things yourself unless you are forced todo it. Learning to solve a problem and learning to learn are two very different things and the later makes your view of a issue much more complete. Many subjects is completely useless stuff that is only in the courses to make them hard, but when I look back I tend to see that many courses were very valuable.


Sounds like you dropped out of academics, were successful in website development, are arguing for a hands on learning approach where it "makes your view of an issue much more complete", and even successfully used compsci books, you write "many subjects is completely useless stuff" and yet in your first post you give advice of doing the opposite of what you found success doing.


I'm saying that academics helped me understand some subjects that have been very valuable for me in my "career" as a website developer.

Perhaps I would have done fine without them, but I'm sure my projects are better as a result of me spending a couple of years learning stuff.

If you want to become a "better" programmer in the context of writing more efficient code, more bugfree code and become more efficient (learning to use the concepts that comes with the language instead of reinventing the wheel). Then yes, school helps.

You can learn it outside school aswell but I bet it will take more time in the long run. I think we'll have to accept that we disagree on this topic.


And indeed, it might just be that, if you happen write a twitter by the seat of your pants, it will choke on the volume and you will be fired and replaced by someone who knows how data structures lead to scalability. You never know...

http://www.techcrunch.com/2008/04/23/amateur-hour-over-at-tw...


You have a fair point... however I never regretted that my early programming was mostly algorithms and data structures. I think that's a ceiling most self-taught programmers find hard to pass. Everything else can be learned with a google... but if you don't have an algorithmic mind relatively simple problem are show stoppers. Stuff like implementing a cache or understanding why sql subqueries suck so much cpu time are pretty straightforward - but I don't want to think how I would approach them without those first years of sorting and graphs.


Downvoted for tone, not for the quality or validity of your viewpoint.


Great list. Four years at school for theory is an increasingly inefficient investment in time and money. A high school senior starting today and ending in four years would learn a lot more about cutting-edge programming by reading HN and following up with lots of experimentation than by going to school.


I agree with your conclusion. but I had to downvote for the poor presentation of the answer.


Style over substance? Another reason down-voting is a disgrace for this website and should have stayed removed.


Nothing to do with style: the other sort of presentation :)

i.e. I believe you started the response with a rather silly statement then structured the rest in a sort of out-of-breath "OMG SRSLY" way. Unreasoned response is bad - but badly structured reason is worse.

I apologise for the rudeness but I feel that sort of posting needs to be discouraged.

I'd have let it pass but for the cancer comment: that's just idiotic.

(sorry, I hope it comes in as constructive criticism - because the point was good, I just doubt anyone really read it)


This is probably one of the reasons they experimented with removing the down-voting on comments. Some people, rather than vote on relevance or insight of the comments feel they should be enforcing their own arbitrary standards.


I think the issue is in looking on down votes as a bad thing :) who cares? You did make a silly comment and people are pointing that out (relevance is fairly subjective; I suspect a number of people read the cancer comment and then stopped reading it as "not relevant")

Sometimes people down vote poorly or for the wrong reasons, I agree. I think this case was justified - but for the cancer comment I myself wouldn't have - indeed I'd probably have upvoted because I do agree. That is how badly it came across (and as you might read elsewhere this is about my 2nd vote today :))


It was a quote from Futurama.

But I have no regrets about the rest. I don't want to see this guy going in the wrong direction, and the suggestion of learning about chip design was just way beyond bad.

But why bother. Hacker news is becoming an echo chamber. I should stick to LISP being my answer to every question.


I think that allowing mean-spirited posts to be down voted is useful. Sometimes it reminds me I need to be a bit more constructive.


"Processor architecture??? Is that really to be taken seriously?"

Sure. You can get big speed-ups by exploiting the storage hierarchy, and by writing less-branchy code that does not bamboozle the branch predictor.

These can be studied from the top-level functional perspective. The low-level details can be ignored.


"improve my PHP abilities to OOP"

Reading that made me laugh. PHP's OOP is extremely flawed (among various other things, like their inability to universalize the $needle and $haystack argument order: http://bugs.php.net/bug.php?id=37088), so using PHP to "improve your technical abilities" wouldn't really get you anywhere except having a better understanding of PHP.

I think that what you're trying to accomplish really needs to be defined in terms that aren't so broad. Especially these days, "technical skills" is such a vague term that it can really be applied to anything.

You don't need to have a complete understanding of some silly framework or whatever in order to still be considered an excellent developer in many ways. For example, you could write a stunningly elegant and clever mathematical algorithm in C without using a function more complex than sqrt(). (Or maybe you could write a more efficient sqrt!)

I think that learning something like that might improve your understanding of machines and could, indirectly, improve your understanding of "web apps and services"—that is, understanding HTTP, statelessness, and so forth.

tl;dr Figure out exactly what it is you want.


I dont want to start a flamewar regarding PHP/OO but I must say that I disagree. There are some things that isnt very well implemented in PHP but in the OO aspect of the language it has most of the needed constructs and if you stay away from the obvious pitfalls its "good enough".

If you value time / fun over code/data integrity at all time PHP is a excellent choice for producing web services. If you are writing a control system for a airplane I would not recommend it.


What are the extreme OOP flaws still present in PHP 5.3? And how does the needle/haystack issue relate to PHP OOP?



You need a sound understanding of CSS, HTML and javascript. Although you may have been messing about with them a lot, try and get an in depth understanding of CSS selectors, what semantic HTML mark up is, and how to write quality code in javascript -- unobtrusive javascript is something to look up.

Javascript is really worth learning in depth. It has some quirks that will gently introduce to some useful topics such as JSON, closures, elements of functional programming, prototype based inheritance, and so on. Further, it will help you understand how to get more out of other dynamic languages too; python, ruby, etc. Douglas Crockford has some great videos on Javascript that are worth looking up.

You're not restricted to client-side programming with Javascript either. For instance, look up nodejs - a nascent server-side javascript framework that looks quite promising. It will really make you think if you've just been a PHP guy up to now!

Try and get a handle on PHP's more advanced aspects - many of which have only really arrived in recent versions. Classes, name spaces, closures and so on. Although I'd really suggest another dynamic language altogether; python is a good choice, but ruby is splendid too.

Once you're confident with that stuff you may want to go in a slightly different direction. Try Java, C, Clojure or Erlang. Try reading some more general computer science books.

I hope that helps. Good luck and all the best.


Before making any suggestions I would ask what is the definition of a better programmer? Since this can be a bit subjective I will suggest that you strive to become an 'expert programmer'. It is difficult to even define what an 'expert' is, but normally one would recognize an expert as someone that effortlessly accomplishes a task. Some characteristics of experts from psychological studies are:

1. Experts such as chess grandmasters rely on a vast store of knowledge of game positions. They tend to organize this information in chunks, which can easily be retrieved from long-term memory. The same is true for other experts from sports to mathematics.

2. They also typically engage in years of effortful study, continually tackling challenges that lie just beyond their competence

In my opinion you need to accumulate both, ie, expand your store of knowledge, as well as continually striving to handle situations where the task in hand is beyond your ability.

At this point in your experience my personal recommendation is to actually focus on number 2, for example refactor some PHP code into OOP, to give you another angle of programming as well as tackle JavaScript for the same reason.

The 10-year rule states that it takes approximately a decade of heavy labor to master any field. As one that has gone through a couple of 10 years:) the best advise I can give is 'learn to program' rather than learn 'to-days-popular-framework-or-language'. Think about it as similar to writing a book, knowing English will not turn you into an author. Practice will as well as motivation.


PHP is mostly an imperative language with a C-like syntax. In imperative languages with a C-like syntax most OOP is just syntatic sugar on a pointer called "this" with a bit of RTTI checks for casting. If your code is unmaintainable with out OOP, OOP isn't going to help.

A far more effective skill to have is to figure out how to build a complicated application simply rather than switching to language that makes it easier to increase line count and have semi-working code.

I know PHP isn't cool anymore but at the same time, Facebook was built with it. One person can't build Facebook (in it's current incantation) so it's pretty useless to try and find the magic framework that will let you. Figure out how to prototype quickly: once your userbase exceeds the capabilities of whatever tech you have picked you'll usually have enough users to find capital/revenue or have it knocking your door down. At that point it's easy to find the skills to port to whatever the language / paradigm de jour is.

Figure out how to make the SMTPs of the world not the X.400s once your not building X.400 you can implement SMTP in just about any language.


I was in your position not long ago. I'd recommend using Ruby on Rails, which will teach you a lot about OOP and the MVC framework. There are some similar frameworks for PHP (like CakePHP), but Rails' established community and abundant documentation make it a better starting place.

Javascript (http://www.w3schools.com/js) is an extremely important part of the web today, and jQuery (http://www.jquery.com) makes it more manageable than ever before. It's not difficult to learn -- you can make a lot of headway in a single day.

If at all possible, work alongside other people. You'll learn a lot from their habits and their code. And work on actual projects. Learning for the sake of learning is much more difficult than learning while you're building something.


I wouldn't concentrate so much on certain programming languages, instead I would concentrate on designing programms. I don't know your background. I guess you are learning on your own, so I would recommend http://www.htdp.org or http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Compute.... Some people will recommend Structure and Interpretation of Computer Programs. This book maybe the best on programming, but I don't think it suits a selfteaching individual.


Good advice and helpful links. I would add picking up a few good books on Design Patterns.


I can do everything I need to with PHP and MySQL, however I'm currently working on JSP, and planning to learn Ruby and Python.

If you want to learn object oriented thinking I would recommend Java or C++. Fortunately I was already proficient at C++ before I started web programming so I already had a fairly firm grasp of object oriented thinking.

As for learning programming languages, to my way of thinking the more languages you know the better, both from a job standpoint and from a flexibility standpoint.


Learning a C language (i.e. C/C++/Java) is great advice for increasing your programming knowledge. You'll learn how software works at almost it's lowest level. I wouldn't advise learning some architectures assembly language unless you really get C and want to really dig into low level programming. It's a great skill, but if you don't want your career to go that way there are better places to invest in your education.

OOP (as mentioned in the question) is a great thing to learn as well. Depending on if you have any experience with OOP I always point people to the book "Design Patterns" by Gamma et al. It changed the way I build software in so many positive ways I doubt I could even list them all.


Build stuff. Break it. Fix it. Build more stuff.


I'd say focus on the basics - learn more about algorithms, operating system internals, data structures, concurrency, human-computer interaction, general OO/Functional/Procedural programming principles, etc. Languages are dime a dozen - once you're strong in fundamentals, picking up a new technology/language/framework becomes a lot more easier.


Buy a subscription to Safari Online and spend 15 minutes each day reading about programming.

It doesn't really matter what you read. Just pick a book that currently sounds interesting and read it. Since you are interested in OO PHP, there is a book called something like "Developing Object-Oriented Applications in PHP 5"


Sounds similar to where I was a few years ago. Here are my tips:

http://breckyunits.com/twelve_tips_to_master_programming_fas...

Feel free to email me if you want to talk further. Good luck!


Lots of people like Ruby+Rails or Python+Django, so these are obvious choices. Also, if you choose a system that lots of people use, it's easier to get support from the net when things go wrong (as they are bound to from time to time).


Learn a new programming paradigm. For example, if you are a OOP literate, learn FP.


91 Ways to Become the Coolest Developer in the World http://www.techquark.com/2008/11/91-ways-to-become-coolest-d...


That is quite an extensive list and probably includes just about everything you would ever need to know. Personally I like to keep it short and sweet: The coolest developer in the world is always learning and is ready to try new things and new approaches. That summarizes probably 90% of those 91 points.


Yeah, that, and the title is totally misleading. There can't be thousands of coolest developers in the world, dammit!


to build complex web applications you need to learn javascript, I would also take move along to ruby / python / erlang as well as/instead of php.

then I would start bashing out applications as quick as you can, stuff with a smaller scope and a clear end so you can keep them public for quite a while and learn how to reduce/remove maintenance cost.


I can't describe how OOP changed my life. You have to learn it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: