I've just read this article which talks about using Python in a serverless setting. Nim is compiled, so obviously, you can't do it exactly the same way, but I had the feeling it would not be that hard to do.

First, you would need some "cloud" to run it on, and I don't think existing serverless offers, like from AWS, would be usable, as they usually target Java/Python, so you would need something like Kubernetes, and maybe Kubeless could be adapted to Nim. You'd start with some repo of your code, possibly based on Nimble, where you would push code (or "references" to code, in the form of URLs). This would trigger some "compile service" to create a new DLL of that code, and put it in an "object store". Once this is complete, you can send request to have "functions" executed on your cloud. Each node would have one (or more?) processes that run in permanence, and have pre-opened connection to your DBs, and a (web?)server to receive requests, such that it only needs to load the DLLs on demand, run the functions (which take input from the DBs), and drop the DLLs when no more needed.

I currently don't have any need for this myself (as "serverless functions" are basically the opposite of "actors", from my point-of-view), but I'd be interested to know if there is any Nim limitations that would make something like this hard to implement, as I can then expect to eventually run into those limitations myself, while trying to spread actors over a cluster.

2017-10-31 14:49:58

as they usually target Java/Python

You forgot to mention JS, which is usually an option and which Nim compiles to. Moreover, nim can compile to asm.js through emscripten to gain even more performance if that is desired.

if there is any Nim limitations

From my experience Nim has proven to be really portable and versatile, so I would not expect any dead ends here.

2017-10-31 21:29:04
@yglukhov Very good point! I'll admit I have no love for JS (I prefer statically-typed languages, and I have trouble taking seriously a language without even a built-in 64-bit integer type, or in this case any integer type). So, I tend to forget about JS. BUT, with something like ASM.js, the performance might just be "good enough". That means one could, potentially, code in Nim and run the code on some cloud-provider serverless API (or some OSS clone thereof), without having to built it all oneself. Nice!
2017-11-01 13:08:28
I was experimenting with distributed computing a bit. The idea is slightly different, because the same binary has to be published to each cluster node and it can run in different roles client/master/worker. It's far from being usable, but at least it can already publish data into worker memory and run arbitrary code remotely on a worker. Usage looks like that: https://github.com/bluenote10/Hydra/blob/master/testapp1.nim
2017-11-01 15:52:24

@bluenote That's interesting; I could reuse some of that for my own experiments. Would you consider adding a short readme.md, and, most importantly, a license?

EDIT: And while I'm at it, I guess you first looked around for other distributed implementations in Nim? Anything else I should look at?

2017-11-01 17:23:47
@monster: since you mentioned Kubernetes - most container orchestration systems can deploy and run arbitrary binaries in Linux containers. What matters is performance and memory usage (and having small binaries is a little plus). Nim is quite good in all of those. 2017-11-01 18:08:07
@monster: Sure, I've added a license and minimal readme. 2017-11-01 18:18:50

@federico3 I just read the 2017 community survey post; some users were complaining Nim's "Unix" binaries were "HUGE"; so it seems not everyone agrees on that (I personally have no idea).

@bluenote Thanks! EDIT: seems like only the readme was committed...

2017-11-01 18:21:47

I have a story of a "serverless" hack. It's ugly, but you might appreciate it:

There was a company that I worked with that used AWS lambda with Go lang binaries. They did this by having the python runtime "exec" the binary with the python subprocess.popen api. As long as the binary and the python bootstrap script were packaged together it worked fine. I used similar tricks to get native C crypto libraries to work from python in AWS lambda.

2017-11-01 19:10:52
@rayman22201 ROFL! So, basically, you can do about anything in "serverless" anyway (as long as you don't go past the resource usage limitations).
2017-11-01 19:42:30