Live data from Hacker News

Elixir v1.20: Now a gradually typed language

elixir-lang.org

311–320 of 426 posts

Re: Elixir v1.20: Now a gradually typed language

#311
post #307

Earlier quoted context omitted.

Yeah, one of the worst practices. I've been working with Elixir professionally for 6 years now and I still see this sh*t everywhere. Bad APIs, bad UIs because someone coupled themselves to the database structure and can't escape. List of memberships? Keep them as a list with the same fields as the junction table. Top-level APIs taking maps with string keys as "params" so they can very easily be cast for a changeset.

This was the only out of box solution when Elixir didn't support types. So, if you really did Elixir professionally for 6 years, you'd know that by now. > Bad APIs, bad UIs because someone coupled themselves to the database structure and can't escape. If you don't commit yourself to the database structures you defined at the time of application creation, then it just reflects poor planning and architecture overall as…

I haven't used Elixer but tt's generally a good idea for the UI to have a different data model than the database (even if it means you initially type almost the same thing twice and have to write a tedious translation layer).

This lets you evolve each part independently and use the "native" types frontend vs backend, which happens surprisingly frequently as the app grows

Re: Elixir v1.20: Now a gradually typed language

#312

Honest question, in the era of vibe and AI assisted coding is there any advantages of using untyped programming languages, apart from the fact that non-typed languages has more traning data for the LLM? This probably controversial, but personally I consider untyped languages as technical debts that need to be fixed sooner or later, and the OP article is partly addressing this very issue. Rewriting critical software i…

I’ve been using Ruby and Elixir for over a decade. Pre-AI I used them for aesthetic reasons. The code was beautiful, and I disliked dealing with types. People without experience in dynamic languages tend to overestimate the number of bugs their type system is saving them from. It’s pretty rare that I run into a bug in production that a type system would have caught. They also overstate how much types help their AI ag…

Go is pretty great - here's a list of tools I use to help me write/build Go- maybe a few of them will also be what you need: https://www.bbkane.com/blog/go-project-notes/

Re: Elixir v1.20: Now a gradually typed language

#313

Earlier quoted context omitted.

> Elixir is having to handle (possibly) hundreds of thousands of processes OMG, why? Why would you ever have so many processes? All of them at the same time? Are you going to animate a 3D scene and run a process for each vertex, or something? No, I mean, if you're WhatsApp - across all nodes - then somehow maybe yes? At scale. But in normal code, slicing workloads too thinly is counterproductive, and having even tens…

I learned it for almost a full year by trying to build a live chat app. I went through Elixir in Action and the official guides and yet those questions were never really answered. I never said I want hundreds of thousands of processes, but thats definitely a thing you need to account for. Errors are often simply swallowed.

> Errors are often simply swallowed.

That's a bit of a misrepresentation. Error handling on the BEAM has a few more layers than in other environments; specifically, the supervision tree can be used to "let things fail". That's not the layer where you should log or handle failures - that's a safety net that ensures your whole system won't go down if your error handling in a single process doesn't work.

For error handling, there are roughly these layers:

    - functions can return {:ok, value} or {:error, error}
    - functions can raise errors (similar to exceptions) that can be caught
    - processes can be monitored from the outside, you get notified when they die
    - processes can be linked and exits can be trapped, also notifying you on failure
    - supervisors can handle process deaths in a configurable manner
    - higher-level behaviours often expose their own error handling callbacks
So there's a bit more to error handling on the BEAM, and I get that becoming familiar with all of them and using them properly can be a challenge. The defaults skew towards high-availability, which is not always what you want in development - sometimes, failing fast and completely (up to stopping the app or the BEAM as a whole) is more convenient. You can have that; you just need to ask for it specifically in your code.

Re: Elixir v1.20: Now a gradually typed language

#314
post #241

Earlier quoted context omitted.

If you use Phoenix, using types at the data model level using changesets and then trickling them down all the way to the UI is a very good compromise. As changesets provide type validations out of the box too.

Do changesets incur a runtime cost?

yes, they do. its minimal though

Re: Elixir v1.20: Now a gradually typed language

#315
post #311
post #307

Earlier quoted context omitted.

This was the only out of box solution when Elixir didn't support types. So, if you really did Elixir professionally for 6 years, you'd know that by now. > Bad APIs, bad UIs because someone coupled themselves to the database structure and can't escape. If you don't commit yourself to the database structures you defined at the time of application creation, then it just reflects poor planning and architecture overall as…

I haven't used Elixer but tt's generally a good idea for the UI to have a different data model than the database (even if it means you initially type almost the same thing twice and have to write a tedious translation layer). This lets you evolve each part independently and use the "native" types frontend vs backend, which happens surprisingly frequently as the app grows

Phoenix does have that. ViewModels. I don't think its required to use though, but we always do.

Re: Elixir v1.20: Now a gradually typed language

#316
post #307

Earlier quoted context omitted.

Yeah, one of the worst practices. I've been working with Elixir professionally for 6 years now and I still see this sh*t everywhere. Bad APIs, bad UIs because someone coupled themselves to the database structure and can't escape. List of memberships? Keep them as a list with the same fields as the junction table. Top-level APIs taking maps with string keys as "params" so they can very easily be cast for a changeset.

This was the only out of box solution when Elixir didn't support types. So, if you really did Elixir professionally for 6 years, you'd know that by now. > Bad APIs, bad UIs because someone coupled themselves to the database structure and can't escape. If you don't commit yourself to the database structures you defined at the time of application creation, then it just reflects poor planning and architecture overall as…

> If you don't commit yourself to the database structures you defined at the time of application creation, then it just reflects poor planning

No it reflects the reality that requirements and applications evolve over time. You sound like someone who's never supported an application for more than 5 minutes.

Re: Elixir v1.20: Now a gradually typed language

#317
post #207

Earlier quoted context omitted.

If you're only willing to use languages with the same features, what's the point? Learning how a different paradigm manages without types can be more insightful.

Yeah I agree learning new paradigms can give you new insights. There's also a balance between learning new languages for fun and for the insights they give, and wanting to ship. As an example: Prolog was mind-bending for me when I tried it and I had a lot of fun with it, but I can't imagine using it to build a product (I'm sure other people have though). Perhaps my first comment sounded more critical than intended. I…

I finally found uses for Prolog haha. For years I would have been able to write exactly your comment.

One use is a spellcheck. Though some bits are in Rust cause backtracking would be too slow.

Another is a game I'm making, the server is in Elixir, and I use erlog to basically program the NPCs in prolog. The game generates events and they are processed into facts if they are perceived by the character.

And with that I can have the system generate goals based on stuff like "I havent seen X at the market for 3 days whilst beforehand I saw X every day. Let me go check on X."

I didn't know Erlang started as a Prolog program basically, but it shows cause they fit together like a match made in heaven.

Re: Elixir v1.20: Now a gradually typed language

#318
post #207

Earlier quoted context omitted.

If you're only willing to use languages with the same features, what's the point? Learning how a different paradigm manages without types can be more insightful.

Yeah I agree learning new paradigms can give you new insights. There's also a balance between learning new languages for fun and for the insights they give, and wanting to ship. As an example: Prolog was mind-bending for me when I tried it and I had a lot of fun with it, but I can't imagine using it to build a product (I'm sure other people have though). Perhaps my first comment sounded more critical than intended. I…

I'll also make the argument that type systems in languages are purely additive rather than orthogonal.

What I mean by that is, I used to write JS. Transitioning to TypeScript didn't alter my mental model of the language.

Likewise for Python with type annotations.

The only time I've had that happen is with Scala 3's dependent types/type lambdas, but thats LITERALLY called "type-level programming", so it makes sense.

Re: Elixir v1.20: Now a gradually typed language

#320
post #111

Earlier quoted context omitted.

LOL LaCk oF eXpErIeNcE. Bro all you have to do is open intellij and it will prompt you to install the correct version of Java.

Don't tell OP this - he doesn't want to install multiple things. You'll scare him away from Java.

Java is ugly anyway
Post reply on HN