4 ms·
It actually is something that gives me pause for thought. In my field of coding (finance) ambiguity is terrifying and eventually you get it wrong. Maybe it's n
by rich_sasha 5y ago
It actually is something that gives me pause for thought. In my field of coding (finance) ambiguity is terrifying and eventually you get it wrong.
Maybe it's not so bad in practice, but looking from the outside, I think... really? To be specific, case-insensitivity doesn't bother me, but the automatic conversion from camel-case to snake-case... very much so.
- nimmer 5y agoStyle insensitivity is a safety feature, not a problem. It prevents bugs where a developer mistakes one variable or proc for another having similar names. For example in another language you might have variables isReady, isready, is_ready and use the wrong one, leading to a bug. Nim does not allow defining 3 different variables like that.
- rich_sasha 5y agoIf it stopped at disallowing the similar names, I'd think it is quirky but fine. A little unusual but harmless, maybe even helpful as you say. But that I can, and other people's code can, refer to the same thing by different names, is a bridge too far. Like I say, it won't deter me from trying the language, probably (I've been saying it for a while), but certainly doesn't make me more keen to try it.
- PMunch 5y agoThe nice thing about being able to run others people code with your style is that your entire codebase stays in one consistent style. You don't run into issues like in other languages where one library author has done some dubious style choices which then propagates into your code. This was always a pain-point for me in Python. And I'm not certain what scenarios you envisage where this would be an issue, why do you care how other people call your functions?
- rich_sasha 5y agoDubious decisions in third-party libraries are common, but camel vs. snake case is probably not the main... I care about how a function is called because so much tooling around programming is effectively grep. I can grep for a function name and get a pretty good idea where it is called. There's also a million variants of grep - git grep, unholy regular expressions (recently I used one to find all instances where foo is called with exactly 2, not 3 params, in Python), IDE plugins and so on. GitHub search? Google search for exceptions? IIRC Nim comes with some kind of "nim-grep" that is camel-vs-snake-aware, but that doesn't fix all the other tools. The minor gripe, additionally, is that you often have quasi-singleton classes called "FooManager", then a single instance called "foo_manager". Now... are these colliding? Or not, because the first letter _is_ case-sensitive? What does "fooManager" map to then? In my utility function, this feature gives me nothing but concerns. But then again, I'm not (yet?) a user the Nim community provides for so... <meh>
- arc776 5y ago> you often have quasi-singleton classes called "FooManager", then a single instance called "foo_manager". Like this: type FooManager = object var foo_manager: FooManager > Now... are these colliding? Or not, because the first letter _is_ case-sensitive? Well as you correctly reason, the first letter's case distinguishes them. Convention in the language is for types to start with a capital letter and instances start with a lower case letter. > What does "fooManager" map to then? It maps to the `foo_manager` instance because underscores are ignored, they're just for you. By the way, underscores are exceedingly rarely used in Nim code because they're not semantically significant, why bother. Still, if you like you can use them in your code, and others can choose not to as they want. Clashing identifiers are a compile error so no worries.
- JackC 5y agoNot a nim user, but I wonder if the styleCheck:error or styleCheck:usages compiler flags would do what you're asking for.
- arc776 5y ago> other people's code can, refer to the same thing by different names They can but the compiler will just tell you it's ambiguous and to qualify it. Also bear in mind Nim has very strong static typing, so for things to clash they also have to have exactly the same type, otherwise no worries. You can even rename symbols on import or force qualification for all symbols, but I've never needed to do either in years of heavily using the language.
- RafaGC 5y agoFor me the biggest potential issue seems grepping probably. I guess that some other tool than ag, grep, etc has to be used for searching.
- nimmer 5y agoYou can use --styleCheck:usages or a linter to ensure that the style is uniform.
- derbOac 5y agoI love Nim and wish it would take off and become as common as python. Case sensitivity isn't affecting that for me. But it still really irks me. There are times when you might want to use the same variables in different cases (math), and the assumption that you wouldn't seems like nannying to me. Also, fundamentally, it's a very english-centric view and encourages that by default. I'd prefer case assumptions weren't implicitly baked into the language at a basic level. I guess for me I just feel like a character is a character and I don't want the language telling me I should view it differently.
- xigoi 5y agoIn math, most variables are a single letter, so style sensitivity wouldn't really apply.
- deleted 5y ago[deleted]
- PMunch 5y agoYou must remember that Nim is a statically typed compiled language with support for distinct types etc. This means that you wouldn't be able to call the wrong procedure if you didn't provide it the right types. Besides, not allowing similarly named but differently cased identifiers causes less ambiguity, not more.
- rich_sasha 5y agoI mean, it really might be fine. I've written maybe 20 lines of Nim in my life, what do I know. I just look at it and see a foot and a gun pointing at it. The arguments for it sound to me like "it's fine, there's a safety and a clever mechanism that prevents shooting yourself in the foot". Maybe it's all fine, but I'd for one feel more comfortable if the gun wasn't pointing at the foot in the first place.
- PMunch 5y agoYeah I can see how it might seem scary. It takes you out of your comfort zone and it's easy to start thinking uncomfortable things have to be scary. I've been using Nim for a couple of years now, and I've never run into a safety issue with it.
- rich_sasha 5y agoI'm all up for new, exciting, slightly scary but promising concepts in programming. Rust's borrow checker. Python extremely-dynamic syntax. Nim's "Python syntax, native code, GC" premise. Exploring different ways to write the same name does not excite me.
- travv0 5y agoReading through the GitHub issue, it seems like the one place it makes sense in my eyes is that you can refer to stuff in external libraries with your convention even if the library uses a different one. I'm not sure if there's something I'm not thinking of, but to me it'd make sense if the library boundary was the only place it let you do it.
- arc776 5y ago> the automatic conversion from camel-case to snake-case... very much so. If an identifier clashes, you get a compile time ambiguity error. It means `is_OK` and `isOk` will report ambiguous identifiers and force you to qualify it or rename it. This also helps further reduce ambiguity indirectly by forcing sensible naming.