Hacker News new | ask | show | jobs
by scoofy 176 days ago
My background is philosophy of language. I studied formal/mathematical logic in grad school. I was always embarrassed that I couldn't code, but the computer sciences classes were teaching languages that were inscrutable for someone even with my background, with syntax heavily focused on jargony math and technical concepts like object orientation (likely java at the time).

Around 2010, I was talking about this with friend about this failing of mine, and he said "you should try python, I've heard it is popular with non-math folks." So I bought a book, and as soon as I opened it, I could just read it. It took me a couple days of reading to wrap my head around object orientation, but on the functional side, I could have written fizz buzz like, maybe half an hour after opening the book.

Humans have logic pre-built into our brains, it's just that we use natural language as our syntax. Python cleverly used as much of the natural language syntax as was practicable to remove the barriers to entry for non-math majors. Whitespace is perfect example of a natural language syntax feature.

1 comments

The whitespace thing is actually one of python's major flaws. That feature attaches syntactic meaning to non-printing characters. From a human standpoint, there're many examples of silence having some kind of meaning. From an engineering standpoint, that entire methodology is insane. Communication needs to be positive and deliberate.

Remember that Apple SSL bug "goto fail"? That was a whitespace bug, because even if the C feature predated python, everyone's eyes had been trained to slide right off that particularly crass shortcut as python was widespread by that point.

>Communication needs to be positive and deliberate.

I don't know what you mean by this.

>The whitespace thing is actually one of python's major flaws. That feature attaches syntactic meaning to non-printing characters. From a human standpoint, there're many examples of silence having some kind of meaning. From an engineering standpoint, that entire methodology is insane.

It's not non-printed characters, it's alignment. The period is a parallel for the semicolon in programming, to signal the end of a unit, but the whitespace in python is a parallel to the bullet point, or poetic stanza. Those both parallel to python in the form of atomic statements.

Most people's concern is the hanging indentation. Here, I would argue that we can effectively prove that hanging indentation is vastly more parallel to natural language than braces. Simply search for "handwritten recipes" and you will see that in a natural language assembly exercises -- effectively a real world parallel to programming -- human beings naturally default to hanging indentation when grouping sub-categories of items together.

https://duckduckgo.com/?q=handwritten+recipes&iar=images

Does this parallel to the jargony math you'll find in math books? No. But it trivially flows from human beings in the real world, and there is nothing formally incorrect in the syntax. Thus, we would likely find that layperson would intuitively understand the hanging indentation, where as braces as syntax is jargony, and must be learned.

> Here, I would argue that we can effectively prove that hanging indentation is vastly more parallel to natural language than braces.

I see where you're coming from. However, I would counter that in the use cases you've shown, as well as all of the use cases I've seen in the real world, there are important differences between them and Python.

1. Hanging indentation is most often used in things that are small in scope, where you can easily see both the start and the end of the list. Python blocks can grow without bound.

2. Hanging indentation in real life doesn't require perfect alignment. Python does.

I don't think it has anything to do with Python. I had plenty of 'if' errors in C++ caused by indenting the second line and not putting braces around it prior to Python. They were always painful to debug. I finally just _always_ put a brace around an 'if' block, regardless of whether it is one line or many, and I've never had that problem again. I think the problem is that C lets you omit the brace for one line; it should always require a brace.

Python executes like it reads, which seems like a positive feature to me. Makes errors like C's two-line if block impossible.

There's functionally little difference between spaces being non-printable characters, unless there are examples of text editors that do not render offset empty space when they're used.

Spaces vs tabs, sure, that's an argument.

But it doesn't seem reasonable to argue that {something that is visible in a text editor} is different than any other kind of character.

It's not like Python was using the bell ASCII or somesuch.