Live data from Hacker News

Obfuscating “Hello World” in Python

benkurtovic.com

31–40 of 59 posts

Re: Obfuscating “Hello World” in Python

#31
post #17

Earlier quoted context omitted.

I will never understand the whitespace complaint. Any code you read in python will follow standardized indenting, by necessity. Why on earth is that a problem?

Easy: because there are people who mistake being used to something for it being good. Also because people know too few different styles of syntaxes and are not required to learn more of them (let's do everything in X! from microcontrollers to OSes!), which makes them inflexible. Syntax matters, but not in the way most people think it does. Syntax should be judged based on how well it supports semantics of a given lan…

Python syntax helps the semantics pretty well I think.

Why do you need braces when the program's tree structure is obvious from indentation?

Re: Obfuscating “Hello World” in Python

#33
post #27
post #24

Earlier quoted context omitted.

GP is not just expressing an opinion, they're expressing it in a fashion so destructive that it seems likely to be a deliberate troll. "icky syntax" is an opinion that the author should have known was unpopular, expressed aggressively as though it were a widely recognized fact. "I have looked into the alternatives and they all seem to be better" provides zero information and just fans the flames; someone trying to be…

Questions don't have to be polite, well-formed, or sensible. That is required of answers.

It's required of any question that expects an answer. Nobody's going to answer your question if you're an ass who doesn't show a modicum of consideration of those being asked the question.

Re: Obfuscating “Hello World” in Python

#34
post #17

I still have problems fathoming how Python managed to get such a big mindshare within the developer community with its icky syntax and forced use of whitespace. What makes it good? I have looked into the alternatives and they all seem to be better.

I will never understand the whitespace complaint. Any code you read in python will follow standardized indenting, by necessity. Why on earth is that a problem?

- Cutting and pasting code may change its functionality. Especially from a non-source medium like web pages.

- I find myself fighting my editor's indentation a lot more as a result. Hitting return at the start of a line in the middle of an existing chunk of code indents to the previous line's indentation not the current line's indentation.

- It's asymmetrical: code drifts off to the right as you go down. Together with the editor issue I've taken to inserting a single '#' at points of down-indentation to mark this.

Re: Obfuscating “Hello World” in Python

#35

Earlier quoted context omitted.

Easy: because there are people who mistake being used to something for it being good. Also because people know too few different styles of syntaxes and are not required to learn more of them (let's do everything in X! from microcontrollers to OSes!), which makes them inflexible. Syntax matters, but not in the way most people think it does. Syntax should be judged based on how well it supports semantics of a given lan…

Python syntax helps the semantics pretty well I think. Why do you need braces when the program's tree structure is obvious from indentation?

> Python syntax helps the semantics pretty well I think.

Yes, I think so too.

> Why do you need braces

You don't. You need some kind of delimiters and newline+indent works just as well as any other kind of delimiter, like braces, parens, begin+end and so on and on.

Re: Obfuscating “Hello World” in Python

#36
I barely know any Python and upon first glance I could easily get an idea of how it worked (without looking at the explanation): by computing the required strings out of funny-named variables with shifts and arithmetic. co_nlocals is obviously the only actual integer constant from which all the other values are coming from.

Only then did I read the explanation, and realised I wasn't far-off (the only thing I got wrong was the string computation, which I thought would be a string concatenation.) I think it says something about the language when even obfuscated code in it is rather readable! (Then again, I do RE where most of the code I'm reading is disassembled machine instructions, so maybe my perspective on what constitutes obfuscation is a bit skewed...)

Re: Obfuscating “Hello World” in Python

#39
post #17

I still have problems fathoming how Python managed to get such a big mindshare within the developer community with its icky syntax and forced use of whitespace. What makes it good? I have looked into the alternatives and they all seem to be better.

I will never understand the whitespace complaint. Any code you read in python will follow standardized indenting, by necessity. Why on earth is that a problem?

Personally I don't care, although copy-pasting Python can be annoying. If your biggest concern with any general-purpose programming language is its syntax, you have probably not put enough thought into semantics issues - the ones that persist no matter how familiar the syntax becomes.

Anyway, Walter Bright, designer of D language, wrote an article on language design [1] touching on the issue:

> Yes, the grammar should be redundant. You've all heard people say that statement terminating ; are not necessary because the compiler can figure it out. That's true — but such non-redundancy makes for incomprehensible error messages. Consider a syntax with no redundancy: Any random sequence of characters would then be a valid program. No error messages are even possible. A good syntax needs redundancy in order to diagnose errors and give good error messages.

I thought that was interesting. It is a pretty much undebatable argument against taking terseness too far.

On the other hand, I have never had a problem with Python's error messages.

[1] http://www.drdobbs.com/architecture-and-design/so-you-want-t...

Post reply on HN