4 ms·
> The computer is really quite proficient at inferring block structure from indentation, and if you use a modern editor this structure is manipulated rather eff
by geocar 12y ago
> The computer is really quite proficient at inferring block structure from indentation, and if you use a modern editor this structure is manipulated rather effortlessly.
Nonsense.
Try pasting a block of Python into Hacker News and you get something that starts off like this:
import os
import random
def do_something(x):
if x:
fd = os.open(x)
and only gets worse. A language with braces/semicolons has no such problem; it is easier to communicate with others, and the absolute value of being able to communicate with others when starting a new language is exceptional.
- vertex-four 12y ago> A language with braces/semicolons has no such problem; it is easier to communicate with others If someone posts more than two lines of practically any curly-brace language as one line, it's illegible. Yes, you can pull it into an editor and fix it automatically, but it's a huge waste of time that is best fixed by simply posting the code properly in the first place.
- geocar 12y ago> any curly-brace language as one line, it's illegible. You might not be able to read it, but others can, so it is by definition not illegible. "Indention language", on the other hand, has actually lost its meaning and therefore is illegible. > it's a huge waste of time that is best fixed by simply posting the code properly in the first place Helping others is never a waste of time, but telling people thy are too stupid to ask for help correctly is cruel.
- vertex-four 12y ago> Helping others is never a waste of time, but telling people thy are too stupid to ask for help correctly is cruel. Asking others politely to help you help them is not cruel in any way. If you allow a community to become a place where people can ask questions without putting any effort at all in themselves, you end up with all the people who can actually help leaving, and your community being full of people who will only ever put in the bare minimum of effort.
- geocar 12y ago"Help you help them" however is only necessary in the python example because data is lost. The indention doesn't mean anything to C programmers, and thus I need no help from them to help them.
- vertex-four 12y ago> The indention doesn't mean anything to C programmers So you could read and debug a 5000-line program written all on one line without reformatting it?
- geocar 12y agoWhat does "5000 lines all on one line" mean? If it fits on a page I don't have trouble reading it. Line breaks tend to make it harder to fit on a page and not easier. Example: http://www.nsl.com/papers/origins.htm http://www.nsl.com/papers/origins.htm
- vertex-four 12y agoYou can honestly read and understand that as-is? And adding line breaks and proper indentation would make it absolutely no easier? Impressive. I don't think there's many C programmers who have that ability.
- geocar 12y agoYes I can read this, and adding line breaks would not make it easier. In fact I think it would make it worse. This has come up before, if you're interested: * https://news.ycombinator.com/item?id=8476189 https://news.ycombinator.com/item?id=8476189 * https://news.ycombinator.com/item?id=8476702 https://news.ycombinator.com/item?id=8476702 It is also something I set out to learn how to do because I saw someone else do it: If someone produces smaller and faster code than me, then I should want to learn from it. When working with others, I will often extemporise my code for their sake. I sometimes make mistakes when doing this, but sometimes making friends is more important than fast and correct programs.
- falcolas 12y ago> it is by definition not illegible illegible, adjective: not clear enough to read. Says nothing about "others being able to read". A doctor's handwriting can be illegible to everyone but the doctor, and not be a contradiction to the definition of illegible. > Helping others is never a waste of time If someone cares so little as to paste unformatted code on a forum which provides simple tools to display formatted code, how much value can you really put in their ability to provide quality code? How is requiring someone else decipher something you didn't care enough to post correctly not ultimately a waste of everyone's time?
- restalis 12y ago"If someone posts more than two lines of practically any curly-brace language as one line, it's illegible." "...you can pull it into an editor ... but it's a huge waste of time..." Well, I know it may sound a little bit awkward, but sometimes I just want it to see it work before looking into it, and copy-pasting curly-braced kind of code is perfect for that. So the curly-braced style solves a lot of such inside content distortions and actually frees me from a huge waste of time.
- TazeTSchnitzel 12y agoC code with whitespace and new lines stripped is equally unreadable. You are arguing that braces should be kept so people who don't indent their code properly on HN can be understood.
- gus_massa 12y ago[Note: if you add two spaces at the beginning of each line, it will look like code: import os import random def do_something(x): if x: fd = os.open(x) Note2: If one line with two spaces is too long, it will mess the whole thread, so if you ever want to quote use italics instead of spaces.]
- brudgers 12y agoSorry about being pedantic. PEPpy Python should have four spaces at each level of indentation...not two. Now I feel better
- wolfgke 12y agoJust put two spaces before each line (https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc: "Text after a blank line that is indented by two or more spaces is reproduced verbatim. (This is intended for code.)"): import os import random def do_something(x): if x: fd = os.open(x)
- wolfgke 12y agoWhy the downvote?
- Scramblejams 12y agoBecause petulant children can downvote here. It was a good comment, and I learned something from it. So thanks! I wonder how a comment system that made downvotes public would do. And further, if the downvoter was required to give a one line justification. And further yet, if the downvote itself could be downvoted. Oh, scrap all that. I'd like to see would happen if downvotes were eliminated entirely, so things sorted to the top purely by upvotes.
- falcolas 12y agoIt's only problematic because the comment grammar used on HN for non-code folds consecutive whitespace down to one space. Ironically, this was done to work around those who feel that text documents should be hard-wrapped at ~70 characters. If the grammar did not apply this folding, then it would be happy to preserve the structure. If I were designing a language, its compatibility with naive commenting systems (or catering to users who refuse to use code blocks provided by most modern commenting systems) would be pretty low on my list. Whitespace, even disregarding indentation, is already very significant to a number of modern languages. Why, then, is this particular form of significance bad?
- zak_mc_kracken 12y ago> Try pasting a block of Python into Hacker News and you get something that starts off like this: You're talking about a web site that seems to have been written by web developers who don't know Javascript exists. Any Python parser will be able to format your snippet correctly.