Hacker News new | past | comments | ask | show | jobs | submit | more nimmer's comments login

This is exactly what Nim does. If you try to define both my_var and myVar it will error out.

The benefit is to avoid confusing variables or procs named my_var, myVar and myvar.


If you define them both yes, but you're still free to use them both.

  var my_var = 1
  myVar += 1
  echo(my_var)
Will happily compile and give you 2. I'd prefer an error in that case because while I'm not liable to make that mistake but I could easily mistype long_variable_name as long_variablename without noticing and then cause myself problems when I try to grep.


  nim --styleCheck:error c x
This enforces the same capitalization style in your code:

  x.nim(1, 5) Error: 'my_var' should be: 'myVar'


Searching has never been a problem for me in years of using Nim but there is `nimgrep` bundled for style insensitive search. Also I'm no RE wiz, but seems like RE might help if it came down it.

Just to stress myself as an anecdote though, I have years in the language and it hasn't come up yet for me, and I've never needed to use `nimgrep`.


You can use --styleCheck:usages or a linter to ensure that the style is uniform.

You cane enable styleCheck:usages by default in the compiler. Also, most editors do variable/proc autocompletion.

Also you can use nimgrep if have to search across projects written by different people.


Style 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.


I 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.


In math, most variables are a single letter, so style sensitivity wouldn't really apply.


If 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.


The 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?


Dubious 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>


> 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.


Not a nim user, but I wonder if the styleCheck:error or styleCheck:usages compiler flags would do what you're asking for.


> 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.


For me the biggest potential issue seems grepping probably. I guess that some other tool than ag, grep, etc has to be used for searching.


You can use --styleCheck:usages or a linter to ensure that the style is uniform.


> A lot of previous contributors

Not really. The fork looks pretty dormant.


I think better phrasing would indeed be something like "several former core developers" - of course we can't really measure up to the size of the original community, and don't yet have any paid developers (like Araq and narimiran [1] in the mainline - although since the end of September there were not a lot of activity on their part as well - [2] ~30 commits (~23 that are marked `[backport]`) and even less [3] for narimiran)

[1] https://forum.nim-lang.org/t/8540#55418

[2] https://github.com/nim-lang/Nim/commits/devel?author=Araq

[3] https://github.com/nim-lang/Nim/commits/devel?author=narimir...

Right now, it seems like most of the work on the mainline seems to be done by community members.


Nim uses GCC and works very well. Nim is among the fastest languages both in runtime and compilation time also thanks to GCC.

GCC supports way more architectures than LLVM.


Clearly you never tried converting existing Python to Nim. It's quick, feels natural and you get idiomatic Nim.

You can even use objects named "self" to ease the transition.

https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programm...



> How would I convince my employer to let me use Nim instead of a better known language?

This is a rephrasing of "nobody ever got fired for buying IBM".

Some organization prioritize innovation and technical acumen.

> So having a nice, performant and good language is just a small part of achieving your goals. You also need the people and the ecosystem.

Many applications don't need a large ecosystem. People can learn.

> Go, Rust, Kotlin, Swift and even Julia have the luck of having some industry heavyweights behind them

Python was never corporate-driven, thankfully, and it is successful.


> It's primarily a testament to how simply mind bogglingly slow Python is

No, Nim is truly among the top fastest languages when writing idiomatic code as shown in many benchmarks.

> But Nim is only one of a whole suite of languages that easily cruise to a 10x performance win over Python

...while also being very friendly to Python programmers, intuitive and expressive. Unlike many other languages.


> For Nim you can't even use case insensitive search because of the underscore thing! Better practice your regexes.

Not at all, unless you decide to mix different styles in the same codebase.


Nim targets all the architectures that GCC targets, including less common microcontrollers.


Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: