First of all, thanks for the code review! I'm just starting in Nim, and I have 
no one else to ask. Secondly, I started coding 33 years ago, so I'm not 
generally a programming newbie. Thirdly, I'm the 
Networking/Server/DB/Load-Balancing/Profiling/Optimizing/Multi-Threading 
"specialist" in my team; basically the "backend" guy (partly, because I'm not a 
native German speaker, and the literature on the "domain knowledge" in German 
is beyond me, so the "other devs" take care mostly of the "business logic"). I 
do use volatile/atomics regularly. I try to avoid locks like the plague; 
firstly, because you can't get a dead-lock without locks, and secondly, because 
volatile/atomics are normally faster. What I was trying to say is, I'm new at 
_native_ concurrency. I assume that atomics and locks will work about the same 
as in Java, but volatile might not. IMHO, volatile used to be "better" in Java 
in the old days, but it got "nerfed" so that all the old _wrong code_ written 
by Java devs would work correctly!

Now for the specific comments:

@wizzardx Thanks. After countless years relying on an IDE (Eclipse, the slowest 
thing ever made thing since the 3 1/2 inch floppies), I feel somewhat helpless 
without one. But my grep-foo is strong, so I just have to get into the habit of 
using it that way.

@mikra Thanks for the overview. I had spotted the post about "about locks and 
condition variables", but I wasn't sure if I got it right. For example, is it 
OK to directly initialize a global variable guarded with a lock, as I did, or 
do I have to leave it uninitialized, and get a lock just to initialize it? I 
wouldn't want to implement a lock-less hashtable myself, but I got used to 
using them, so it's good to see how it's done.

@rayman22201 I don't use any "refs" in myList(). In fact, it doesn't even 
accepts refs as type parameter, but I had to ask the forum to know how it's 
done. About "Your typeID proc is badly inefficient." I know! But I really 
didn't want to implement my own hashtable on the shared heap at this stage 
(firstly) (I assume the Nim library hashtables only work on local heap?) and 
secondly I would have used atomics instead of a lock anyway, if I had know how 
to! Thirdly, my assumption is that this code will only be called when 
initializing the modules, but afterward the app will just use the IDs, so 
simplicity trumps efficiency in that case (or, learn how to walk first, before 
you try to run). 

Reply via email to