Possible issue with getting the starting address of a Nim string

2024-08-26 Thread cblake
Well, there is this now: What's that old saying? A PR is worth a thousand words? ;-) ;-) { PR could abbreviate "picture" if that is too hard to track.. }

Running procs from a list of procs

2024-08-24 Thread cblake
This works: proc test1 = echo "Hello" proc test2 = echo "World" for p in [test1, test2]: p() Run Note the dropped optional ()s for an empty parameter list. Before you were trying to "call" a "string" which is.. not something most people would expect to work. E

Faster Euclidean algorithm

2024-08-23 Thread cblake
Mostly I wrote all that to show how big an impact the "table's corner" effect you mention can be and to encourage moving away from anti-thermal sleep()s in favor of small times which require more care. Just to be clear, there are 9*9 inner loops by 500 pairs in that last batch, so 40_500 gcd pai

Faster Euclidean algorithm

2024-08-22 Thread cblake
Possibly harmful to result interpretation esp. cross-CPUs with things like RPi/ARM: The minimum over `101` runs in your `bench` template is good to reduce noise from CPU spin up to higher clock rates, BUT the two `sleep()` s are bad since you are probably giving the CPU/OS time to put the CPU ba

Fusion OS: a hobby kernel written in Nim

2024-08-21 Thread cblake
Kernel-tracked contexts/scopes (along the lines of transactions for DBs) is an interesting idea. If memory allocation { sbrk/mmap(anonymous)/etc. } is a part of that, it could actually _include_ a variant of arena-style memory management. Hierarchy may also be interesting (as with nested transa

Fusion OS: a hobby kernel written in Nim

2024-08-21 Thread cblake
@grd (Araq obv. knows this), the OS does clean-up everything it can automatically, but to the OS, a "scope" is a "process". So, you do not need to free memory or close file handles or sockets or memory maps if your program logic knows a process is about to die & be reaped by the OS "soon enough"

Request: please maintain a changelog on your project

2024-08-08 Thread cblake
Maybe helpful to someone - lately, I've just been using a shell script equivalent to: git log --oneline $(git describe --tags --abbrev=0)..HEAD Run to populate github release notes with important changes. Then I can just `nrel -u` and go to `github.com` to click on a

Datafame library that handles time series data

2024-08-04 Thread cblake
As @Vindaar says, it really depends upon how much statically compiled vs. dynamically interpreted typing you need|want. If you are currently using Polars but only through the "dynamic lens" of Python bindings then you could be in for a world of cross run-time/compile-time impedance mismatches.

nim simd (avx2) How to get going?

2024-07-27 Thread cblake
You just want to use pointers and the AVX load instructions like but you will have to ensure your seq/array/openarray that you run `addr x[0]` on are all long enough &| pass that length to your routines.

Compile times normal or my fault?

2024-07-24 Thread cblake
> Any ideas? Though "how much C nim generates" can evolve/vary, it might still help to see how much time is in `gcc` vs. `nim` by simply doing `nim c -c --d:threadsafe -d:useMalloc my_web_app.nim` (i.e. `-r` -> `-c`).

TinyCC/tcc vs zig cc compile-times/etc.

2024-07-20 Thread cblake
I should also have mentioned that I have a `d=nimPreviewSlimSystem` in my `nim.cfg` which still breaks many things (self tests, [nimble](https://github.com/nim-lang/nimble/issues/1050), etc.) but which does make the empty file compile time `1.0779 +- 0.0088` times faster (notably, quite a bit s

TinyCC/tcc vs zig cc compile-times/etc.

2024-07-20 Thread cblake
While I see you already figured out your answer, since you revived this ancient thread, I can perhaps say some other things that might be helpful for fast compiles. I do this in my $HOME/.config/nim/nim.cfg: # Ideally, each Nim compiler flag would have an associated defineSymbol, B

simpleargs - Dead simple CLI parsing.

2024-07-05 Thread cblake
`cligen` does not hide the main control flow, per se (which you mention 3 times) -- `dispatch` is meant here as a verb after all meaning "do something". You can even define `mergeParams` to redirect "do it to what?". CLauthors must even choose _where_ to invoke - unconditional global code, guard

simpleargs - Dead simple CLI parsing.

2024-07-02 Thread cblake
By all means, do your own thing, but > and don't let you write your own docstrings is (and always has been) simply untrue of (at least) [cligen](https://github.com/c-blake/cligen). proc foo(myParam=1) = discard import cligen; include cligen/mergeCfgEnv dispatch foo, usage="

StableSeq

2024-07-01 Thread cblake
Given that Nim has qualifiers like `noinit` (in the memory handling optimization area, no less), `NoMoveSeq` is another idea family. "move" is what's used in a few places for address instability. I still kind of like "unmoved" as the only real possibility of confusion...just isn't there. Data t

StableSeq

2024-06-30 Thread cblake
Yeah..Good point, @jackhftang. A discrete log formula might yield a slightly faster `[]`. This relates to my `# User growth policy for below?` comment and the way I let people "guess" an initial `cap`. I have seen people target as low as 1.10x exponential growth and as high as 4x.. a big range.

StableSeq

2024-06-30 Thread cblake
Oh, and in terms of an alternative to `append` due to missing stdlib conventions, `added` might work as in "stable address of that which was just added" but if these things are unmovable addresses, we should try to make `ss[i].addr` also work so maybe `ss[^1].addr` could also.

StableSeq

2024-06-30 Thread cblake
Well, you did list 4 points and didn't mention extending to `Table` until just now. A lot of OS people mean "pinned" to refer to memory pages that are prevented from being swapped out to disk. If we want some short adjectival English words for "immovable" or "immobile" we can use [thes](https:/

StableSeq

2024-06-30 Thread cblake
With Araq's exponential growth idea keeping the lists very short (like 16..48 at most, at 8 bytes an entry or maybe 1..2 cache lines typically and no more than 6 cache lines), I should perhaps have said that, it might be faster to even do a linear search up to 8..16 entries instead of `lowerBoun

StableSeq

2024-06-30 Thread cblake
Re: the ring proposal - I understand it's not quite the same, but there is also already `std/deques`. I didn't do any ensureMove/lent/sink/etc., and I just picked `Colony[T]` since that seems to be used in at least one other ecosystem and doesn't sound "suggestive" of, well, anything - so peopl

StableSeq

2024-06-30 Thread cblake
> 4\. `nav` should probably use some better algorithm I feel like long-term rather than a linked list, you would be better off building around something like: type HunkSeq*[T] = object caps, lens: seq[int] datas: seq[UncheckedArray[T]] Run It's o

Please help, learning NIM to speed up Python programs, but strange results

2024-06-06 Thread cblake
@epoz \- this & related topics come up a lot, but here is a perhaps more informative thread than many: (though maybe you will fall asleep before reading all of it). @PMunch, I think `hyperfine` leaves "on the table/floor" much opportunity for precision on the

Hot Code Reloading viability for Jupyter-Notebook like Nim IDE

2024-06-01 Thread cblake
Yeah.. that came up in a private conversation as the easiest next step for global "workspaces" like the R repl has. There' s still perhaps some trickiness if any objects contain pointers to other objects since pointers are not "fat" (or encoded as offsets to some base address to be "re-linked at

Hot Code Reloading viability for Jupyter-Notebook like Nim IDE

2024-05-30 Thread cblake
@Niminem \- I have done the `std/memfiles` thing a lot to avoid "recalculating The World" only because your process exited. >1 value is not hard and you're already close. is really a generic data layer ("like CSV but running off **_live_** mmaps because, once you

Where does the complexity of quote from the manual comes from

2024-05-24 Thread cblake
ChatGPT sez: The quote "Complexity seems to be a lot like energy: you can transfer it from the end-user to one/some of the other players, but the total amount seems to remain pretty much constant for a given task." is attributed to Richard P. Gabriel, a well-known computer scientist and writer.

Where does the complexity of quote from the manual comes from

2024-05-24 Thread cblake
Outstanding sleuthing, @Yardanico! (The ideas seem to have been definitely floating around from the 1960s with Herb Simon and systems complexity theory and later in the 80s with Fred Brooks and Richard Gabriel and others and of course many of us like physics metaphors because Physics is "imitati

Custom constructors

2024-01-24 Thread cblake
@lim1999 \- it could be you are only using units of measure to drive your exploration of Nim, in which case may or may not help you, but it seemed worth point it out since it is a fairly thorough exploration of compile-time units of measure in Nim.

TCC on ARM(el) backend problem

2024-01-21 Thread cblake
I am one of the successful users and can also confirm I'd be alienated. :-) :-) :-) { Though I could probably also patch around things. } Not that I think Araq does not know this, but it bears re-mention every time that it's always better to construct something reproducible -- whenever talking

orc mm slower than markandsweep in my experience

2024-01-17 Thread cblake
@enb450 \- WELCOME! Also, 3 things: 1. PGO can also be very useful (2..3X) - or not at all or even hurt! - and may be worth a try: 2. To expand on why recursive Fibonacci is a terrible benchmark, which it absolutely is @Araq is 100% right, some backen

missing topN/partial_sort in stdlib :-(

2023-12-27 Thread cblake
FWIW, if you're going out to the nimbleverse already, it's already in [adix/lptabz](https://github.com/c-blake/adix/blob/4f4e502125d75874a56de0a7a60298de7d1d5a53/adix/lptabz.nim#L1084) and for small key spaces (like char or short-indexable) in [adix/ditab](https://github.com/c-blake/adix/blob/4f

How to force inline?

2023-12-15 Thread cblake
@gcao \- because your file name seems to be "fibonacci.nim", it bears mention that some versions of some compilers and some versions of Nim have an ability to inline several recursion levels of f(n)=f(n-1)+f(n-2) BUT they are very finicky about the shape of code to trigger this code optimization

how to feed stdin to external process and redirect stdout ?

2023-11-08 Thread cblake
The trickier parts of any approach in this vein arises when keeping alive the "companion process" to your reader and IPC is a big topic { [Here are some slides](https://nmsl.cs.nthu.edu.tw/wp-content/uploads/2011/09/images_courses_CS5432_2016_15-classipc.pdf) and [cligen/osUt](https://github.co

How to pass an optional table as an argument to a function?

2023-11-04 Thread cblake
Nim has optional named arguments. How about simply import std/tables proc maybeTable*[T](collection: seq[T], table=initTable[T]()): T = if table.len == 0: discard # same if users passes an empty table Run It's actually possible to do more here, like have some

Labelled exceptions for smoother error handling

2023-11-01 Thread cblake
If you just want to get a "raise location" into various messages for the purposes of better logs then you could do something like the Linux glibc `backtrace_symbols` (3) at the point of the `raise` (`gcc` itself provides mostly what is needed via `__builtin_return_address`). On the one hand that

how to wrap c scanf procedure in nim

2023-10-27 Thread cblake
Maybe being explicit here will help. So, proc scanf*(fmt: cstring): int {.importc, varargs.} var a, b, c: cint echo scanf("%d %d %d", a.addr, b.addr, c.addr) # 3 echo a # first 3 cints that echo b # user put into stdin echo c Run Save the above in a

And the fastest language to print hello world is ...

2023-10-16 Thread cblake
The numbers on that page seem sloppy, incomplete, and probably misleading - at least for Nim, but probably for more. It seems like this is honestly more of a libc/OS benchmark than a PL one. E.g.: E.g., using `tim` out of [bu](https://github.com/c-blake/bu), just copy-pasting that program

related_post_gen benchmark

2023-10-12 Thread cblake
> "how performant is the 'idiomatic' solution" Sure, but what is "idiomatic" cannot be easily measured without surveys which are rarely done. E.g., for this very benchmark there were like 8 Rust and 8 differently optimized Go variants hidden under "Old Results". Which is "most idiomatic"? That

related_post_gen benchmark

2023-10-11 Thread cblake
Re: 8% - `jsony` also seems to use `std/tables`. You can tell from the extra `dt`, `dt2` instrumentation how small a fraction the initial hashing is. I get ~ 1%. And I never said it fulfilled all the rules..some of which are just dumb. It would be very easy to boost to 128 tags and 2^32 posts i

related_post_gen benchmark

2023-10-11 Thread cblake
FWIW, there is a way to make the hashing part barely matter at all, at least for 5000 posts and tag distributions like the posts.json in the repo. I actually got a run time about 75% of the one in the repo from PMunch (with both compiled with `-d:danger`) - just one 1 CPU. No idea about github C

related_post_gen benchmark

2023-10-11 Thread cblake
@inv2004 \- if all you want to do is use this as an exercise to learn / teach this specific benchmark, you could be sure to pack the whole problem into an L2-CPU by using the techniques of to **_pack a whole hash cell into just 8 byte

Nim boilerplate

2023-10-11 Thread cblake
Possibly more helpful to reduce boilerplate is with `template` as used, e.g. at the bottom of which is then used by the example program . (That is for new style `concept` whi

related_post_gen benchmark

2023-10-11 Thread cblake
> very few if any posts have 65..100 tags In fact, one can systematize based upon that to keep the hot-path memory footprint small by using 1 bit out of the 64 as an "overflow flag". So, e.g. up to 63 tags work with the bit-vector and the ones past that (64..100) are treated specially as done,

related_post_gen benchmark

2023-10-11 Thread cblake
(key concepts are triple-star bold-italic for your reading ease) @inv2004 \- fnv1 does byte-at-a-time processing which is slower compared to 8-byte at a time processing on modern CPUs just because there are many fewer loops. So, **_for example_** , here is a table I made { on just one CPU (i7-6

Is there a `terminal.setRaw` on Linux?

2023-09-23 Thread cblake
Making `getCursorPos` work with both Windows & not would strongly motivate export of `getCursorPos`, IMO. (And maybe `setRaw` along for the ride...).

Is there a `terminal.setRaw` on Linux?

2023-09-23 Thread cblake
I also noticed that after my suggestion. :) FYI - even with no PR you can just `import terminal {.all.}` on non-Windows. E.g.: import terminal {.all.} echo setRaw.repr Run Maybe you know that already, too. You do expose yourself to recompilation trouble if that pa

The secret of Nim

2023-09-22 Thread cblake
By the way, in case it went over anyone's head, this thread is an, ahem, not so subtle reference to a movie [based on a book](https://en.wikipedia.org/wiki/Mrs._Frisby_and_the_Rats_of_NIMH) (series) I enjoyed as a kid too many decades ago: I d

Is there a `terminal.setRaw` on Linux?

2023-09-17 Thread cblake
NOTE: You may need to get `_BSD_SOURCE` or `_GNU_SOURCE` C `#define` 'd on Linux to implement Araq's fine suggestion. `nim c --passC:-D_GNU_SOURCE` is one way, but you could also do a Nim pragma in the source code (like `{. passC: "..." .}`). Alternatively, `cfmakeraw` does very little { as Ara

Improving Examples and Documentation

2023-09-13 Thread cblake
Documentation (and both teaching / writing in general) is a never-ending task with strong dependency / variation across target audiences & situations. Every year new kids enter kindergarten. :-) One can always try to be better / reach more, but there is also almost never "one level". E.g., unive

why float casting is not working ?

2023-09-08 Thread cblake
A quick `grep` suggests about 210 packages in ~560 files use expression `type()`. So, I don't know.. that's like 10% of Nimble packages. Of course, there are definitely many packages not in the nimble index, and also dark code that is not even public. I am aware of at least order(100) subcommand

why float casting is not working ?

2023-09-08 Thread cblake
I think `typeof` is better in an expression context like above -- sorry -- and `type` use there is "deprecated" (but works obviously if you compile & run it). I have no idea what the timeline for really deprecating this use is or how much of the nimbleverse will break if it actually goes away.

why float casting is not working ?

2023-09-08 Thread cblake
Also, you don't need the apostrophe `'` for `float` and `uint` (and maybe others): echo type(1f)," ",type(1u) Run And if you put the word "Nim" after the triple open quotes it will syntax-highlight your code on The Forum (if you did not know).

\suggestions on handling \destructuring of array/seq into a list of named fields?

2023-08-15 Thread cblake
This might get you started: import std/macros macro toLets[T](vals: openArray[T], vars: varargs[untyped]): untyped = result = newStmtList() for i, v in vars: # change| to const or var result.add(quote do: (let `v` = `vals`[`i`])) var fieldList = [

Why is My Nim Code Faster when Doing This

2023-08-08 Thread cblake
Surprised no one has yet mentioned: import std/algorithm proc main = var s = "Hello world" when defined(faster): reverse(s, 0, s.len - 1) for i in 1..200_000_000: reverse(s, 0, s.len - 1) main() Run and which side steps all the allocation stuff

Why `unsafe_addr` had to be used in StringSlice?

2023-06-15 Thread cblake
or **_ap_** pended if you ever want to just `cast[cstring](trigm[0].addr)` :) The speed-up is mostly about the impl of `hash`, I expect. So, if that 25% storage vs `array[3]` is not paid for by better memory alignment you could also re-do `hash(Trigram)` to load a uint32 and then `hash()` that..

Measures - A library for conversion and definitions of measurement units

2023-06-04 Thread cblake
You may want to have a look at: and other related SciNim projects like Measuremancer & Datamancer.

Bloom filter comparisson

2023-05-27 Thread cblake
> storing all trigrams of a file in a normal hash set The comparison is not between an exact set & Bloom, but between Bloom & another approx idea: hash sets of B-bit numbers (sometimes called fingerprints or truncated hashes or just B-bits of hash), just as what Bloom 1970 does. It is true that

Platonic: core math concepts

2023-05-26 Thread cblake
A firm operational boundary in this space is: what you know when. @mratsim's example is the one I always give in relation to [nio](https://github.com/c-blake/nio): file sizes / contents (e.g. headers) are intrinsically something you only know at run-time. Full stop. `nio` has to do that whole r

Bloom filter comparisson

2023-05-26 Thread cblake
While [this misunderstanding happens a lot](https://github.com/c-blake/adix#a-word-of-caution), Bloom Filters have always been about space optimization with little consideration of caching/blocking, even in the [aboriginal 5 page paper by Bloom](https://crystal.uta.edu/~mcguigan/cse6350/papers/

feasible lib(s) to do FFT on image with minimal dependencies?

2023-05-15 Thread cblake
At least from the "checkmarks" in the README, `pixie` does not write JPEG. So, it may not do the raster -> to JPEG. [ggplotnim](https://github.com/Vindaar/ggplotnim) was another thought, but it looks like it uses `cairo` as an image writing backend. I looked a little through Nimbleverse, but co

feasible lib(s) to do FFT on image with minimal dependencies?

2023-05-14 Thread cblake
@oyster \- low-pass filtering is roughly [how JPEG works in the first place](https://en.wikipedia.org/wiki/JPEG). You can probably just use average per 8x8 block JPEG compression ratios to score image blurriness. Or variations on that theme. If your input is already delivered in `.jpg`, this com

fetching data from many small .txt files

2023-05-02 Thread cblake
First, always best to have reproducible test data! Great initiative, @Zoom! @tcheran did not specify if the grid was fixed over samples or varying. Either could make sense (e.g. with wandering sensors that use the GPS satellite network to self-locate), but very different perf numbers & optimizat

How to implement Trie data structure.

2023-05-02 Thread cblake
There is a more fully worked out example in \-- the core idea is over by line 63. I may soon be lifting the [ternary search tree](https://en.wikipedia.org/wiki/Ternary_search_tree), that unordered trie, and that which uses both, t

fetching data from many small .txt files

2023-05-01 Thread cblake
I believe you may be running into this bug: Let me punch a new cligen-1.6.2 release for you. Give me a few minutes.

Can I quick get table last key value use like at(idx) function?

2023-05-01 Thread cblake
I think there is an argument to be made for "something super basic in `std/` that could maybe be a B-tree" and _something else_ with a lot of knobs/levers when people know they want a hash table and want to be able to tune it. In fact, that might even be what @Araq has a draft of. I am also fin

fetching data from many small .txt files

2023-05-01 Thread cblake
Huh. Well, if you got only a 5% speed-up then that is consistent with your prior IO bound claims, but also consistent with said IO being very slow.. maybe from anti-malware as you propose. The Defender stuff could be intercepting system calls, too. That might be another reason to try the `std/m

fetching data from many small .txt files

2023-04-30 Thread cblake
I suspect there may be system settings to optimize small file IO on Windows 10, but I am not the person to ask and that is actually not very Nim-specific. I will observe that 3,000 lines of 40-ish byte lines is like 120 KiB or 30 virtual memory pages which may not be what everyone considers "sma

Can I quick get table last key value use like at(idx) function?

2023-04-30 Thread cblake
FWIW, this should already work in [adix](https://github.com/c-blake/adix) in compact-insertion-ordered mode [lptabz](https://github.com/c-blake/adix/blob/master/adix/lptabz.nim#L708). The data will not be very predictable if you start doing any deletes, but @Angluca's use case sounds very stati

How to inverse set?

2023-04-18 Thread cblake
The name in mathematics is ["set complement"](https://en.wikipedia.org/wiki/Complement_\(set_theory\)) not "inverse" and there is a func in a stdlib module for this: import std/setutils echo complement({'a'..'z'}) Run

+= operator with if statement gives errors

2023-04-17 Thread cblake
This also works (with or without parens): inc myFloor, if myMoves == UP: 1 else: -1 Run

How to make os (e.g. ubuntu) interpret nimscript shebang

2023-04-17 Thread cblake
The manual needs updating regarding this. At the very end of the standalone section is also missing the `e` in `nim e` (and has the `--hints:off`).

Speeding up compile times

2023-04-12 Thread cblake
@vanyle \- I always use [the mob branch](https://repo.or.cz/w/tinycc.git), but virtually never have trouble on Linux x64 with `nim c --cc=tcc --mm=markAndSweep` except that the code runs more slowly in exchange for the faster compile times, much as would be the case for `gcc -O0`. I will reiter

Speeding up compile times

2023-04-12 Thread cblake
If you don't know about it, might help you. Specifically, if you are using `gcc` then `-O0` might help for your "fast iteration" work flow. Or, if you can, `tcc`. (You may need to use an older GC like --mm:markAndSweep to get that to work these days.)

Negative number as program argument

2023-03-17 Thread cblake
Cool. Well, just raise issues on the repo if you have any questions. The docs of many details could be better, but the closed issue threads are a vast catacombs.

Negative number as program argument

2023-03-17 Thread cblake
Well, I called it "parseopt3" 7 years ago because I thought I might try to get it into the stdlib. In the early days, `cligen` was just cligen.nim, argcvt.nim, and then parseopt3.nim. Had I tried to get it in to stdlib (or just tolerated the stdlib diffs), it would have been only 2 modules. At t

Negative number as program argument

2023-03-17 Thread cblake
The nim stdlib parsopt has various deviations from POSIX. You may find more to your liking. `cligen` supports the `--` separator in its `cligen/parseopt3`. Also, when auto-converting string->binary integers from positional params (say to a receiving `seq[int]`

Export C library components when using `--app:lib`

2023-03-15 Thread cblake
> in the Nim object cache but don’t seem to be[..]linkedin Maybe add `--passL:foo.o` ?

Help with a simple gstreamer application

2023-03-03 Thread cblake
I think the last 3 `--passC` (with the `-l`) should instead be `--passL`.

Is it possible to only compile the linked modules but not the executable?

2023-02-21 Thread cblake
I confess to not being 100% sure what you mean by the "module and not the program", but maybe `nim cpp -c foo.nim` to only generate ".cpp" files or `nim cpp --noLinking=on foo.nim` to stop at a forest of ".o/.obj" files in your nimcache are what you are after? (Both are revealed by `nim --advanc

RosettaBoy - Gameboy emulator rosetta stone

2023-02-18 Thread cblake
Profiling shows like 35-40% of the CPU time is just in that `nim/src/ram.get` template. This is supported by overall time variations as big as 12% I see by fiddling with the way `of`-branches work in `ram.get` (showing 10% changes in branch mispredicts via `perf stat -ddd` on a Linux Skylake acr

How to catch/ignore exception when iterating over a CSV file with CsvParser?

2023-02-10 Thread cblake
You may be able to re-structure your code like: import std/[os, syncio, streams, strutils, parsecsv] var x: CsvParser open(x, newFileStream(stdin), paramStr(1)) while true: try: if not readRow(x): break if len(x.row) == 17: echo join(x.row,

`-d:nimPreviewSlimSystem` reduces the execution time of simple nimscript programs to a half

2023-02-10 Thread cblake
At least for me, timings around a few 10s of milliseconds tend to be fairly polluted by system noise. So, I reproduced your result like this: touch j.nims tim "nim e j.nims" "nim e -d:nimPreviewSlimSystem j.nims" 0.055969 +- 0.34nim e j.nims 0.026807 +- 0.71

command line parametr with whitespace

2023-02-04 Thread cblake
Oh, yeah, FWIW, @domogled's apparent intent can be gotten with let x = r--title:new title with whitespace # ^start with " can skip 1^ Run on both Linux & Windows. Not great, but maybe not totally useless. There are "better" external thin

command line parametr with whitespace

2023-02-04 Thread cblake
Possibly helpful. The impl on Windows & Unix differs (big `when` and documented differences in `lib/std/cmdline.nim`). On Linux one sees (instead of what @enthus1ast describes): import os let x = r"""--title "new title with whitespace # ^space needed

RosettaBoy - Gameboy emulator rosetta stone

2023-02-03 Thread cblake
> I did not add march because looks like rust does not do it. On Linux Skylake i7-6700k, `-march=native` made Rust slower but Nim with gcc-12 faster. Even on one platform, fiddling with backend flags or PGO often moves things by >>> the +- 6% deltas you (now) see cross-lang. { But good work! Thi

RosettaBoy - Gameboy emulator rosetta stone

2023-02-03 Thread cblake
It is an unfortunate truism that those who put the most energy into many-prog.lang benchmarks often have little expertise in optimizing more than about 2 of said langs (never mind experience &| patience for the many compilation modes usually available &| more careful measurement). Indeed, it is

Minimising of using imports in the same project

2023-02-01 Thread cblake
On Linux you can also do something like [exsz](https://github.com/c-blake/cligen/blob/master/util/exsz) { mostly just `nm -oS --defined-only -fposix -td | sort -nk5` } on your nim-cache directory *.c.o's after building to explain object size in terms of functions / symbols which was useful for

How to ref value types in tables?

2023-01-30 Thread cblake
I'm not sure it has anything to do with `seq`-specialness as this also seems to work (as does changing `object` to `tuple` or `newTable` to `initTable`): import tables type Weight = object w: int labels: seq[string] var tab = newTable[string, Weight](8) let em

RosettaBoy - Gameboy emulator rosetta stone

2023-01-30 Thread cblake
I would try --passC:-march=native and also [PGO](https://forum.nim-lang.org/t/6295) before concluding much as mentioned [here](https://news.ycombinator.com/item?id=33347990).

How to ref value types in tables?

2023-01-30 Thread cblake
I could be missing something, but maybe worth mention that var s = addr tab.mgetOrPut(0, newSeq[int](1)) inc s[0] Run also already seems to work.. (unsure about borrowing semantics).

How to ref value types in tables?

2023-01-29 Thread cblake
You could also write a little update helper `proc` or use a hash table lib that supports an `editOrInit` template as mentioned here:

Why Nim does not support comparison between different types?

2023-01-27 Thread cblake
There is also a problem in @shirleyquirk's example of whether unmodified `char` is `signed` or `unsigned`: Basically `char a` could be either +128 or -128 before it is promoted to a C `int`. So, a << 1 can be ei

(In)secure Defaults

2023-01-08 Thread cblake
Since neither new Forum thread nor RFC arose out of , to cross reference: As per usual, feel free to either discuss or ignore.

A seasoned programmer's take on Nim's docs

2023-01-06 Thread cblake
Good point, but I saw no perf diff between urandom & random on my boxes, both 550 MB/s. The bigger diff for me was from 35+ GB/s for /dev/zero.

A seasoned programmer's take on Nim's docs

2023-01-06 Thread cblake
I mostly agree with all @pietroppeter said in this thread...but I tried to reproduce the AMD Linux `dd` benchmark justifying this > It's only about twice as fast. [..] Frankly, the performance difference is > such a non-issue that I would nuke existing statistical PRNGs all together. and notice

A seasoned programmer's take on Nim's docs

2023-01-03 Thread cblake
Thanks. I did similar in `cligen` for multi-commands to get a [default pre-commandList blurb from the top of a module doc comment](https://github.com/c-blake/cligen/blob/master/cligen/macUt.nim#L128). Even short blurbs can add lots of context to ident names & types...I'm not sure if the impatie

A seasoned programmer's take on Nim's docs

2023-01-03 Thread cblake
Re: priorities, as with the style-insensitivity debate, there is a **_strong selection bias_** in who one hears from (maybe stronger, actually). People @jtv mentioned who find docs lacking and immediately give up do not hang around to weigh in on project priority debates. It's hard to say how mu

Ttop - System monitoring service tool with tui and historical data

2022-12-23 Thread cblake
A different take on similar data reporting is which also comes with a `procs find` tool you may find interesting.

Nim version 2.0 RC1

2022-12-21 Thread cblake
Link posted to HN as well, FYI. Thanks @treeform.

Set Length Seq

2022-12-09 Thread cblake
Agreed. See also which could maybe be fleshed out/fixed up.

Why is Rust faster than Nim in this CSV parsing example?

2022-12-06 Thread cblake
No idea about any official positions. Both `markAndSweep` (gasp! a _runtime_!) and `mm:refc` give the best times on this one eeking out 10..20% better than the memory mapped versions (maybe recoverable with huge TLBs on the maps). { but this kind of thing does tend to vary from OS-to-OS and CPU-

  1   2   3   4   5   6   >