iex> l = 1..3 # equivalent to [1,2,3]
iex> Enum.reduce(l, fn item, acc -> acc + item end)
# or
iex> Enum.reduce(l, &(&1+&2)
# or the built in
iex> Enum.sum(l)
# all return:
6
I should have picked a different example -- the idea I was trying to get across was that mutability within a loop is useful.
Here’s a similar question I asked with Python vs. OCaml and Lisp. Short-circuiting loops seems to cause the code to become fairly ugly in functional languages
Module design doesn't seem any harder than class design in JS or Python.
Do you mean the language is generally harder for non-developers? Or that Elixir is harder for JS/Python developers to pick up and write good code? Or something else?
Writing well designed Elixir code does seem to require a fairly different approach from most common OO languages, at least at a surface level. (Although IMO that's more because you can copy OO patterns you've seen before without thinking much about why they're good patterns than because good design in Elixir is much different from OO)
sure thing! I'll try to make points related to what I observed and experienced in my org, starting with one huge huge huge preamble which is: I work in an average org with average joe devs. an average joe dev to me is someone who "just wants a job" and is not very interested in furthering its own professional development or learning new things unless trained & forced by the job. it's perfectly fine to be an average dev, I understand I'm sounding like a snub but the difference is real, exists, it's tangible as I touch it every day.
having said that, designing a proper elixir module (which basically is a bunch of functions that operates on a certain data structure usually represented by map of a certain shape) carries a certain level of fundamental understanding of the operation you're doing, which in my experience is one of the hardest things to get correctly.
It also requires a different way of exploring code as you can't do the familiar `.` and see what happens, you can't just do `price.toCentsValue` but need to do `price |> Price.toCentsValue` and so you need to know the existence of the `Price` module, which might not exist and be buried in `Cart` or as an helper in some controller because you did not understand clearly the domain and the modules responsibilities. Attaching behaviour to data is powerful, explorable, and most people are used to it, even if it's the wrong place in principle, with modules this is flipped, it's now data that must thread through operations, and it's not super easy to grasp.
Also, tooling is not that good (dialyzer sucks, intellij plugin not that good, vscode lsp good but still not a proper experience from people coming from c#/java, type annotations are not that readable...), pattern matching and destructuring on fn arguments confuses people and it's not super easy to read, and a million other papercuts related to tooling and syntax.
We don't have many elixir codebases (let's say around 15-25%) and I've seen incessant whining about "we don't want to maintain elixir" simply because the majority of people cannot be bothered to learn another mountain of quirks and papercuts (every lang has them) plus also losing the familiar way of working they already have, and having to remember that for the spot ticket that appears once in a blue moon on jira for elixir. That's why I think elixir needs extra support from the organization, basically in mandating it to be the primary language, teaching people proper design + proper code navigation and structure techniques, etc.
I hope I've been clear in my long winded ramblings; and I still wish a great future for elixir, so it becomes more approachable in average places like mine
> It also requires a different way of exploring code as you can't do the familiar `.` and see what happens, you can't just do `price.toCentsValue` but need to do `price |> Price.toCentsValue` and so you need to know the existence of the `Price` module, which might not exist and be buried in `Cart` or as an helper in some controller because you did not understand clearly the domain and the modules responsibilities. Attaching behaviour to data is powerful, explorable, and most people are used to it, even if it's the wrong place in principle, with modules this is flipped, it's now data that must thread through operations, and it's not super easy to grasp.
Not sure, I think you're picking and choosing things to ramble about. While you can't just do `price.toCentsValue`, and have to call `Price` module, in a OO language, you would need to instantiate `price = new Price(amount 10)` or something before calling `toCentsValue`. This means you're aware of the Price class, same as being aware of the Price module. If anything being aware of the module infact is better IMO since it allows you trace through explicitly what the code is going to do. Your point is correct if you're working through macros though.
I'm not really picking anything, just sharing how it went with elixir in my org. I'm sure we could have done better, but the pit of success was not there for the polyglot teams. the elixir-only teams did a bit better, but mostly they just learned the ecosystem and then GTFO'ed out to greener pastures since they just wanted to write elixir and only elixir.
about your specific counterpoint, I think it's partially valid; I don't instantiate modules, I might not have named structs but just operate on Maps so I don't know the supposed module name, I might have misplaced the function in another module (while it's very intuitive to stick it to the object in oop)...and a million other things that are way too different for the average joe.
We could certainly debate the objective merits of Elixir vs other languages (which seems to be the primary discourse in this thread and elsewhere) but hearing subjective developer experiences is also critical.
It doesn't matter if Elixir is objectively better or not, if lots of devs who are exposed to it are having a hard time it's worth asking why.
In addition to developers not wanting to expend additional effort to learn a new language or paradigm, I believe there are gaps in the ecosystem especially around medium-advanced topics.
The org I work at has the same issue with Elm, there is one Elm product and no one really wants to take those tickets because everyone hates dealing with it. It has become a total pain in the ass, and I believe someone is rewriting the app in React
I'm guessing the people who actually love Elm left.
You really do have to love a paradigm to work with it, because paradigm shifts have a cost. Elm's paradigm shift is "do everything declaratively/immutably/non-side-effecty" and the massive (IMHO) benefit of going about things that way is "no runtime errors" (!!!) in addition to quite performant code.
But yes, the cost is there, and it is that you sometimes just want a side-effect to get something done, you sometimes just want to call into another library to get something done, etc.
The thing is, if Elm allowed this, or made it easier, you'd lose the Elm guarantee of "no runtime errors". Which, frankly, is a pretty big one- just inspect any popular domain's web page and you're likely to see dozens of JS errors that are simply hidden from most users, contributing to a "janky" web experience.
I literally just inspected this very page I'm typing this comment on and I see:
This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”.
Error: Promised response from onMessage listener went out of scope
The cost of perfection is high. You really have to love the ideal.
But yes, if no one does, then Elm is a boondoggle.
I'm dealing with something similar with NixOS. NixOS's big guarantee (which is also big) is basically "no build or runtime failures that are due to misconfigured dependencies". But there's a steep learning curve and scattered documentation. The core idea is amazing, though, and that's what I love. The rest I tolerate while climbing the mountain.
> I work in an average org with average joe devs. an average joe dev to me is someone who "just wants a job" and is not very interested in furthering its own professional development or learning new things unless trained & forced by the job
so basically you're all doing things you hate, which is literally the worst possible work environment, and you're trying to use this as a data point for why Elixir "isn't for average coders". I have news for you, dude, you're not even at the "average coders" level, you just work in a "code mill", I'm guessing India.
you have an absolutely skewed perception of average in our field. I'm guessing "less than 3 years of experience".
nevermind the random stab, it's just to make you understand how random some answers are. in any case, no one is trying to touch your precious language, if you can't understand the context in which elixir failed (hot startup that HAD to hire everyone and its dog in 3 months + polyglot environment), not my problem
your last paragraph largely answers your questions.
it doesn’t take much to yeet some python scripts (and more) at the wall and get something to stick. SO, GPT, pick your poison, it’s painfully easy. solved problems as far as the eye can see, with a little glue or tape to hold it together.
elixir demands more of an investment. more than approximately zero is quite a bit if you already have momentum.
(elixir can absolutely be yeeted. not arguing otherwise.)
Honestly long run elixir code by LLMs is going to be better because the llm won't have enough attention or context to be sure that mutable passes to functions don't absolutely wreck your data
Do blue collar workers require healthcare from college educated people? Do they benefit when American industry is competitive on in the international marketplace?
We shouldn’t be leaving people behind but the idea is that we all benefit from an educated workforce.
There’s plenty of arguments to be made over the details but let’s not miss the big picture here.
My recollection of the details is fuzzy, but I think a common solution to this is connection draining. You set up your deploy to bring up the new instance and direct all new traffic to that one and then hold the old one open until all sessions/connections end.
Can't remember if/how that routing was accomplished in the BEAM (Erlang/Elixir VM). It's definitely possible but you might have to implement it yourself.
I really like Derrick Reimer's blog[0] for these types of posts. You might have to go back in time to find something a little more technical. On second glance, it seems the older articles are no longer available. You can find most of them[1] on the Wayback Machine though.
I really hate how the wealthy benefit from my washer, dryer, dishwasher, Internet, air conditioning, access to a huge variety of food... When will the wealthy start passing the benefits of progress on to the rest of us?
We've got big problems in our economy and income inequality is certainly one of them, but it's asinine to pretend that most individuals in society have not benefitted from technological progress.
Different time scales. Except the internet these are all things that come in the last 100 years. Clearly average well being has increased in that time frame. Less clear if the last two decades have been advantageous for people in the US. I understand there are solid stats that the median person in the world and the bottom quartile, have improved.
My kids have a vastly more fragile lifestyle then I did right out of college.
It's weird that in the face of growing evidence[1][2], people will still argue that it's "asinine" that a lot of people got the short end of the stick. Imagine we both went fishing and I took 80% of the fish and gave you 20%, when you turned around and asked for 50% if I said "look you were hungry yesterday and you clearly benefitted from 20% of the fish, why are you complaining" I assume you wouldn't just say "ok you're right".
Even your list is out of touch; many of my friends in San Francisco don't have in-unit washer or dryers. Look I don't even think I'm even making a crazy observation; I'm just continuing the trend - as AI gets better and more pervasive it's only natural that wealth will concentrate without some force to redistribute it (either through wages or taxes).
Your fishing example assumes a zero sum economy, when one of the first things you learn in economics classes is that the economy is not zero sum, that comparative advantages enable positive sum outcomes.
A better example is, we go fishing, I catch fish, you chop wood, we build a fire with my wood and eat with your fish. We are both better off than we were before.
The metaphor is not the economy - it's about being told to shut up in the face on inequality. At the end of the day if I can't raise my concerns and negotiating, then I might as well be under a monarchy and we can erase all pretense about this being fair.
Well, we're talking about the economy, which is where you implied the inequality. My point is that you're making it seem to the reader that you're conflating the two things, making it seem like you're implying that the fishing is about the economy.
If you want to talk about shutting up in the face of inequality, pick a better example, or better yet, mention that you're not talking about the economy at all, even though that's the point of discussion here.
>mention that you're not talking about the economy at all, even though that's the point of discussion here.
Are you implying there is no income equality today? I don't understand your contention with my point. It's more just asking me to ignore actual data and be happy with the fact that I can buy a flat screen TV for $200.
It's seems natural that capital accumulates - and with AI this process is only going to get more concentrated; and looking backwards its clear we its only going to get worse.
Income inequality in what? The...economy, right? This is why I was confused, since you say your analogy is not about the economy, yet that's what we're talking about.
Income inequality in the economy is present, yes, but economists are not in agreement whether it's a good or bad thing, and whether redistribution of wealth would even solve it [0]:
> Despite the extensive existing literature on income inequality and economic growth, there remains considerable disagreement on the effect of inequality on economic growth. Existing literatures find either a positive or a negative relationship. In this paper, we attempt to theoretically examine that relationship with a stochastic optimal growth model. We make the disagreement clear within a single model. We conclude (i) that both are possible – that is, higher inequality can retard growth in the early stage of economic development, and can encourage growth in a near steady state, (ii) that income redistribution by high income tax does not always reduce income inequality. Income inequality can be reduced by higher income tax in a near steady state, but it cannot be reduced in the early stage of economic development, and (iii) that two government polices – rapid economic growth and low income inequality – can be achieved by low income tax in the early stage of economic development, but both cannot be achieved simultaneously in a near steady state.
Now if you would like to submit literature on this topic, please do, as simply talking about what seems "natural" or "clear" does not really mean anything.
None of which take away from your point though: it's definitely a different mental model than you use for Python/Go/Javascript.