At what likelihood do likely/unlikely become useful?

2021-05-18 Thread xioren
Fair enough, thanks.

At what likelihood do likely/unlikely become useful?

2021-05-18 Thread Araq
likely/unlikely are useful so that the compiler can layout the code for optimal instruction cache access. Usually the icache is large enough so that you see no difference, but in theory I would expect the cutoff to be at >50%. The branches themselves are predicted correctly >90% of the time by t

At what likelihood do likely/unlikely become useful?

2021-05-18 Thread xioren
I'm going through old code seeing where I can optimize and am unsure when adding "likely" or "unlikely" is appropriate. Would any likelihood above 50% benefit from "likely"? 75%? 90? What is the cutoff?

Andre von Houck's Nim Web Framework has great potential - A must see!

2021-05-18 Thread kobi
My gripe with it was window only, or online-only. Is this my mistake?

NodeJS for Nim

2021-05-18 Thread juancarlospaco
Async HTTP Web Server

Concept containing seq of self

2021-05-18 Thread jyapayne
Looks like you have to use `typedesc T`. Not sure if that's a bug or not: type TreeNode* = concept t, type T t.children is seq[typedesc T] proc isRootNode*(self: TreeNode): bool = true type Numbers = ref object children: seq[Numbers] let

Nim as a classic programming language

2021-05-18 Thread bpr
Reading the [new style concepts RFC](https://github.com/nim-lang/RFCs/issues/168), we see that the first goal is Empower concepts to make generic code type-checkable at declaration time, not only at instantiation time. Run >From that we can draw some hope that th

Nim 2.0 -- thoughts

2021-05-18 Thread DIzer
I do not take in what are you talking about... When i told on Rustish way - I meant (first of all) on its ability to create and maintain (mostly AUTOMATICALLY ) simple projects at the Cargo's level. It is about the case when your pease of code relies upon THIRD PARTY packages (those are in not m

Show Nim: Pixie now supports text layout and rasterizing, including rich text with styled spans!

2021-05-18 Thread linwaytin
I'm happy to see the integration with `typography`. Congrats the project reaches 2.0. I would suggest writing a blog post to introduce this library. You can share the link on Hacker News so that more people can know your work and `nim`.

Show Nim: Pixie now supports text layout and rasterizing, including rich text with styled spans!

2021-05-18 Thread guzba
I somehow got it into my head that Nimble was somewhat semver-ey, where the major version should be used to indicate changes that are not backward compatible. It turns out Nimble versions and it's `>=` operator is not quite like npm with this stuff. Now at least my understanding is corrected.

Python style in Nim

2021-05-18 Thread lscrd
After some reluctance, as I was used to Python list/dict/set comprehensions, I finally tried `collect` and I’m rather satisfied with it. I find important that it doesn’t cause any overhead. I appreciate the procedures and templates from `sequtils` too (especially those with `it`) but they creat

Python style in Nim

2021-05-18 Thread Zoom
For this specific case `mapIt` from sequtils works just fine, but the catch is, these templates don't, eh, compose well. :P They all consume the iteration. As soon as you need to do some additional transformations, they are more or less useless (so most of the time I don't even bother). This is

Concept containing seq of self

2021-05-18 Thread xigoi
Have you tried `{.explain.}`? > By default, the compiler will report the matching errors in concepts only > when no other overload can be selected and a normal compilation error is > produced. When you need to understand why the compiler is not matching a > particular concept and, as a result,

Dynamic size limit for sets

2021-05-18 Thread xigoi
Nim's built-in sets must have a static size. You'll probably have to implement a dynamic set yourself (perhaps using `seq[int32]` and some bitwise magic), or check if someone has already implemented it.

Using generic procedure with mixin can be dangerous?

2021-05-18 Thread demotomohiro
> IMO yes and there is no bug here. When a generic instantiation is re-used, no > scope checking is performed. Then, fixing this problem seems hard. Maybe, restriction like "If a generic proc use mixin, One of type parameter must be a module local type" might fix it. But that might be inconveni

Weaning myself off bash for Nim for little plumbing tools

2021-05-18 Thread SolitudeSF
`nim r` places binary in nimcache

Nim as a classic programming language

2021-05-18 Thread Araq
It trusts the user.

Weaning myself off bash for Nim for little plumbing tools

2021-05-18 Thread alexeypetrushin
Thanks, I didn't knew about `nim r` and always used `nim -r` :)

Nim as a classic programming language

2021-05-18 Thread bpr
The concept is not checked in the procedure body during the declaration, like a regular non generic type would be. That's unfortunate. I wonder if there's a conservative solution to rule out cases like this without making the concepts unusable? For those who use C++, C++ 20 concepts fail this t

Nim as a classic programming language

2021-05-18 Thread margin
> There is nothing to prove really. These annotations override the compiler's > reasonings. Well I mean if an acyclic prameter/type is acyclic, but it's to complex to figuring that out, does the compiler trust the user or is an error issued?

Python style in Nim

2021-05-18 Thread Araq
> Using collect macro is almost as long as allocating the new collection and > populating it manually. While the whole point of comprehension is to be a > shortcut. No, the point is to turn a `for` loop into an expression and Nim's `collect` accomplishes that successfully and without overhead.

Python style in Nim

2021-05-18 Thread alexeypetrushin
Having comprehensions would be still better. Using `collect` macro is almost as long as allocating the new collection and populating it manually. While the whole point of comprehension is to be a shortcut. let data = for s in splitString: parseHexStr(s) Run

Python style in Nim

2021-05-18 Thread Yardanico
Sugar module (called `future` in the past) did have list comprehensions, but they were hard to understand so almost no one used them, hence they were deprecated and moved out of the stdlib

Weaning myself off bash for Nim for little plumbing tools

2021-05-18 Thread alexeypetrushin
I don't compile Nim, and use `nim c -r program.nim` instead or add `#!/usr/bin/env nim c -r` at the top of `nim` file.

Concept containing seq of self

2021-05-18 Thread SimplyZ
Hello! I'm quite new to nim and I have a question regarding concepts. I'm trying to create a concept for a simple tree. However, I'm having a confusing issue. How come this compiles: type TreeNode* = concept t t.children is seq[type t] proc isRootNode*(self: TreeNo

Show Nim: Pixie now supports text layout and rasterizing, including rich text with styled spans!

2021-05-18 Thread treeform
Thank you! But really we changed some minor APIs and now stuff breaks compatibility. We plan to have many versions.

Nim as a classic programming language

2021-05-18 Thread Araq
> What is the strategy for these 5 things, if the compiler can't prove them for > certain situations, is then an error issued or not? There is nothing to prove really. These annotations override the compiler's reasonings.

Nim as a classic programming language

2021-05-18 Thread margin
> Nim's type system, Concepts. Do they provide statical guarantees? Let's see... I find having both generics and templates is too much. Either approach has its advantages.

Dynamic size limit for sets

2021-05-18 Thread juancarlospaco
See the example here, it puts `high(int32)` in a `high(uint16)` set:

Dynamic size limit for sets

2021-05-18 Thread etorres404
Hi! I've been playing a bit with Nim's sets to check if I can use them for my application. In particular, I have to deal with a huge amount of sets, so I look for as much memory efficiency as possible. >From what I have seen, it seems the standard `set` would fit my needs. This >would be a si

JS FFI - getting started

2021-05-18 Thread juancarlospaco
Make some noise here, so it gets Merged or something, give your opinion if it is useful or whatever:

Onivim2: A surprisingly good working with Nim editor

2021-05-18 Thread bpr
I'm tempted to buy it just because I'm an OCaml fan, and it's written in ReasonML.

Weaning myself off bash for Nim for little plumbing tools

2021-05-18 Thread bpr
I like this topic. Reminds me of [this](https://www.teamten.com/lawrence/writings/java-for-everything.html).

JS FFI - getting started

2021-05-18 Thread mantielero
One more question: how can I "import" a .js file from nim (kind like `dynlib`, when doing FFI with C). I mean something like: when defined(nodejs): import crossfilter from './crossfilter.min.js' # <--- This is the Javascript that I want to replace Run This is

JS FFI - getting started

2021-05-18 Thread mantielero
@juancarlospaco, gracias! Finally I managed to get it working with: * `crossfilter.nim` import jsffi when not defined(js): {.error: "This module only works on the JavaScript platform".} type Crossfilter* = ref object proc crossfilter*(a:ope

JS FFI - getting started

2021-05-18 Thread juancarlospaco
It depends how you want to design, you can make it more safe, or not. You can see an example on the `FetchOptions` of `jsfetch`, has `newfetchOptions` and `unsafeNewfetchOptions`

JS FFI - getting started

2021-05-18 Thread juancarlospaco
`a: openArray[JsObject]`

JS FFI - getting started

2021-05-18 Thread mantielero
It looks good. For the record, I did: import jsffi ... proc crossfilter*(a:seq[JsObject]): Crossfilter {.importc:"crossfilter".} ... Run and import crossfilter, jsffi let data = @[ js{ name: "Rusty", type: "human", legs: 2 },

JS FFI - getting started

2021-05-18 Thread sdmcallister
Another example but with vega-lite: import jsffi, strutils, json, jsconsole proc vegaEmbed(id: cstring, vlSpec: JsObject) {.importc.} proc parseJsonToJs*(json: cstring): JsObject {.importjs: "JSON.parse(#)".} var vlSpec = """{ "$schema": "https://vega

Onivim2: A surprisingly good working with Nim editor

2021-05-18 Thread zetashift
It has a different take on sustainable FOSS: . So in a way it is FOSS! That being said, I found it worth my money.

JS FFI - getting started

2021-05-18 Thread juancarlospaco
Try JsObject instead of JsonNode ?

Onivim2: A surprisingly good working with Nim editor

2021-05-18 Thread enthus1ast
It's not FOSS :/

JS FFI - getting started

2021-05-18 Thread mantielero
I'd like to try FFI with JS. For that purpose, I'd like to play with [crossfilter](https://github.com/crossfilter/crossfilter). A minimal crossfilter example looks like `example.js`: var livingThings = crossfilter([ // Fact data. { name: "Rusty", type: "human", legs:

pkcs11 implementation

2021-05-18 Thread shirleyquirk
There's a wrapper of gnutls [here](https://github.com/FedericoCeratto/nim-gnutls) that provides pkcs11 functions, maybe that could help.

Nim as a classic programming language

2021-05-18 Thread xigoi
Concepts provide positive guarantees, but not negative guarantees. Nim will still use static duck typing to try to substitute the type, and if it works, cool.

Int/Floating Point Cast Result

2021-05-18 Thread choose
I have not. Thanks!

Nim as a classic programming language

2021-05-18 Thread Sixte
Nim's type system, Concepts. Do they give statical guarantees? Let's see... #{.experimental.} type Aclass = concept x x.inum is int Anobj = object fnum : float inum : int Bnobj = object text : string inum : int

Weaning myself off bash for Nim for little plumbing tools

2021-05-18 Thread cblake
You can also just use: #!/usr/bin/nim r Run (or whatever other path to nim), though it may produce unwanted or use an unoptimized compile output depending upon your config.

User feedback needed about synchronization primitive call once

2021-05-18 Thread OneStepGuy
And not to forget about the _singleton_ pattern: proc singleton(): string = var witness {.global.}: bool if witness: result = "Kilroy was here" else: result = "First time initialization" witness = true when isMainModule: for f

Python style in Nim

2021-05-18 Thread kaushalmodi
@matthesound For your example, I'll simply use `mapIt` from `sequtils`: import std/[strutils, sequtils] echo "0x42 0xDEADBEEF 0x1".split().mapIt(fromHex[int](it)) Run

Weaning myself off bash for Nim for little plumbing tools

2021-05-18 Thread PMunch
For writing small scripts in Nim you might want to check out [`nimcr`](https://github.com/PMunch/nimcr). It will allow you to add a shebang to your Nim file and it will automatically recompile whenever you change it and only shows compilation warnings if the file fails to compile.

User feedback needed about synchronization primitive call once

2021-05-18 Thread euant
I haven't actually tested the library in a while now, and Nim has a habit of changing. Last time I did check was with Nim 1.2.6, and we're now up to 1.4.6 so things may have changed. I would also read the pthread docs the same way personally, with `deinitLock` being unsafe if `initLock` hasn't

User feedback needed about synchronization primitive call once

2021-05-18 Thread b3liever
Nice, I wasn't aware of your implementation, I should have searched nimble. Btw isn't your package affected by [issue](https://github.com/nim-lang/Nim/issues/14873#issuecomment-784241605)? For me I can't get the object init function and destructors to work.

Karax steps forward

2021-05-18 Thread Araq
Yes, if you think in "components" you're already using the wrong mental model and Karax won't help you. And yeah, maybe Svelte can be an inspiration as a virtual DOM is fundamentally at odds with the _stateful_ DOM.

User feedback needed about synchronization primitive call once

2021-05-18 Thread euant
There was a thread on this very topic a while back, but I can't for the life of me find it now. At the time, I created the following library:

pkcs11 implementation

2021-05-18 Thread viralpoetry
Dear community, I am in search for a pkcs11 client implementation or wrapper over some library to work with smartcards. If you are aware of such projects, please share. Thank you !

NimConf 2021

2021-05-18 Thread pietroppeter
Currently, the two most viewed and commented posts are [Nim 2.0 -- thoughts](https://forum.nim-lang.org/t/7983) and [How to make Nim more popular](https://forum.nim-lang.org/t/7906). How about organizing for NimConf 2021 a round table (or two) with a moderator (@narimiran ?) and invited "paneli