If syntax isn't important why does this feel so good...
I love syntax, waiting to grow out of it, but only going deeper.
I think there’s a lot to be said about the UX of textual programming & using what we can learn from visual design to help point us to the important parts of programs.
Syntax is one of those "mountains are mountains and waters are waters" sorts of things. For beginners, it really matters, then you get used to it, learn a bunch of languages, and care a lot less where the periods and parentheses go, but in the end it is the primary programming user interface and good syntax choices have a pleasing rhythm and rhyme.
Snake-case would have avoided the ambiguity, but is a little slower to type.
Is it? Did you measure? I did, and after five tries of typing with hyphens, my best time was 11% slower than the first try typing with underscores. Same reason as your reason to use dots for field accessors.
Underscores avoid not only the syntactic ambiguity, but also a linguistic one. Hyphens naturally occur in words such as “32-bit” and “self-reference”. Writing things like “address-of” and “do-twice” is grammatically incorrect. Underscores on the other hand have no other meaning than to separate words in tokens.
I have a suggestion of something that is better than underscores for real: Spaces. “ address of ” is so much nicer than “ _addressof ”, or even worse “ address-of ”. Spaces are also the fastest to type, as there is a large spacebar where the two strongest fingers are resting all the time, in contrast to the key for hyphens and underscores that requires an excursion with the pinkie.
“do-twice” is grammatically incorrect
Don't you mean in_correct? 😁
Something I've also been thinking about is whether you can see the tokens in your peripheral vision. Hyphens work quite well for this - they make identifiers look like one big blog. Underscores are a bit too separating.
Periods are also nice because they are visible like spaces but are not spaces, and it's nice to have two different kinds of spaces to play with.
Toying with the idea of reusing the .
for field definition to free up :
for ufcs.
foo/bar(key1: val1, key2: val2)
vs foo:bar(.key1 val1, .key2 val2)
“address of” is so much nicer than “address_of”, or even worse “address-of”.
That would make it pretty hard to spot where tokens begin and end.
std.child process.exec(
:allocator,
argv: ['deno', 'run', '--allow-read', 'test.js'],
max output bytes: std.math.max int(usize),
)
Nim has this funny feature where it doesn't matter if you use snake case or camel case. The identifiers my_variable
and myVariable
refer to the same thing! Feels somehow wrong to me but maybe it's better for beginners
That would make it pretty hard to spot where tokens begin and end.
In my experience, spaces between tokens make it clear: std .child process .exec
I'm also using a a variable-space font, so “std.child_process.exec” and “std.child-process.exec” also have too little space between the tokens in comparison to the big underscore or hyphen within the token.
“Where a number of issues are being taken into account in a design decision, inevitably the ones which can be most clearly expressed carry the greatest weight, and are best reflected in the form. Other factors, important too but less well expressed, are not so well reflected. Caught in a net of language of our own invention, we overestimate the language’s impartiality. Each concept, at the time of its invention no more than a concise way of grasping many issues, quickly becomes a precept. We take the step from description to criterion too easily, so that what is at first a useful tool becomes a bigoted preoccupation. […]
In this fashion the selfconscious individual's grasp of problems is constantly misled. His concepts and categories, besides being arbitrary and unsuitable, are self-perpetuating. Under the influence of concepts, he not only does things from a biased point of view, but sees them biasedly as well. The concepts control his perception of fit and misfit- until in the end he sees nothing but deviations from his conceptual dogmas, and loses not only the urge but even the mental opportunity to frame his problems more appropriately.”
— Christopher Alexander. > Notes on the Synthesis of Form > . Chapter 5: The Selfconscious Process.