Criticism of Parallel Nim

2021-03-13 Thread mratsim
There is nothing parallel about a web server by the way. It's all about concurrency. And the Erlang and Go approach have significant overheads that are unacceptable for a system programming language. You can't use either Erlang or Go for **parallel** problems such as those from high-performanc

Criticism of Parallel Nim

2021-03-13 Thread Araq
There is / which you can use to base your server on. It uses a single `spawn handle(client)` and inside your handler you can use ordinary, blocking Nim code that uses the thread pool and thus the blocking nature doesn't affect the handling of o

Why I can't unmarshal JSON with spaces in the JSON keys?

2021-03-13 Thread treeform
Jsony with a rename hook: import jsony type FooBar = object `Foo Bar`: string const jsonString = "{\"Foo Bar\": \"Hello World\"}" proc renameHook*(v: var FooBar, fieldName: var string) = if fieldName == "Foo Bar": fieldName = "Foo

Criticism of Parallel Nim

2021-03-13 Thread alexeypetrushin
> Note that there is no way at a low-level to do some IO without blocking, > kernels may just not offer async API. Javascript and Go delegates those calls > to a threadpool to make them async. The low-level primitives could be the same, but how those low-level building blocks are used make the

Criticism of Parallel Nim

2021-03-13 Thread alexeypetrushin
> If you have some custom synchronize functions and you want to use it in web > server, then create dedicated threads to those task or send those tasks to > some other dedicated processes/servers. It's like double language problem in Python, if you want it fast you need to use C-wrappers. In th

Criticism of Parallel Nim

2021-03-13 Thread jackhftang
I have read your [long previous post](https://forum.nim-lang.org/t/7583#48122) together with this one. My overall feeling is that you are shooting yourself in your foot. If you have some custom synchronize functions and you want to use it in web server, then create dedicated threads to those ta

Get system wide config dir

2021-03-13 Thread shirleyquirk
on *nix (even weirdos like GoboLinux and NixOs) : at the very least a symlink to /etc exists. /etc/xdg probably exists. $XDG_CONFIG_DIRS could be a thing (not on my machine) on osX: /etc exists and is used for some things but i think its readonly. homebrew uses /usr/local/etc, native apps use /

Non-async inside async, how it's executed?

2021-03-13 Thread alexeypetrushin
A question about Jester/httpbeast, it seems like it's both async and multi-threaded. So I assume there are N event loops, one for each thread. So even if event loop is blocked for some thread, other threads should still work and not being blocked? I tried to create example with multiple threads

Criticism of Parallel Nim

2021-03-13 Thread mratsim
Note that there is no way at a low-level to do file IO without blocking, kernels may just not offer async API. Javascript and Go delegates those calls to a threadpool to make them async.

Criticism of Parallel Nim

2021-03-13 Thread alexeypetrushin
> This is wrong - you can use them just fine, but they'll _block . Well, you also can use microscope to hammer nails, it would work too, no one said you can't do that.

Criticism of Parallel Nim

2021-03-13 Thread Yardanico
And have you actually seen (Jester uses it by default)?

Criticism of Parallel Nim

2021-03-13 Thread Yardanico
> How to read/write some data from/to the file? You just use open/read/write > file operations from the std you already know, right? Wrong. They can't be > used because they are not async, you need to learn a special async API like > std/asyncfile. This is wrong - you can use them just fine, bu

Non-async inside async, how it's executed?

2021-03-13 Thread dom96
Sure, that approach works and is what I use in Nim in Action. That said, it's wasteful since you're busy-looping so I wouldn't use it for anything that needs to be performant. My hope is that we can implement something better (see )

Get system wide config dir

2021-03-13 Thread lhupfeldt
I was looking for an standard OS agnostic way of getting the directories.

Criticism of Parallel Nim

2021-03-13 Thread alexeypetrushin
Couple days ago I started evaluating Nim for the server side. I already used Nim for half a year, for data processing, it works well, so I decided to also use it on the server. The project is not critical, yet it's important enough so the server should work more or less reliably and be relative

Get system wide config dir

2021-03-13 Thread Yardanico
Well, I'm not aware of any stdlib module/Nimble package that does that so feel free to port `appdirs` to Nim :)

Get system wide config dir

2021-03-13 Thread lhupfeldt
You are probably right that many languages/std-libraries do not provide it, but the location (hopeflly) should be well defined on any OS. On Linux it is part of the [XDG](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) specification. The [appdirs](https://pypi.org/

Get system wide config dir

2021-03-13 Thread Yardanico
For getting an env variable you can just use

Nimview - a lightweight UI helper

2021-03-13 Thread marcomq
Yes - I had a look to eel and neel. But both had the big disadvantage that they always required to open ports on localhost just to display the ui. This opens a big security attack vector and makes it complicate, if multiple of these applications try to run on the same machine. I'm also not sure

Why I can't unmarshal JSON with spaces in the JSON keys?

2021-03-13 Thread Yardanico
Your answer is good, but it's missing the case if we don't have a pure string-string mapping. In that case, we can do it this way: import json,tables const jsonString = "{\"Foo Bar\": \"Hello World\"}" let foobar = to(parseJson(jsonString), Table[string,JsonNode])

Get system wide config dir

2021-03-13 Thread Yardanico
I don't think that there's a standard way on Linux to specify the system-wide config directory.

Get system wide config dir

2021-03-13 Thread lhupfeldt
Hi, is there a way to get the system wide config dir, e.g. `/etc` on Linux? Even better, is there a way to get the config dir search path, e.g. `[getConfigDir(), getSystemConfigDir()]` (assuming a `getSystemConfigDir`)

Why I can't unmarshal JSON with spaces in the JSON keys?

2021-03-13 Thread shirleyquirk
you could use a `Table[string,string]` instead import json,tables const jsonString = "{\"Foo Bar\": \"Hello World\"}" let foobar = to(parseJson(jsonString), Table[string,string]) assert foobar["Foo Bar"] == "Hello World" Run

Why I can't unmarshal JSON with spaces in the JSON keys?

2021-03-13 Thread juancarlospaco
Because `Foo Bar` Run **is** `FooBar`

Splat operator in Nim?

2021-03-13 Thread juancarlospaco
Check how `echo` does it. :)

Why I can't unmarshal JSON with spaces in the JSON keys?

2021-03-13 Thread shirleyquirk
interesting, it's that `Foo Bar` is not the internal name for that member, it gets converted to `FooBar` type Foo = object `Foo Bar`: string #FooBar: string # error attempt to redefine FooBar var x:Foo x.FooBar = "world" assert x.FooBar = "world

Why I can't unmarshal JSON with spaces in the JSON keys?

2021-03-13 Thread hronro
Why I can't unmarshal JSON with spaces in the JSON keys? import json type FooBar = object `Foo Bar`: string const jsonString = "{\"Foo Bar\": \"Hello World\"}" let foobar = to(parseJson(jsonString), FooBar) Run [Nim Playground](h

Splat operator in Nim?

2021-03-13 Thread drkameleon
Yep, it is lol (I guess I got a bit... carried away).

Channel / Actors based parallelism? Are there such Web Servers?

2021-03-13 Thread JPLRouge
I worked on a sync communication for the web with socket [WEBWSI](https://github.com/AS400JPLPC/nim_webwsi)

Splat operator in Nim?

2021-03-13 Thread aEverr
Your seq is impossible, sequences are single type only

Splat operator in Nim?

2021-03-13 Thread ElegantBeef
As was mentioned that's invalid Nim code. At one point I did throw together this macro for someone in the realtime chat which is similar to what you want. import std/macros macro `<-`(p: untyped, args: array): untyped = let t = args.getType count = t[1

Splat operator in Nim?

2021-03-13 Thread drkameleon
I know, but I still don't get it how this could help in my case. Let me elaborate: proc doSomething(x: int, y: string, z: int): int = echo "I'm doing something with: " & y return x + y ; and I have an array like this: let arr = @[2, "something", 3]

Splat operator in Nim?

2021-03-13 Thread juancarlospaco
`openArray` can take array or seq of any length.