Thursday, February 21, 2008

Up a Level


I think I've figured out
that my difficulty with programming isn't the programming language itself, it's the specific syntax used to describe the language.

Every language builds up its own specialized syntax. Even when there are common terms the implementation of those terms can vary wildly.

I'm looking at Python again. Figured I'd give it another go. Fine.

This, for example, is mostly gibberish to me:

"The actual parameters (arguments) to a function call are introduced in the local symbol table of the called function when it is called; thus, arguments are passed using call by value (where the value is always an object reference, not the value of the object).

When a function calls another function, a new local symbol table is created for that call. A function definition introduces the function name in the current symbol table. The value of the function name has a type that is recognized by the interpreter as a user-defined function. This value can be assigned to another name which can then also be used as a function. This serves as a general renaming mechanism."

The tutorial hasn't mentioned local symbol tables. Call by value hardly makes sense since they haven't explained anything about an object reference. It's useless to me.

And this kind of shit is everywhere in "basic" tutorials. None of this syntax is the same in any programming reference I've ever seen. It even changes when you start talking about language variants or special extensions or "wrappers," whatever the fuck those are.

Not to mention that most beginner tutorials in Python do everything through the interpreter. This is, I guess, supposed to make things easier. But if you try to put the same stuff into an IDE text panel and then Run it from there, none of the examples work properly. Variables aren't initialized or you can't return a result from something something. No explanations whatsoever.

The tutorial starts so easy, too. Here is arithmetic. Here is a while loop. Oh, now here are twenty kinds of functions that won't work outside of the interpreter. No, we aren't going to explain any of the specific terms in use.

This is pretty much every programming tutorial I've ever read. It's like going to Cambodia thinking you have at least a conversational grasp of the language and suddenly you're confronted with a few thousand local dialects that sound almost nothing alike.

Bleh.

6 comments:

Silvanis said...

Wow, that is insane. I have to spend a little bit thinking of what the heck they're talking about, and I've been immersed in programming for years.

Not that it helps, but they're talking about a programming concept called "scope". The basic concept is that anything you define can only be used in the space it was defined in. So if you call a function that has a variable named foo, it only exists as long as you're inside that function.

"arguments are passed using call by value (where the value is always an object reference, not the value of the object)" makes no sense. They're either completely wrong (most likely) or Python does something REALLY weird. Call by value means that the function is getting a copy of the variable and not the original. This means that if you change the variable inside the function, those changes are lost once the function finishes. The alternative is call by reference, which sends a reference/pointer/"Here I am!" object to the function so it can interact directly with the variable. Generally, you only want to do this if the function needs to change the value, or you are using a complex structure for your variable.

If that's the quality of the tutorials you're finding, it's making me want to write one...

Anonymous said...

The funniest thing about the tutorial is where it's found:

http://docs.python.org/tut/tut.html

Yes, it's the official documentation.

Silvanis said...

That actually makes some sense. It was probably written by someone who's developing the language, and they can't get past the implementation details to tell other people how to actually USE it.

I mean, you don't need to know what a "local symbol table" is unless you're writing a compiler. It also makes sense that the examples aren't in an IDE if they have gotten so used to directly using the interpreter.

Anonymous said...

Programming language documentation is always fucking useless. This is simply a law of nature.

I tried to learn Java at one point, back when it was supposed to be the new hot thing. Tried to do it using Sun's proto-wiki manual page that they had at the time. It was like pulling teeth. And I used to code in C, so it wasn't like I'd never seen a similar language structure before.

Personally, I think the problem is OO programming. It's a powerful tool, but it's not necessarily an easy thing to understand, and nobody seems to have ever worked out a way to introduce it that wasn't painful.

Procedural languages may be considered gauche now, but I always had a much easier time with them. They're a much better fit for my (admittedly terrible) programming style, which is basically "tell the computer what to do, and no fucking around."

There is certainly no excuse for a scripting language like Python that refuses to spit back an error in something resembling plain English.

Anonymous said...

I think the truth is that unless you're already experienced enough to do your own research(and know about implementation details like symbol tables), most language tutorials are unapproachable without someone around to guide you.

This is very bad for a new programmer, since it is instantly exclusionary. People often go on about "the right starting language" when the key thing to learn in programming is the abstract concepts. Like I said above, getting the concepts enables you to research the syntax. The average programming tutorial is based on the inverse of this - you know the concepts, here's new syntax.

Symgnostikos said...

I find the book "Core Python Programming" is an excellent resource. That said, I think it really depends on what you know.

I'm not a language master of any sort. This book, while giving the basics, also provides enough info to help you understand the why and how of Python. It's really good, I think.

I was never fond of online tutorials for python. They got me a bit of what I need to do, but I never fully learned the language. A book can definitely help in that case.

If you're looking for a book, this site has a ton of reviews for Python books:

http://www.awaretek.com/book.html