How should I learn programming?
Regards Ahmed
Regards Ahmed
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.
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.
I'm jealous of Emma, I bet that would be a really strong base for building programming skills.
http://news.ycombinator.com/item?id=2701504
While doing that, start pre-reading for your specific interests.
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.
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
Learn the basics of JavaScript on this site and then move on to other languages.