Hacker News new | ask | show | jobs
by lotides 4427 days ago
I've been trying to learn to code (I'm a designer) for a while now. I've read books, played around with making things and I'm now taking the JavaScript course on Codecademy. It taught me:

   var functionName = function() {
   // whatever
   }
I had no idea there were other ways to write a function. I still don't understand what the benefits or drawbacks are of each method. Maybe I haven't made it that far yet. But I literally have no idea what most of you are talking about in this thread. I feel like I visited a post written in chinese.

The scope of learning to code seems overwhelming. Finding small bugs in syntax and design is stressful. What I'm supposed to learn (language, style, syntax, frameworks) seems to change faster than I can learn it. I wish I would have started all of this earlier ... like when I was 10.

5 comments

I am in a similar position to you, in that I only very recently picked up any javascript.

What's worked for me: use whatever meager skills you have to work on a real project that you find interesting. Not something that can hurt people if it goes wrong, but something you care about. Concentrate on the user experience. Eventually, you'll learn better ways to do things as you need to.

I made http://asoftmurmur.com

If you want a laugh, look at the source (the javascript at the bottom of the main index). It's probably the worst JS I've ever seen, but I concentrated on the user experience and I'm pretty happy with how that worked out. I'm now building an Android version and the source is a thousand times more elegant and concise. In the grand scheme of things, I'm sure it's still awful, but that's fine, so long as the user experience is good. Next time the code will be better.

Build something real. When you run into a problem you can't solve by yourself, ask for help. This will naturally create a narrow but ever-expanding scope in the face of a limitless quantity of knowledge. I don't know anything about programming, but that's what's worked for me so far.

I'm using asoftmurmur now. I think it is the best noise generator out there. Who cares what the code looks like?
My advice: don't sweat it. Best thing to do would be to code and build things, and then you'll come back to this article in a year and be like, oh, that's obvious. Abstruse technical details don't matter that much, especially when you're starting out.
I'm currently finishing up writing a programming book for absolute beginners and I couldn't agree more with this advice. Don't sweat it! You don't need to learn all of the details of the latest framework. Get comfortable with some small piece of the landscape, stake your claim, and build something you like with it.
Javascript is not the easiest first language to pick up, though obviously it is the one you will get the most bang for your buck from as a designer.

I think what might help you is thinking of programming languages as foreign languages. They have their own vocabulary and grammar. So right away, let that take the pressure off in terms of how quickly you are picking it up. Some people can pick up foreign languages easily. Others can pick up programming languages just as fast. But even if you don't have a natural knack for it, with some persistence practice and time, you will get there.

Also, remember that the person you are talking to in your new language (the computer) is the biggest grammar nazi you have ever met. And they will refuse to acknowledge you unless you use the proper form exactly right. So you can't get away with just memorizing "Could you please tell me where is the bathroom?" because one day you'll accidentally say "Could please tell me bathroom", and your previously helpful foreign friend will completely blow you off. What that means is I think it will be easier if you try to really understand every part of the line you are writing: What is a function. What is "var". WHY do you use var sometimes, and sometimes not, and what is the difference. What is the crazy jQuery syntax all about, with $'s, and parenthesis, and callbacks, etc.

It will take you more time up front, but will lead to fewer frustration in the long run.

Good luck!

Don't worry about it. Programming is easier for an adult to pick up than, say, music or math.

Definitely don't waste your time chasing the latest and greatest. Most frameworks are fads — that's why they go in and out of fashion so quickly. Once you solidly understand the basics, and once you have gained some experience (you probably need a year or so), you'll know enough to evaluate libraries and frameworks efficiently.

Build something using the tools you already know. Don't use too many libraries. Don't copy in code from StackOverflow which you don't understand. Don't listen to know-it-alls who respond to your questions with "why would you ever want to do that?" Just code up a solution to your current problem, and move on. You'll be a good hacker before you know it.

PS: I do suggest you learn to program outside the web domain. The web is unusually beginner-unfriendly because (1) you have to keep dealing with the browser-server stateless request-response fundamental design, and (2) the browser and the DOM are pretty confusing concepts.

There aren't, the name of a function is optional (if you assign it to a variable.) So you can write:

    function a() {}
    // or
    var a = function() {}
    // or
    var a = function a() {}
    // or
    obj.prototype.a = function() {}
    // or
    obj.prototype.a = function a() {}
There is little difference in the function declaration. The difference is if you named it or not.

The reason you have to be careful with the var a = function() {} forms is because variables are hoisted. So while the function will exist, your variable will not point to that function until the assignment happens.