Wednesday, December 31, 2008

Re: [BLUG] Looking to study further in computer science

I'm only going to comment on the Python stuff, since I'm a Python guy.

And I think that sentence serves as a fine disclaimer!

On Tue, Dec 30, 2008 at 11:04 PM, David Ernst
<david.ernst@davidernst.net> wrote:
> Then everyone started talking about Python. I suspect Python is a
> great language. I've barely used it. Basically, my feeling is that
> if I had a project well-suited for Python, I'd probably just do it in
> perl.

There's definitely something to be said for just the language you know best.

> Python's approach to object-orientation seems only slightly
> less an afterthough than perl's... you still have no real support for
> anything private/protected,

I don't know Perl so I can't really comment on it.

You can declare private attributes and methods inside a class by
prepending "_" to the name. This makes it so someone won't casually be
able to mess with it from outside the class, but it does not make them
untouchable; there is a convoluted way of accessing the "private"
stuff, I know.

I've yet to personally find a single situation where that isn't
enough, though. I can't even imagine a situation where that's not
totally sufficient.

It's in line with the philosophy that you don't need to force
programmers to strictly type their variables, I believe.

If the programmer wants to do something weird like cram an int into a
variable that previously held a boolean, let 'em; it's up to them not
to do anything stupid with that variable anyhow. If the programmer
wants to do something mega weird like go fiddle with a declared
private method, well, I guess, it's up to them not to do anything
stupid with that method anyhow.

I mean, we put up a big fence around Niagara Falls as a visual
reminder that it's a bad idea to jump in, and as a physical barrier to
protect against minor accidents. We don't make it a huge, unscalable
plexiglass barrier because that's just not necessary 99.99999999% of
the time.

And if, every few years someone climbs the fence and dives off, well...

> and you still have that "explicit self"
> thing (c.f. http://beust.com/weblog/archives/000501.html) which is
> kinda funny in perl but more strange in Python which seems to be more
> proud of its OO support.

Yeah, that's a little weird to wrap your head around at first, I
suppose.The weirdest part is just declaring a method to accept an
argument that you then don't need to pass it. After wrapping my head
around it the first time, though, and as someone who uses Python
pretty regularly, it's never been an issue for me.

It's no weirder than the quirks of every other language I've learned,
though. Fr'instance, how come English infinitives are two words? How
come your nouns don't have gender? And what's with all the exceptions
to the rules??? ;-)

For the more CSy among you, you might be interested in Guido's
explanation as to why the explicit self must stay:
<http://neopythonic.blogspot.com/2008/10/why-explicit-self-has-to-stay.html>
I, however, was bored to distraction after the first couple of
paragraphs; it's just way over my head.

> And, I must admit, I'm hung up on the
> significant white space thing. I'm sure I could get over it,
> but... why?

Why not?

Using whitespace in a consistent and significant way greatly increases
the readability of code, in my not quite so long-lived opinion.

You did it in both your examples below; I *suspect* you're more
against it being *enforced*, since you probably developed your own
whitespace style before sitting in front of Python, that against
significant use of whitespace in general. How off the mark am I?

I learned Python alongside Java, and taught Python and Java classes
concurrently. I was much less (and much less often) irritated by
Python complaining about unexpected indents than I was by Java
complaining about curly braces.

Even in curly brace languages, I try to use Python-esque whitespacing
because, well, it helps me keep track of the silly braces.

> 7.times do
> whatever
> end
>
> should really make us all pause and wonder why so many languages
> consider it perfectly natural to write things like
>
> for (x = 1; x <= 7; x++) {
> whatever
> }
>
> At least many languages have now copied perl's "foreach $x (1..7)"
> approach, which is far more readable than the classic C-style syntax
> that java (foolishly, imho) emulated.

Is this an example of what you mean? (in Python)

for i in range(7):
whatever

> Having said all that, I'll again say that I can't really recommend
> Ruby over Python, and they are good for similar kinds of things.

I don't know *anything* about Ruby, really, except that some people
*really* dig it.

We've got someone here in Fort Wayne who really digs Ruby. He agrees
with David's sentiment that he greatly prefers Ruby, and that it's
probably pretty comparable to Python in many ways.

> You see? You get me sucked into writing long emails! Now I'm behind
> on everything else I was going to do this evening...

ditto, ditto, ditto, this morning... ;-)

> David

Simón

_______________________________________________
BLUG mailing list
BLUG@linuxfan.com
http://mailman.cs.indiana.edu/mailman/listinfo/blug

No comments: