4 ms·
Tokens of a bygone era. I wish more languages were like Python and didn't require so many cruft characters.
by k3n 14y ago
Tokens of a bygone era.
I wish more languages were like Python and didn't require so many cruft characters.
- cobrausn 14y agoThe first time I ran into the spaces vs. tab problem I wanted my curly braces back.
- rejschaap 14y agoInvisible cruft! The worst. Also, Python is crufty by convention with its __init__ and __new__.
- k3n 14y agoThat's an issue you run into once, set your editor, and then never have to worry about it again. On the other hand, curly braces will plague you as long as you use C-inspired languages. An editor will only help you to more easily produce the cruft, it won't absolve you of the responsibility.
- papsosouid 14y ago>That's an issue you run into once, set your editor, and then never have to worry about it again. HN needs /. style comment ratings for things like this. You deserve your "+1 funny" for that. >curly braces will plague you as long as you use C-inspired languages Curly braces don't cause (potentially hard to find) errors like mixed invisible indentation does. You can't be "plagued" by them at all, they are harmless. And they even let your code be completely unambiguous so you can use tools to reformat your code as you please/need.
- deleted 14y ago[deleted]
- qu4z-2 14y agoMuch as I like the /. "semantic rating" system, I'm glad HN doesn't have it, so we don't get these sorts of passive-aggressive ratings. Regarding your second point, curly braces do cause potentially hard-to-find errors, specifically when the indentation and the curly braces don't match up. Admittedly it's very easy to get into a set of habits where you don't do that, but the same can be said for the mixed indentation issue.
- papsosouid 14y agoExcept that there is no potential for ambiguity, so tools can easily highlight indentation that doesn't match braces as an error for you, and tools like "indent" can automatically indent the code correctly based on the braces.
- qu4z-2 14y agoBut those are both ways to keep your two different notations for structure in sync. If you only have one structure, you don't have that problem in the first place.
- cobrausn 14y agoYou run into it again when you start working with other developer's code. And once you learn to use curly braces, you don't forget that either. I haven't been plagued by curly braces since college - I work with C / C++ / Lua / Ruby on a daily basis. I seriously don't see how it's any different than remembering to indent your python code. An editor certainly doesn't absolve you of that responsibility either. I'll put it this way - when I look at a block of code with braces (or begin / end), non-rendered characters don't affect the correctness of it.
- k3n 14y agoI just think they're redundant. Indention in non-Python code is 100% aesthetic; it doesn't affect program behavior, we just do it because it helps us non-compilers understand the code. And if you follow most any sane coding standard, indention will always be congruent with braces. So, you're essentially attempting to convey the same concept -- program structure -- via 2 different mechanisms: tokens (curly braces) and indention, where of course the former is required, while the latter is the fodder of more flame wars than anyone cares to count. The sad thing is, these flame wars over code formatting are the most contentious to humans and yet the least meaningful to the compiler. One solution would be to remove the indention -- hey, we already have the tokens informing us of the lexical code boundaries...but this produces unreadable code. The other solution is to remove the tokens; since we as humans will naturally structure our code in block paradigms, then we can piggyback on a behavior that is already innate to programmers.
- pekk 14y agoEnforcing a convention (like go fmt) will also take care of the issue. However, this doesn't end up being really different from what Python does by rejecting mixed tabs and spaces. So.
- qu4z-2 14y agoI agree with you. It seems odd that we have the structural information in our program twice: Once for humans, and once for computers. The computers are perfectly capable of understanding the human construct, so let's use that.
- tobiasu 14y agoUntil you refactor some python code and the indentation gets messed up without you noticing... Been there, done that. And unlike languages with explicit begin/end markers, an editor can't re-format it or warn about it, because there is no information to work with.
- pekk 14y agoPerhaps you didn't understand, but that doesn't happen when you set up your editor. Anyone who actually uses Python spends 0% CPU thinking about soft tabs because the editor is already set up to deal with this and almost everyone uses soft tabs, as suggested by PEP8.
- qu4z-2 14y agoThere's no reason an editor can't reformat most cases. If you copy a block of text out of one indentation-level and into another, you simply need to adjust the leading indents by a fixed amount. Obviously if you're changing which statements are or are not part of a block and thus need to re-indent things per-line you'll need to do it manually, but you'd also need to manually move the braces around, and it'd be less obvious if you forgot.
- Someone 14y agoTechnically, you don't have to type any { or } to write C code. ??< and ??> will do 'fine' as replacements, as do <% and %> (http://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C http://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C)
- manaskarekar 14y agoOr lisps. Commas in sequences? Cruft!