←back to thread

650 points Stratoscope | 7 comments | | HN request time: 0.784s | source | bottom
1. psychoslave ◴[] No.43503594[source]
If you are looking for alternative to kebab case to write identifier in programming language which reserve the - (U+002d) as an operator, chances are good you can use · (U+00B7 · MIDDLE DOT), that we use in middot case.

So isMorePleasantToRead, is_more_pleasant_to_read or is·more·pleasant·to·read is up to you.

replies(2): >>43503658 #>>43504170 #
2. nlitened ◴[] No.43503658[source]
But how pleasant is it to write?
replies(1): >>43504061 #
3. psychoslave ◴[] No.43504061[source]
On the bépo layout that I use, extremely well, as it sits between ’ (U+2019 ’ RIGHT SINGLE QUOTATION MARK) and ‑ (U+2011 ‑ NON-BREAKING HYPHEN), each being generated by altgr+shift and x . and k (which are all on the opposite side of the keyboard compared to altgr key).

At least from the point of view of digital gymnastic, it’s not really any worst than camel or snake cases, though direct access to dash could be said to give a small facilitation for input in kebab case.

So it really depends on the keyboard layout used (or whatever input device facility is used). What’s you favorite input method lately? Does it really doesn’t provide a convenient way to input more than ASCII visible glyphs?

Plus, let’s be honest, identifiers are generally written in full expanse only once, then autocompletion is going to do it for us. And we all know we spend more time reading identifiers than declaring new ones.

4. thomasjb ◴[] No.43504170[source]
This is intriguing to me, do you know which (programming) languages tolerate this?
replies(2): >>43505478 #>>43508388 #
5. psychoslave ◴[] No.43505478[source]
Python

    python3 -c "some·identifier = 0; print(some·identifier)"
C

    echo -e '#include <stdio.h>\nint main() { int some·identifier = 0; printf("%d", some·identifier); return 0; }' | gcc -x c -o temp - && ./temp
C++

    echo '#include <iostream>\nint main() { int some·identifier = 0; std::cout << some·identifier; return 0; }' | g++ -x c++ -o temp - && ./temp
Ruby

    ruby -e 'some·identifier = 0; puts some·identifier'
Javascript

    node -e 'let some·identifier = 0; console.log(some·identifier);'
Rust

    echo 'fn main() { let some·identifier = 0; println!("{}", some·identifier); }' > temp.rs && rustc temp.rs && ./temp 

Go throw an invalid character U+00B7 '·' in identifier

Java throw error: illegal character: '\u00b7'

C# is really annoyed with it apparently:

    echo 'using System; class Program { static void Main() { int some·identifier = 0; Console.WriteLine(some·identifier); } }' > Program.cs && mcs Program.cs && mono Program.exe

Program.cs(1,60): error CS1056: Unexpected character `·' Program.cs(1,60): error CS1525: Unexpected symbol `identifier', expecting `,', `;', or `=' Program.cs(1,99): error CS1056: Unexpected character `·' Program.cs(1,99): error CS1525: Unexpected symbol `identifier'

That’s it for the top in TIOB index I tested in the frame of this message.

replies(1): >>43506903 #
6. thomasjb ◴[] No.43506903{3}[source]
Thank you very much for testing it! I'm plugging away on Advent of Code 2015 in C, I'll give this a go to see if I like it
7. steveklabnik ◴[] No.43508388[source]
The reason this works in Rust is that Rust follows Unicode's categorization of which code points are useful as identifiers: https://www.unicode.org/reports/tr31/

MIDDLE DOT is Other_ID_Continue

I know less about the other languages but it wouldn't surprise me if they did similar things.