News for hackers. Stuff that matters.
Re:Why Elixir? A Rebuttal to Common Misconceptions by the_gastropod on Wednesday July 23, 2025 @01:01PM (#44661430)
Elixir is a strongly typed language (as opposed to a weakly typed language like JavaScript or Perl). You cannot, for example, do `"4" - 1` in Elixir. Dynamic vs static typing is a mostly orthogonal scale, where Elixir is (mostly) dynamically typed.

There are some very sharp Computer Scientists who believe static typing is unnecessary. Joe Armstrong (co-designer of Erlang) once said: "a type system wouldn't save your system if it were to get hit by lightning, but fault tolerance would"

Re:Why Elixir? A Rebuttal to Common Misconceptions by coffeeindex on Wednesday July 23, 2025 @01:15PM (#44661601)
Seems a bit strange to posit fault tolerance as an alternative to a type system. Personally, I view type systems as a bonus to DX more than something strictly designed to prevent errors
Re:Why Elixir? A Rebuttal to Common Misconceptions by pmarreck on Wednesday July 23, 2025 @01:26PM (#44661716)
It's in line with the erlang philosophy of letting things crash trivially and restart instantly. Due to the universal immutability, starting a new process from a given state in Erlang/Elixir is nearly instantaneous and has extremely little overhead as they are not OS threads, they are BEAM VM threads.

Very opposite the Go model, btw.

Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Wednesday July 23, 2025 @01:40PM (#44661867)
Letting you wrong computations crash does not make them right.
Re:Why Elixir? A Rebuttal to Common Misconceptions by pmarreck on Wednesday July 23, 2025 @04:09PM (#44663431)
LOL. This only makes sense if you can know all the ways your code will fail... which you cannot.

Erlang/Elixir's approach is to simply say, "It's gonna fail no matter how many precautions we take, so let's optimize for recovery."

Turns out, this works fantastically in both cellphone signaling, which is where OTP originated, as well as with webserving, where it is perfectly suited.

Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Wednesday July 23, 2025 @04:48PM (#44663868)
I don't know who are arguing with? Everyone loves the otp.

It just does not catch logics errors.

Re:Why Elixir? A Rebuttal to Common Misconceptions by em-bee on Wednesday July 23, 2025 @05:13PM (#44664101)
whether that matters or not depends on whether the logic error occurs because of a rare combination of events or as a result of a certain state and whether that state remains after recovery. if there is for example a logic error that causes the app to crash after say 10 minutes of runtime, or eg. at a certain message size, then a recovery will reset the runtime and it will work again. it will of course invariably fail again after another 10 minutes or when the same message is resent, because it is a logic error, and logic dictates that the error won't go away no matter how often you restart, but it will work in the meantime.

in other words, any error that doesn't occur right at start can be recovered from at least for all those operations that do not depend on that error being fixed.

Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Wednesday July 23, 2025 @05:55PM (#44664447)
This sound like a wild and very contrived argument.

Both because that memory leaks are normal is types languages - and does usually not matter in most serious applications - and because this class of errors is usually not what types catch.

Types have value when you 1) refactor and 2) have multiple people working on a code base.

The error you see when you don't have types is something like a BadArityError.

Re:Why Elixir? A Rebuttal to Common Misconceptions by never_inline on Wednesday July 23, 2025 @01:41PM (#44661875)
To restart and fail again? How does that help with logic errors caused by wrong type objects?
Re:Why Elixir? A Rebuttal to Common Misconceptions by pmarreck on Wednesday July 23, 2025 @04:11PM (#44663459)
It doesn't prevent the error, but it also won't take down your server when malicious users (or just lots of normal users) start to bang on that input with the problem, and your non-BEAM VM pool starts to run out of available preloaded stacks... You get a new Erlang process in well under a millisecond on modern hardware

It WILL log the error, with a stacktrace, so you have that going for you

Note that even with typing, you cannot avoid all runtime errors

Also note that this tech was first battle-tested on cellphone networks, which are stellar on the reliability front

Re:Why Elixir? A Rebuttal to Common Misconceptions by victorbjorklund on Wednesday July 23, 2025 @03:01PM (#44662749)
Depends on the error. Lets say it is an error that happens once every 1 million users.
Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Wednesday July 23, 2025 @01:26PM (#44661722)
While I greatly appreciate elixir it is completely malplaced to contrast fault tolerance and type systems - they solve very different needs.

As such fault tolerance does not guarantee that you MRI scanner does not kill your patients.

You likely want both.

Re:Why Elixir? A Rebuttal to Common Misconceptions by OkayPhysicist on Wednesday July 23, 2025 @01:54PM (#44662026)
It's likely Armstrong conflated the two there because a significant part of the fault tolerance of Erlang comes from the loose coupling via message passing between components, which in no small part is tied to the dynamic typing. It's a Postel's law thing, being generous in what you accept and strict about you send.

Elixir's seamless pattern matching paradigm, IMO, largely negates the need for strict typing. If you write your function signatures to only accept data of the type / shape you need (which you are incentivized to do because it lets you unpack your data for easy processing), then you can write code just for the pretty path, where things are as expected, and do some generic coverage of the invalid state, where things aren't, rather than the norm in software development of "I covered all the individual failure states I could think of". This generic failure mode handling, too, greatly benefits from dynamic typing, since in my failure state, I by definition don't know exactly what the structure of my inputs are.

Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Wednesday July 23, 2025 @02:04PM (#44662155)
Yep, I have written and maintained several large scale applications In elixir and live the computation model.

However,elixir depreately needs proper types. IMHO the needs for types are in no means negated by pattern matching, and I also see hints at why you would say so.

> If you write your function signatures...

The point of types is worry less refactoring.

If you work at a place where you can define the arhicture for the entire lifecycle of the application without ever needing to Refactor, then sign me up! I want to work there.

Re:Why Elixir? A Rebuttal to Common Misconceptions by throwawaymaths on Wednesday July 23, 2025 @01:34PM (#44661803)
no, but effort is a finite resource so it justifies why they didn't bother.
Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Wednesday July 23, 2025 @01:54PM (#44662033)
Well, the people behind elixir seems to have accepted that typing is necessary.

I see this story on an on: some hacker makes a language, they hate types because they want to express themselves. The languages gets traction. Now enterprise application and applications with several devs use it and typing gets essential - types will then gradually be added.

Re:Why Elixir? A Rebuttal to Common Misconceptions by throwawaymaths on Wednesday July 23, 2025 @03:33PM (#44663066)
sure, a few years behind typescript/mypy isnt really so bad for a language without a microsoft or a google behind it, is all im saying.
Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Wednesday July 23, 2025 @04:02PM (#44663359)
> isnt really so bad for a language without a microsoft or a google behind it, is all im saying

What? Elm was literally the result of a single grad students side project - elm incorporates both a sound type system and FRP.

This has nothing to do with time. It was a decision not to support it.

Re:Why Elixir? A Rebuttal to Common Misconceptions by throwawaymaths on Wednesday July 23, 2025 @07:28PM (#44665154)
sure part of the decision is that you can't really soundly type (in a developer sanity preserving way) across a cluster that runs multiple versions of software (which is a real use case that the authors absolutely needed to support as part of the core business). but they let dialyzer in to the core so it's not like the team was actively hostile to typing.
Re:Why Elixir? A Rebuttal to Common Misconceptions by tossandthrow on Thursday July 24, 2025 @04:53AM (#44668537)
These are some weird sentences thrown into this thread.

What you are describing is a runtime concern that has nothing to do with types.

These issues are neither amplified nor alleviated by using types.

Re:Why Elixir? A Rebuttal to Common Misconceptions by bccdee on Wednesday July 23, 2025 @02:01PM (#44662120)
Okay? But "the features you need would have taken effort to implement, so we didn't implement them" is not a very good sales pitch when you're trying to convince me to use your tool to do my job.
Re:Why Elixir? A Rebuttal to Common Misconceptions by throwawaymaths on Wednesday July 23, 2025 @03:34PM (#44663075)
ok. don't use it then. but be aware: your attitude is why things get stuck in (sometimes really awful) local minima in tech.
Re:Why Elixir? A Rebuttal to Common Misconceptions by bccdee on Wednesday July 23, 2025 @03:59PM (#44663334)
Any tool that justifies the choice not to implement an important and highly-requested feature with "effort is a finite resource" alone is not viable for serious development work. It's not prioritizing, it's a refusal to prioritize.
Re:Why Elixir? A Rebuttal to Common Misconceptions by throwawaymaths on Wednesday July 23, 2025 @07:58PM (#44665386)
you probably shouldn't bulldoze into a situation with assertions like you've made with such a limited grasp of the history at play.
Re:Why Elixir? A Rebuttal to Common Misconceptions by bccdee on Wednesday July 23, 2025 @01:48PM (#44661952)
I've never had a system crash from a lightning strike, fault-tolerant or otherwise. I have had systems crash from null pointer errors though, and fault-tolerance did nothing to fix that except turn a crash into a crashloop.

I have the same attitude toward overly permissive type systems that I do toward the lack of memory safety in C: People sometimes say, "if you do it right then it isn't a problem," but since it objectively IS a problem in practice, I would rather use the tool that eliminates that problem entirely than deal with the clean-up when someone inevitably "does it wrong."

Re:Why Elixir? A Rebuttal to Common Misconceptions by bluesnowmonkey on Wednesday July 23, 2025 @06:21PM (#44664636)
We had a cluster of servers, dynamically scaling up and down in response to load, and one day started seeing errors where an enum string field had an impossible value. Imagine the field is supposed to be "FOO" or "BAR" but one day in the logs you start seeing "FOO", "BAR", "GOO", and "CAR". Impossible. "GOO" and "CAR" did not exist in the code, nothing manipulated these strings, yet there they were.

Long story short, a particular machine that joined the cluster that morning had some kind of CPU or memory flaw that flipped a bit sometimes. Our Elixir server was fine because we were matching on valid values. Imagine a typed language compiler that makes assumptions about things that "can't" happen because the code says it can't... yet it does.

Re:Why Elixir? A Rebuttal to Common Misconceptions by 3eb7988a1663 on Thursday July 24, 2025 @12:06AM (#44666808)
I am not sure I want the system to continue operating in that scenario. You have corrupted hardware that could be trashing other records. What if it is flipping bits on financial transactions?
Re:Why Elixir? A Rebuttal to Common Misconceptions by spooky_deep on Thursday July 24, 2025 @09:57AM (#44670738)
Depends how you use the statically typed system.

For example

    match parseFoo json with
    | Ok foo -> 
      process foo
    | Error message ->
      print message
This will skip bad messages and be statically typed in the valid case.
Re:Why Elixir? A Rebuttal to Common Misconceptions by bccdee on Tuesday July 29, 2025 @01:13PM (#44725914)
That only works for enum discriminants. What if it were modifying the data payload, producing valid but corrupt messages?

The only way to tolerate that kind of error is checksums on your data, and I don't think any language has that kind of redundancy built in.

Re:Why Elixir? A Rebuttal to Common Misconceptions by dminik on Wednesday July 23, 2025 @01:10PM (#44661544)
Tbh, the strongly typed and dynamically typed combination seems like the worst option.

You get zero help and punished hard for failing.

Re:Why Elixir? A Rebuttal to Common Misconceptions by em-bee on Wednesday July 23, 2025 @01:59PM (#44662086)
how so? most dynamically typed languages are also strongly typed. that includes python, ruby, common lisp, smalltalk... if it was the worst option, this would not be the case.
Re:Why Elixir? A Rebuttal to Common Misconceptions by dminik on Wednesday July 23, 2025 @02:02PM (#44662127)
A casual look at the history of basically anything will tell you that the best option isn't necessarily always the one that succeeds.
Re:Why Elixir? A Rebuttal to Common Misconceptions by em-bee on Wednesday July 23, 2025 @02:09PM (#44662202)
sure, but when the majority of popular languages use that paradigm then it surely can't be the worst option either. what is it that makes it a bad combination?
Re:Why Elixir? A Rebuttal to Common Misconceptions by dminik on Wednesday July 23, 2025 @02:32PM (#44662440)
Please, smalltalk and common lisp don't qualify as popular languages.

I don't want to look at TIOBE, so let's look at the stack overflow survey from 2024. https://survey.stackoverflow.co/2024/technology#admired-and-...

Strong + Static: TypeScript, Java, C#, C++, Go, Rust, Kotlin, Dart, Swift, Visual Basic, Scala

Weak + Static: C

Strong + Dynamic: Python, Lua, Ruby, R, GDScript(*)

Weak + Dynamic: JavaScript, PHP, Matlab, Perl

At this point I'm reaching into the low percentages. I think it's pretty clear that Strongly + Statically typed languages are massively over-represented on the list.

Both Strongly and Weakly Dynamically typed languages are similarly represented.

Note: I'm open to editing the comment to move languages from and to various categories. I haven't used many of them, so correct me if I'm wrong.

Re:Why Elixir? A Rebuttal to Common Misconceptions by em-bee on Wednesday July 23, 2025 @02:36PM (#44662491)
smalltalk and common lisp don't qualify as popular languages

not anymore. they were very popular in the industry at one point. very few other languages have so many independent implementations as smalltalk and lisp. a testament to their wide spread use in the past.

Strong + Static: TypeScript; Weak + Dynamic: JavaScript

that doesn't make sense. typescript is javascript with types, it can't be both strong and weak at the same time.

but i believe we have a different definition of weak. just because javascript, php and perl have some implicit type conversions doesn't make them weakly typed. i believe it takes more than that. (in particular that you can't tell the type by looking at a value, and that you can use a value as one or another type without any conversion at all)

C is weakly typed, it was always a major criticism, C++ too i think (less sure about that).

once you correct for that you will notice that all languages in the strong and static category are less than 30 years old and many are much younger. (java being the oldest. but there are older ones like pike which is also strong and static and goes back to 1991)

the strong and dynamic category goes back at least a decade more. (if you include smalltalk and lisp)

what this does show is that static typing has experienced a renaissance in the last two decades, and also the worst is really using any form of weak typing.

i still don't get what makes strong and dynamic a bad combination, other than it's bad because it is not static.

Re:Why Elixir? A Rebuttal to Common Misconceptions by dminik on Wednesday July 23, 2025 @03:25PM (#44662989)
I mean, if you define weak like that, then yeah. But also, what languages are you left with? Assembly? Then again, it does fit with your definition of popular being popular 45 years ago. Tbh, I'm not sure if smalltalk was ever even popular. It was certainly influential, but popular?

I know that there are discussion about what strong vs weak even means, but I think most people would place the weak distinction way above yours on a possible weak-strong spectrum.

C can certainly be argued to be weak. My understanding is that it's mostly due to pointers (and void* especially). C++ is much better in this regard. I mostly just did not want to add a Weak + Static category just for one language.

Well, now that you've defined Strong to also include all of the languages I consider Weak, then yeah, no issues at all.

Re:Why Elixir? A Rebuttal to Common Misconceptions by em-bee on Wednesday July 23, 2025 @09:35PM (#44665944)
definitions are hard. but i am mostly concerned to make sure we are talking about the same thing, regardless of what that thing is called. i do accept and agree that javascript, php and perl may be considered weaker than python or ruby. but to which degree may be a matter of taste. to me they are still strongly typed for the most part. (and let's not get into the definition of static, that's another can of worms)

but the interesting question is really the one posed at the beginning. what makes strong but dynamic a bad combination?

i think we agree that weak is bad. implicit type conversions like 1+"2" range from the annoying to problematic and dangerous. if we eliminate weak that only leaves strong and static vs strong and dynamic.

i agree that strong and static is better in most cases, type declarations help, and pike the language i use the most myself which is somewhere between python and go, has powerful types that are a joy to work with, but for comparison in typescript types come across as more annoying (in part because they are somewhat optional, and because they get lost at runtime, so they don't help as much as in truly typed languages) but strong and dynamic has shown to be a solid combination, especially with python and ruby. so i don't feel the combination is as bad as you seem to suggest.

Re:Why Elixir? A Rebuttal to Common Misconceptions by iLemming on Wednesday July 23, 2025 @06:13PM (#44664588)
> smalltalk and common lisp don't qualify as popular languages.

Sure, Smalltalk isn't, but Lisp is a different story. In this context I assume we all mean to say "Lisp" and not "Common Lisp" specifically.

Lisp (as the entire family of PLs) is quite massively popular.

Standard rankings have major blind spots for Lisp measurement, they miss things like, for example, Emacs Lisp is everywhere. There's tons of Elisp on GitHub alone, and let me remind you, it's not a "general-purpose" language, its sole function is to be used to configure a text editor and there's mind-boggling amount of it out there. AutoLISP is heavily used in CAD/engineering but rarely discussed online. Many Lisp codebases are proprietary/internal. Also, dialect fragmentation artificially deflates numbers when measured separately - many rankings consider them different languages.

If you count all Lisp dialects together and include: Emacs Lisp codebases, AutoLISP scripts in engineering, Research/academic usage, Embedded Lisps in applications, Clojure on JVM and other platforms - babashka scripts, Flutter apps, Clojurescript web apps, etc;

...Lisp would likely rank much higher than typical surveys suggest - possibly in the top ten by actual lines of code in active use.

Re:Why Elixir? A Rebuttal to Common Misconceptions by throwawaymaths on Wednesday July 23, 2025 @01:35PM (#44661815)
nah you just get log lines. crash is not as bad as you think it is.
Re:Why Elixir? A Rebuttal to Common Misconceptions by dminik on Wednesday July 23, 2025 @02:06PM (#44662173)
I mean, it is a kind of a bug that is easy to prevent with a static type checking, but also one that will always (or almost always) get triggered.

Log lines are whatever, but a system that goes into a crash loop or fails on most requests isn't great.

Re:Why Elixir? A Rebuttal to Common Misconceptions by crabmusket on Wednesday July 23, 2025 @07:14PM (#44665039)
Nope, getting a TypeError on "1"+2 is not being "punished". That's way better than getting malformed data that you weren't expecting which keeps the system "working" until an error happens somewhere else, later, where it's more confusing.
Re:Why Elixir? A Rebuttal to Common Misconceptions by hinkley on Wednesday July 23, 2025 @09:05PM (#44665769)
OpenTelemetry.js did this. Being written in typescript they wrongly believed they didn’t need to check the data type for user-supplied numbers. Yeah so my production data started having dropouts because somewhere we incremented by “2” instead of 2, and then OTLP choked on 100% of the data from that process because one stat out of thousands was not to its liking and had a three thousand digit ‘number’ in it.

I never did track down the last spot where we screwed that up. This was a system we shifted from statsd, so the offending callers were either working by accident or only killing some data points for one stat and nobody noticed.

So then OpenTelemetry.js had to start sanitizing its inputs and not assuming the compiler should catch it. I still think it odd that something called “.js” was actually “.ts” under the hood.

Re:Why Elixir? A Rebuttal to Common Misconceptions by dminik on Thursday July 24, 2025 @03:29AM (#44667957)
Not getting an error on "1" + 2 is very bad if that's not what you wanted to do. Agreed.

Getting an error on "Value: " + 2 is very annoying if that's what you wanted to do.

The solution here is Static typing, not Strong/Weak typing.