Live data from Hacker News

Obfuscating “Hello World” in Python

benkurtovic.com

41–50 of 59 posts

Re: Obfuscating “Hello World” in Python

#42
post #34
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?

- 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 wit…

Your first complaint can be easily solved with a good text editor. I use sublime and it will handle whitespace differences when pasting. I haven't had any trouble pulling from webpages. Secondly, it isn't any harder to indent after hitting return than to add a Bracket. Same number of keystrokes and again, a decent editor can fix this problem too. Lastly, this is just a personal preference. Clojure code also drifts right, but its just a matter of training your brain to interpret it.

Re: Obfuscating “Hello World” in Python

#44
post #42
post #34

Earlier quoted context omitted.

- 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 wit…

Your first complaint can be easily solved with a good text editor. I use sublime and it will handle whitespace differences when pasting. I haven't had any trouble pulling from webpages. Secondly, it isn't any harder to indent after hitting return than to add a Bracket. Same number of keystrokes and again, a decent editor can fix this problem too. Lastly, this is just a personal preference. Clojure code also drifts ri…

How can it handle whitespace differences when pasting correctly?

I have a conditional block. I want to paste some code at the end of it. Do I want to paste it inside the condition, so indented the same as the preceding line - or outside the condition,so indented one level less than the preceding line?

With a brace delimited language, if I put the cursor inside or outside the brace and paste, an editor has enough information to correctly indent it. With whitespace delimiting, the editor doesn't have enough information.

Re: Obfuscating “Hello World” in Python

#45
post #34
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?

- 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 wit…

Not supporting Copy & Paste is a feature.

Re: Obfuscating “Hello World” in Python

#46
post #43
post #41

"There should be one-- and preferably only one --obvious way to do it."

I don't think this counts as "obvious". BTW my intuition say turing completness require that there are many ways to do it, for at least some values of "it", but I can't proove it.

Since turing completness implies that you can write an interpreter for any other programming language you can do it in python in at least as many ways as there are programming languages where you can do it.

Re: Obfuscating “Hello World” in Python

#47
post #39
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?

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 shoul…

The 'ideal' language, in my eyes, would allow terse representation of _algorithms_, not of the language syntax. This often means that you need several different ways to do the same kind of thing in different contexts.

"The syntax is terse" doesn't help if the libraries aren't. We want libraries and common concepts to be terse. That's why I feel that any language designed without heavy consideration for how it's standard libraries are to be used is a regressive exercise. Write your libraries how you want them to be used, then figure out the syntax from that.

Re: Obfuscating “Hello World” in Python

#48
the level of obfuscation is impressive. i wonder if similar obfuscation for javascript exists? The one from google doesn't seem to quite work right and end up breaking my script. The paid version from jscrambler seems to work but seems like a large waste of money to obfuscate one file.

Re: Obfuscating “Hello World” in Python

#49

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 use it (full-time for 8 years) because of the syntax and the forced use of white space. The language encourages people to write better and more maintainable code. Out of interest, what language are you using that you prefer the syntax of? Python is notoriously similar to pseudocode, and I can't think of a mainstream language (other than Ruby) that even seems to care about syntax.

>The language encourages people to write better and more maintainable code.

Python lowers the barrier to entry for programming. Nowadays lots of business analyst types and such are getting into programming because of Python. As a result I have seen some horrendous looking Python code out there which performs quite poorly.

Re: Obfuscating “Hello World” in Python

#50
post #34
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?

- 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 wit…

Those are valid complaints, but they are kind of on the same level as saying "I have to type 'int' to declare an int, what a drag!"
Post reply on HN