Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I might add kebab-case to my current language project. From all the code I've written, I only found a handful of - operators not surrounded by spaces, so that ambiguity wouldn't bite me often.

Also, I wish the unary negation operator was more visually salient. `foo * -bar` is very different from `foo * bar`, but it's only a handful of pixels on the screen. I've thought about trying to render it as an em-dash or something. Didn't NASA lose a rocket over a spurious - sign?



Some languages use ~ for negation; wasting it (and other common chars) on bitwise ops is a waste in most languages that don't specifically target bit twiddling.

That said, have you considered making this outright illegal without explicit parentheses? I actually wish that more languages would require that any sequence of operators has the same precedence throughout; i.e. a+b*c would also be illegal. It's always a pain to remember the exact precedence rules, especially since they're not consistent across PLs, so I'd prefer any expression that is ambiguous to be explicitly disambiguated.


APL uses ¯ for negative numbers. - is a ambivalent function (it can work as a monadic or dyadic function)


Code is symbolic and not like a (western) written language.

Kebab-case and snake_case may seem to read better when looked at code like it would be written text, but they read worse than camelCase when looked at it in a symbolic way.

https://news.mit.edu/2020/brain-reading-computer-code-1215


I have a similar opinion on using the exclamation point for the NOT operator.

It can be very hard to spot sometimes, especially after an opening bracket - if(!something())

Of course its generally better to try and rename functions or refactor to avoid the negative if possible.



There are coding fonts that make the "-" look more like a minus than a hyphen. I know that Iosevka and its variants do.




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

Search: