12 ms·
Underscores are stupid
- oligophagy 14y agoAll you have give up for this is tightly-packed arithmetic statements, like this: 5*5-3 Instead, you have to give your tokens some breathing room: 5 * 5 - 3 I don't know, that seems pretty stupid too.
- pilot_pirx 14y agoand gets even worse if you bring variables into the game. a = 5 b = 3 everybody from nearly every programming language would expect that after c = a-b you will find c to be 2 not nil (or throwing an exception or whatever)
- haukur 14y agoI've always found code without spaces around these symbols to be very undreadable.
- pilot_pirx 14y agoYes, but in this case it's not about readability, but about extremely significant whitespace. Forgetting a space and your code has a totally different meaning.
- xyzzyb 14y agoWhitespace is already extremely significant in programming. "foo[1]" vs "foo [1]" for example.
- pilot_pirx 14y agoDepends on language, in Ruby those statements would be identical. But anyway, that's no reason to make things even worse.
- mbrubeck 14y agoIn Ruby those statements are the same when foo is bound to an array, but they are different when foo is bound to a function...
- megablast 14y agoAnd I have found the opposite. Horses for courses.
- nessus42 14y agoI never pack my code like that without whitespace, as doing so is only readable when you have single-letter variables, which is not very common. I agree with the OP. CamelCase and underscores are both scourges.
- bryanlarsen 14y agoThere's an easy fix for part of the problem: bind shift-space to underscore. Yes, you still require shift, but IMO it's the stretch not the shift that makes typing an underscore jarring. xmodmap -e 'keycode 65 = space underscore'
- TeMPOraL 14y agoUnless you use Emacs (as the author seems to), in which case you have S-Space bound to starting/ending selection. But in general yes, one can rebind underscore to something that doesn't require pressing Shift.
- drbawb 14y ago"the stretch"? Properly typing an underscore should utilize two hands and shouldn't require a stretch at all.
- bryanlarsen 14y agoIt moves your pinky, your smallest and least mobile finger, to move up two rows, which requires a typical person to completely flatten that finger. Either that, or you end shifting your whole hand. Which means that you end up moving your hand a lot while typing because the underscore may easily be the most common keyboard character encountered in some programs.
- drbawb 14y agoObviously everyone has different shaped hands - but for me, the pinky doesn't need to be entirely flat to reach the underscore. I also don't have to shift my whole wrist. Either way, reaching the + key on QWERTY-102 is objectively more difficult than the underscore [uses the pinky, is farther away than the underscore from homerow], and also requires a shift-modifier. I use + far more than _ while I'm coding. (And I'm currently writing most of my code in Go, so I use _ quite a bit since it's a blank identifier.) Maybe I just have big hands, but it honestly doesn't impede my typing at all to add an underscore to the text.
- malloc47 14y agoOne of the most efficient everyday optimizations I've made in the past few years was to adopt the lisp-style naming convention for my local file system hierarchy. Removing all capitalization and special characters (other than the dash) makes navigating via CLI much easier. And having a predictable naming scheme means I rely on tab completion slightly less too, as I have more predictive capability regarding how I might have named things in the past. More generally, treating my home folder as, essentially, an exposed API for which I'm the primary consumer has paid dividends.
- sp332 14y agoI think they should make keyboards with the spacebar divided, and make the left half (or I guess the right if you're left-handed) into a shift key.
- wahnfrieden 14y agoThe Kinesis Advantage keyboard effectively does this, except the left half is for backspace. Since it has very conveniently placed modifier keys like ctrl under my thumbs, I remapped capslock to shift so that it's on the home-row.
- drbawb 14y agoThis would drive me bonkers. For some reason I've never been able to hit the spacebar on the left side. (I mean, it's not like I'm physically incapable. I just instinctively hit SPACE with my right thumb.) Getting used to using my left thumb would just be awkward. I also have a nasty habit of using the LSHIFT exclusively. Even when it's not technically appropriate to do so.
- pkamb 14y agoSome Japanese keyboards do this. Tiny spacebars and extra modifier keys. I've always wanted to buy one and put keys like backspace and delete on my thumbs. Japanese ThinkPad USB keyboard (with TrackPoint!): http://i.imgur.com/4dWVJ.jpg http://i.imgur.com/4dWVJ.jpg
- idleloops 14y agoI think the left side is more suited for backspace. Which is how my Compaq keyboard is setup - the key is physically divided into two. Perhaps the spacebar is just too big, and could be divided better into other modifiers. My left thumb is usually wasted (though not on a Mac, where the thumb can easily reach the Command key.) Some people however - seem to alternate thumbs on the spacebar - or rather use the other hands thumb to the hand that just typed a character. I personally always use the right thumb to space.
- raganwald 14y agoThis misses one point when comparing Lisp to languages like Ruby. Lisp does not have infix notation. Therefore, you never have to worry that "foo-bar" (the symbol) could ever be confused with "foo - bar” the operation subtracting bar from foo. That’s because in Lisp, foo-bar is written "(- foo bar).” Since a Lisp programmer spends all his time writing "(- foo bar),” when he sees “foo-bar,” his brain easily parses it as a symbol, and he never needs to wonder whether it should actually have been “foo - bar” with spaces to separate the infix operator from the symbols representing variables.
- ken 14y agoI don't think this has anything to do with infix versus prefix. It works in Lisp because the reader knows (roughly speaking) that symbols are terminated by whitespace or parentheses. If you wrote a version of Ruby that was still infix but where you needed to put spaces around all symbols, then "foo-bar" would work fine there, too.
- raganwald 14y agoYou are echoing Avdi’s point. I understand it, I just happen to disagree with it. If Lisp was an infix language, then yes foo-bar would mean something different to the parser than foo - bar because of the whitespace. But what’s also at stake is whether that language would be readable to humans without mistakes. Part of what makes Lisp work, IMO, is that you never try to type foo - bar, so you never run into an accident by mistakenly typing foo-bar and having the parser think you meant a hitherto undefined symbol. Whether that’s a worthy tradeoff is a matter of opinion, and I’ll take Avdi’s word for it that he believes the benefits of calling symbols foo-bar outweigh the odd time you might type the wrong thing. I’m just pointing out in addition to the “whitespace is the separator” argument you both make, there’s also the “foo - bar doesn’t mean foo subtract bar” argument.
- astine 14y agoExcept that in Lisp "-number" is totally different than "- number" and I rarely have to worry about it when I code in Lisp. I code in both Lisp and Ruby on a regular basis, and I don't see the ability to write "x-y" as any real advantage. I already separate my tokens with white space by default because I see "x-y" as a single token.
- soulcutter 14y agoI write code slower than my typing speed anyway. This sort of typing efficiency obsession leads people to use dvorak or crazy non-standard keyboards. No thanks, not worth caring about.
- lclarkmichalek 14y agoYes I rather thing that the writer has a bit too much time on his hands
- ctdonath 14y agoMaybe because he's eliminated all that time wasted by typing underscores.
- drbawb 14y agoI don't understand why people wouldn't be obsessed with typing efficiency. Granted you don't need to type all that fast for programming. However I do have to type full-speed when writing documentation, composing an e-mail, working on a presentation, etc. Not to mention Dvorak and "crazy non-standard keyboards" demonstrably reduce RSI, which is a far greater benefit than typing speed. (Unless you like having disgusting chemical compounds injected into your wrists; or want your wrist cut open so that doctors can work on some of the most delicate tissues in the body.)
- bluejack 14y agodisagree. like_underscores. concerns about using shift key seem misplaced & for those who have some form of birth defect that prevents use of two fingers simultaneously, keyboard remapping is easy.
- wahnfrieden 14y agoModifier keys cause strain that can lead to RSI.
- goostavos 14y agoI like 'em, too. What terrible ordeal that we must push the shift bar while typing. Honestly, I've always found them to be more human readable than CamelCase.
- vidar 14y agoWriting almost exclusively in a underscore-encouraging language like Python has numbed me to these issues.
- ineedtosleep 14y agoWith me as well, though it is getting slightly annoying to the people I work with that it's been transferring over into some of the PHP code I have to write.
- idleloops 14y agoIt's not as if underscores aren't used liberally in the standard library. Which is probably a hangover from C.
- JoeAltmaier 14y agoI use case instead of underscore. Doesn't help the shift-issue, but reduces the length of identifiers e.g. file_not_found becomes FileNotFound.
- Peaker 14y agoIThinkItIsObjectivelyMuchLessReadable I_think_it_is_objectively_much_more_readable The difference in length is pretty small anyway.
- RobAtticus 14y agoThat's a bit contrived considering you're (a) writing a sentence and (b) you use some really short words (i.e., "I", "It", and "Is"). I think for things like FileNotFound or similar its not really that different in readability, and comes down to preference.
- JoeAltmaier 14y agoYou get used to anything. For instance, I find your 1st example much more readable, but I've been doing it for years. Names tend to be pretty small anyway. Here are some random ones from the code I'm working on (Sococo Teamspace) CreateVariant - a method soLogWriteInfo - a method (I didn't write) clHeadSSt - a circular list head for a stream
- Kilimanjaro 14y agoThis may solve your problem: my.long.name = 1 a.short.name = 2 one.long.result = a.short.name - my.long.name one.string:trim:upper Use dots for identifiers and colons for class props and methods. Now we just need to design a whole new language :(
- barik 14y agoUsing dot as a name separator is actually the convention the R programming language, so it's certainly not a new idea. Ironically, it used to be the case that R did not allow _ as a variable character.
- JadeNB 14y agoAt least on a US keyboard, colons require the shift key, too.
- idleloops 14y agoCleanse those colons!
- pkamb 14y agoIn Dvorak, the underscore key is where the apostrophe is in QWERTY, just to the right of your pinky. Nice little upgrade.
- idleloops 14y agoYes, but it still requires SHIFT + - to get the underscore.
- uptown 14y agoSemicolons. Underscores. Spaces. Tabs. Every couple weeks it's some new minutiae profiled as the cause of all the world's problems. Don't people have better things to focus on than this?
- raganwald 14y agoSome people are detail-oriented. How can you expect Mr. Grimm to obsess over corner cases in his code but shrug at what he perceives are problems with representing it? The people who think only in terms of the “big picture” while glossing over the details are not programmers. They are “architects.” EDIT: This second statement is probably not correct. I would use strikethrough if I could. But the first statement still rings true with me, many programmers are detail-oriented, which means that they care about lots of things other people would consider irrelevant. Whether this is, on the whole, a good thing or not is another matter. But I do not think it is surprising.
- drbawb 14y agoI feel that you're mostly right. However I think we all focus on different details, to an extent. For example, I'm a great typist so the underscore key has never really bothered me. But to call the author out on being detail oriented would be inane of me. I myself don't like keyboards that have small backspace keys. I also still hate OS X for having the window control cluster on the top-left corner. I know I certainly get paid to think about the details. The only variable here is which details.
- suprememoocow 14y agoAgreed! This really shouldn't be on HN front page.
- pjmlp 14y agoSpecially if we take into consideration that this is country specific. Many country specific keyboards also need modifier keys to access the hyphen.
- caryme 14y agoInteresting that he calles dashes "ordinary, easy-to-type, recognizable, [and] visually unambiguous." What he's referring to as a dash is actually a hyphen (-), which is pretty ambiguous when compared to the en dash (–) and em dash (—), both of which require modifier keys to type (and are frequently used in prose, to counter another of his claims). Fortunately, I've never seen em dashes or en dashes used in code.
- tantalor 14y agoJust to clarify your clarification, that symbol is HYPHEN-MINUS, U+002D. It is in the "Punctuation, Dash" category.
- davidcuddeback 14y agoHe's discussing this in the context of writing code, not typography. I think it's fair to assume we're starting with the premise that we would only choose characters that are easily typed on common keyboards. Choosing uncommon characters in programming languages, such as en-dashes and em-dashes, is choosing to deliberately make our lives more difficult [1]. I think it's pretty clear from the article that his comments were meant to be taken in that context. If he'd chosen to preempt the pedantic readers by making that context explicit, it would have only diluted the article with noise that most people would rightly assume is implied by the context. I don't know what your keyboard looks like, but mine doesn't have en- or em-dashes on it, and I wouldn't even consider them for a programming language syntax. [1] Even when using en-dashes and em-dashes in prose, they can often be typed with multiple consecutive hyphens, e.g., '--' and '---' in LaTeX.
- drbawb 14y agoWell, the author himself is pretty ambiguous. While most of the article talks about code, the author mentions underscores being ambiguous in the context of underlined fonts. (I don't even think my text editor [for code] supports underlined fonts.) He also mentions only using shift once or twice per sentence when writing prose. So it would seem that the author is just hating on _ in all contexts. Which is kind of silly. (Though I'll admit, the point of it being improperly handled with underlined fonts is certainly a valid complaint.)
- RobAtticus 14y agoOnly nerds know what underscores are? I think anybody who grew up in the early Napster/Limewire/Kazaa days knows what an underscore is because they probably downloaded a file like Michael_Jackson_-_Beat_It.mp3
- caryme 14y agoAnd because in middle school, everyone had one in their email address and AIM screen name.
- diminish 14y agoAny time I have some feelings, I try to clean up the emotions and use my reason. Underscores solve a lot of problem and are useful in technology and programming and then suddenly i_love_underscores.
- kasperbn 14y agoSo the problem is not the underscores but the many shift keystrokes which is a valid point. The solution is to refactor the keyboard layout.
- wahnfrieden 14y agoAs a daily python user at home and at work, I realized I'm typing a huge amount of underscores. My keyboard supports rebinding keys and programming macros (a feature I've never used until now) so I remapped an extra \ key on it so that it would type _ without me holding shift. Small change, but it's much less of a strain. (I'm using a Kinesis Advantage keyboard.)
- kibwen 14y agoI've been thinking about trying to find a reasonable way to map the underscore to shift+space, but I'm not sure if that would somehow break some application that expects otherwise. It also seems to be quite difficult to achieve on Windows without registry hacks (I presume it would be easier on Linux, but haven't tried it yet).
- Stratoscope 14y agoIt's very easy on Windows with the strange and wonderful AutoHotkey [1]. I recommend the more advanced AutoHotkey_L fork [2], but this script should work in either version. Install AutoHotkey and then create a file called Underspace.ahk with this content: ; Underspace for AutoHotkey ; Converts Shift+Spacebar to underscore #SingleInstance force +Space:: Send _ Now launch that file. Try Shift+Space and it should type an underscore for you. If you want to stop the script later, find a green "H" in your system tray and right-click it. After you try it, I'll be curious how it works out for you. Myself, after trying it for just a minute or two, I'm not so sure if I like it. I'm finding a lot of spurious underscores before capitalized words, or after a word like "I" that ends with a capital letter. That's because I've been sloppy about the timing of when I press the Shift key before or after a space. So I won't be using this script myself (not that I need it - I don't like to code using names_with_underscores) but maybe others will find it useful. [1] AutoHotkey home page: http://www.autohotkey.com/ http://www.autohotkey.com/ [2] AutoHotkey_L: http://l.autohotkey.net/ http://l.autohotkey.net/ (minor edit for clarity)
- kibwen 14y agoThis tool looks really cool. I see what you mean about the spurious underscores... think I'll try it out for a day and see whether or not I can live with it. Thanks!
- cgag 14y agoAfter writing a decent amount of Clojure recently, underscores do seem ugly, but I think I find commas even more annoying. I can accept underscores for the reasons raganwald mentioned, but having to write [1, 2, 3] instead of just [1 2 3] bothers me more than it probably should.
- VMG 14y agoI noticed this too after using Coffeescript, going back to plain JS. It's especially annoying when shuffling array elements or function parameter around: all items need to be separated by a colon, except for the last one, that must not have a trailing comma, making line swapping a nightmare. Drives me nuts.
- vorg 14y ago> all items need to be separated by a colon, except for the last one, that must not have a trailing comma, making line swapping a nightmare Then use a language which allows trailing commas in lists, param-lists, maps, e.g. grOOvy
- deleted 14y ago[deleted]
- yaix 14y agoSorry, but when I read this article I was just thinking that some people seem to have just too much free time...
- radarsat1 14y agoMaybe it's just me, but I never notice issues like this. Some people want to completely optimize their experience, like when Vim users tell me it's better than Emacs because they don't have to reach for the cursor keys. I dunno. For some reason this super-optimisation of keystrokes doesn't bother me. Avoiding reaching for the mouse is good, but I don't particularly care if I have to hit shift.* Maybe I prefer to think more and type less, or something. I can't quite say. * Admittedly the French keyboard where all numbers in the top row are shifted, and symbols are unshifted, drives me kind of crazy, but that could just be due to hard in-grained training on an American keyboard layout.
- to3m 14y agoIt's like the difference between wearing silk underwear and hessian underwear. Or being able to code while listening to an audio book vs needing peace and quiet. It's not a question of thinking less, or thinking more, or being more careful. Some people can put up with this stuff, and some people can't.
- ta12121 14y agoI think the interpunct should be revived and used as a character allowed in identifiers. (http://en.wikipedia.org/wiki/Interpunct http://en.wikipedia.org/wiki/Interpunct)
- libria 14y agoReally just a matter of convention, and dash is too heavily associated with minus. A single underscore is a permissible variable name in some languages; in Go it has a special meaning (blank identifier). Would a single dash be as well? For example, how would you interpret i - - Is it i (minus) (variable named dash)? And is `i--` a legitimate variable name? Maybe Ruby doesn't have this construct, but then it would have a completely different naming contention from existing languages.
- ajanuary 14y agoFavouring dash over underscore to break words in variable names doesn't preclude using underscores in variables names ever. A sometimes used _ is okay. Its_using_it_almost_all_the_time_that_the_author_is_questioning.
- gnuvince 14y agoHate to break it to him, but parentheses require hitting the Shift key as well. Twice.
- idleloops 14y agoYeah and that's pretty horrible too...
- darklajid 14y ago"Underscores require me to hit the Shift key. When writing prose, I only hit the shift once or twice per sentence. In Ruby, I have to hit the shift key every few letters. Awkward. Inefficient." There are languages that survive in spite of the heavy use of uppercase letters, without useless complains like this. Let me repeat, in German: "Es gibt Sprachen die trotz starker Nutzung von Grossbuchstaben ueberleben, ohne ueberfluessige Beschwerden wie diese." Damn, I just broke my pinky..
- slantyyz 14y ago>> "Underscores require me to hit the Shift key. When writing prose, I only hit the shift once or twice per sentence. In Ruby, I have to hit the shift key every few letters. Awkward. Inefficient." That passage sticks out to me as well. Especially the "Awkward. Inefficient" part. Maybe the guy needs to learn how to type, because hitting shift for me is muscle memory that requires no thinking. That Grade 9 typing class in 1984 just continues to pay dividends for me.
- simias 14y agoWhat colour do you want your bikeshed painted today? I for one, don't like the "->" operator in C. It requires two characters and the use of the shift key. I would like that the next standard just used "." for all member access and let the compiler work its magic and guess what needs to be done. Of course that would break a sizeable amount of legacy code, but who cares about that anyway. The important is that the code looks good, especially if I enable drop shadows and anisotropic filtering in my editor.
- agscala 14y agoI like the arrow since it reminds me sometimes that I'm working with a pointer and not an object on the stack
- lclarkmichalek 14y agoPointers aren't always to objects on the heap, they can be pointing to locations on the stack as well.
- agscala 14y agoRight, but I don't know what you're disagreeing with since I never said that they only point to the heap.
- evincarofautumn 14y agoNot to mention that it’s a poor approximation of the → character.
- DeepDuh 14y ago"let the compiler work its magic." if you want that, use a higher level language. One of the foundations of C is that there is as little implicit behavior as possible. I'd hate to be left in the dark whether my . will now result in a pointer or a dereferenced value and I doubt it would even work for the compiler to figure this out in all edge cases.
- extension 14y agoTry binding shift-space to underscore. You'll start to feel much better about it.
- foxhop 14y agoBravo! Also underscores in uri strings look awful. this_uri_is_ugly.html vs this-uri-is-pretty.html I wish python allowed for dash in its script names... cannot import from module-test.py but I can from module_test.py Thank you for posting this, I "laughed-out-loud".
- idleloops 14y agoThe reason page uris aren't so good with underscores, is that you can loose them if they are displayed underlined as links.
- chris_wot 14y agoI program in Underscore, you insensitive clod!
- swah 14y agoTruly find-file is much more readable than findFile. IMHO. Also directory? vs isDirectory
- rmk2 14y ago> Underscores require me to hit the Shift key. When writing prose, I only hit the shift once or twice per sentence. In Ruby, I have to hit the shift key every few letters. Awkward. Inefficient. Oh my, oh my, how do people ever cope with that vile "having to hit shift" that have regular capitalisation of all nouns etc. Surely such a thing is impossible, as is hitting shift when you need an underscore. I understand that some things could be more efficient, but "hitting shift" hardly qualifies in my opinion...
- wvenable 14y agoI wonder how the author types all the brackets in LISP without the shift key. I'll take an occasional underscore over that mess any day.
- deleted 14y ago[deleted]
- ttt_ 14y ago>> I understand that some things could be more efficient, but "hitting shift" hardly qualifies in my opinion... I does qualify as something that probably contributes to Repeated Strain Injury which most programmers should worry about.
- idleloops 14y agoActually I think there is a speed and comfort issue relating to any symbol that requires key chording. To test this try using sticky keys for a while - it's much more comfortable - it seems to free up the fingers more. I use alternate hands when using the shift key, so that's not the issue. Perhaps it's just that I've got into a bad habit of depressing the shift key with a little more force and holding it for longer. With sticky keys I seem to dance off the keys better. If you have a number pad, perhaps it might be better to switch the number row with the symbols (i.e. don't use SHIFT to get to the symbol.) I think that's the default for French layouts.
- whatevr 14y agorepeat after me. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die lisp die. die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.die.
- darrikmazey 14y agoI for one love it when someone types whole paragraphs about the desire to avoid keystrokes. Every language has it's irritating quirks, none of which do I care enough to write about.
- RandallBrown 14y agoI don't really like underscores either. Leading underscores to mark member variables? That looks weird. A trailing underscore? Ugh, even worse because you can't use code completion to find all the member variables. With that said, who cares? Don't use them if you don't want to. It might be more inefficient, but typing speed has never been the thing that slows me down while I'm writing code.
- mxfh 14y agoI see them as the next best thing to having an actual non-breaking space, why all the hate?
- evincarofautumn 14y agoIt’s odd that the author does not mention the truly ridiculous thing about underscores: they are a holdover from typewriters, where they were used to provide underlining by overstriking. The fact that we now have beautiful proportional-width screen fonts that support underlining—and do not generally support overstriking—makes underscores unnecessary. And yet we insist that a programmer be able to write every modern programming language on a 50-year-old typewriter. You know, just in case.
- Boxer 14y agoMy only problem with underscores is that when I read them aloud in my head, I hear a longer pause than for a hyphen, so code with lots of underscores takes longer to read, or at least feels like it does.
- colomon 14y agoFor what it's worth, Perl 6 allows dashes in identifiers, and many of us working with the language have gleefully taken to using them instead of underscores. I can't tell you why it makes a difference, but somehow underscores now feel clumsy/ugly to me, despite two decades of happily using them in my C++ code.
- SeoxyS 14y agoWhile I agree with the sentiment, I have two points: 1) The goal of a programming language is to be as unambiguous as possible. This is why we have syntax, and do not program in english. As soon as you use the same token identifier for two purposes, you introduce ambiguity. Take markdown, for example: * Hello *world* In this line of code, which asterisk should be considered a bullet, and which an indication of emphasis? It seems obvious to a human, but codifying it in a set of rules for a computer is another matter, which introduces complexity and future bugs. (Eg., what do you do in this situation: `* Hello* world`. As somebody who is writing a full formal lexer for markdown, I can tell you first hand that it's an extremely annoying part of the specification.) Lisp does not have this problem, because it is governed by an extremely simple and effective set of rules: - An identifier can contain most unambiguous special characters, including - ! ? / + < > = etc. - There are no operators, only functions. - A hyphen by itself is a perfectly valid identifier. - The standard library includes a function named hyphen which performs a subtraction operation. Taking that into consideration, it makes the entire situation completely ambiguous. `a-b` is one identifier. `a - b` and `- a b` are both a string of meaningless identifiers. `(a - b)` performs function `a` with arguments `-` and `b`, and `(- a b)` performs function `-` with `a` and `b`. Ruby is actually interesting in that it is one of the few languages which, like lisp, does not have operators. You could remove ambiguity by doing `a.-(b)`. However, readability immediately goes out of the window. Much more so than in lisp's case. Consider this: (4.*(5)).+((7.*(9))./(3)).+(1) #<= the meaning of life It's semantically a perfectly valid expression, but how long did it take you to mentally evaluate it to 42? Compare with: 4*5 + 7*9/3 + 1 2) If you're going to be writing an article about it, please learn the right terminology. - is a hyphen. Dashes are – (en-dash) and — (em-dash). Hyphens separate contracted words. En-dashes indicate a range. Em-dashes indicate a aside, much like a parenthesis.
- devmach 14y agoI've got a feeling that HN crowd is lately loosing it's focus by spending it's time on "hipster" topics too much. Page long commenting on a fluffy article ( e.g "5 * 5 - 3" beats "5*5-3" ) may be good for your mind but imho, this thing should not be on the front page.
- aleyan 14y agoUnderscores are silly! We only use them in code to separate words in tokens because the default natural word separator, whitespace, is already used to distinguish tokens. At my old job, we had DSL that allowed and encouraged very descriptive variable and procedure names with space in them. To implement this unambiguously the language had to exclude all the operator characters from variable names and procedure calls with a sigil. A line of code may have appeared like this: line slope estimate = @some function( x - step size ) / ( x - step size); Feels a bit strange at first but quickly becomes natural, especially when dealing with wordy domains (math was a bad example).
- sbmassey 14y agoIdiomatic REBOL code avoids the shift key for its commonest syntax. Code grouping (where necessary) uses '[', ']'; multi-word variables are separated by '-'; etc.
- draegtun 14y agoDamian Conway provides some excellent insight/advice on underscores vs hyphens: Personally, I'd prefer to see the English conventions carried over to the use of general use of hyphen and underscore in identifiers in the core (and everywhere else). By that, I mean that, in English, the hyphen is notionally a "higher precedence" word-separator than the space (or than its intra-identifier stand-in: the underscore). For example: there's an important difference between: initiate_main-sequence_detonator_phase() and: initiate_main_sequence-detonator_phase() The former initiates the detonator phase for the main sequence; the latter initiates the main phase of the sequence detonator. More simply, there's a difference between: $obj1.set_difference($obj2); and: $obj1.set-difference($obj2); The first is setting a difference; the second is computing a difference-of-sets. The rule I intend to use and recommend when employing this new identifier character in multiword names is that you should place an underscore between "ordinary unrelated" words, and a hyphen only between a word and some modifier that applies specifically to that word. Which, if applied to Temporal, would lead to: my $now = DateTime.from_epoch(time); The C<day> method also has the synonym C<day-of-month>. (These are also available through the methods C<week-year> and C<week-number>, respectively.) There's a C<day-of-week> method, The C<weekday-of-month> method returns a number 1..5 The C<day-of-quarter> method returns the day of the quarter. The C<day-of-year> method returns the day of the year, The method C<whole-second> returns the second truncated to an integer. The C<time-zone> method returns the C<DateTime::TimeZone> object (i.e. only C<.from_epoch()> actually uses underscore). Oh, and the optional C<:timezone> argument to C<.new()> should probably become C<:time-zone> for consistency with the C<.time-zone()> method (or, preferably, we should jut bite the bullet and go with C<timezone> throughout). Damian From Perl6 mailing list: http://www.nntp.perl.org/group/perl.perl6.language/2010/04/msg33511.html http://www.nntp.perl.org/group/perl.perl6.language/2010/04/m...
- recurser 14y agoSwitch to a Japanese keyboard - none of the @ _ ; or : characters require the shift key.
- altrego99 14y ago> That’s a trade-off I’ll gladly make if it means using dashed identifiers instead of underscores. Not me. I would gladly trade off having to expand all my equations for having to type underscores a few times. In fact, this is very subjective - and one could argue having to sacrifice compactness of expressions is stupid.
- cheatercheater 14y agoDon't worry about underscores being difficult to type, just use a more ergonomic keyboard layout: http://bitbucket.org/cheater/us_split/overview http://bitbucket.org/cheater/us_split/overview It's just like qwerty, but with less pain.
- yuchi 14y agoA bit late in the wagon, but have a look at http://pogoscript.org/ http://pogoscript.org/