Small Nim js fib benchmark

2022-11-18 Thread hyl
In my unscientific comparison, I was comparing minified to minified and Nim still did well. I also like the Nim->JS output not being pre-minified, because it makes it easier to see what Nim is doing (some other compiles-to-JS languages don't output readable JS).

Small Nim js fib benchmark

2022-11-17 Thread hyl
That is true, and for small programs there's not necessarily much gain. I guess there's two ways of looking at a compiles-to-JS language: is it 1) a small syntax skin over JS maybe with compile-time checks (eg TypeScript, CoffeeScript), or 2) a significant semantic departure from JS (eg Clojure

Small Nim js fib benchmark

2022-11-16 Thread hyl
> In my case I'm making a WebExtension, so code size is not my priority. But I > would need a bleeding edge JavaScript WebExtension / browser API binding to > actually use Nim at work. I agree that the code size of Nim's output isn't so important: there are many tools to minify or compress Java

Nim v2: what would you change?

2022-05-10 Thread hyl
Pretty minor thing compared to some of the stuff here: I really like using Nim's UFCS to chain together calls, but this currently doesn't work well when I need to disambiguate by module. Eg: `foo.bar.baz.quux` works until I import a module with a conflicting function name. The obvious extension

NImScript task and using a shebang line

2022-02-10 Thread hyl
Oh you are right @SolitudeSF! I did not know that. This works: #!/usr/bin/env nim r --hints:off --warnings:off echo CompileTime Run Something subtle I think I'm noticing is that running using nimcr is faster than `nim r` after compiling the time. Not sure why.

NImScript task and using a shebang line

2022-02-09 Thread hyl
@pietroppeter I believe `nim r` would compile before every run, while nimcr checks whether the source file has changed since the last compilation, and if not, then it just runs the previously compiled binary. @jyapayne Thanks! I guess that would work. I'd need to explicitly unignore any other h

NImScript task and using a shebang line

2022-02-09 Thread hyl
I recommend @PMunch's library, nimcr, too. You can also define tasks in config.nims. You can list them with `nim help` and run them with `nim taskname`. You can have a config.nims in a directory (like the root of a project), or have one for your user at ~/.config/nim/config.nims Or you can add

Stdlib and fusion evolution

2021-01-07 Thread hyl
I'm not a stakeholder in nim, so I don't want to pollute the RFC, but I wanted to share that the "diamond" problem that arne and disruptek discussed is something that I've seen. What we did in that case is actually sort of similar to what Araq initially proposed. We had version folders (eg `v1`

Seq, table. How to efficiently reference the last item

2020-12-15 Thread hyl
Thanks I think that was it!

Seq, table. How to efficiently reference the last item

2020-12-15 Thread hyl
I didn't see it mentioned, but mySeq.high also exists. That is: `let lastElement = mySeq[mySeq.high]`. That can be useful sometimes, eg: `for i in 0..mySeq.high: ...` That doesn't help in the OrderedTable example though, you still need to know the key. I'm a little surprised that there isn't an

Advent of Nim 2020 megathread

2020-12-07 Thread hyl
@fxn does mgetOrPut do what you need?

Package level scope

2020-12-04 Thread hyl
There is also the option of having a specific public API module that only exposes what you want to expose. This gives the "second level" Sixte is asking for. There's nothing stopping a consumer from importing the private modules, but I feel that if your module makes it clear that the public modu

Advent of Nim 2020 megathread

2020-12-03 Thread hyl
Right, everyone gets just one private leaderboard of their own, but you can join as many as you want (as far as I understand it). Here is mine: 681448-60235f8f Please only join if you are doing Advent of Code 2020 and the first language you use to solve each day is nim. Honor system because I d

Advent of Nim 2020 megathread

2020-12-02 Thread hyl
+1 to making a new 2020 specific nim leaderboard. I can make one if no one else wants to.

Advent of Nim 2020 megathread

2020-11-27 Thread hyl
If we hit the 200 limit, then I like @pietroppeter 's idea to make a year-specific leaderboard. Last year we had people who weren't actually using nim on it XD @xigoi I'm in a similar situation, and busier this year than the last one too.

Proposal: Renaming imported symbols

2020-07-27 Thread hyl
I'm not a perfectionist, but I work with people who can be. I enjoy nim a great deal, but if I wanted to use nim on a project with them, then I know this will be a sticking point. The use case I'm most concerned about is when reviewers are viewing code in github or bitbucket or similar, and don'

required type seq[float or float32 or int], but expression is of type: seq[float32]

2020-07-27 Thread hyl
tim-st is correct. Right now your code requires the two args to be the same type, you need to tell the compiler that they might be different. There are a few ways to approach this. What tim_st suggested, and a couple more here: [https://play.nim-lang.org/#ix=2srJ](https://play.nim-lang.org/#ix=2