Advent of Nim 2022

2022-12-01 Thread remix
https://github.com/remigijusj/aoc-2021/tree/main/2022

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread Araq
Maybe adapt [lexim](https://github.com/Araq/lexim) to implement URL parsing.

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread jasonfi
Great work, although this is obviously more of a proof of concept and not yet ready for serious work. Besides SSL, there doesn't appear to be any handling/parsing of URL parameters. The handling of such parsing is also critical to performance. Jester creates a very useful Request object, but th

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread guzba
I honestly have no idea at this point. The actual nuts-and-bolts implementing of SSL in code is not something I am familiar with. More to learn.

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread Araq
> Doesn't seem so, but usually those services are served behind a > Nginx/Apache/Caddy instance or Cloudflare (or some other cloud) that handle > all the details. Yes, I know. So let me rephrase my question. How much work would it be to implement SSL support?

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread guzba
Today it does not, so those using Mummy would want to consider having something like Nginx or whatever do the SSL stuff and reverse proxy to your Mummy server. Or put Cloudflare infront of the server. I've personally found self-hosting + Cloudflare Tunnels to be an interesting option too, very

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread Yardanico
Doesn't seem so, but usually those services are served behind a Nginx/Apache/Caddy instance or Cloudflare (or some other cloud) that handle all the details.

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread Araq
I love it! Does it support SSL?

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread guzba
* Yes, for global memory you'll want to use atomics / locks. Async does not actually save you from this either, races are easy to create with await so I consider it a wash. * I just kind of randomly set that. Honestly set it to 1000 threads if you want, it doesn't matter, better to be super high

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread Yardanico
How would I go about using global objects with Mummy? I assume I will have to use atomics/locks manually myself? And since there's a `maxThreads` which is set to 2x of CPU count by default, does that mean that if requests take a long time to do, all other requests will just stall and have to wa

Show Nim: Mummy, a new HTTP + WebSocket server that returns to the ancient ways of threads

2022-12-01 Thread guzba
Hello all, today I wanted to share Mummy, my new multithreaded HTTP + WebSocket server written entirely in Nim. [GitHub link for Mummy](https://github.com/guzba/mummy) I started writing Mummy because I wanted an alternative to async. There are very good historical reasons for async (refc + thre

Advent of Nim 2022

2022-12-01 Thread mishankov
Here are mine solutions for this year AoC: Hope I'll finish it this year

Upcoming standard library changes

2022-12-01 Thread Hlaaftana
Moved out packages (all seem to be on nimble): * * * *

Executable crashes unless compiled with -d:release

2022-12-01 Thread ci4ic4
Thanks, it works with both. I guess there should be some build time patch or flag to take care of this in the latest versions, as it doesn't happen with the released version.

Advent of Nim 2022

2022-12-01 Thread fuddlesworth
Decided to learn nim. Here's day 01.

Advent of Nim 2022

2022-12-01 Thread ElegantBeef
My solutions will be [here](https://github.com/beef331/nimtrest/tree/master/aoc2022). _When my solutions do not appear it means my solution for the first part was too specialised and I am off to kick rocks_ :P

Do you have to use 'ref' for the field types within ref objects?

2022-12-01 Thread Araq
> But if you don't mutate, copy-on-write optimisation may help? Copy-on-write requires a reference count and Nim's objects don't have any (`ref` do but they already offer reference semantics). So the optimizer does it all at compile-time, no reference counter is required. On the one hand this d

Built-in (whole) array programming in Nim v2 or even sooner for scientific computing

2022-12-01 Thread Araq
What you say is true but we also need more scientists who can manage the complexity of `nimble install arraymancer`. Joking aside, we're working on a better embedding of the documentation of external nimble packages into the core documentation which should help a lot for discoverability.

Advent of Nim 2022

2022-12-01 Thread fxn
Day 1 was the warmup, but I am learning so here my solution . I've seen a few solutions to the first part that built sequences (in other programming languages), but to compute a max you do not need to store them all.

Do you have to use 'ref' for the field types within ref objects?

2022-12-01 Thread fxn
> But I know that nobody really cares about "consistency" when everybody comes > from existing languages which are not consistent; the only thing that really > matters is familiarity. I am learning Nim and I'd say I've recognized this consistency goal in some places and that feels awesome. Like

Do you have to use 'ref' for the field types within ref objects?

2022-12-01 Thread alexeypetrushin
@Araq, thanks for the explanation. > The optimizer cannot change the semantics though so **if you mutate** > afterwards, you will get a copy. Yes, but if you don't mutate, copy-on-write optimisation can do the trick. And allow to pass around large value objects by reference, without breaking th

Built-in (whole) array programming in Nim v2 or even sooner for scientific computing

2022-12-01 Thread TKD
I believe that being able to do array programming in the same way as Modern Fortran will be a huge boon and benefit. I know this can be done via macros easily or through a library (e.g., Arraymancer) but having it built-in would be excellent for scientific computing. A goal would be to be able

Polymorphism doesn't work building a dylib for Playdate (Cortex M7) with ARC

2022-12-01 Thread ringabout
Progress: replace data init function with consts for typeinfov2 has been merged. It should work for C backend.

Parsing Unicode and lexbase

2022-12-01 Thread drkameleon
Makes sense, that's along the lines of what I was thinking... Thanks for the input! :)

Parsing Unicode and lexbase

2022-12-01 Thread Araq
You should really do it with macro or a series of `elif buf.continuesWith("⊞", pos)` checks. I didn't use a macro but I used a code generator for reasons that have to do with bootstrapping.

Do you have to use 'ref' for the field types within ref objects?

2022-12-01 Thread auxym
As far as I know, nim always passes by ref for value types larger than 24 bytes.

Do you have to use 'ref' for the field types within ref objects?

2022-12-01 Thread Araq
> In some cases compiler optimises how data passed around, in other cases it > does not. For practical purposes it means that you can't just declare data as > value and let the compiler figure out how to pass it around efficiently. All it means is that you didn't understand it. Others can use th

Do you have to use 'ref' for the field types within ref objects?

2022-12-01 Thread Stefan_Salewski
> use ref even if you don't need its semantic. Actually, we have the byRef and byValue pragma to change how the compiler passes proc parameters: We have to attach these to the object/tuple, so we can not modify the

Nim 1.6.10 released

2022-12-01 Thread pietroppeter
updating with choosenim from 1.6.6 to 1.6.10 on my Windows throws error due to antivirus (updating to 1.6.8 goes fine): C:\Users\ppeterlongo>choosenim update stable Updating stable Downloading Nim 1.6.10 from nim-lang.org [##

Parsing Unicode and lexbase

2022-12-01 Thread drkameleon
I now - as I was typing the question as a matter of fact - noticed this: and its corresponding: So, I guess the answer is I'm already doing it pretty much like it shou

Parsing Unicode and lexbase

2022-12-01 Thread drkameleon
**Question/food-for-thought:** What would be the most sensible way to go about support unicode values in a lexer using `lexbase` / BaseLexer as its basis? I mean, as far as I can tell, using `BaseLexer` we can actually load up our string/input into a buffer and move through it byte-by-byte:

Upcoming standard library changes

2022-12-01 Thread cblake
Slight enhancement to @Hlaaftana's suggestion: a construct like `when not declared(system.stdout): import std/syncio` is maybe better - allowing code to work like before in both old & new Nim's with or without `-d:nimPreviewSlimSystem` or probably later Nim's that split by default-with-opt-out

Advent of Nim 2022

2022-12-01 Thread moigagoo
Oof, let's see for how many days I'll be able to handle this :-)