Nim in 2018: A short recap
nim-lang.org
nim-lang.org
For those of you who haven't tried the language out, I highly recommend it. I have even been suggesting it to students who want to get out the mainstream language bubble (C++, JavaScript, Python, etc.) so that they can learn something different. They have really liked it!
a lot of newer crypto/utility/math libs from the status-im people
NimTorch: a new Nim ML framework
improvements in the other ML libs( Arraymancer, Neo etc)
high level wrappers / DSL-s for a lot of existing
libs/api-s web dev libs/DSL-s
pattern matching libraries
and a lot more that i am probably forgettingIt just feels like a list of what happened, rather than a summary of how Nim progressed in 2018...
But that’s an important Nim philosophy - do not put into the language things if you can efficiently and nice-syntaxly implement them in a library. Once pattern matching is sufficiently mature - if it is too slow as a macro library, or the syntax too cumbersome - it will likely find its way to a core language feature.
But if it’s good enough, it will stay a library (possibly, but not necessarily, part of the standard library); why burden the language?
There is also https://github.com/krux02/ast-pattern-matching (optimized for usage in macros / metaprogramming)
Yes: they all use the macro system, but this is a good thin IMO: it's better to leave the core language simpler and to build such abstractions on top of it.
* A return variable within procedures that works in the same fashion as an assembly routine with a registry
* Mutable strings
* Mutable everything
* Hate speech against functional concepts in the community (with all the related biases that this brings)
* Some arrogant community members were tolerated just because they wrote popular blog posts on Nim implementing a fashionable pet project.
* no clear consistent design direction
* too many pragmas
* too many pascal syntax mixed with other language syntaxes
* no module namespacing
* modules worked not much better than C libraries... (I am generalizing)
* poor ecosystem made out of incomplete mutable libraries
* python 3 (without any library or optimization) was faster than compiled nim to count words on a moderately large text.
After I realized about python was easily beating Nim in spead and readability only with the standard library without any optimisation on python's side (and Nim being fully compiled), my interest on Nim went down to 0. I thought there were other places were I thought I could better invest my time.
Did something from that list changed? is there any reason to look at Nim again in 2019? did someone here had a better or different experience than mine?
EDIT: format, reworded sentences, expanded opinions
I would like to add 2 more things:
- there are at least 3 incomplete logging and http server libraries (please provide documentation if you want anybody to use your library)
- documentation is not always clear how to use the language
- This is true and there are plans to improve it, if you have any feedback on what could be clearer, you can share your thoughts here: https://forum.nim-lang.org/t/4523
Do you still have examples around? I haven't used Nim yet, but it could be interesting to take a look at something like this to understand what happened.
The implementation was quite straight forward in both languages: count words and then some statistic counting. It made me think that Nim will end up making me think all the time in the CPU and the compiler in the same way I did when I programmed C (and still high level languages beat the things by achieving much faster cleaner designs/prototypes/high level patterns, etc).
To be fair in my initial criticism, I guess a highly skilled Nim developer could beat python on a restricted environment, and in high level async processes both might differ in less than 1% in performance matters; but my code was really trivial and a straight forward iteration.
are you trolling?
> Some arrogant community members were tolerated just because they wrote popular blog posts on Nim implementing a fashionable pet project.
for example?
> * A return variable within procedures that works in the same fashion as an assembly routine with a registry
Not sure I see the parallels between assembly and I don't understand why you think this feature is negative, can you elaborate?
> * Mutable strings
I love these! No need for messing around with `StringBuilder` and the like.
> * Mutable everything
That's simply false. You can choose between mutability and immutability, in fact you can even have an immutable `string` if you really want one: `let x = "asd"`.
Now let me discuss some of your other points:
> * Hate speech against functional concepts in the community (with all the related biases that this brings)
Communities are large. A lot of us love functional programming and are bringing more and more of it into Nim.
> * Some arrogant community members were tolerated just because they wrote popular blog posts on Nim implementing a fashionable pet project.
Can you elaborate on who this was and how/where they were tolerated?
> * no clear consistent design direction
> * too many pragmas
> * too many pascal syntax mixed with other language syntaxes
These are mostly subjective so there isn't much I can say. Perhaps Nim just isn't for you due to its syntax, but many out there love it.
> * no module namespacing
> * modules worked not much better than C libraries... (I am generalizing)
This is false too. Every imported module is in its own namespace.
> * python 3 (without any library or optimization) was faster than compiled nim to count words on a moderately large text.
Did you compile with -d:release? :)
> I love these! No need for messing around with `StringBuilder` and the like.
D has immutable strings and no StringBuilder. Same with Python. Concatenating isn't exactly hard.
They are not arrays of characters until you use ASCII/KOI8 or similar encodings. So there is no point in mutating them, you need unicode normalization facilities, formatters and stuff to deal with them properly. And a proper mutable unicode string would give you a terrible performance penalty.
It's also what allows Python to do interning of strings, since they can't change.
let foo = someValue
var bar = someOtherValue
yields an immutable foo and a mutable bar for all types except strings.I'm guessing that's a detail that's lost on folks who haven't spent much time with Nim, because the way mutability and immutability work in Nim is different from how it works in any mainstream language.
The disastrous handling of the transition python2 to python3 with UTF-8 string and the idiosyncratic nonsense like " ''.join([str1, str2]) to concat anything speaks for themselves.
Python 2 had several shortcomings, but not with strings I think. The transition to python 3 is more more a matter about a migration execution rather than a technical aspect related to strings (which I don’t find that terrible, especially given all facilities provided to make the migration easier to the new incompatible runtime).
That's political talk. In practice I never have seen a python library that do not blow up when migrated in Python 3 with a Unicode related error, because one of the dev was using python2 string as binary vector.
By having mutable strings you lose the chance of relying on them as hashable objects and constant cost for comparison and several memory optimizations for duplicates and other optimizations when you have a runtime. There is a lot to win in the big game (or perhaps not that much if someone is thinking too much into a constrained system).
mutable string: a buffer made of chars which can be modified on demand with little memory
immutable string: some abstract data which ensures some properties that can be leveraged for many purposes
For example, I cannot tell what compilation option I used but I remember I went for the max speed I could and that I used default Nim language constructs and default python constructs (no libs), the compilation was one of the most sold features so I believe I used the release mode and that there was a marginal difference in favouring of python (subsecond). Think However that python has also many optimizations for string manipulation and that under the cover all runtime objects are references whereas in compiled languages developers are naked in front of the CPU.
Knowing that you are core-dev I must say that building a language is very hard, and that by not bringing much to the state of the art and overselling too early it is easy to get compared and valued by subjective aspects or mere impressions. Heads up, keep it with the great work and do not take it personally, make the language shine in some unique aspect.
Also do not forget that my comment was just an unfavourable opinion based on some observations I made years ago; I could change my opinion on the language anytime and give it again a chance if it brings me any benefit for my development, or it is fun, or it has some solutions for the problems I need to solve.
Thanks for answering.
That said, I do agree with GP's first point, and can at least elaborate on it from my own perspective: At first I liked the implicit `result` variable, mostly just because it saved some typing. I quickly found it to be a source of confusing bugs, though, because accidental mismanagement of the feature would result in default values being implicitly returned rather than compiler errors. I think I ultimately agree with the Zen of Python here: Explicit is better than implicit.
Also, Nim has, by my count, three different ways of returning a value from a proc: The implicit `result` var, returning the value of the last expression, and explicit `return` statements. It has four if you count modifying ref arguments. That's pretty TMTOWTDI for my tastes.
import os
then both existsFile("test.txt")
and os.existsFile("test.txt")
will work whereas I prefer Python's forcing you to use the later. Nim is definitely a language for small teams where you can expect everybody to agree on sensible best practices and not get too clever.You should definitely give Nim another shot. It has been very pleasant to use.
> I love these! No need for messing around with `StringBuilder` and the like.
But if I get a string passed to me and want to hold on to it for later use, I can't be sure that someone else holding a reference to it won't modify it after I got it, right? So I will have to make a copy to be safe. Or does Nim solve this somehow?
I've never heard "hate speech" against functional concepts: I've worked on functional-ish/pattern matching libs and i know other people from the community that love functional lang ideas. However those ideas are not as prevalent as in functional languages tho(obviously).
I'd say a lot of those points are very subjective(syntax/pragmas/modules etc). It's true that the ecosystem is still small and documentations is not good enough sometimes: this is something that probably can't change without a stable 1.0 first(and serious doc efforts started last month).
"Hate speech against functional concepts" was a metaphor for repetitive comments without foundation against some concepts and highly respectable design choices, where I often saw people pretending these to be dumb without really discuss the points properly, or exploring choices or constructs without acknowledging any single good thing from it. You can consider that a subjective, generalized opinion if you want.
Think that "that functional approach" has a lot to borrow from, even when still working within a mostly imperative language. Perhaps it is not a true red flag but in my eyes it was an involution. Totally subjective if the focus of the language is becoming a better and more advanced C (rival of Golang for example)
Please, at least realize what you have done, and don't do it again. Please.
If you feel my metaphor is hurting that's because you feel targeted there in some way, but here everyone is adult enough to build their own opinions and look by themselves there. If my comment made it to the top it is because it was upvoted in spite of having the way of use the language I have and the way my opinions are. That wasn’t the first comment when I wrote it.
I hope you realize what you are doing censoring people's opinions based on your subjective judgement of everyone else’s possible reactions, discarding people’s own judgement.
Saying that a community could die because of a negative opinion online is senseless, precisely because truly injust opinions positively reinforce groups by creating a feeling of resistance and victim identification. But my opinion was honest and metaphors are just a way of using language.
Anyway, I respect mostly all opinions but censorship. And in regard on whether somethign is hate speech or not... really, criticize an abstraction, not even an object, who could take that sentence in a literal way and interpret it by the word? You are drowning in a glass of water (yes, that's another metaphor, just in case).
And about the votes; not sure how you deal with it, but I take it easy with the downvotes, I won't censore my opinions because of them; and at the end of the day not really much people cares about other's opinions let alone votes, karma or reputation in an anonymous forum. If someone was decided to use nim they will give it a try by themselves anyway.
Wait, how? I just stated the fact as I perceived it - most of your posts were in various shades of gray. That's it. I didn't say anything about you, personally, which is what 'ad-hominem' would be.
> lobbies that want to promote their solutions in order to sell them to the Hacker News audience.
I'm not involved in any way with any of such lobbies in general, nor with the Nim community in particular. What I'm interested in is the quality of the debate on HN.
> I won't censore my opinions because of them
I can't understand why do you insist that I wanted to censor your opinion. I object to one particularly stupid way of phrasing that opinion. Had you written something like "some members of the [Nim] community seemed to be dismissive or even hostile to the ideas of functional programming" - I wouldn't have said anything! It's the same opinion, and it would cost you nothing to think for a bit and consider your phrasing a bit more carefully. I would even give you a benefit of a doubt if you used quotes around "hate speech", giving a hint that it's a metaphor - but you didn't, you played it straight, and I don't understand why. Is inserting quotation marks that much of a hassle to you? Is it that you don't understand, or perceive, the difference between 'hate speech' and '"hate speech"'?
As for the "usage of language" being subjective - sure it is. While they are subjective, there are norms and rules to follow, depending on the time and place. Imagine yourself farting loudly on a family gathering, then insisting that you're entitled to do just that because it's the way you express yourself and not doing it would be censorship. Yeah, you would be right, actually, but do you honestly expect people around you to just accept the stench?
I would like to ask to simply refrain from such farting, metaphorically speaking. As I already said, accusing a community of tolerating hate speech of any kind is a very serious thing and shouldn't be done lightly. It's similar in weight to saying that someone is a Nazi, or racist, or misogynist, or a terrorist. Would you like to be called a terrorist, even if it was said metaphorically?
To summarize: I'm not talking about the content of your opinions - arguing with them is a separate matter - only about the way you phrased them. I don't want to censor your opinions. I do want to censor the "usage" of the language which is harmful to the quality of debate (and, potentially, to the community in question). I believe you that you didn't intend to use the language in such a way, but you did. Be it sloppiness, dyslexia, or whatever that caused it - you crossed the line and I reacted to that. Your phrasing could result in the damage to the community, but honestly, I'm not that interested in that; on the other hand, your phrasing did influence the quality of the discussion negatively, which is what interests me much more. Hence the reaction.
What I'm wondering about is why do you defend your "usage of language" so much. Is it really the only way you can express yourself? Is it really impossible for you to use the language in a better way? If you are handicapped somehow and really can't perceive the difference between "censore" and "censor", then I'm sorry, I won't say a word. On the other hand, if you are capable of that, then I honestly can't understand why do you insist on writing comments as sloppy as yours.
I'm just guessing here, but did you compile Nim in debug mode? (nim c filename.nim)
From my experience, compiling files in release mode (nim c -d:release filename.nim) makes similar tasks run 10-100x faster than Python (usually around 30x for my use cases), and it doesn't require "highly skilled Nim developer" as you mention in your reply.
* NimFP[1]
* Zero-Functional[2]
Disclaimer: my very first language was Haskell and I'm now a Nim core contributor.Mutability: just like Ocaml, Nim has `let` and `const` and mutable function parameters and mutable variable need `var`.
Caveat: for reference types, immutability is shallow (you cannot change the reference but you can mutate the reference content).
Also many people in Nim community are pushing for more control on mutability, you can see for example the proposition on writetracking[3].
* [1] https://github.com/vegansk/nimfp
* [2] https://github.com/zero-functional/zero-functional
* [3] https://nim-lang.org/araq/writetracking.html“Shallow immutability” is not just a “caveat” — it’s a complete abuse of the word “immutability”.
If you can in-place modify the interior of a so-called immutable value in any way (possibly excepting code within some kind of “unsafe” blocks), it is by definition not immutable. Immutability is a pure, all or nothing kind of thing.
That you are trying to present immutability as synonymous with C++ style “const”ness perhaps reinforces the parents’ post that Nim is not friendly or even aware of the functional paradigm of programming.
But unlike others, I think it’s okay that it doesn’t support immutable variables. It certainly doesn’t outright condemn the language. However, let’s not pretend it’s something that it’s not.
I don't agree on immutability, just like you have shallow copy and deep copy, you have shallow immutability and deep immutability.
Also functional programming also distinguish pure (Haskell, Idris, ...) and impure functional programming (Ocaml, ...).
Allowing side-effect through reference doesn't mean that a language is hostile to functional programming. It just means that it does not enforce purity.
For example, kotlin is very promising language on the paper, but in the reality it is being developed by people who kept a Java mindset and way to structure problems and code (and they repeat same concepts and ideas as they do in java, for example calling DSL to every single piece of nested code).
I'm not a fan of Nim because types go after the variable. But the fact that you did not consider that you may have messed something up and just thought "yeah totally, a language built to compete with C++ is slower than python", really discredits your entire post.
It didn’t take me long to prefer this syntax to that of Java, C, C++, etc.
[citation needed]
The way Nim, Rust, etc do it, with a useless 'var' keyword even when a type is present, is clearly needlessly verbose (ie, inferior, though I'd hesitate to say vastly), but I'd be interested to see a analysis of the merits of something like "Foo[2] foo = bar()" vs "foo Foo[2] = bar()" (or maybe that should be "foo [2]Foo = bar()"?), since it hadn't actually occurred to me to use the latter order seperate from the useless keyword.
How about we consider the normal case (where you write out the types):
int num_entries = ..
float div = ..
float result = num_entries // div
vs num_entries: int = ..
div: float = ..
result: float = num_entries // div
Because they are on the right, they aren't aligned which makes it harder to parse (imo). It gets even worse with more complicated types (lists etc).let foo = Bar();
Anyway, these are all subjective perspectives, but I was personally won over to them, especially as I started using type inference more often.
Contrary to hipster belief "Mutable strings", "Mutable everything" is not some accusation against a language...
I'm sure many other commenters have singled out this comment, but do you have an example? I find this quite hard to believe. Surely this would have manifested elsewhere and people would have pointed it out ages ago? Nim compiles (or transpiles, if you prefer) to C/C++, after all.
It is certainly not generally the case that Python beats Nim in speed, not even close. I would imagine something was wrong with your implementation or you hit some weird Nim bug or edge case.
But based on the comments from everyone it is reasonable to say that my implementation had something wrong or the test was off in some regard.
Having said that, I had to parse the whole wikipedia dump xml file once and extract just the text. The python code for the same was so slow and would have taken days to go through the whole xml file.
In my quest to find something faster, I came across a nim program that would take the xml in and dump a plain text file (or markdown?) file. It did the work within 2 hours.
So I don't believe it was slower than python.
Nim certainly has it's place and it is more comparable to go in speed.
If you are a pythonista I have a question for you, especially since I could still give Nim a try, how much effort would be for you to add 2 or 3 generators and asyncs in the python code and put in place a better architecture without any macros? how easy is the same thing in Nim without any library our of the standard library?
This speed of prototyping and bringing a better architecture to the solution sooner matters a lot more to me than raw speed (that comparison against python in speed was the last drop).
I believe you when you say that Nim won, after all they promose that some parsers such as csv parser could fit in the L2 cache and so on... hopefully the language and quality of libraries has improved.
P.S. how big was the whole wikipedia as XML? all languages?
Thus, asking someone to write a stdlib-only solution in Nim is a bit of a trick question...
Other comments are more a matter of opinion or view, but with respect to speed or memory use - Nim competes favorably with C++, D, Zig and friends. Neither CPython nor PyPy is in the same league.
https://stackoverflow.com/questions/30197068/why-is-my-c-tex...
https://stackoverflow.com/questions/9371238/why-is-reading-l...
So I wouldn't be at all surprised if you could make the same mistakes in Nim. But of course it would be unfair to claim that that means Nim is slow in general.
> * Some arrogant community members were tolerated just because they wrote popular blog posts on Nim implementing a fashionable pet project.
Arrogance is a problem, but kicking out a participant should require a bit more than their being arrogant.
Yes. See many past conversations on why Github Issues become unmanageable.
Labels help to segment, but aren't enough.
I find the number of 'open' issues a demotivator (bordering on depressing) for my projects, or when I look to work on others; even if most aren't issues but support questions/feature requests/on hold. If not triaged well, digging through to find the real bugs takes effort.
Github tried with 'Projects' but I haven't seen many (any?) projects using them successfully. For individual workflows they seem to work well. Big projects have fallen back on milestones.
And in my opinion it is not like that, see my comment on the top level.
However, some of those are subjective opinions: a lot of people do see it as pythonic in syntax, even not if pythonic in other decisions. It is cross compilable and fast and one can write readable macros and create readable DSL-s with it.
All other similar languages have even bigger issue counts: this is a shallow metric to base a conclusion on.
We have a new RFC repos to brings a bit more sanity to the bug tracker: https://github.com/nim-lang/RFCs/issues
Language is not just about a compiler and a better syntax, it is a huge ecosystem too, which either means a successful community(e.g. Python) or backed up by big guys(Google, Facebook,etc)
Life is short, for product development I am stuck with C, Python, Java, HTML/CSS/JS, SQL, that's about it and they're already more than I need and more than I can handle. Other than these obvious ones I may learn a little rust and dart in 2019, rust in particular seems interesting as a great fit to write standalone utilities.
Sure, you can bootstrap something really quickly in Python and Nim, but when it comes to creating beefy APIs, I find that Go offers a much shorter development cycle. Sure it is slightly more verbose, but when your code compiles it usually works (which is partly due to the way Go deals with errors). If you need to handle a large number of requests, scaling with Go is a breeze and a nightmare in Python.
I'm inferring from the list of languages you described above that you're doing a lot of line-of-business applications where, yeah, it's almost essential to have that huge, Java or Python sized ecosystem.
Nim doesn't have that. But Nim isn't really aimed at that kind of work, either. What it does have is very good C/C++ interop, which means that it's easy to interface with existing low-level libraries. That makes it a pretty decent option for writing low-level bits, or looking to incrementally migrate from C/C++ to something a bit more modern.
For the mostly-Java stuff I'm working on, I rather wish the native components were written in something like Nim. They'd be easier to maintain if they were.