Hacker News new | past | comments | ask | show | jobs | submit login

http://code.google.com/p/anic/wiki/FAQ

> Q: Why are backslashes (\) used as language operators? Isn't that confusing, given they're used in other languages as escape characters?

> A: This is a valid point, but backslashes were chosen for a purely pragmatic reason; on virutally all keyboards, backslashes are very easy to type (requiring only a single keystroke). This is a handy property for backslashes to have because in ANI, you'll be typing them a lot!

> Incomers from other languages might be thrown off a tiny bit, but a programmer that's spent some time with ANI will quickly come to realize that there is actually never any good reason to end a line of ANI code with a syntactual backslash! If one insists on doing so anyway, they are writing ill-formatted code that would be confusing regardless of how backslashes are interpreted by the language. Thus, the backslash conflict is there in theory but irrelevant in practice.

> The usage of \ in the language syntax is a thought-out practical compromise, though the issue may be reconsidered in the future depending on programmer feedback.

To see what the backslash does, see the Pipes section: http://code.google.com/p/anic/wiki/Tutorial

Edit: I'm not defending these arguments, simply pointing out that the developers have put forth some reasons.




> on virutally all keyboards, backslashes are very easy to type

That's such a typical US-centric attitude. On (most?) European Apple keyboards, "\" is alt+shift+7 or some similar Vulcan death grip combo. Not exactly "very easy to type".


Yeah right, I guess the 100 millions or so French-speaking people don't amount to much. On French keyboards it's ctrl+alt+"<" (which is at the bottom left of the keyboard), or, when available "Alt Gr"+"\".

Going out of your way to produce such small and dubious improvement is always a bad idea imho.

If you really think C syntax is a pain point, the sanest thing to do is to go with textual keywords like in ruby or lua.


Sorry, I'm not the developer. I was just saying that the FAQ explains the choice of backslash, regardless of whether it is sane or not.


I understand that, my reaction was of course towards the developer explanation and not you.


> If you really think C syntax is a pain point, the sanest thing to do is to go with textual keywords like in ruby or lua.

Why?


Keywords are reasonable easy to type (I'm much faster typing plain text without special characters), simple to auto-complete and read very well. For example, they could have used something like "to" instead of "->", eg:

    "Hello World" to std.out
That's just an idea I had on the spot, not sure how it would play out. But I think this stream programming would actually lend itself well to some sort of literate syntax.


This is indeed what I meant. Typing "end" is, for me at least, way faster than typing "}". The reason is that "end" does not require modifier keys, and that all the letters are relatively accessible in the middle of the keyboard. (If you don't speedtype, this might not make as much a difference.)


Thanks for the elaboration. I might even agree about the typing, even though e.g. `end' requires one keypress more than } for me. But I find that punctuation stands out more. From a practical point of view, I prefer reading Haskell's

  \arguments -> body
to Scheme's

  (lambda (arguments) (body))
because it stands out more. What gives me as the reader an even better hint without getting in the way, is indentation. That's why I prefer that to e.g. curly braces for reading. (Writing, especially in non-programming editors, like a webform, is easier with explicit markers like `end' or } though.)


You do know that "\" doesn't even exist on Japanese keyboards, right? It was replaced by "¥" a long time ago.

If you were serious about making things easy, you'd look at all the common keyboard layouts (not just American ones) before choosing a "thought-out practical compromise" that is of dubious practicality.


How do you do escape sequences in C (or pretty much every other language)?


printf("Some message¥n");

DOS and Win9x were particularly disgusting: C:¥DIR¥SUBDIR¥README.TXT

It's regarded more as a necessary evil than anything else. Any language featuring it prominently will be unlikely to achieve much popularity in Japan.


The reason why that works is that it is not that the Japanese keyboard layout that lacks the backslash, but the Japanese character set. See (http://blogs.msdn.com/b/michkap/archive/2005/09/17/469941.as... for details)

Also, in C, you can just type ??/ instead of backslash.


So, as far as ANI is concerned, you could just do latch¥ - no problem ;-) though ugly.


What does Ruby do?


Sorry, not the developer. Just someone who read the FAQ.


They should really try that on a German keyboard. On mine, backslash is not even listed on the keys as an icon. (Same for Swedish, Norwegian, or Dutch, I think).


Then you have a non-standard keyword. Standard layout has \ on the same key as ß (the base letter) and ? (the shift variant).


How do you type paths in Windows? Do you use the forward slash instead?




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: