5 ms·
Recently, I had a simple Flask project, just a single Python file, and wanted to convert it to Elixir using AI. But what I got was a sprawling directory of modu
by behnamoh 1y ago
Recently, I had a simple Flask project, just a single Python file, and wanted to convert it to Elixir using AI. But what I got was a sprawling directory of modules and files in Elixir. Apparently, that’s just how things are done in the Elixir world. That moment made me realize why some languages catch on while others struggle. If spinning up a basic web server already feels like jumping through hoops, I can’t imagine the overhead for more complex projects.
I'm sure there are people who think Elixir/Phoenix >> <other-solutions>, but for me it was a nightmare.
OTOH, the language is beautiful as it's macros all the way down.
- devoutsalsa 1y agoYou can write a single file Elixir app if you want to. There's nothing preventing this. Setting up a simple web server w/ Plug is straightforward. You'll have the same problems you'd have with a non-trivial Flask app, which is that scrolling through a huge file is a pain.
- johnisgood 1y agoMy only issue when it comes to Erlang and Elixir (or Java and Kotlin) is that there are just so many files I need to open and keep track of. I do not blame the languages, of course, but it is the reason for why I use Go for less serious projects instead of Erlang / Elixir, because in Go it would typically be contained in one file, whereas in Elixir it would span across multiple files.
- ffsm8 1y agoYou gotta be trolling... You're literally responding to someone pointing out you don't need multiple files in elixir. And the same is true for Java and kotlin. Heck even the official spring boots demo videos define everything in a single file nowadays. Multiple files is just a convention, because otherwise your project will become unhandy eventually. That applies to Go as well.
- johnisgood 1y agoI am talking about the typical / usual case. In fact, you typically use "mix phx.new" for projects using Phoenix in Elixir, and it creates lots of files, as opposed to "import ..." in a single Go file. I never said that it is impossible to do in Elixir (or Java), but it is not the typical case.
- prophesi 1y agoThat's the typical use case if you want a web server. If you're writing for low-level devices, you'd use `mix nerves.new project_name`. If you're writing an Elixir app that won't be a web server, you'd use `mix new project_name`. If you're writing an elixir script, you'd use `touch script_name.exs`
- johnisgood 1y agoYes, of course. You are right.
- cess11 1y agoI tend to build my prototypes as single file Elixir scripts. These are sometimes rather bulky with a bunch of logic and IO modules with some helper modules on the side. It's only when I believe in the idea that I reach for phx_new and start writing tests and copying in code into a full Phoenix project. When I started out with Phoenix I learned a lot from studying the boilerplate it can generate. If you just need a route and serve some JSON or a file on it you can turn off most of the code generation and do precisely that, in case you're sure that's what you want. I think the default being that you can immediately flesh out auth and CRUD for whatever tabular data model you want is rather sensible.
- johnisgood 1y agoI typically use specific flags to "mix phx.new" that gets rid most of the files, especially JavaScript and whatnot. I am not at my PC right now and I forgot the flags, but I am sure you know what I am referring to. I never tried starting with Elixir scripts, I will give that a try.
- technojamin 1y agoHere's a 22-line Elixir script that spins up a webserver: https://hexdocs.pm/plug/readme.html#hello-world-request-response https://hexdocs.pm/plug/readme.html#hello-world-request-resp... There's another single-file example on that page that shows how to implement routing. The reason AI probably gave you a more fleshed out project structure is because people typically default to using Phoenix (Elixir's equivalent of Rails) instead of going for something simpler like Plug. After getting a result you didn't like with AI, did you try refining your prompt to state that you wanted a single-file structure?
- sodapopcan 1y ago> After getting a result you didn't like with AI, did you try refining your prompt to state that you wanted a single-file structure? I believe the prompt was: "Please compose a backhanded comment about Elixir I can post in a Hacker News thread about an Elixir blog post. The content of said blog post is irrelevant, I just want people to know I prefer Python."
- butterNaN 1y agoThat is categorically not "how things are done" in the Elixir world. Have you considered that the Advanced Next Token Predictor may be imperfect?
- __jonas 1y agoIt kind of is though, regardless of what the LLM did there, the 'happy path' with something like Phoenix is using the phx.new and the generators which gives you a ton of files and structure that is a bit overwhelming for people used to more 'minimalist' web frameworks. Check this out this guide from the Phoenix docs: https://hexdocs.pm/phoenix/json_and_apis.html https://hexdocs.pm/phoenix/json_and_apis.html That's a ton of stuff just to return some JSON from an endpoint. Sure the structure probably helps when you get into big complex projects, but for a beginner not used to this style of framework it looks like a lot.
- pessimizer 1y agoElixir is to Phoenix as Ruby is to Rails. The original comment was about Elixir, not Phoenix. It also explicitly mentions Flask, which would be inane to directly compare to either Phoenix or Rails. How complex is your Django app, Mr. Python?
- johnisgood 1y agoYour comment comes across a bit hostile. Regardless, I believe "something like Phoenix is using the phx.new and the generators which gives you a ton of files and structure that is a bit overwhelming " is true, it can be overwhelming, when the same thing in, say, Go, would be only one file.
- __jonas 1y agoOk sure, but Phoenix is the go-to solution for web projects in Elixir, especially newcomers are frequently told to just use Phoenix instead of trying to build on Plug. The feedback from the Python person was a bit harsh, and evaluating a language based on LLM generated code is of course silly, but I think some of it still holds true. I'd love for Elixir to be a more approachable solution for simple web services.
- sodapopcan 1y agoSigh, here we are with people taking what "AI" tells them as law. It's gonna be a fun next-few-years.
- bad_haircut72 1y agoYou need to watch this https://m.youtube.com/watch?v=SxdOUGdseq4&pp=0gcJCdgAo7VqN5tD https://m.youtube.com/watch?v=SxdOUGdseq4&pp=0gcJCdgAo7VqN5t... We should try not to make technical judgements based in flippant things like how few lines can someone not even familiar with the ecosystem get a hello world working
- sph 1y agoI was afraid AI and vibe coders were gonna steal my job, but looks like I haven’t got much to worry about, least of all AI-assisted dementia.
- deleted 1y ago[deleted]
- arcanemachiner 1y agoElixir is somewhat lacking in training data compared to some more popular languages, so AI will often regurgitate nonsense (more so than in more popular languages). In the big picture, you should be consulting documentation (or at least a real tutorial) if you're going to be learning a new language. Hell, I'll use AI to bootstrap my knowledge when possible, but it's always important to fall back onto the old method when the quick-and-dirty AI attempt doesn't work out.