Well, in Elixir's defense, please note this script includes the server AND the tests for it, the server per se could be done just with:
Mix.install([{:plug_cowboy,"~> 2.0"}])defmoduleServerdousePlug.Routerplug(:match)plug(:dispatch)get"/hello-world"dosend_resp(conn,200,"Hello World!")endmatch_dosend_resp(conn,404,"Nothing to see here")endendPlug.Cowboy.http(Server,[],port:4000)System.no_halt(true)
Also, this is a totally standalone script, it does not require ANYTHING else besides you having Elixir installed and calling elixir server.exs, as the dependencies are downloaded for you with the function Mix.install on the beginning of the file, so you could totally just download that script and run it. While with express, AFAIR you need to install express too, which either involves a npm -g express (that might lead to problems with different express versions) or having a folder structure and a package.json, which is not that simple TBH.
Definitely good points! I suppose my suggestion would have to include something unsavory like exec("npm I express@latest -g") to truly get it into a true single file that you can run with just Node installed which just... yeah, yuck.
I guess I could make that point that Deno has this functionality built in if I wanted to be that kind of JS/TS fanboy but then we're out of the "simplistic" and well documented context.
For the record, I dig Elixir + Phoenix. I'm not a Node dev strictly (though it's what clients have most commonly been asking for, in my experience), I just think it's the defacto for most simple tooling.
Yeah, deno is a nice project, hopefully it gets traction as it solves a lot of the problems node has. But I'm sticking with Elixir either way. 😄
Your comment got me thinking though: is this something we want? I mean, is there a valid use case for a very simple server like this? Cause if there is, maybe there is room for another library on top of plug that would make all this simpler. Maybe even improved tooling around single-file scripts servers IDK 🤔
I think there's a use-case for incredibly simple tooling. I mean... the Docker build for deploying this server to production just has to have Elixir installed and that's pretty cool!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Well, in Elixir's defense, please note this script includes the server AND the tests for it, the server per se could be done just with:
Also, this is a totally standalone script, it does not require ANYTHING else besides you having Elixir installed and calling
elixir server.exs
, as the dependencies are downloaded for you with the functionMix.install
on the beginning of the file, so you could totally just download that script and run it. While with express, AFAIR you need to install express too, which either involves anpm -g express
(that might lead to problems with different express versions) or having a folder structure and apackage.json
, which is not that simple TBH.Definitely good points! I suppose my suggestion would have to include something unsavory like exec("npm I express@latest -g") to truly get it into a true single file that you can run with just Node installed which just... yeah, yuck.
I guess I could make that point that Deno has this functionality built in if I wanted to be that kind of JS/TS fanboy but then we're out of the "simplistic" and well documented context.
For the record, I dig Elixir + Phoenix. I'm not a Node dev strictly (though it's what clients have most commonly been asking for, in my experience), I just think it's the defacto for most simple tooling.
Yeah, deno is a nice project, hopefully it gets traction as it solves a lot of the problems node has. But I'm sticking with Elixir either way. 😄
Your comment got me thinking though: is this something we want? I mean, is there a valid use case for a very simple server like this? Cause if there is, maybe there is room for another library on top of
plug
that would make all this simpler. Maybe even improved tooling around single-file scripts servers IDK 🤔I think there's a use-case for incredibly simple tooling. I mean... the Docker build for deploying this server to production just has to have Elixir installed and that's pretty cool!