thick web client
I'm thinking about ways of implementing thick client using Nim as an implementation language. The architecture I look onto is an (embedded) server and set of web clients which also runs computing nodes (JS generated by Nim).
Re: Can I disable the GC and use "gc:none" or the "new runtime" for only parts of the code?
Totally agree - start simple and optimize where needed. Nim works very well as a result from PoC to production to scale. This blog is a great example of this workflow: [https://www.chameth.com/2018/12/09/over-the-top-optimisations-in-nim](https://www.chameth.com/2018/12/09/over-the-top-optimisations-in-nim)/
Re: Newbie experience with the documentation
I think most people will start reading from top to bottom. I read the first three entries.
Re: Can I disable the GC and use "gc:none" or the "new runtime" for only parts of the code?
@Araq I see you already answered this question once when I used another username I forgot about. Sorry :D Also Nim seems to prefer that you copy list collection data-structures like seq etc. instead of sharing them between threads, but this time I really have to share them between multiple worker threads. I want to write the scheduler code that guarantees that no worker threads are working on the same batch at the same time myself.
Re: Nim for Beginners Video Series
Font size Ok.
nim-lang snap issue
FYI: I installed Nim v1.0.0 using the snap nim-lang package in fresh Linux Mint 19.2 and Ubuntu 18.04.3 Linux and there are a couple of issues: 1.- the binaries are named nim-lang.* 2.- When trying to compile I get an error: Error: execution of an external compiler program 'gcc -c -I/snap/nim-lang/50/lib -I/home/sergio/Dev/test_nim -o /home/sergio/snap/nim-lang/50/.cache/nim/test_d/test.nim.c.o /home/sergio/snap/nim-lang/50/.cache/nim/test_d/test.nim.c' failed with exit code: 1 In file included from /snap/nim-lang/50/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h:7:0, from /snap/nim-lang/50/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:34, from /snap/nim-lang/50/lib/nimbase.h:257, from /home/sergio/snap/nim-lang/50/.cache/nim/test_d/test.nim.c:9: /snap/nim-lang/50/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:168:61: fatal error: limits.h: No such file or directory| ---|--- In both cases the gcc version is gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4. The limits.h is present so that is not the issue. Is there any suggested workaround for this issue. Note that the usual "apt install nim" brings an old version, 0.17.2 which compiles a test file so it is unlikely to be a gcc issue. Also installing v1.0 using chosenim works fine. As I can't find any easy way to provide feedback in the snap store I hope that the snap developer, Hayden Barnes (haydenb) finds this information. Sergio
Re: Can I disable the GC and use "gc:none" or the "new runtime" for only parts of the code?
So should I enable Nim's soft realtime GC for everything and then use `ptr` where I want to manage memory myself? Is that the default, what should I do to use it? Can I compile using C99 to be able to use the `restrict` keyword with `emit`? As an example, this is how I implemented one batch processor in C99 that can be used by any of the worker threads that picks it up (that is available for work): void waves_integrate(XRESTRICT(waves_t*) waves) { size_t wave_index = 0; XRESTRICT(float*) velocities = waves->velocity; XRESTRICT(float*) last_heights = waves->last_height; XRESTRICT(float*) target_heights = waves->target_height; for(wave_index = 0; wave_index < WAVE_COUNT; wave_index++) { // Load float velocity = velocities[wave_index]; float last_height = last_heights[wave_index]; float target_height = target_heights[wave_index]; // Transform float force = (TENSION * (target_height - last_height) - velocity * DAMPENING); // Store last_heights[wave_index] = last_height + velocity + force; velocities[wave_index] = velocity + force; } } Run Here `XRESTRICT` is replaced by the `restrict` keyword that the C compiler supports. The `waves_t*` argument is a pointer to one of the batches. Sorry for the C code, but I just want to know if I can do this in Nim.
Re: Nim for Beginners Video Series
#5 is live ! The font is now 34 on both text and terminal. Link: [https://youtu.be/aa5WKYzqZI4](https://youtu.be/aa5WKYzqZI4)
Re: Can I disable the GC and use "gc:none" or the "new runtime" for only parts of the code?
To manage memory manually is not a sin in Nim and directly supported via `ptr`. You can use NimScript as the scripting language. It does support everything you mentioned here. But what makes it complex is the "mid level" part, you need to decide which GC to use. I think Nim's soft realtime GC is what you want to use for it.
Re: Cross compilation linux -> win + wine issue with file reading
Well `echo` does swallow the zeros, but that's not what you use. Strange.
Re: call glibc functions
Read this please: [https://nim-lang.org/docs/manual.html#foreign-function-interface](https://nim-lang.org/docs/manual.html#foreign-function-interface)
Re: Lambdas?
[https://play.nim-lang.org/#ix=1XgA](https://play.nim-lang.org/#ix=1XgA)
call glibc functions
I can feel it's a stupid question but how I call glibc functions from nim ?
Re: Cross compilation linux -> win + wine issue with file reading
Yes, the NULL character (00) appears to be missing. Weird because I have used wine for other software that opens files too and had zero issues. I tried using fread and I get the same result. It reads exactly the same amount of bytes, but the 00s are removed. So it must be some bug in wine, who knows.
Can I disable the GC and use "gc:none" or the "new runtime" for only parts of the code?
For parts of the code I want to have full control over memory, but for other parts I still need a GC. Is this possible? Basically I want a part to be more like C where I have to manage my own memory and do not mind to not use any extra features that require a GC. I finally want the application to have the following layers: high level: non-compiled game code for modding using Nim script ([https://github.com/komerdoor/nim-embedded-nimscript](https://github.com/komerdoor/nim-embedded-nimscript)) mid level: compiled game code using garbage-collector low level: data-oriented game engine not using a garbage-collector I've been coming back to Nim multiple times waiting for the moment that I can finally switch. I also use several C libraries that I have to create bindings for, hopefully that is now easier as well. Is using Nim as a scripting language still a good idea of would you recommend to use Lua there instead?
Re: Why the Translator term was not used?
Does this still persists as of now ? Regards, C.Smith
Re: Lambdas?
Being a Lisp fan too (Nim fan of course), I have a section for ["Lambdas in Nim"](https://scripter.co/notes/nim/#lambda) in my Nim notes.
Re: How do nim users who have some proficiency in Lisp compare the two?
> How do nim users who have some proficiency in Lisp compare the two? As @Libman said, they are quite different. But you do see hints of Lisp in Nim here and there. Some examples: the way the AST parsing of Nim happens, and that it can be represented as a Lisp expression (See [lispRepr](https://nim-lang.github.io/Nim/macros#lispRepr%2CNimNode)), Nim templates can be redefined as you can do lisp expressions, you can easily introspect the types of variables and procs, as you can do in lisp. I even started this fun project [elnim](https://github.com/kaushalmodi/elnim). > Are there any Lisp developers here who have used both in earnest? I got exposed to lisp as I use Emacs and I loove hacking in Emacs-Lisp to make Emacs do whatever I want. And I have used Nim to replace bash and Python for me. More importantly, it has found a unique spot at my work where I use Nim as an interfacing language between C/C++ and SystemVerilog. \--- Hey @rayman22201, thanks for the mention :) Yep, my website source is in Org mode.
Re: Newbie experience with the documentation
Trick to find all procedures that return SomeType: `:) SomeType`
Re: Newbie experience with the documentation
You got the colon and parens in reverse order. But I came to say here this. Once you know the consistent style of proc signatures, it's really easy to search for things. The procs are defined as: proc foo(arg1: Type1; ..): ReturnType = Run So to search for procs returning that ReturnType, you just search for `): ReturnType`.
Re: Newbie experience with the documentation
> [https://nim-lang.org/docs/theindex.html](https://nim-lang.org/docs/theindex.html) > > > Looking for type with ctrl+f drives me crazy. I give up. Indeed, there is a trick here: search for "Natural:" (note the trailing `:`). I think we might want to document this. On the other hand, I would guess most users would try and search like this:
Re: Great tutorials needed
Thank you! Also, It used to be under the books section before, but now in its position it will be overlooked most likely :)
Re: Unexpected error using parseInt
Hi guys, thx for pointing me in the right direction and also to ways to better find my way in Nim docs. I am new to Nim (but not to programming) and missed the overloaded function completely. Now it works OK.
Re: Newbie experience with the documentation
>From >[https://nim-lang.org/docs/manual.html](https://nim-lang.org/docs/manual.html) >there is a way to reach >[https://nim-lang.org/docs/manual.html#type-sections](https://nim-lang.org/docs/manual.html#type-sections) No ideal, but most people start with reading a tutorial. Ever tried that?
Re: Lambdas?
I don't think so: [https://hub.docker.com/_/ubuntu?tab=tags](https://hub.docker.com/_/ubuntu?tab=tags) They do have devel tag (I'm using that BTW) but it means that this is the development version of Ubuntu, i.e. eoan, not that it contains some packages for developers. So, I have to install GCC and wget manually: [https://github.com/moigagoo/nimage/blob/develop/flavors/slim.nim#L8](https://github.com/moigagoo/nimage/blob/develop/flavors/slim.nim#L8)
Re: 1.0.0 is here
I'm disappointed that 1.0 was released without fixing the deadlock in resizing **threadpoll**. * [https://github.com/nim-lang/Nim/issues/11875](https://github.com/nim-lang/Nim/issues/11875) * [https://forum.nim-lang.org/t/5212#32697](https://forum.nim-lang.org/t/5212#32697) -> [https://github.com/yglukhov/threadpools](https://github.com/yglukhov/threadpools) (thankfully)
Re: Newbie experience with the documentation
While reading your post for the first time I got the impression that you were looking for data type "Natural" \-- I searches for Natural in docs and found it fast. But now I have the impression that you are looking for keyword "type"? Keyword type is mentioned in tutorial 1, maybe not early enough. Well, explaining something can be difficult if one does not know the audience. The "type" keyword and the type section is in no way an invention of Nim, Pascal, Modula, Oberon have it. Generally, when we explain something, we have to start somewhere. Whenever I read a science paper, there are a dozen of new terms for me, often I have to consult other papers to learn their meaning. But of course Nim devs will continue to improve docs.
Re: Great tutorials needed
This deserves more details on the [learn page
Re: Compiling fails with --gc:refc and --opt:speed
I have upgraded to Nim 1.0.0 and tested my setup again. Now the compiling works fine, if I specify the compile options in my *.nim.cfg file, but if I specify them as arguments, the compilation fails. I have inserted check in my code, to verify that it is a release build (echo defined(release)), which verify it. I can live with updating my *.nim.cfg, but I would like to know why it happens. Any suggestions? **Case 1 - Fail** nim c -d:release myProgram Run This will result in the memory crash like my posts above. **Case 2 - Success** * myProgram.nim.cfg contains -d:release nim c myProgram Run This compiles and finishes in _only_ ~300 sec.
Newbie experience with the documentation
Hi there :) Here is a recap of my recent experience. [https://nim-lang.org](https://nim-lang.org)/ So lets explore this language, shall we? Lets see what this type is: [https://nim-lang.org/documentation.html](https://nim-lang.org/documentation.html) Wow, that is a lot of documentation. Lets start: [https://nim-lang.org/docs/lib.html](https://nim-lang.org/docs/lib.html) Oh, here is no type listed. Just some typeinfo. Anyways, its probably in some of the other categories: [https://nim-lang.org/docs/manual.html](https://nim-lang.org/docs/manual.html) Hnn, again this typeinfo. Isnt type supposed to be a fundamental part of the language? [https://nim-lang.org/docs/theindex.html](https://nim-lang.org/docs/theindex.html) Looking for type with ctrl+f drives me crazy. I give up. Did anybody of you anytime put yourself into the position of a complete beginner and went through that whole process? I think the 1.0 release is a great opportunity to finally get your documentation in shape. Otherwise, a seemingly super elegant language misses part of its audience group and that would be super sad. With regards: ShalokShalom P.S: The preview is not working here. Linux Firefox current on KaOS. P.P.S: Also creating threads and visiting my own profile does not work until I confirm the email. It might be worth notifying this, instead of silently assuming people are doing so. There is no notification at any point, despite the fact that you let me write a thread. Thanks a lot for your attention.
Re: Shared table with ref objects from different heaps. Will this work?
Would `--gc:boehm` make it better?
Re: How to change C compiler globally on Linux?
I opened this issue [https://github.com/nim-lang/Nim/issues/12292](https://github.com/nim-lang/Nim/issues/12292) I hope I provided enough relevant informations.
Re: Shared table with ref objects from different heaps. Will this work?
Definitely a problem and the reason why we have the `.gcsafe` effect.
Re: Lambdas?
You may also want to check out js-like arrow function. [https://nim-lang.org/docs/sugar.html#%3D%3E.m%2Cuntyped%2Cuntyped](https://nim-lang.org/docs/sugar.html#%3D%3E.m%2Cuntyped%2Cuntyped)