How to Efficiently Implement Microservices with Nim?

2024-07-25 Thread blackmius
i think nim have enough network libraries from which to choose, perfomance of each is not state of art but and not terrible either. the development rapidity is a bit less than python but much faster than c++

StableSeq

2024-06-30 Thread blackmius
maybe then skip-list?

StableSeq

2024-06-30 Thread blackmius
* you can access chunks via tree not linearly, it might be simple binary tree or B+tree where chunks is leafs and intermediate nodes containing their offsets, then you perform chunk search logarithmically but it costs some additional space

Iterators dont inline

2024-06-21 Thread blackmius
ok, bad example. why then my first JsonNode example also shows worse perfomance when there is additional iterator in between? JsonNode as i know is ref JsonNodeObj so there should not be a copy

Iterators dont inline

2024-06-19 Thread blackmius
is it not enabled by default when compiled with -d:release -d:danger?

Iterators dont inline

2024-06-19 Thread blackmius
Found that use of iterator which just extend field is cost additional computation time (about 20% time more) nim import std/[json, times, monotimes, tables] let a = %*{"a": 1, "b": 2, "c": 3} var start = getMonoTime() for i in 1..1_000_000: for k, v in a.f

Iterators dont inline

2024-06-19 Thread blackmius
have managed to simplify type A = object a: int b: int iterator q1(): A = for i in 1..1_000_000: yield A(a: i) iterator q2(): A = for i in q1(): yield i var b = 0 start = getMonoTime() for i in q1(): b += i

Iterators dont inline

2024-06-19 Thread blackmius
have managed to simplify type A = object a: int b: int iterator q1(): A = for i in 1..1_000_000: yield A(a: i) iterator q2(): A = for i in q1(): yield i var b = 0 start = getMonoTime() for i in q1(): b += i

Error: await expects Future[T]

2024-05-10 Thread blackmius
я посмотрел примеры использования nigui в их репозитории похоже, тебе надо запустить сервер и оконное приложение в отдельных потоках и наладить их общение через каналы 1. как я понял window.msgBox это блокир

Error: await expects Future[T]

2024-05-10 Thread blackmius
await only accepts futures your echoError is not returning future as i see it actually returns void so error saying ”await expects future but found void”

Can I check if a proc is async at compileTime without a macro?

2024-05-05 Thread blackmius
i think the problemis that you actually trying to call function and not check the procedure const a = typeof(complete()) maybe you somehow need to do it using macros and check ast

How to create a logical expression programmatically?

2024-05-04 Thread blackmius
i assume you want to create a query language in nim.

Anonymous chat service, powered by Nim

2024-05-03 Thread blackmius
i have white screen on iphone, no matter safari or chrome

I Have Created a Kinda Logging Solution :)

2024-05-03 Thread blackmius
difference between proc and func is very easy, funcs do not have side effects side effects is everything that change external state (everything outside that func), echoes, quiting, throwing errors, changing global variables and etc, the func should be pure and just return the result that depends

NVIDIA uses Nim!

2024-04-11 Thread blackmius
Now also and meta is using nimble for their storage system

Template default parameters question

2024-02-04 Thread blackmius
make overloading template webSession(sessionInfo: untyped, baseUrl: string, actions: untyped): untyped = webSession(sessionInfo, baseUrl, Chrome, false, actions) Run

linking on Mac M1

2024-02-03 Thread blackmius
I can confirm that building nim from repo helped. now it compiles.

linking on Mac M1

2024-02-03 Thread blackmius
yes, i installed it via choosenim, will try to build it from repo, thank you all

linking on Mac M1

2024-02-02 Thread blackmius
I am trying to link uWebSocket library on my MacBook Pro 2021 M1 Pro and getting linker error ld: warning: ignoring file /usr/local/lib/libuv.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /usr/local/lib/libssl.

Sum types, 2024 variant

2024-01-10 Thread blackmius
also why not use OOP? type Node = ref object of RootObj BinaryOpr = ref object of Node a, b: Node UnaryOpr = ref object of Node a: Node Variable = ref object of Node value: string Value = ref object of Node value: int m

Sum types, 2024 variant

2024-01-09 Thread blackmius
I prefer the @treeform way for sum types. it looks like it should work already in language. good intuitive way. for whom thinks extra “kind” field is overhead can make macros macros extracting kind enum and making boilerplate

Nim Tooling Roadmap

2023-12-13 Thread blackmius
great news!

Nim raw syscalls

2023-12-10 Thread blackmius
its not builtin you need to do importc proc syscall(arg: cint): cint {.importc, header: "", varargs.} var SYS_write {.importc, header: "".}: cint syscall(SYS_write, 1, "hello world\n".cstring, 12) Run

Exceptions not being handled with libuv: bug or what?

2023-11-26 Thread blackmius
also try to handle errors not globally but in async function nim proc main() {.async.} = try: await dial(...) except e: stopLoop() raise e asyncCheck main() runForever() Run

Calling the generics parent function

2023-11-23 Thread blackmius
But i found more preferably to just rename base update to `updateBase` and call it so

Calling the generics parent function

2023-11-23 Thread blackmius
`type Enemy = ref object EntGroup[T] = ref object of RootObj items: seq[T] EnemyEntGroup = ref object of EntGroup[Enemy] method update[T](self: EntGroup[T]) = echo "general update loop" method update(self: EnemyEntGroup) = procCall update(EntGroup[Enemy](self)) ## << What to put here to call the

Nim Community Survey 2023

2023-11-23 Thread blackmius
i saw that every forum thread is answered or what do you mean by "ignored"?

Nim Community Survey 2023

2023-11-23 Thread blackmius
Also id like to see the raw results of poll, will you post it somewhere?

Exceptions not being handled with libuv: bug or what?

2023-11-21 Thread blackmius
maybe uv_loop run your code in another thread. it may do it but i dont remember in which case

Exceptions not being handled with libuv: bug or what?

2023-11-20 Thread blackmius
with this code you specified you return earlier then raising an exception also check where the future.fail will lead. it jump into asyncCheck or something that awaits a coroutine and exception will be raised without emiting nimTestErrorFlag remove error checking part if err != 0:

Question from one of my customers.

2023-11-19 Thread blackmius
I think it depends on how fast you can start maintaining customer applications. If it is quick change customer will think he can do same thing with someone else: find new programmer let him small time to learn nim and he got new person maintaining his code. moreover for secret even you already k

NIR

2023-11-06 Thread blackmius
voting for AST mapping for IC

Malebogia

2023-08-30 Thread blackmius
the new 3 procs has the same blocksize iterator pattern, wouldn't it better to extract it and reuse?

Idiomatic way to zero-copy iterface with binary bitmap array

2023-08-26 Thread blackmius
Also openarray is not a real type. Its used as parameter type to show what parameter is an array with length and subscript operator. So you don`t need to cast everything to it unless you need a generic proc accepting any array like. I can suggest you to make your own structure with overload subs

Idiomatic way to zero-copy iterface with binary bitmap array

2023-08-26 Thread blackmius
you cannot access bitvector without bitwise operations so it's always not zero-copy. Unless you using machine with non-word memory access but nowadays its pretty uncommon.

Networking with Nim

2023-08-13 Thread blackmius
googled for you

IPv6 compatibility (dual-stack AF_UNSPEC)

2023-08-11 Thread blackmius
seems like it be easier to create your own network stack library in nim

Nim 2 and need for try-finally?

2023-08-11 Thread blackmius
yes try/finally still needed for types lacking =destroy. If you using low level primitives like handles which rarely used in c bindings you still need to free resources yourself. So having SocketHandle is just a distinct cint and you need call close on created socket to free it usage in OS

Why does ref object have this behaviour?

2023-08-08 Thread blackmius
most likely, there is a need to understand what ref object is. here is an example what happend if it was c void* ret() { void* a = malloc(1); // sizeof empty object printf("%p\n", &a); // printing addr of a return a; // returning pointer to some object }

Why this nim code is not valid?

2023-08-05 Thread blackmius
` nim import strutils, sugar type Writer[A] = (A, string) proc to_upper(s: string): Writer[string] = (s.toUpperAscii(), "to_upper()") proc to_words(s: string): Writer[seq[string]] = (s.split(" "), "to_words()") proc compose [A, B, C]( m1: (A) -> Writer[B], m2: (B) -> Writer[C] ): (A) -> Writer[C

CBOR?

2023-08-05 Thread blackmius
i made small google research on finding CBOR and yes there is no nim implementation. maybe it would be easy to make bindings to existing c/c++ libraries

CBOR?

2023-08-03 Thread blackmius
it's bad answer, but why not msgpack?

How to close a Logger

2023-07-31 Thread blackmius
https://nim-lang.org/docs/logging.html#FileLogger

Fame and fortune for Nim?

2023-07-03 Thread blackmius
finally, the opportunity for paid nim jobs...

thoughts on a backend target for bun?

2023-06-26 Thread blackmius
moreover JS supports to run everything as async function, just await pure function js function sync() { console.log('i am not async'); } async function a() { await sync(); // hidden transform to Promise.resolve } await a(); Run

Best Web Framework Features?

2023-05-25 Thread blackmius
have you seen ? I have done several projects on it and I can say that in general this is enough in most cases for my tasks. I have mainly used it on projects where there is a separation of frontend and backend, so this story is not about SSR. but this framework sol

fswatch, non blocking usage?

2023-05-10 Thread blackmius
fswatch is apparently an event loop itself. To run them both at the same time, they must be launched in different threads and communicate between them through the means of communication of threads of the Channel type. But this will greatly complicate your program, so look for analogues of fswatc

pure nim io_uring library

2023-05-09 Thread blackmius
that the library currently covers only sending and receiving requests to the kernel. When io_uring supports [ways to register](https://github.com/blackmius/nimuring/blob/master/src/nimuring/io_uring.nim#L1173) different structures in the kernel (26 ops in total). And there are 8 of them, wh

pure nim io_uring library

2023-05-08 Thread blackmius
well, I think that curbing io_uring has opened a pandora's box, which entails rewriting a huge part of the existing synchronous code. I'm not only talking about replacing read/write calls in such systems, but also that with io_uring you can create new file descriptors and change their attributes

pure nim io_uring library

2023-05-07 Thread blackmius
I stopped changing the implementation often enough, so I think now I can show everyone <https://github.com/blackmius/nimuring>

Optimise async request / code [For Beginners]

2023-04-27 Thread blackmius
poll() queues all futures in same thread, there is no difference

Optimise async request / code [For Beginners]

2023-04-26 Thread blackmius
try not to create a separate client, but to use one global

Viability of a website generator using nim.

2023-04-24 Thread blackmius
> If the front-end HTML form is written to send a POST to the front-end CGI > with the wrong object format, a compile-time error is thrown. you can’t rely on the compiler, anyone who visits the site using curl will knock down the server

Viability of a website generator using nim.

2023-04-24 Thread blackmius
maybe take something from js world the mainstream hydration or etc like this that means you can generate not only static js code for running SPA, but also a version with prefilled values and raw html, that after sending to web comes alive.

Long string in source file

2023-04-23 Thread blackmius
var a: string = """ +6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359 642961730265646132941876892191011644634507188162569622349005682054038770422928924589790986076392

Do you miss these compact syntaxes?

2023-04-01 Thread blackmius
the problem is you need wrap `discard` in paranthes import std/sugar proc on_click(fn: (string) -> void): void = discard on_click((e: string) => (discard)) Run but o found more annoying that you need specify auto type import std/sug