Comment by behnamoh

1 day 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.

Here's a 22-line Elixir script that spins up a webserver: 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?

  • > 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."

Sigh, here we are with people taking what "AI" tells them as law. It's gonna be a fun next-few-years.

You 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.

  • My 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.

    • You 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.

      15 replies →

I 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.

Elixir 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.

That is categorically not "how things are done" in the Elixir world. Have you considered that the Advanced Next Token Predictor may be imperfect?

  • It 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

    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.

    • Elixir 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?

      2 replies →