

How should I learn programming? - ahmedjim

Hello Hackers.
I hope everyone is doing great. I have been a reader of HN for so long due to my genuine interest in internet and programming. I am a Finance graduate and an ACCA. Frankly I don't enjoy my profession anymore. I have seen myself interested in learning how to program and build web apps. I would like to know about two things. First that do we have any professionals out there who quit their former professions (finance, marketing, etc) and pursued programming as their careers? What difficulties did you face and is it worth it or not? Secondly I want to know the different resources where I can learn how to program? I would be very happy to hear from you. Thanks<p>Regards
Ahmed
======
drostie
I actually still think that one of the best ways is to watch some of the
Abelson-Sussman lectures. Unfortunately, they teach Scheme, but fortunately...
they teach Scheme. (They also unfortunately have prehistoric audio quality.)

    
    
         http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/
    

The bad thing about Scheme is that while it prepares you for function-oriented
languages like Clojure and JavaScript (and hence Node.js) and to some extent
Python, Scheme is not used by itself much on the web.

The great thing about Scheme is that, unlike Python -- where I suddenly find
myself explaining that this is generator syntax, that is function syntax, and
so on -- lisps (like Scheme) have some extremely simple syntax principles.
This makes them very easy to teach to someone who hasn't seen programming
before, and helps people through understanding what exactly machines do.

You may also want to start with JavaScript. (Do not confuse JS with Java.) JS
has some of the best returns for its investment, because if you're building
web apps, you will eventually have to face it anyway. (JS is the programming
language of the Web.) You should run Firefox with Firebug (and eventually
GreaseMonkey) if you want to make the most day-to-day use of learning JS.

JS allows you to more readily have a concrete goal. Concrete goals are great
for the dive-right-in school of programming. Let me offer this as something
attainable: Sudoku. Go and find a web site which lets you play sudoku, and if
you've never played, familiarize yourself with the rules. There are a bunch of
them, like "if all the other numbers appear in this row, column, and box
except one, then this number should be that one number." I will give you a
little bit of a head start on this: on the site puzzle-sudoku.net, here is how
to get the board elements in a JavaScript object which you can then enumerate
and query:

    
    
        // useful to know the JS operators:
        //   https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence
        // and the floor() function:
        //   https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/floor
        function sudoku_groups(inputs) {
            var out, i, row, col, box, square;
            out = {rows: [], cols: [], boxes: [], all: []};
            for (i = 0; i < 9; i += 1) {
                out.rows[i] = [];
                out.cols[i] = [];
                out.boxes[i] = [];
            }
            for (i = 0; i < inputs.length; i += 1) {
                row = Math.floor(i / 9);
                col = i % 9; 
                box = 3 * Math.floor(row / 3) + Math.floor(col / 3);
                square = {row: row, col: col, box: box, input: inputs[i]};
                out.rows[row].push(square);
                out.cols[col].push(square);
                out.boxes[box].push(square);
                out.all.push(square);
            }
            return out;
        }
        var board = sudoku_groups(
            // this selection line would be different for other web sites:
            document.getElementsByClassName("brd")[0].getElementsByTagName("input")
        );
    
        board.boxes[3]; // write this to inspect the 4th box in Firebug.
    

I'm not saying you have to know what all of that does right now! Especially if
you've never seen JavaScript before. But I am making your first programming
task a little easier by solving the problem of finding the elements and
turning them into a useful data structure for you to play with. Once you know
the language a bit better, you might like to peek inside this to see how it
works -- but you might also just use Firebug's "inspector" tools to see what
the data structures look like without my help.

When you want to start _solving_ the Sudoku, you might start looking through
board.all to see which elements do not yet have a value. Then you might want
to start writing and using rules like this:

    
    
        function fill_in_if_only_one_option_remains(square) {
            var options;
            options = [
                false, // 0 is not an option
                true, true, true, true, true, true, true, true, true
            ];
            // here is how you cross off a square from the options
            function cross_off(other_square) {
                options[other_square.input.value] = false;
            }
            if (square.input.value === "") {
                // to be perhaps written by you: cross off all of the options which
                // appear in board.boxes[square.box], board.rows[square.row], and
                // board.cols[square.col]. Then, if there is exactly one option 
                // left, fill it in, like "square.input.value = 9;"
            }
        }
        // then you can apply it to the whole Sudoku board like this:
        board.all.forEach(fill_in_if_only_one_option_remains);
        // it might be useful to look up Array.forEach() :
        //   https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
    

And then you might realize that this rule is not quite strong enough to solve
Sudoku puzzles, and start thinking about how to describe even stronger Sudoku-
solving strategies to a your computer. You might start a GreaseMonkey script
to try to apply the automatic procedures every 1000 ms (every second) that
you're on this page, so that as you solve the Sudoku the computer "helps you
out" in realtime. You might start implementing 'speculative' algorithms, where
you type 'a' instead of 1, 'b' instead of 2, and so on, to see if this leads
to a contradiction somewhere down the line -- and your computer can notice
that you're thinking speculatively and start to type 'a', 'b', and 'c'
alongside you. (You might want to use an uppercase letter to denote the letter
which started the speculative train of thought off, though, because it will
quickly get lost!)

So that's the sort of thing which programming is, and that's how I'd look to
learn it. Dive right in like a six-year-old: play for ten minutes, fall, hurt
yourself, cry for five; then get up and breathe deep and play with it some
more, repeat as necessary.

~~~
lowlyscientist
Abelson-Sussman's SICP is a steep learning curve for an absolute beginner: I'd
recommend reading How To Design Programs first (and SICP right after), which
is similar but a bit more gentle. It also uses Scheme, but focuses most at how
to think about programming problems, and general "design recipes" for solving
them.

~~~
drostie
That may be very good advice; I haven't seen How To Design Programs.

While the SICP lectures do in fact have a ridiculously huge scope, I was also
surprised when rewatching them -- mostly with how basic they were when they
started. "Here's adding, here's subtracting, here's what a lambda is." One
thing that's nice about SICP is that assignment is very consciously "added on
later."

I wouldn't have expected them to be beginner material either, but then I met a
nice gal named emma on Freenode's ##club-ubuntu IRC channel, who was using
SICP to learn programming. I remember remarking that this must be very hard
and she didn't understand why it should be.

~~~
lowlyscientist
That's true, I do recall skimming through the very early parts of SICP.

I'm jealous of Emma, I bet that would be a really strong base for building
programming skills.

------
ColinWright
Learn Python the Hard Way- discussed here:

<http://news.ycombinator.com/item?id=2701504>

While doing that, start pre-reading for your specific interests.

------
lowlyscientist
I am very interested to hear about difficulties one might face doing this, as
I'm in a similar situation. Currently I am a scientist in R&D for a blue chip
company, but have been programming for fun and as a small part of the job for
a couple of years. I'm interested in moving to a full-time programming job,
but am worried about the typical minimum requirements; after all, I have no CS
degree and haven't been coding since a young age.

~~~
eric_bullington
I'm in a similar situation -- transitioning from another profession, with a
background in public health (epidemiology and biostatistics) and
interpretation/translation (as a certified translator). I've been programming
for fun and as a small part of my job for the last few years, but now have
reached the point where I really need to find a full-time job as a developer
since I'm find myself constantly drawn to writing code for side projects
instead of focusing on my current job's requirements. I've been bitten by the
programming bug, so to speak. I'm starting to pick up freelance jobs, and am
working on open source projects in the hopes of gaining experience. I'm hoping
to enter the profession through the machine learning/NLP route -- with my
graduate studies in biostatistics, and fluency in several human languages, it
seems like a natural fit.

I'd love to hear from others who have transitioned from another profession to
programming in recent years. Advice from experienced programmers on how to
break into the profession full-time would also be most welcome.

~~~
lowlyscientist
Was it easy to pick up the freelance jobs? One of my colleagues recommended
just applying for contract work with a low rate - sort of just for a foot in
the door - but I have yet to try this. How did you go about it?

------
ExpiredLink
> do we have any professionals out there who quit their former professions
> (finance, marketing, etc) and pursued programming as their careers?

Yep

> What difficulties did you face and is it worth it or not?

Probably no: <http://www.halfsigma.com/2007/03/why_a_career_in.html>

------
belmer
First Off, you need to tell us what language you are interested in. Like PHP,
ASP.Net, python or whatever. In that case readers of your post can recommend a
better suggestion and resources to where you can learn to program.

------
zync
Use Code Academy - Free to Use

<http://www.codecademy.com>

Learn the basics of JavaScript on this site and then move on to other
languages.

------
SanjeevSharma
I would recommend codeacademy.com. My 10 year old son is using the tutorials
there to learn programming.

------
zack12
Are you from Pak?

