6 ms·
I brought it up recently in the #nim irc channel, trying to get a good explanation. The creator still seemed to think it was a good idea, and I could not convi
by keypusher 11y ago
I brought it up recently in the #nim irc channel, trying to get a good explanation. The creator still seemed to think it was a good idea, and I could not convince him otherwise.
- scardine 11y agoYeah, I feel your pain. This is a deal breaker for me. My OS of choice for the last 25 years has a case sensitive filesystem, all the programming languages I learned (well, except PHP) are case sensitive, it is too hard to unlearn. BTW, PHP has weird case sensitivity rules. Case sensitive (both user defined and PHP defined): * variables * constants * array keys * class properties * class constants Case insensitive (both user defined and PHP defined) * functions * class constructors * class methods * keywords and constructs (if, else, null, foreach, echo etc.)
- dom96 11y agoWhy would you need to unlearn it? Simply write code as you would write it in a case sensitive language.
- scardine 11y agoI've been programming Python for a living for the last 8 years or so. In Python there is a convention for naming classes with `CamelCase` and instances with `snake_case`. I could do that in a case insensitive language, but I can't do this in Nim because it is not only case insensitive, it violates the "principle of least astonishment" by normalizing variable names in a way that makes `FooBar` equivalent to `foo_bar` or `F_o_O_b_A_r`. If you can't see the trouble with this, I rest my case.
- dom96 11y agoIf I understand you correctly, the convention is basically the following, right? class FooBar(): pass foo_bar = FooBar() The equivalent in Nim: type FooBar = object var foo_bar = FooBar() Compiles and runs perfectly fine. How can this be the case? Well, the identifier equality rules in Nim have changed a while back, to make the first letter of every identifier case sensitive. So, FooBar == Foo_Bar == Foobar, but fooBar != Foo_Bar.
- scardine 11y agoYou are right. Nim is not case insensitive anymore, it is case sensitive for the first letter. But in my defense, the last time I checked it used to be! Quoting from the wayback machine: > Nimrod is a style-insensitive language. This means that it is not case-sensitive and even underscores are ignored: type is a reserved word, and so is TYPE or T_Y_P_E. The idea behind this is that this allows programmers to use their own preferred spelling style and libraries written by different programmers cannot use incompatible conventions.
- klibertp 11y agoI can see potential problems, but have you actually tried it and found any problems in practice? And you can always just learn another naming convention. That's not hard. Almost every language comes with its own way of naming things. For me - I'm using really a lot of languages at the same time - it's actually helpful because it makes easier to tell which language I'm writing right now...
- kevin_thibedeau 11y agoCase insensitive identifiers have no bearing on using case sensitive file names. Nim's system is admittedly baroque but it is an attempt to have (mostly) insensitivity without breaking the most common forms needed for C-interop. Just use it as if it were a fully insensitive language, choosing unique identifiers, and the partial case sensitivity will rarely be a problem.
- phaylon 11y agoIs there a way to enforce a particular style across a project? From what I've read the abiliity for projects to be internally consistent, even with third party library usage, seems to be one of the big advantages of this design-wise. So if you had an optional setting somewhere that enforces it, it might help communicate the intention of the feature.
- progman 11y agoThere are actually good reasons to reject similar variable names in general. They are a no-go in scripting languages. Fortunately the Nim compiler catches typos. http://blog.codinghorror.com/the-case-for-case-insensitivity/ http://blog.codinghorror.com/the-case-for-case-insensitivity...