r/programming • • Aug 30 '08

Tour De Babel -- Rant about programming languages (at Amazon)

http://steve.yegge.googlepages.com/tour-de-babel
13 Upvotes

122 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Aug 31 '08

[deleted] — view deleted comment

2

u/13ren Aug 31 '08 edited Aug 31 '08

Minor irritation: I've had Python code that looks indented but isn't. This is probably because I have tabstop=2. I think semantics that depend on the invisible is problem-prone! :-) Whitespace in make has a similar issue. However, once I realized what was happening, it hasn't happened again, so I think it's a minor irritation. The same problem also occurs in C-style code, in that when I cut-and-paste code written with different tabstops (and vice-versa), the places where spaces were used instead of tabs are revealed.

The other issue is that you can't inline function definitions etc - which in some cases would be clearer. (I like Haskell's \ for this - tho I've only seen it, not used it)

On ruby: why can't it use C-style } instead of end? Are { and } already used for something else?

0

u/[deleted] Aug 31 '08

[deleted] — view deleted comment

2

u/13ren Aug 31 '08 edited Aug 31 '08

I know you can do that, but they're not on one line. i.e. due to Python's need for indentation, you can't say this:

def myfunc(): def myfunc2(): pass

erruum, maybe "inline" doesn't strictly mean "on one line". Please take my comment as having the latter meaning :-)

0

u/[deleted] Aug 31 '08

[deleted] — view deleted comment

3

u/13ren Aug 31 '08 edited Aug 31 '08

curious: why don't they use def for that as well? That would seem more consistent (to me).

Here's code using lambda:

s = 'hello to all da people in da house'
s = s.split()
print map( lambda word: len(word), s )

[5, 2, 3, 2, 6, 2, 2, 5]

Instead of the keyword "lambda", why not have:

print map( def(word): len(word), s)

then you could name it too, if you wanted (I have a feeling this is an old, old controversy that doesn't really matter - I'm just wondering if there is a satisfying reason for it, apart from parser-convenience in distinguishing them).

0

u/[deleted] Aug 31 '08

[deleted] — view deleted comment

3

u/13ren Aug 31 '08

I don't know anything about this, so I'm not trying to argue, but... the change seems only in syntax, not semantics. How is it changed semantics?

0

u/[deleted] Aug 31 '08

[deleted] — view deleted comment

2

u/13ren Aug 31 '08 edited Aug 31 '08
func = def my_function(arguments):

You're right there are semantic differences, for Python. Javascript allows the above (ie. return a function pointer from the function definition expression). I think it's a good thing.

The other semantic change you mentioned (lambda version wouldn't accept a name) isn't necessary. You make the name optional, for all cases; implying you could also do this:

func = def (arguments):

That's how it is in Javascript - not saying JS is the ultimate language, just that it's possible (I do think JS is elegant - just browsers/DOM aren't)

However, I'm happy to accept Python as it is - just curious.

→ More replies

1

u/13ren Aug 31 '08 edited Aug 31 '08

ah, thanks, it's seeming that lambdas are what I want. That's really cool, now I feel happy. :-)

I'm new to python, and all the examples where I thought a lambda would be appropriate have used separate functions.

2

u/Old_Cartographer_938 Aug 31 '08

Lambdas are exactly where the whitespace issue bites you. You can't have multi-line lambdas in Python.

There is, however, an argument that you shouldn't have multi-line lambdas. But people positing that argument are wrong. :-)

0

u/[deleted] Aug 31 '08

[deleted] — view deleted comment

1

u/13ren Aug 31 '08

thanks, bookmarked

1

u/Leonidas_from_XIV Aug 31 '08

There are some tools like functools.partial or operator.itemgetter that in fact, make lambda obsolete.

2

u/mernen Aug 31 '08

On ruby: why can't it use C-style } instead of end? Are { and } already used for something else?

Just because Matz didn't want it, basically. I guess he did it that way because using } would require an opening brace, making it in the end not really shorter, just distributing weight around. For almost all purposes, Ruby makes block-opening keywords completely optional (the only exception is the block-passing do, but these are also exactly the situation where you are also allowed to use {})

2

u/Leonidas_from_XIV Aug 31 '08

why can't it use C-style } instead of end? Are { and } already used for something else?

Because they are used for blocks and dictionaries/maps. But I suspect they could be used, because Ruby's grammar is (from lexer/parser viewpoint) quite complex.

0

u/Leonidas_from_XIV Aug 31 '08

I had seen both problems, but they somehow never outweighted the advantage of indentation.

If I paste some block, I often have to change other stuff as well, so the indentation is the tiniest problem whcih can trivially be solved automatically.

As to blog posts or forum posts without indentation: these are often people who don't care enough and I plainly refuse to give them any help besides "edit your post and fix the formatting". And people who care and whose code is valuable find ways to include code in comments (be it in a pastebin which can highlight code or be using formatting directives).

4

u/[deleted] Aug 31 '08

typing 16 spaces in Reddit posts is a royal pain

Also I indent using tabs not spaces, you can't press tab in a textarea.

0

u/Leonidas_from_XIV Aug 31 '08

typing 16 spaces in Reddit posts is a royal pain

So when you post C code, it is completely unindented and without previous editing also completely unreadable?

3

u/[deleted] Aug 31 '08

C code doesn't rely on line breaks and indenting.

it is unambiguous like that by design.

0

u/Leonidas_from_XIV Aug 31 '08

No, but programmers find it easier when the code is indented properly. Take a look at the camel-shaped Perl code. I'm sure it runs just fine, but it is harder to understand. Intendation exists for a purpose, C-Programmers usually do indent, too and not because of the compiler.

2

u/[deleted] Aug 31 '08

That's why C prettifiers exist.