Intro to Coding/Programming

[QUOTE= Prof. Dijkstra]
I think of the company advertising “Thought Processors” or the college pretending that learning BASIC suffices or at least helps, whereas the teaching of BASIC should be rated as a criminal offence: it mutilates the mind beyond recovery.
[/QUOTE]

Meh. Dijkstra was a very smart man, a genius even, but this statement is elitist bullshit. BASIC may be impractical in today’s world but that doesn’t mean it had no value.

He’s pretty modest here, but I think the absolute best way to get into programming (which is something a tad larger in scope than mere coding) would be to take an intro course at your local community college.

You’ll (hopefully) learn the appropriate concepts as well as a lot of the nitty-gritty about actual coding.

The reason I say that programming is separate from coding is because at least in my book, coding is more of a mechanical process of literally stringing together the various keywords and what-not to make a working function or whatever. Programming is larger in scope- it’s about solving the problem using coding skills. An analogy might be that coding is like sawing accurately and hammering nails well, while programming is more like carpentry- knowing when and why to make a certain cut, or to join your boards a certain way, etc…

Coding is something that you halfway end up self-learning from a book anyway (nobody’s going to spend classroom time teaching you the ins and outs of a particular language’s implementation of arrays, for example), but programming is generally something that is taught, and where there are definite best practices that you should learn.

At the time of Dijkstra’s diatribe idiomatic BASIC programming was a mass of unstructured GOTO commands, a style of programming abhorred by all sensible people with any exposure to ALGOL 60 and its progeny.

I’ve heard good things about codeacademy.

I’d recommend Python as your first language. Holy Christ do not start learning to program in C (and I say this as someone who writes C code for a living and thinks its a valuable language to know). You can learn it later, if it turns out you like this stuff.

Reasons Python is a good first language (OP, you don’t have to understand what these mean, they’re really here to make my case to the other coders):

  1. It has a C-like syntax, so the things you’ll learn will easily be transferred to any language in the C family (C/C++/Java/Objective C, etc.)

  2. You can type code directly into the interpreter rather than screwing around with a compiler.

  3. It can be object-oriented, but it doesn’t force you into it like Java does.

  4. It enforces good style habits.

  5. It’s garbage collected. Memory management is not a beginner-level skill.

There are many more, but Python is a great first language.

It’s worth remembering that the “B” in BASIC stands for “Beginner’s”. The language is designed, right from the outset, as a teaching language. As such, it can be good for the new student while simultaneously being terrible for the experienced professional, and a lot (though not all, of course) of the diatribes are really just against it being used in inappropriate contexts.

As for “a mass of unstructured GOTOs”, isn’t that how machine code works, too? I don’t think that any machine code has anything like a FOR loop directly implemented, so the hardcore programmier-than-thou machine coders don’t really have a leg to stand on on that score.

Yeah my first experience with this was with intro to C in college. It was…disasterous to say the least.

Right. DCnDC may not be aware that this was written 40 years ago. The problem with BASIC back then is that it led to an undisciplined programming style. My friends who were CS professors dreaded the incoming freshmen from the '80s who programmed in BASIC on their PCs and so had to be broken of the bad habits they had acquired.

I was a TA for a PDP-11 assembler class in the '70s. Before we let students anywhere near assembly language, we assigned them a Pascal program to do, and then ripped apart their code, especially when they did anything unstructured. That scared them into paying attention to structured programming techniques while writing assembler code. (We also threw away the grade on the first assignment.)
I suppose no one even uses the term spaghetti code any more. But that kind of code sure existed. I even wrote some myself before I became enlightened.

BASIC was invented at Dartmouth long before structured programming existed. It was meant to make lots of students have access to programming on their time sharing system, which was advanced for the day. But as a teaching tool, it is kind of like encouraging students to count on their fingers as an introduction to calculus.

While machine language might not have FOR loops inherent, you can code in it so that you only use FOR loops or WHILE loops. Autoincrement and autodecrement in PDP-11 assembly language actually supported simple FOR loops quite nicely. I would have gone quite mad grading and helping students with their assembly language assignments if we had not forced them into writing structured assembly code.

May I suggest that we move the discussion of the history of various computer languages to another thread? What Dijkstra thought of BASIC and Algol, and how PDP-11 assembly language should be written are completely irrelevant to the question of where the OP should start learning to code, and are just confusing the issue.

I was taught by the professors who invented BASIC and it can be used as an effective first teaching tool for programming. But we quickly moved on to C and assembler for the more complex concepts, with some Pascal and Fortran thrown in for good measure IIRC.

It’s all GOTOs under the covers. Machining coding hasn’t been done since forever except by crazy people, but assembly language can be structured just as well as any high level language, and with the use of a macro-assembler should always be. C is really just a high level assembler adding better notation for the structures that should have been done with macros. Spaghetti code can be produced in any language, don’t blame the language, blame the programmer.

Which was, as CS professors, their job. But BASIC is what got many of those students to walk through that door in the first place.

Look, I’m aware of the history, the fundamental differences between programming languages, and the differing ideologies within the coding community. The purpose of BASIC was to teach not necessarily even programming, but merely the basic use of computers to people who weren’t scientists or mathematicians.

I am not suggesting anyone code their next project in BASIC. I just get annoyed at the casual dismissal of a tool that introduced the very idea of programming to literally an entire generation of people; it holds an important place in the history of computing, whether you like it or not.

Similarly, you can code in BASIC in such a way that you only use its GOTOs to implement those same loops. And it does even have a FOR construct, albeit not as flexible as the one in, say, C. The problem here is not the tool; it’s in how the tool is used.

Obviously higher-level languages enhance productivity, but …
[QUOTE=carniverousplant]
One of my professors in graduate school said that machine language made him understand programming.
[/QUOTE]

I think many beginning programmers are confused by simple concepts like pointers; this confusion disappears if you can think about the real machine.

Nitpick: IBM’s System 360 has a BXLE instruction, which effectively implements the C code
… while ((r1 += r2) <= r3)
Obviously labels are needed: there is no machine language idiom for “{ … }”. There’s a BXH for the reverse test; and some other “loop-assistances” in some other machine languages.

Huh … my machine came with PHP installed … it does everything I want to do … seemed easy enough to learn as a complete beginner. MySQL is a free download if you want a robust database.

I can say “I front-end MySQL with Firefox.” That really impresses the girls …

BASIC was invented before structured programming was understood, so I am in no way condemning the language. The problem my friends faced was not that the kids knew about programming, it was that they thought they knew **all ** about programming. Structured code is not the only thing - BASIC does not allow you to construct any interesting data structures beyond arrays.
Yes, you can write structured code in almost any language - but you have to be exposed to it first, and someone learning BASIC from a book back then is not going to be. (This is where this is relevant to how to the learn programming topic of this thread.) If you start with a language which supports structure, you’ll at least get exposed to it.
And while you can write BASIC like C , you can also write C like BASIC. I’ve seen this, and it ain’t pretty.
I learned to program before the structured programming revolution, in machine language and Fortran, so I can testify from personal experience that learning how to do it right changes your whole way of thinking, and made me at least a 10x better programmer.
GoTos have their (rare) uses, but for a first language it might be better to banish them and only allow next and loop exit type statements instead, which provide 99% of the functionality and none of the risk.

The problem is the concept of availability. If your introduction to programming only involves gotos and simple for loops, you are not going to think of better structures in general. Ditto for data structures. (I’ve taught data structures, so I’m a big fan of them.)
That’s why we forced our class to do the first assignment in Pascal (though we didn’t think of it in those terms.) Get exposed to structure, get your finger burned for not using structure, and you’ll do it right even when you have to construct the structure yourself.
Hell, my dissertation was about a Pascal-like high level microprogramming language, with a full set of control structures. If you can do it in microcode, you can do it anywhere.