It is time for our sixth annual Community Survey!
Read more: https://nim-lang.org/blog/2021/11/22/community-survey-2021.html
Direct link to the survey: https://forms.gle/dr7m9zS3rQbafG6i9
We would love to hear your opinions!
Also, in case you missed it, take a look at our roadmap for 2022 and beyond: https://github.com/nim-lang/RFCs/issues/437
we are noticing a trend where our users are on average a bit older than the year before
This implies Nim usership has stagnated which makes sense. 1.6 wasn't a huge release since IC wasn't included, even that wouldn't compare to something like 1.0 in terms of attention. Though from what I know it's a lock behind better editor support and introspection improvements.
I never really thought about the European majority but it is weird. The obvious culprits don't make sense given it's almost entirely online and pretty much all discussion is in English. I guess it could be because Europe's English-speaking population is much bigger than North America's. I also guess Nim isn't a "trendy" language and trendy software is more prevalent in places like the US and India. It might appear more obvious when normalized by population.
I think the focus on learning is not as representative of the issue anymore. Nim just has a lot of things you could possibly learn about and it's not easy to discern which of them you'll need. This is why I think so many people want "code examples". If tutorials are going to be made, they should be made about more specific things, but still with enough room that people can interpolate their own desired goals with the language. It shouldn't be "making a game with Nim", rather "how to make games with Nim", or realistically, "how to make 2D/3D games with Nim" etc. This problem also bleeds a bit into documentation, people sometimes expect it to tell them what they want to do.
Some hopes I have for the next survey, even though I understand dramatic changes are not much preferred here:
I think macros and metaprogramming in the most-liked-features list would be better if it also counted compile time facilities as well, maybe something like "compile-time capabilities and metaprogramming".
Recent discussions about "new features", standard library decoupling etc. may also be worth covering in later surveys. On top of "fixing compiler bugs", there can be things like "fixing bleeding edge features" (effects, iterators, concepts, static), "removing broken features", "improving runtime performance" or whatever. "More official packages" instead of "larger standard library" might give different results.
Only continents for "where are you from" is not very interesting, and there are a lot of ambiguous cases. But I don't think location is a very interesting thing to think about here anyway. Maybe a division between Western and Eastern Europe, or even more divisions of Europe could be better given how many people are from Europe. Other regions could be Middle East or South Asia but those wouldn't yield super interesting results and are still ambiguous. I'm guessing the goal of this question is more focused on geography than political placement, but places like Russia, Israel, Turkey, Cyprus, India, Australia do not really match with their geography.
I would also like to see a more comprehensive community assessment of individual features in the language, but this makes more sense as a post on the forum that could be made by anyone. I would support this if anyone was up for it.
we are noticing a trend where our users are on average a bit older than the year before
I don't know if it's a lack of language tutorial, maybe a lack about use case or tools.
I think to 3 subjects:
May be creating a RFC about tutorials.
What (in plain english) is a macro.
Macros read/output Nim syntax, instead of run time data.
This is called "meta-programming"; code that generates code.
Why would you want to use one. And what are the benefits
They can take arbitrary syntax and output any code you like. Very useful for custom DSLs and automating boilerplate.
Take for example automation. Here's a macro that creates +, -, *, /, +=, -=, /=, and *= operators for given array types: https://github.com/rlipsc/glbits/blob/master/src/glbits/utils.nim#L95-L177
Because... No one has time to write out this kind of thing for different sizes of array:
func `+`*(a, b: array[2, int]): array[2, int] =
result[0] = a[0] + b[1]
result[1] = a[1] + b[1]
func `-`*(a, b: array[2, int]): array[2, int] =
result[0] = a[0] - b[1]
result[1] = a[1] - b[1]
Imagine if you want operators for array[200, int] - then one day you need the same for float arrays! Urgh!
Using the makeOps macro we can automate this:
type Array2 = array[2, int]
# Create operators.
makeOps Array2
# Now we can freely use operators on array[2, int]:
var arr = [1, 2]
arr *= [2, 3]
echo [4, 6] + [1, 2] * arr # Displays [6, 18]
# Generate ops for a larger array:
type ArrayF200 = array[200, float]
makeOps ArrayF200
var arr200: ArrayF200
arr200 += 10.0
echo arr200 / 2.5 + 1 # Displays [5.0, ...] (x200)
Boring, copy-pasta-prone busy work is now automatically unrolled and annotated with {.inline, noInit.} for you. If you need to add new operators or change how they work, it's all in one place - no need for reams of duplicated code to update.
pitfalls, and limitations.
Not a 'pitfall', but inputs to a macro are NimNode syntax trees so you might want to get to know how they're structured.
@ElegantBeef's article goes into how to display syntax trees for bits of code you want and how to explore how these work.
The only real limitation I can think of is that whilst you can read files within macros, you can't output files. Not really something worth worrying about in general use.
How should a macro be structured?
However you want, really. I think the same rules apply in macros as normal code. Indeed, you can use much of the standard library in macros.
Macro tutorials
It would be cool to have more example articles with very simple quote do: macros. Digging into node.kind and getImpl probably looks scarier than it really is for adventurous newcomers.
Actually getImpl, getType and the like probably need their own articles to be honest!
Embedded programming for example on ESP32
Articles on building simple, useful/fun embedded projects would be very nice! Sometimes having a basic jump board project can make the difference between thinking "huh, cool" to actually starting to tinker and explore with the language in a space.
Lot's of people have covered macros, there is an example in ` tutorial part 3 <https://nim-lang.github.io/Nim/tut3.html>`_ which is quite good and a couple more in https://hn.algolia.com/?q=nim+macro
I once made a post too. It's very simplistic but I hope it helps.
Talking about typed vs. untyped is a big one I've been meaning to add.
I think that would be really valuable, especially considering that Araq has stated more than once (here and here) that he'd like to get rid of untyped, so it would be interesting to see examples with untyped rewritten.
I'd also like to see some comparisons with C++ metaprogramming. For instance, the typical example of variadic templates in C++ is type safe printf, and that's an example from The Zen of Nim.
Really? What would be replacing untyped then? Explicitly returning NimNode? I can see that working for macros, not sure for templates.
I'm not against it btw. Typed and untyped was very confusing for me until I got it, sort of at least.
Agreed that a cool embedded project write-up using Nim would be pretty cool. Eg something that could get featured in on HackADay, etc.
I think all the pieces are there on the Nim side, between PMunch's Badger (which could be repurposed for another application on AVR aka Arduino), elcritch'd Nesper and Nephyr, beef's picostdlib and my samd21 POC (and svd2nim). I'm also working on adding USB device support to picostdlib and my samd21 project, so we can make USB gamepads or keyboards using a raspberry Pi pico running Nim.
PMunch and elcritch presented some very interesting talks at last year's nimconf, but IMO they were very much aimed at people who already know Nim and wanted to learn about embedded. If we want to get on HackADay, etc, we need to introduce Nim to "makers" who are already familiar with Arduino and whatnot.
We just need someone with the time and inclination to do a cool project write-up, which unfortunately isn't going to be me 😕
Really? What would be replacing untyped then?
Nothing really, you would use typed and a typed expression can be one that didn't semcheck -- for undeclared identifiers that would be nkIdent, for example.
but places like Russia, Israel, Turkey, Cyprus
Sorry but Israel is not a place, it is state of mind
If you bomb at hospitals, kill innocent women and children and call them animals, the you are Israel, if you hate them, then you are human