News for hackers. Stuff that matters.
Re:Why I Use Nim instead of Python for Data Processing by zmmmmm on Saturday September 25, 2021 @02:01AM (#28650877)
It's primarily a testament to how simply mind bogglingly slow Python is outside of its optimised numerical science ecosystem. Which also why I don't use it that much, because while numerical analysis is a big part of what I do, so is what I would call "symbolic manipulation" and unless you go to quite some effort to transform every problem into a numerical one, Python is just awful at that.

But Nim is only one of a whole suite of languages that easily cruise to a 10x performance win over Python. And that isn't counting multicore - if you count that you quickly get to a 100x improvement.

Personally I use Groovy for much of what I do for similar reasons (which is somewhat unusual) but its just a placeholder for "use anything except python".

Re:Why I Use Nim instead of Python for Data Processing by amyjess on Saturday September 25, 2021 @02:43AM (#28651028)
> It's primarily a testament to how simply mind bogglingly slow Python is outside of its optimised numerical science ecosystem.

From my experience in using Python at my last job, I'll also add that Python is decent at tasks that aren't CPU-bound.

I wrote a lot of scripts that polled large amounts of network devices for information and then did something with it (typically upsert the data into a database, either via direct SQL or a REST API to whatever service owns the database). All these tasks were heavily network-bound. The amount of time the CPU was doing any work was minuscule compared to the amount of time it was waiting to get data back from the network. I doubt Nim or any other language would have been a significant performance improvement in this case.

For what it's worth, that made these scripts excellent candidates for multithreading. I'd run them with 20+ threads, and it was glorious. At first I did multiprocessing, because of all the GIL horror stories, but multiprocessing made it very difficult to cache data, so eventually I said "well, all this is network-bound so the GIL doesn't even apply" and switched over to multiprocessing.dummy (which implements pools using the same API as multiprocessing but with threads instead of processes), and I never looked back.

Edit: For what it's worth, Nim sounds like a really cool language, and it's right up my alley in several ways, I just don't think Python is particularly slow at network-bound tasks that use very little CPU.

Re:Why I Use Nim instead of Python for Data Processing by m_mueller on Saturday September 25, 2021 @03:15AM (#28651165)
I agree with your entire post but, and I‘m saying this as a fulltime python dev, there‘s often a point where it starts being bothersome, and that usually comes only later in the lifecycle of an application after it had some organic growth. Some day e.g. a sales manager comes down to your lair and asks you if you couldn‘t just also parse this little 200MB Excel spreadsheet after it came over the network such that your ETL process could save it into a new table. And boom you‘re into CPU bound lands now. Often it‘s fine, you can wait those 1-2min for a daily occuring process. But what if for example you put this whole component behind a REST API that is behind a load balancer that is set with a certain timeout? There are even strict upper limits if for example you chose AWS Lambda for your stuff.

And suddenly you need to introduce quite a bit more technical complexity into this story that‘s gonna be hard to explain to management - all they see is that you now can insert a couple of millions of DB rows and their Big Data consultants[TM] told them that this is nowadays not even worth thinking about.

Point being: If your performance ceiling is low, you‘re gonna hit it sooner.

Re:Why I Use Nim instead of Python for Data Processing by rsyring on Saturday September 25, 2021 @10:44AM (#28653573)
> there‘s often a point where it starts being bothersome

My team and I have been using Python for web, scripting, and ETL development since 2007. I don't recall the last time Python wasn't "fast enough" for anything I needed to do. I'm sure it's legitimately too slow for plenty of use cases and classes of programming domains. But for a general purpose language that makes our developers incredibly productive (which is what we optimize for organizationally), I've not "often" found the point where it becomes bothersome. On the contrary, I'd say I've rarely found it. And in those cases, the workaround to make it fast enough is there.

That's not to dispute your experience. I just want to provide a counter example.

Re:Why I Use Nim instead of Python for Data Processing by akho on Saturday September 25, 2021 @02:42PM (#28655220)
Does Python give you an actual productivity edge? I do not see how.

Python developers are easier to hire (certainly than Nim), have a monolanguage experience (meaning less onboarding), but are not magically more productive. Developer availability is still a great reason to choose Python.

Re:Why I Use Nim instead of Python for Data Processing by m_mueller on Saturday September 25, 2021 @05:16PM (#28656241)
YMMV. My background is in financial applications and there it’s a quite common problem popping up, especially (but not exclusively) in analytics.
Re:Why I Use Nim instead of Python for Data Processing by DeathArrow on Saturday September 25, 2021 @04:02AM (#28651390)
>Point being: If your performance ceiling is low, you‘re gonna hit it sooner.

And that isn't the only culprit. Large code bases will be hard to structure, maintain and organize. And you will spend more time writing tests than writing productive code. Because you don't have many defenses against errors and because once a bug will hit production it will be very difficult to debug.

Re:Why I Use Nim instead of Python for Data Processing by m_mueller on Saturday September 25, 2021 @06:48AM (#28652073)
I somewhat disagree there. IMO you can structure a large application just as well in python as in Java, but it requires more architecture guidance as your degree of freedom is higher. Regarding testing, mypy and later python versions have been a big help there, I don't think it's much of a difference anymore and I'd take it over Node.js for that reason because the core language IMO is more consistent and strict and requires way way less outside dependencies. In fact the standard lib for me is the main reason to choose python today.

So for me it's really performance being the main thing to think about with python. If one anticipates tighter latency or throughput requirements I'd go for something else.

Re:Why I Use Nim instead of Python for Data Processing by someguy101010 on Saturday September 25, 2021 @01:33PM (#28654805)
Is there a problem with binding c or c++ to your python project in these situations?
Re:Why I Use Nim instead of Python for Data Processing by m_mueller on Saturday September 25, 2021 @05:08PM (#28656199)
The whole build gets quite complex. Numba is interesting but also still a bit limited in what it supports. There are no silver bullets and sometimes you can find a good fit, but IMO the JVM or C#/.net overall have a better story when it comes to write performance critical applications (but don’t need to get the last 20% such as HFT or HPC sims), as you can also find people on the market who understand how to do and maintain that more easily. There are tons of python devs but in my experience at least on European market their understanding of underlying systems tends to be limited.
Re:Why I Use Nim instead of Python for Data Processing by csmpltn on Saturday September 25, 2021 @03:17AM (#28651184)
> "I'll also add that Python is decent at tasks that aren't CPU-bound"

IO-bound tasks are almost by definition outside of your Python application's control. You yield control to the system to execute the actual task, and from that point on - you're no longer in control of how long the task will take to complete.

In other words, Python "being fast" by waiting on a Socket to complete receiving data isn't a particularily impressive feat.

Re:Why I Use Nim instead of Python for Data Processing by bmicraft on Saturday September 25, 2021 @02:01PM (#28654950)
The main point (I think) was that python is a viable language for many use cases that are not processing intensive, while also being very easy and quick to write which is often the most important thing.
Re:Why I Use Nim instead of Python for Data Processing by gpderetta on Saturday September 25, 2021 @04:04AM (#28651398)
In my experience, Python is so slow that it will make CPU bound tasks that have no business being CPU bound.
Re:Why I Use Nim instead of Python for Data Processing by otherme123 on Saturday September 25, 2021 @03:14AM (#28651163)
You have to be reaaaaaally slow to be beaten by a network. Also, touched by the OP, if it takes 3 hours to write some code that in Python takes only 1, or if the compile times are huge, Python can beat other languages in speed (that edge fades when the same program is used over and over again).

But as demonstrated, Nim is fast to write and fast to compile, so Python has little edge. Just it's huge ecosystem.

Re:Why I Use Nim instead of Python for Data Processing by baq on Saturday September 25, 2021 @05:29AM (#28651759)
> Just it's huge ecosystem.

self-contradiction at its best. kindly be reminded the same advantage was the only thing that kept Java alive for so long until it finally started to enter the XXI century a couple years ago.

you just can't discount an ecosystem, especially if its huge.

Re:Why I Use Nim instead of Python for Data Processing by curioussavage on Saturday September 25, 2021 @11:24AM (#28653832)
Exactly. Also I’m not impressed with a lot of the ecosystem. After getting more acquainted with many very important libraries I can see the poor quality and it’s scary. Grateful for the free tools but IMO there other Languages like go where more essential libraries and tooling are written by better programmers. Like actual professionals instead of hobby tier
Re:Why I Use Nim instead of Python for Data Processing by yellow_lead on Saturday September 25, 2021 @03:23AM (#28651219)
As other commenters point out, how can a language be fast in a way besides something CPU bound? You are saying it is fast when it's not doing anything. Not sure I understand.
Re:Why I Use Nim instead of Python for Data Processing by baq on Saturday September 25, 2021 @05:31AM (#28651762)
it's a shorthand for 'fast enough'. is it slow if nobody would notice if it was 10x faster?
Re:Why I Use Nim instead of Python for Data Processing by nerdponx on Saturday September 25, 2021 @05:42AM (#28651815)
You might want to look into async (asyncio or anyio) instead of or in addition to threads for network-heavy code. Async coroutines I find can be much easier to debug and develop than OS-threaded code.
Re:Why I Use Nim instead of Python for Data Processing by CraigJPerry on Saturday September 25, 2021 @05:27AM (#28651748)
The thing with Python is it's usually pretty easy to optimise quite impressively.

E.g. random example:

Sprinkle some cdef's in your python and suddenly you're faster than c++

https://github.com/luizsol/PrimesResult

https://github.com/PlummersSoftwareLLC/Primes/blob/drag-race...

25.8 seconds down to 1.5

Re:Why I Use Nim instead of Python for Data Processing by Jensson on Saturday September 25, 2021 @09:01AM (#28652832)
I've tried cython and it isn't competitive with C in real world cases. Cherry picking a case where it is competitive doesn't help your case. Its performance tend to be around the level of Java, another language people say is competitive or faster than C++ but in practice C++ is still twice faster than Java in most cases.

Still, getting Java level performance out of python is a huge improvement and should be enough for most cases.

Re:Why I Use Nim instead of Python for Data Processing by CraigJPerry on Saturday September 25, 2021 @02:18PM (#28655055)
Ahh my point was more that you can score a 17x performance boost with minimal effort rather than any absolute performance advantage over c++.

For a c++ comparison python would be much better pointing out the productivity advantage it has over the notoriously low productivity of c++ development - rather than competing on execution performance.

Re:Why I Use Nim instead of Python for Data Processing by PartiallyTyped on Saturday September 25, 2021 @01:58PM (#28654933)
There is also numba, which is very impressive in its own right, and also pypy, which supports features up to Python 3.7.

Some may consider Jax, and its XLA compiler, but unless you require gradients, numba will be significantly faster, an instance of this is available here [1].

XLA runs on a higher level than LLVM and therefore can't achieve the same optimizations as numba does using the latter. IIRC numba also has a Python to Cuda compiler, which is also very impressive.

[1] https://github.com/scikit-hep/iminuit/blob/develop/doc/tutor...

Re:Why I Use Nim instead of Python for Data Processing by stavros on Saturday September 25, 2021 @05:53AM (#28651851)
Apparently mypyc does the same if you have types in your code, though I've never used it.
Re:Why I Use Nim instead of Python for Data Processing by p7g on Saturday September 25, 2021 @11:20AM (#28653805)
> It's primarily a testament to how simply mind bogglingly slow Python is outside of its optimised numerical science ecosystem.

CPython's slowness doesn't boggle my mind at all. It's a bytecode interpreter for an incredibly dynamic language that states simplicity of implementation as a goal. I would say performance is actually pretty impressive considering all that. What _does_ boggle my mind is the performance of cutting-edge optimizing compilers like LLVM and V8!

At least there is a benefit to a simple implementation: Someone like me can dive into CPython's source and find out how things work.

Re:Why I Use Nim instead of Python for Data Processing by flohofwoe on Saturday September 25, 2021 @06:57AM (#28652106)
IME Python is pretty great as cross-platform scripting-, automation- and glue-language up to a few thousand lines of code. Essentially replacing bash scripts and Windows batch files or for simple command line tools that don't need the performance. It should be just one language in one's language toolbox though.
Re:Why I Use Nim instead of Python for Data Processing by nimmer on Sunday September 26, 2021 @08:03AM (#28660195)
> 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.

Re:Why I Use Nim instead of Python for Data Processing by sevensor on Saturday September 25, 2021 @09:14PM (#28657536)
> mind bogglingly slow Python is outside of its optimised numerical science ecosystem

Granted, but inside its optimised numerical science ecosystem, Python is, in fact, fast enough. If most of your program is calls into numpy, Python will get you where you need to go. In my experience, one scalar Python math operation takes about the same amount of time as the equivalent numpy operation on a million-element array. Linked against a recent libblas, numpy will even distribute work across multiple cores. So much for the GIL.

Re:Why I Use Nim instead of Python for Data Processing by nerdponx on Saturday September 25, 2021 @05:44AM (#28651822)
I often recommend PyPy for "non-numerical" data processing when performance matters.

Also, "awful" is too harsh. Probably 90% of Python code just doesn't need to be faster than it is.

Re:Why I Use Nim instead of Python for Data Processing by mattbillenstein on Saturday September 25, 2021 @03:46PM (#28655701)
I'd guess closer to 99%...
Re:Why I Use Nim instead of Python for Data Processing by gameswithgo on Saturday September 25, 2021 @06:52AM (#28652085)
Nim isn’t unique in its performance, but it “feels” a lot like Python making it a nice gateway drug for Python users to start wasting less electricity.
Re:Why I Use Nim instead of Python for Data Processing by IshKebab on Saturday September 25, 2021 @02:45AM (#28651040)
Yeah should really be "Why I don't use Python for Data Processing". I would consider Typescript as an alternative too which I'm sure would get a similar speedup.

Also I don't know how anyone could design a language in the 21st century and make basic mistakes like this:

> Nim treats identifiers as equal if they are the same after removing capitalization (except for the first letter) and underscore, which means that you can use whichever style you want.

If that's any indication of the sanity of the rest of Nim then I'd say steer well clear!

Re:Why I Use Nim instead of Python for Data Processing by matthiaswh on Saturday September 25, 2021 @08:23AM (#28652571)
I wish this tired, boring argument didn't derail every conversation that remotely mentions Nim. See: literally every past HN post with "Nim" in the title.

Nim's underlying, perhaps understated philosophy is that it lets you write code the way you want to write code. If you like snake case, use it. If you want camel case, sure. Write your code base how you want to write it, keep it internally consistent if you want, or don't. Nim doesn't really care.

(That philosophy extends far beyond naming conventions.)

What this avoids is being stuck with antiquated standard libraries that continue to do things contrary to the language's standards for the sake of backward compatibility (arg Python!) and 3rd party libraries where someone chose a different standard because that's their preference (arg Python! JavaScript! Literally every language!). Now you're stuck with screaming linters or random `# noqa` lines stuffed in your code, and that one variable that you're using from a library sticks out like a sore thumb.

Your code is inconsistent because someone else's code was inconsistent - that's simply not a problem in Nim.

Could Nim have forced everyone to snake_case naming structures for everything from the start? Well, sure, but then the people that have never actually written code in Nim would be whining about that convention instead and we'd be in the same place. After having actually used Nim, my opinion, and I would venture to say the opinion of most, is that its identity rules were a good decision for the developers who actually write Nim code.

Re:Why I Use Nim instead of Python for Data Processing by patrick451 on Sunday September 26, 2021 @09:59AM (#28660945)
> I wish this tired, boring argument didn't derail every conversation that remotely mentions Nim. See: literally every past HN post with "Nim" in the title.

This is a serious design flaw. It absolutely should be front and center when Nim is discussed.

> Nim's underlying, perhaps understated philosophy is that it lets you write code the way you want to write code. If you like snake case, use it. If you want camel case, sure. Write your code base how you want to write it, keep it internally consistent if you want, or don't. Nim doesn't really care.

I want to write code where "myFoo != my_foo". Evidently, nim doesn't allow that, so this argument seems pretty hollow.

> Now you're stuck with screaming linters or random `# noqa` lines stuffed in your code, and that one variable that you're using from a library sticks out like a sore thumb.

This is because we have crappy linters. If a linter can't tell that an identifier is camel case because it is third party, it's a bad linter.

> Could Nim have forced everyone to snake_case naming structures for everything from the start?

This would have been preferable to this madness.

Re:Why I Use Nim instead of Python for Data Processing by goodpoint on Monday September 27, 2021 @10:18AM (#28670929)
> then the people that have never actually written code in Nim would be whining about that convention

Spot on. I wrote plenty of Nim and the style-insensitivity is a feature and not a bug.

Not allowing the use of 3 different variables named userName, user_name and username only encourages readable and robust code.

Re:Why I Use Nim instead of Python for Data Processing by IshKebab on Sunday September 26, 2021 @03:26PM (#28663813)
> 3rd party libraries where someone chose a different standard because that's their preference

C & C++ don't have a standard style but Python and JavaScript definitely do. And Rust and Go and I would guess most projects. Find me a popular library in one of those languages that doesn't use the standard style.

Re:Why I Use Nim instead of Python for Data Processing by elcritch on Saturday September 25, 2021 @03:29AM (#28651246)
> Yeah should really be "Why I don't use Python for Data Processing".

Not entirely. Nim‘s benefit here is that it’s superficially similar enough to Python that’s it’s easy for people from that world to pickup and start using Nim.

> Also I don't know how anyone could design a language in the 21st century and make basic mistakes like this: > If that's any indication of the sanity of the rest of Nim then I'd say steer well clear!

It may seem like a design mistake at first glance but it’s surprisingly useful. It’s intent is to allow a given codebase to maintain a consistent style (eg camel vs snake) even when making use of upstream libraries that use different styles. Not including the first letter avoids most of the annoyance of wantonly mixing all cap constants or lower case and linters avoid teams mismatching internal styles. Though mostly I forgot it’s there as most idiomatic Nim code sticks with camel case. I’d say not to knock it until you’ve tried it.

The rest of Nim’s design avoids many issues I consider actual blunders in a modern language such as Python’s treatment of if/else as statements rather than as expressions, and then adding things like the walrus operator etc to compensate.

Re:Why I Use Nim instead of Python for Data Processing by rualca on Saturday September 25, 2021 @05:02AM (#28651653)
> It may seem like a design mistake at first glance but it’s surprisingly useful. > It’s intent is to allow a given codebase to maintain a consistent style (eg camel vs snake) even when making use of upstream libraries that use different styles.

That doesn't sound right at all. It sounds like a design choice aimed at achieving the exact opposite: inconsistency without any positive tradeoff in return.

> Not including the first letter avoids most of the annoyance of wantonly mixing all cap constants or lower case and linters avoid teams mismatching internal styles.

That does not sound right at all. At most, it sounds like the compiler does not throw errors when stumbling on what would otherwise be syntax errors, but you still have all the mismatches in internal styles and linters complaining about code and teams wasting time with internal piss matches, and more importantly a way to foster completely futile nitpicking discussions within a language community.

Re:Why I Use Nim instead of Python for Data Processing by IshKebab on Saturday September 25, 2021 @05:46AM (#28651828)
> It’s intent is to allow a given codebase to maintain a consistent style (eg camel vs snake) even when making use of upstream libraries that use different styles.

This doesn't make sense. For an entirely new language you can just have the entire ecosystem use the same style, e.g. like Rust does. Or even Python!

Re:Why I Use Nim instead of Python for Data Processing by hexo on Saturday September 25, 2021 @07:51AM (#28652387)
It actually makes a lot of sense. I personally don't want to touch .Net langs because of their PascalCase and camelCase coding style which I find very unfortunate arbitrary decision. And well, didn't really want to get into Nim because of camelCase but since I've learned about this feature I'm reconsidering again.
Re:Why I Use Nim instead of Python for Data Processing by maleldil on Saturday September 25, 2021 @10:45AM (#28653578)
Do you really dislike camelCase that much to avoid an _entire_ ecosystem because of it?

I prefer snake_case too, but avoiding a language because of a minor convention like that seems weird.

Re:Why I Use Nim instead of Python for Data Processing by hexo on Saturday September 25, 2021 @01:17PM (#28654690)
Only language where I can stand it is Haskell. camelCase is relatively ok, but PascalCase for non-types (i.e. function names) is a big no-no :)
Re:Why I Use Nim instead of Python for Data Processing by gilrain on Saturday September 25, 2021 @11:06AM (#28653721)
When there are so many excellent languages to choose among, a trivial distinction can almost be a relief.
Re:Why I Use Nim instead of Python for Data Processing by stavros on Saturday September 25, 2021 @06:18AM (#28651951)
I'd agree, if you want a consistent style, ship a formatter with your package manager, like Rust does with `cargo fmt`. If it's there by default, it'll quickly be a standard.
Re:Why I Use Nim instead of Python for Data Processing by aEverr on Saturday September 25, 2021 @08:41AM (#28652708)
there are many packages and maintainers of such who just dont give a damn about the formatter or the style, some people just *want what they want*
Re:Why I Use Nim instead of Python for Data Processing by stavros on Saturday September 25, 2021 @08:45AM (#28652719)
Sure, but there's a standard formatter, they become a small minority.
Re:Why I Use Nim instead of Python for Data Processing by aEverr on Saturday September 25, 2021 @08:53AM (#28652780)
and with style insensitivity they become a non-issue?
Re:Why I Use Nim instead of Python for Data Processing by stavros on Saturday September 25, 2021 @09:01AM (#28652830)
The compiler might not be sensitive to style, but *I* am.
Re:Why I Use Nim instead of Python for Data Processing by atom_arranger on Saturday September 25, 2021 @10:42AM (#28653551)
I guess the best thing would be having a formatter that can switch the style for you locally. I don’t think Nim has this currently, would be neat if they did.
Re:Why I Use Nim instead of Python for Data Processing by stavros on Saturday September 25, 2021 @09:05PM (#28657501)
I don't think most people care about a specific style, as long as it's consistent. That's why I love Black, we all disagree with it equally, but each for different reasons.
Re:Why I Use Nim instead of Python for Data Processing by benjamin-lee on Saturday September 25, 2021 @03:27AM (#28651228)
I actually use TypeScript/JavaScript a lot for this reason, especially for biological algorithms that I want to run in the browser. The developer tooling is also as good as you can hope for, especially when using VS Code. I actually wrote a circular RNA sequence deduplication algorithm in it just recently [1].

With respect to the identifier resolution in Nim, it strikes me as more of a matter of preference. Especially given the universal function call syntax in Nim, at least it's consistent. For example, Nim treats "ATGCA".lowerCase() the same as lowercase("ATGCA"). I do appreciate the fact that you can use a chaining syntax instead of a nesting one when doing multiple function calls but this is also a matter of style more than substance.

[1] https://github.com/Benjamin-Lee/viroiddb/blob/main/scripts/c...

Re:Why I Use Nim instead of Python for Data Processing by qwerty1793 on Saturday September 25, 2021 @04:34AM (#28651551)
That's great. However the method that you use to find the canonical representative [1] is quadratic (when the string has length N, there are N rotations and for each rotation you need to check N characters to determine whether this is earlier than the best on that you have found so far). For large strings you would probably want to switch to one of the linear minimal string rotation algorithms [2], for example Booth's Algorithm.

[1] https://github.com/Benjamin-Lee/viroiddb/blob/main/scripts/c...

[2] https://en.wikipedia.org/wiki/Lexicographically_minimal_stri...

Re:Why I Use Nim instead of Python for Data Processing by benjamin-lee on Saturday September 25, 2021 @04:51AM (#28651621)
You hit the nail on the head. This is just the lexicographically minimal string rotation with a canonicalization step. I have actually had this on my to-do list for a while. The truth is that the data set I'm applying this to is small (though I'm doing my best to change that by discovering new viroid-like agents) so the optimization has yet to become pressing. At some point, I'd like to spin this script out into a standalone tool but I'm not sure the demand is there yet.
Re:Why I Use Nim instead of Python for Data Processing by zmmmmm on Sunday September 26, 2021 @12:06AM (#28658316)
The main beef I have with the javascript ecosystem for data analysis is lack of multicore. Yes lots of things can be solved by converting multi-core to multi-process or using other workarounds but there are a whole class of problems where shared memory access makes a huge amount of sense.
Re:Why I Use Nim instead of Python for Data Processing by thewakalix on Saturday September 25, 2021 @03:10AM (#28651136)
How is that a basic mistake? I think having two distinct identifiers that differ only by case sounds like a mistake!
Re:Why I Use Nim instead of Python for Data Processing by otherme123 on Saturday September 25, 2021 @03:19AM (#28651196)
What I found useful is that even if some author uses snake in his library, it doesn't spread to your code, so you can still adhere to the standard.
Re:Why I Use Nim instead of Python for Data Processing by IshKebab on Saturday September 25, 2021 @03:29AM (#28651241)
Various programming languages (and file systems!) have had some form of case insensitivity and it always turns out to be an absolutely terrible idea:

* It makes searching for identifiers harder. For Nim you can't even use case insensitive search because of the underscore thing! Better practice your regexes.

* The case insensitivity rules are usually super complicated and don't apply to everything, so now it's an extra thing you have to mentally compute when coding. This is probably the biggest problem and I'm sure it has led to bugs, e.g. in SQL.

* Do you enjoy the tabs vs spaces debate? How about single quote Vs double quotes? Ugly inconsistently styled code? Well you'll love this!

* Unicode case insensitivity is actually really really complicated (this mostly applies to filesystems).

You're basically opening yourself up to an array of annoyances and gotchas for essentially no benefits.

I've literally never seen anyone use two identifiers that only differ by case, but if that were actually a big problem it could be solved just by making that illegal. You don't have to resort to the insanity of case insensitivity.

Re:Why I Use Nim instead of Python for Data Processing by haxscramper on Saturday September 25, 2021 @04:15AM (#28651441)
> Do you enjoy the tabs vs spaces debate? How about single quote Vs double quotes? Ugly inconsistently styled code?

Nim solved tabs/spaces debate by allowing only spaces. Single/double quote are also completely separate, so there is no inconsistency as well. About "inconsistently styled code" - due to style insensitivity, effects are not viral. If you depend on a library that uses `get_name` but your project adopted `getName()` your don't need to suffer.

> Unicode case insensitivity is actually really really complicated

Which is why nim only handles case insensitivity for ASCII identifiers and not Unicode. Which makes sense because 99.9% code is written in ASCII.

> The case insensitivity rules are usually super complicated and don't apply to everything

Quoting from the manual - "only the first letters are compared in a case-sensitive manner. Other letters are compared case-insensitively within the ASCII range, and underscores are ignored." Unicode is not handled in style-insensetive manner, so the rule is pretty simple.

> It makes searching for identifiers harder. For Nim you can't even use case insensitive search because of the underscore thing!

Technically true, but in reality this comes up so rarely, I didn't have any issues with this ever. Nim projects usually adopt camel/pascal case.

For some reason, people often assume that allowing style insensitivity instantly throws the whole language ecosystem in complete disarray and everyone starts writing code mixing every possible style of writing at once, swapping styles on every second identifier just for their amusement.

Re:Why I Use Nim instead of Python for Data Processing by IshKebab on Saturday September 25, 2021 @07:49AM (#28652376)
> so the rule is pretty simple

So it's only identifiers, what about keywords, compiler directives? And only ASCII characters... And it doesn't affect the first character randomly. Sure very simple.

> If you depend on a library that uses `get_name` but your project adopted `getName()` your don't need to suffer.

Yeah because nobody ever imports code from other projects, copy/pastes from StackOverflow etc. /s

> Nim projects usually adopt camel/pascal case.

So why do you need case insensitivity??!

Trust me this is a decision they will regret.

Re:Why I Use Nim instead of Python for Data Processing by haxscramper on Saturday September 25, 2021 @08:25AM (#28652581)
It does affect identifiers, built-in keywords and type names in the same manner, though it is completely beyond me why anyone would write 'tY_PE Position = tUPLE[x, y: iNt]'.

If we are going to dismiss any nontrivial behavior as "sure very simple" then sure, having two distinct incompatible ways to write get_name (or getName) looks better.

It does not "randomly" not affect first character. Most style guides for camel/pascal case treat first character differently, with types being capitalized and regular variables starting in lowercase. Making whole identifier style-insensetive would significantly reduce number of possible names. So this rule makes 'building' and 'Building' different, but at the same time does not differentiate between 'get_name' and 'getName'.

> Yeah because nobody ever imports code from other projects, copy/pastes from StackOverflow etc. /s

I don't understand your point (even considering /s) - if I do import code from my other projects or copy-paste it from somewhere it simply doesn't matter to me what style they used - I'm not required to fix copied code, or adapt to the style my dependencies use.

> So why do you need case insensitivity??!

If their code gets into larger ecosystem it will not affect anything else, or at least it's effects would be minimized. It is a win-win solution - library author uses their preferred style, I (and everyone else in the ecosystem) stick to common convention, and everyone bis happy.

> Trust me this is a decision they will regret.

I've been using nim for multiple years now, and I have never seen anyone actually regretting this. Of course, when new people come to the language they sometimes are really surprised by this, but rarely ever complain about this in the long run.

EDIT: forgot to mention that nim is more than a decade old language, and "decision they will regret" should have happened years ago, yet it does not seem to be the case.

Re:Why I Use Nim instead of Python for Data Processing by nimmer on Sunday September 26, 2021 @08:01AM (#28660177)
> 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.