How to use SharedList

2021-05-04 Thread nnahito
I would like to share the seq[string] variable across multiple threads. I found the following article with the comment "you should not share any heap-allocated managed objects (refs, strings, seqs) across threads". I also found a notation that says "I would suggest using the standard library's

Counting word frequencies with Nim

2021-05-04 Thread cblake
To be clear, I didn't mean to be overcritical of you or your efforts -- good job stdlib tuning (and thanks!), but the general 1.25x faster in lang X than lang Y kind of subculture. For this particular case, I couldn't even reproduce ratios on various CPUs as accurately as their speed ratios on B

Counting word frequencies with Nim

2021-05-04 Thread cblake
Oh, yeah...another reason that test is messed up is that to make it easy for job interviews he defined tokens so `split` can work, but the text data itself has all kinds of punctuation in it. This artificially amplifies the "novel vocabulary per byte" by something like 3x, and that parameter rea

Counting word frequencies with Nim

2021-05-04 Thread Zoom
Yeah, this fact gave me a chuckle too, but it seems to be a reasonable choice to simplify the code a bit for those solutions when you can't just pass a list of separating tokens to a function.

Counting word frequencies with Nim

2021-05-04 Thread Zoom
Thanks for your thoughtful (as usual) reply. You can see I deliberately avoid using the word "benchmark" for the whole affair, as I understand the usual concerns: "better run on the same machine", "this compares a dev's familiarity with the language, not the language itself", etc. In my view the

File IO for the JS backend on node

2021-05-04 Thread ynfle
It's confusing for people that aren't familiar with nim that odd numbers aren't releases

How to make Nim more popular

2021-05-04 Thread iagovar
Make a cs106a with Karel the Robot in Nim. IDK to what extent is that possible, but you can't get more entry-level and suave than that.

Counting word frequencies with Nim

2021-05-04 Thread cblake
This "benchmark" while classic because of the historical importance of both Knuth & McIlroy is not very good because it is very sensitive to the size of CPU caches which vary on test/comparison machines. IIRC, the particular example text of King James bible from Gutenberg*10 can, with a lot of e

What is the correct way of mapping C functions with return type "const char *"?

2021-05-04 Thread kaushalmodi
@doofenstein Your explanation makes so much sense! I spent hours debugging this. And this was the fix :D proc f_scopetest_nim() {.exportc, dynlib.} = var scope = svGetScope() let -origScopeName = svGetNameFromScope(scope) +origScopeName = $svGe

What is the correct way of mapping C functions with return type "const char *"?

2021-05-04 Thread doofenstein
I'm not familiar with the API, but the thing with returned const char* values is that you don't own the memory the pointer is pointing to, so it can change the value whenever it wants to in proceeding functions, if it doesn't want to continously leak memory by always returning new memory (it doe

global var & thread

2021-05-04 Thread Neodim
Thanks a lot for directions for investigating, now it's time to trying it!

import unicode, strutils: ambiguous call; both unicode.strip and strutils.strip

2021-05-04 Thread Araq
> Or declare an alias to strutils's strip (or the other way). Er, please don't. :-)

Counting word frequencies with Nim

2021-05-04 Thread Zoom
**TLDR:** Counting words with Nim, improving performance on [benhoyt/countwords](https://github.com/benhoyt/countwords), beating Go. [Code here](https://github.com/ZoomRmc/countwords_nim/). * * * About a month ago a [post by Ben Hoyt](https://benhoyt.com/writings/count-words/) with his perform

Nim as a classic programming language

2021-05-04 Thread Sixte
Nim is in the line of classic programming languages: FORTRAN, Pascal, C. Nim represents a minimal (if not THE minimal) closure over C's memory model. * FORTRAN did not use a stack for variables at all, because any of these were placed in global memory. Recursion did not work of course, but the

How to make Nim more popular

2021-05-04 Thread deech
Yeah, I think Nim is a better C++ is good, but I think it would be good to really hammer that there's very little risk to trying it since the FFI is so easy. And there's also low risk of language lock-in because if Nim isn't right for your org, you can just exportc your Nim code back to C++ and

How to make Nim more popular

2021-05-04 Thread bpr
> I think it's worth making a big deal out of Nim's C++ interop. I couldn't agree more. There is so much C++ code out there that it warps the space of programming language design, kind of like IEEE floating point. That's why I suggested in another thread looking at C++ if there is going to be an

What is the correct way of mapping C functions with return type "const char *"?

2021-05-04 Thread kaushalmodi
Hello, My main use of Nim is for writing code that compiles to something that's compatible with SystemVerilog DPI-C interface. SystemVerilog is an HDL/HVL language that can talk to C via its DPI-C interface. SystemVerilog compilers ship with an svdpi.h like looks like [this](https://github.com

How to make Nim more popular

2021-05-04 Thread deech
I think it's worth making a big deal out of Nim's C++ interop. Now for all those companies with big C++ codebases a new language is not such a huge gamble and being able to easily call heavily templatized C++ APIs is something most langs can't do today.

How to make Nim more popular

2021-05-04 Thread jasonfi
South Africa (at the moment).

How to make Nim more popular

2021-05-04 Thread enthus1ast
May i ask which country you're in?

How to make Nim more popular

2021-05-04 Thread jasonfi
I started a company and I'm using Nim, but it's tough going as a single developer. I've between trying different project ideas to find something that enough people will be interested in.

How to make Nim more popular

2021-05-04 Thread treeform
I agree with @dom96 about starting a company that uses Nim. Make that company become successful.

Prompt issue with stdout.write

2021-05-04 Thread enthus1ast
I can imagine that It could have something to do with buffer settings (maybe terminal, and or c library.) But I do not know exactly (and also would not rely on these behavior/settings).

No difference between asyncHttpClient and httpClient?

2021-05-04 Thread GengisKaizer
Async calls aren't related to cpu time (like for loops are), instead they're related to network connection and response time within a timeout (sync calls usually will wait forever if there is no response) Doing for loops like those in the example above are unconsistent, because suppose the serve

Prompt issue with stdout.write

2021-05-04 Thread shirleyquirk
Are you compiling with `nim c -r` or `nim r` ?

How to make Nim more popular

2021-05-04 Thread SebastianM
Maybe someone could create a leaflet so it could be downloadable from the website and printed to give away?

Prompt issue with stdout.write

2021-05-04 Thread SebastianM
Hey guys, I have a small problem. On one of my gnu/linux distro (Arch Bang) after compilation of code there's no prompt to enter a name but application waits to enter something (which should be later). I've installed even readline, but it was still the same. when echo is used as a prompt it wor

Prompt issue with stdout.write

2021-05-04 Thread SebastianM
Thank you for your quick answer. Indeed now it works. But I'm not sure why here it was necessary and on other distro it wasn't. Any ideas?

Prompt issue with stdout.write

2021-05-04 Thread enthus1ast
You must call strout.flushFile

How to make Nim more popular

2021-05-04 Thread juancarlospaco
I do not believe Rossetta has a massive traffic nowadays..., and is hard to stomp into Nim content if you are not searching for Nim, and if you are searching for Nim you already knew Nim anyways. Better to record 60 second screencast videos and post it to Twitter, Tiktok, Twitch, Youtube, etc.

import unicode, strutils: ambiguous call; both unicode.strip and strutils.strip

2021-05-04 Thread konradmb
Or declare an alias to strutils's strip (or the other way). import unicode, strutils# remove this comment ! const stripStr = strutils.strip [...] alias "*" & s.stripStr.capitalizeAscii & "* ", starredWord Run

How to make Nim more popular

2021-05-04 Thread saem
There needs to be an understanding of Nim's worth and value, the former ensures the latter doesn't take over and one simply chases external opinions. Obsessing over value is an easy way to lose oneself as it's quite focused on how the outside perceives you. There needs to be a proper organizati

import unicode, strutils: ambiguous call; both unicode.strip and strutils.strip

2021-05-04 Thread Symb0lica
As described in the error message, both strutils and unicode define a strip procedure that matches the call. To fix this your options are: Specify which version to call, e.g. strutils.split(curStr,' ') Run or don't import one of the strip procedures, e.g.

import unicode, strutils: ambiguous call; both unicode.strip and strutils.strip

2021-05-04 Thread jakubDoka
you have to write `moduleName.item` to get rid of ambiguous calls so for example `strutils.strip(str)`

import unicode, strutils: ambiguous call; both unicode.strip and strutils.strip

2021-05-04 Thread masiarek2
Adding "import unicode, strutils" triggers error:/Volumes/T7/Nim/_my_code_ex/template_alias_reference.nim(28, 18) Error: ambiguous call; both unicode.strip(s: string, leading: bool, trailing: bool, runes: openArray[Rune]) [declared in /Volumes/T5/.choosenim/toolchains/nim-1.4.6/lib/pure/unicode

No difference between asyncHttpClient and httpClient?

2021-05-04 Thread alexeypetrushin
Yes, to make async calls in parallel, they should be **initiated without waiting** , and then waited on the futures.

How to make Nim more popular

2021-05-04 Thread wani
It seems that every comments do not contradict each other, they almost mention to the same domain. There are 2 strategies to do marketing Nim and both has a few method to approach. * Let many organizations decide to use and support Nim on their project. * Decide to use and support Nim on y

No difference between asyncHttpClient and httpClient?

2021-05-04 Thread PMunch
As @GengisKaizer pointed out, putting your async calls in a loop like that doesn't really work. When `await` is called the thread will be paused waiting for that call to complete, and since that is within the loop it will pause the loop and not schedule the next call until the previous one is do

No difference between asyncHttpClient and httpClient?

2021-05-04 Thread GengisKaizer
I think async is meaningless if put inside a loop like that. try opening a slow website instead and doing a loop which writes to a console some text, the one with sync will lock and do nothing until the site is fully loaded, the other will print immediately instead.

5th Nim online meetup

2021-05-04 Thread miran
Two weeks after the previous meetup, it is time for another one! The meetup will take place this **Friday (May 7th) at 3pm UTC**. To check the time in your timezone, use [this link](https://time.is/compare/1500_07_May_2021_in_UTC). Join us at: (no registration n

No difference between asyncHttpClient and httpClient?

2021-05-04 Thread talaing
Hello everyone, I'm not sure if this is right place to ask, basically I'm pretty new to this language, I just switched from Python to Nim. I'm trying to make some HTTP requests with _asyncHttpClient_ , but they seem extremely slow. There's literally no difference between async and non async. I

How to map a JS dictionary paramter in the Nim importjs header?

2021-05-04 Thread DomoSokrat
I would have expected that to do the right thing… As it turns out, you can use the macro `{}`, but then you can't use variables as keys: let opts = JsObject{`type`: cstring"extended", desc: cstring"fortified"} Run Or set the fields explicitly: var opts = newJ

global var & thread

2021-05-04 Thread b3liever
> Using global vars leads to GC-unsafe errors. I don't think that makes sense with `arc/orc`. Use a Lock / RwLock on a global variable or pass data through a channel.

How to map a JS dictionary paramter in the Nim importjs header?

2021-05-04 Thread Hlaaftana
You should do `js{"type": "extended", "desc": "fortified"}` using the [{} macro](https://nim-lang.org/docs/jsffi.html#%7B%7D.m%2Ctypedesc%2Cvarargs%5Buntyped%5D). Tables can only have a single type for values, `{"a": "foo", "b": 1}.toTable` does not compile. Also they are a pure Nim type

Issue with defaults for mutable generic function parameters

2021-05-04 Thread shirleyquirk
Another option is to use Option instead of a custom typeclass

Problems with Bounty Source: unable to make recurring donations

2021-05-04 Thread Veralder
Personally, I prefer to donate to people in person without the help of platforms. I don't really trust outlets that pretend to be charity companies. Most of them are just schemes that steal people's money. The best way to donate is when you help a poor person who has come to the street. However,

File IO for the JS backend on node

2021-05-04 Thread Araq
> It's not a bug, it is just that our sysadmins/devops do not like to upgrade > things "unnecessarily". The question is why the devop decided to give you 1.3.5 to begin with -- something which is not a release.

How to make Nim more popular

2021-05-04 Thread Clonk
I firmly believe Nim has a marketing problem. Nim has a very technical oriented community with a "show don't tell approach". Nim market itself as a powerful tool. But If you want Nim to grow and be used in companies, you need to convince non-technical people as well. Non-technical are usually

How to map a JS dictionary paramter in the Nim importjs header?

2021-05-04 Thread halloleo
Cool! Makes sense. Now I'm using: func myfunc*(data: cstring, opts: JsObject) {.importjs: "mylib.$1(#, #)".} Run And I'm trying _on the Nim side_ to provide this` JsObject` aka dictionary: let opts = toJS({"type": "extended", "desc": "fortified"}.totable)

global var & thread

2021-05-04 Thread jasonfi
Here's a good article on the subject: At the end of the page is an example of using a shared table between threads. Each worker thread is spawned with a guarded pointer to the table. The guard provides a lock to ensure only a single thread modifies

How to map a JS dictionary paramter in the Nim importjs header?

2021-05-04 Thread DomoSokrat
Try `JsObject` or `JsAssoc` from the `jsffi` stdlib module.

How to map a JS dictionary paramter in the Nim importjs header?

2021-05-04 Thread halloleo
I have a JavaScript library with a function which takes a dictionary object as parameter: function myfunc(data, opts) { ... //opts is used like: opts.type == ... opts.desc ... ... } Run In the Nim header definition like

File IO for the JS backend on node

2021-05-04 Thread xigoi
Yes, because testing if the package works on older versions is a waste of time.

Nim packages and LTS Nim

2021-05-04 Thread halloleo
> In other words, we need a new LTS that makes ARC the default. :-) Makes total sense. Would be great to stick with that for a while then.