News for hackers. Stuff that matters.
Re:Strong arrows: a new approach to gradual typing by anonyfox on Thursday September 21, 2023 @07:14AM (#37595986)
I cannot support much in terms of money or time currently, but somehow I'd wish there are ways to speed this up.

Sure, sponsoring from big corps comes with their own problems, but maybe that would be an option? There are quite some that use Elixir (or BEAM in general) out there...

Idk what would be the best approach.

But I am very convinced that Elixir and the wider ecosystem (not only phoenix liveview) is (or could be) the very best "default" web app stack we have right now in general. It solves _so many_ problems of other comparable tech stacks right out of the box, one way or the other, and is the only one I've noticed a sentiment of pure joy from seasoned devs that also lasts well after the novelty wears off.

At this point it looks "only" like a number problem to become mainstream (again a number problem). No idea how to solve it, just felt I needed to share my thoughts as a data point here.

Like the type system here: I'd _kill_ to have this exact implementation today rather than _maybe in a few years_. And yes, I can draw comparison to Typescript, Rust and Haskell which I used for projects in the past. Its like combining the very beast ideas (and adding some more) into one awesome thing.

Re:Strong arrows: a new approach to gradual typing by tempotemporary on Thursday September 21, 2023 @07:22AM (#37596027)
> It solves _so many_ problems of other comparable tech stacks right out of the box

Could you expand top 5(or more) major pain points that it solves?

Re:Strong arrows: a new approach to gradual typing by anonyfox on Thursday September 21, 2023 @07:49AM (#37596258)
I don't thinks that would be a helpful discussion right here. Any one point there might come someone who points at some external "solution" (package, tool, ...) that might also do the same feature in some way for X, ignoring the fact that there are lot of Y without that particular thing still, but leads into derailing the argument anyways.

Elixir (and esp. Phoenix for web dev) is more like the culmination of the best ideas and heavily draws/depends on the last decades of real-world experience. Most stuff isn't (or shouldn't) be surprising, but the point is that everything you might need for the vast majority of projects is right there, nicely packaged up into a unified nice thingy.

But to give you a few of _my_ top points:

1. Architecture and DX for complex interactions: there is no need to bring in supplemental infrastructure crutches (Redis, AWS whatever service, ...) in many cases to begin with. OTP, which is like a core library always available, already includes the building blocks for things like cache servers, application clustering and supervision strategies, ... .

2. Reliability and availability: this tech is the original one achieving the "nine-nines" of uptime record. To get an idea of how, https://www.youtube.com/watch?v=JvBT4XBdoUE this talked is packed and excellent, and also highlights a few things why it can achieve my point 1 above.

3. "SPA-like" interactivity with full server side rendering without all the pains of exposing/consuming a dedicated HTTP API in between, or overcomplicated nuances of rendering pipelines (also see react server components) to achieve SSR/CSR in a way that not sucks or is noticeably slow. Liveview is tried to be replicated in other stacks, but they don't come close in reality today or complicate the apps' infrastructure with additional crudges. And don't get me started on the integration testing story compared with SPA+Backend setups.

4. Agents/Message passing parallelism (not only concurrency, but also distributed!) at your fingertips, which makes modeling current "async problems" kinda trivial. OTOH, building something like a proper async-based web framework in rust is quite a pain in the ass, with lots of type fiddling needed, instead of doing the solution you actually want to deliver with it.

5. Some absolutely awesome takes on some typical libraries. Take the ORM options for javascript/typescript (all with severe tradeoffs, and analysis paralysis ontop). Take Rails' ActiveRecord with lots of magic and while great to get started becomes quickly bloated (iE fat models) in bigger projects. And then Ecto got it "just right" with slim schemas, changesets, and basically pure functions + pipelines. Any "model" can be used within new usecases by adding new changesets/validations explicitly and easily, there is no "general" validation right on the model level you have to tiptoe around, and starting If-cascades.

Re:Strong arrows: a new approach to gradual typing by clementai on Thursday September 21, 2023 @08:25AM (#37596592)
I would add some more points.

6. Livebook, Jupyter notebook are amazing in Python, Livebook is the same but for Elixir. Also you can connect to your running environment and interact with it.

7. The Nx ecosystem, ML is not only a Python thing now, Elixir is completely usable for ML now.

8. Ash framework, this is not a web framework but a framework for your domain, it's amazing

Re:Strong arrows: a new approach to gradual typing by anonyfox on Thursday September 21, 2023 @08:57AM (#37596961)
absolutelt hard agree on livebook, but I think thats not an immediate thing every webdev needs.

but speaking from recent practice, it is laughably simple and kinda mindblowing for non-experts in this stuff. Like, I klick me a few smart cells to interact with external data and get a connection/data, write a few straightforward logic modules to do something, and a super simple form for users of this thing (like two inputs and a submit button, and an event handler) and I can eliminate a business workflow or report. I can call a dev into it ad-hoc to help with a code snippet like a liveshare-coding-session. And finally I deploy it to a bookmarkable URL with a password.

Maybe an hour worth of work, _including_ talking with people while fleshing this out in quick iterations as-we-speak.

I mean people kinde get how cool phoenix is for one reason or the other, but livebook is really killing it for me. It's hard to talk with business people about tech internals no matter how awesome, but its a different game with lightweight livebooks. If you also happen to have phoenix as your actual product/app, linking the livebook indeed is nice to directly call functions instead of rewriting those snippets in SQL... but the endgame here is when the livebook starts to become unwieldly due to increasing feature requests, it can be integrated into a phoenix app rather easily, since a dev starts out with working code to begin with (and can play with it interactively).

Re:Strong arrows: a new approach to gradual typing by throwawaymaths on Thursday September 21, 2023 @09:19AM (#37597202)
> it can be integrated into a phoenix app rather easily

I can't figure out how to do this.

Re:Strong arrows: a new approach to gradual typing by anonyfox on Thursday September 21, 2023 @09:40AM (#37597468)
By this I mean taking the code logic snippets and slap a dedicated new liveview UI on it within your phoenisx app - which isn't too hard since the initial ui in the livebook is pretty bare bones. Yes its rebuilding the whole thing technically, but probably really quick to do
Re:Strong arrows: a new approach to gradual typing by paradox460 on Thursday September 21, 2023 @01:20PM (#37600833)
I've replaced postman (and postman likes) with a liveview notebook. It's absolutely great. No need to mess with weird plugins or mentally have to parse responses, you can just use cells that use real elixir to do that.

It's really nice

Re:Strong arrows: a new approach to gradual typing by daxfohl on Thursday September 21, 2023 @09:06AM (#37597056)
I read that Brex moved away from Elixir to Kotlin. If Elixir was really that great then why would a company put such a big effort to ditch it? That killed off my interest in learning it, but maybe their reasons were invalid? Genuinely curious.
Re:Strong arrows: a new approach to gradual typing by WJW on Thursday September 21, 2023 @09:20AM (#37597217)
Do you reject learning any language that has been migrated away from by any company? Why not make up your own mind about whether it is nice instead of depending on rumours about other companies?

In any case you could have easily googled "brex elixir" and have found their blog explaining their reasoning as the first result: https://medium.com/brexeng/building-backend-services-with-ko...

Re:Strong arrows: a new approach to gradual typing by indigo0086 on Thursday September 21, 2023 @12:06PM (#37599703)
"Development speed: The future will be great and we want to get there fast. Our choice needs to help us move with urgency and focus. A type-system was a non-negotiable choice here."

While Jose Valim did a good job in his talk about dispelling the idea of type system offering all these promises that may or may not be true, the idea will never die. This could mean that it is the right idea, but it could also mean that now's the time to look into a way to offer it in away it attracts people who have that perception while offering a type system of value.

Re:Strong arrows: a new approach to gradual typing by throwawaymaths on Thursday September 21, 2023 @09:17AM (#37597174)
I hear new Cto came in, got nervous about hiring. They are still hiring for elixir positions, though?
Re:Strong arrows: a new approach to gradual typing by weatherlight on Friday September 22, 2023 @01:17AM (#37608167)
i heard basically the same and also (the new CTO just really like kotlin and knew a bunch of people who know kotlin and wanted to bring them over. )

again, take the above with a grain of salt.

Re:Strong arrows: a new approach to gradual typing by josevalim on Thursday September 21, 2023 @09:51AM (#37597610)
You will find examples from companies moving away from Elixir, Python, JavaScript, Scala, Java, etc. I don't think there is any programming language that is "unditchable". So I'd suggest to analyze the reasons that made a company move away from X, check if they are still relevant, if they'd apply to you, and, if yes, if they are a deal breaker or something you can work around.

For the Brex case, if I remember correctly, lack of static typing and early-development of gRPC tools were the reasons back then. How much this impacts your needs is up to you.

Re:Strong arrows: a new approach to gradual typing by jerf on Thursday September 21, 2023 @10:41AM (#37598335)
'I don't think there is any programming language that is "unditchable".'

There can not exist one perfect programming language for all uses. (Sometimes people don't like that statement but I think if you seriously sit down and work the math it's pretty obvious that, as a simple for instance, Rust is not going to replace all shell scripting and shell scripting is not going to replace all Rust, and that's just an example, the principle holds in numerous dimensions in the programming language space. [1])

There are always people making bad decisions, some of those bad decisions are about which programming language to adopt for a problem.

So, yes, you'll always be able to find companies dropping some language, but it isn't necessarily the language's "fault".

I don't say this on every such article in the comments because it's kinda kicking someone while they're down, but I would assess that the clear majority of the ever-present torrent of "We switched from X to Y and look how much better Y is!" are actually long and detailed explanations of how the company in question chose the wrong technology for their problem, not how bad X is. The two major exceptions are "our tech in X predates Y existing as a valid choice, and now that it does, it's a better choice" (can't blame them for existing before the right tech, I've made that move myself in my own career) and "We did our research and X really should have worked but we got into it only to discover that it really didn't for some reason we could not have reasonably anticipated". That latter is pretty rare, IMHO, but I've seen it a couple of times. (Generally it is when a closed-source stack has a fundamental problem and you can't fix it, because it's closed source.)

(I suppose there's also "X was a good choice initially but we outgrew it", but in my very opinionated opinion even these are often... dubious. It happens, yeah, but in my personal opinion it still means the language chosen was not able to scale the solution. Only people truly suprised by their growth, which does happen, should reach for this.)

[1]: And if that still bothers you, think small shell rather than large. I'm not going to write Rust for the equivalent of "awk '{ print $3 }' myfile | sort | gzip > sorted_names.gz". However broken shell legitimately is as a programming language, you simply can not argue with that kind of bang-for-the-buck.

Re:Strong arrows: a new approach to gradual typing by sodapopcan on Thursday September 21, 2023 @10:20AM (#37598027)
Too bad, you're missing out. Did you look into companies that have not ditched it?

People don't tend to write articles titled, "We've been using the same tech for 10 years and have had no major issues with it so we are still using it." It's always the "we ditched x for y" ones that get traction and the actions of ONE company can seemingly have a far-reaching impression for people who otherwise know nothing about the technology in question.

Re:Strong arrows: a new approach to gradual typing by di4na on Thursday September 21, 2023 @09:45AM (#37597522)
Tbf. While more money to allows stability of people involved would help, it would not really speed it up that much.

Typescript had ms behind it and it still took a decade. At some point the engineering, experiments and learning take time and you can hardly speed it up with more ressources.

Re:Strong arrows: a new approach to gradual typing by anonyfox on Thursday September 21, 2023 @10:35AM (#37598243)
Maybe more like different layers could do different strategies? I can't even imagine what could happen to the BEAM itself if there are the same amount of ressources put on it like in our modern JS engines that have come a loooong way. Its already an amazing piece of tech in itself, but I wonder what an army of experts could do ontop of it.
Re:Strong arrows: a new approach to gradual typing by sodapopcan on Thursday September 21, 2023 @03:00PM (#37602362)
Then we might have NPM for the BEAM--Uber popularity isn't always a good thing. Don't get me wrong, though, I want Elixir to get more popular.
Re:Strong arrows: a new approach to gradual typing by josevalim on Thursday September 21, 2023 @10:37AM (#37598288)
I understand many would love to have this yesterday but I strongly believe we should not speed it up. :)

This is potentially the largest change the language will ever go through and we are being very intentional and deliberate on every step and decision we make. Once we start collecting feedback from the community, it may speed up or slow down the process, but I want to make sure everyone gets plenty of time to experience and internalize the changes.

When it comes to funding, the on-going work on Elixir type system is well funded by companies like Fresha, Starfish*, Supabase, and Dashbit. However, we also want to venture into new research areas, such as existential set-theoretic types, which would allow us to type behaviours (such as GenServer) similar to how one would type first-class modules in OCaml (or Typeclasses in Haskell). If someone is interested in sponsoring research work, hit me up (github.com/josevalim), and I can put you in touch with the proper institutions.

Re:Strong arrows: a new approach to gradual typing by moljac024 on Thursday September 21, 2023 @04:50PM (#37604118)
I would like to add that for what it's worth, I wouldn't mind slower compilation times if it means we get the type system as described. If it really does end up having a significant impact on performance, would you be open to making compile-time type-checking optional instead of scrapping the whole thing?
Re:Strong arrows: a new approach to gradual typing by josevalim on Friday September 22, 2023 @01:56PM (#37615332)
If it comes to this, we will certainly need to have a discussion on the topic. So I am definitely open to discussing the idea!
Re:Strong arrows: a new approach to gradual typing by Aerbil313 on Thursday September 21, 2023 @11:28AM (#37599106)
I’m curious. What exactly is Elixir good for? What do you find in it more appealing than other languages?
Re:Strong arrows: a new approach to gradual typing by anonyfox on Thursday September 21, 2023 @11:56AM (#37599571)
I have listed a few points here in the other comment: https://news.ycombinator.com/item?id=37596258

as a more general/subjective/emotional note:

The very pragmatic take on FP makes code in most cases so much easier to reason about. Immutability, no magic coming from some dark corner of the codebase unexpectedly, thinking in steps of data transformation from the get go, piping operator to make this visually pleasant, handling edge cases with pattern matches right at the function head level explicitly, ... and to have stateful stuff, there is OTP right on your fingertips with GenServer/Actor/ETS/... .

And a genserver basically is only just another module that implements certain callbacks and then gets spawned. Modelling some scenarios are are breeze with that. And when I feel like I need some better syntax for some exotic problem I am dealing with, I can bend and stretch my language constructs via hygienic macros right away.

And the whole experience is _extremely_ polished in terms of DX. docs, tests, doctests, interactive shell, a AOT-compiler, a JIT-runtime, and some very high-quality ecosystem bangers, like phoenix/livebook/membrane/boradway/Nx/Axon/... . Its like best of all worlds, and definitively the _very best_ choice for orchestrating stuff, which is a boon when you run into a problem you'd rather not use elixir for. Like building a native extension in rust/zig for some raw CPU task is a breeze.

Its not so much the individual feature (no matter which one) but the overall package.

Re:Strong arrows: a new approach to gradual typing by OkayPhysicist on Thursday September 21, 2023 @04:47PM (#37604084)
It's a functional, concurrent-first language. People have talked about the upsides of functional programming to death, either you prefer it or you don't. The concurrency story, though, is a significant advantage exclusive to the BEAM languages. They utilize green threads with message passing queues that we call "processes" (not to be confused with OS-level processes).

A good almost-toy level project I built in Elixir was a Minecraft server proxy. At the top level, you've got a listener process, that waits for an incoming TCP connection, and a Supervisor process, who's responsible for the existing connections. When the listener receives a new TCP connection, it spawns a process under the Supervisor to handle that incoming connection, and goes back to listening. That's about 10 lines for code: 4 in the initiation (function declaration, start Supervisor, start Listener, end), and 6 in the Listener (function declaration, get new TCP connection, spawn process as a child of the Supervisor, assign TCP connection, recurse, end)

The child processes are running a little state machine to do some parsing of the TCP stream. They receive TCP packets as a series of messages, and based on those messages they do various things. Unimportant for the purposes of explanation, except to say that the built-in gen-statem state machine handler simplifies it down to a series of functions that match a message, and produce a new state.

But what if I receive a packet that I don't have a defined response to? Well, I don't need to write any extra code for that. When it fails to pattern match any of my states, the process is going to crash. Then it's children will crash (including the tcp connection, which will be closed by this operation), then it'll tell it's Supervisor "Alas, I am slain". By default, the Supervisor would replace it with a clone, passed the same initial arguments. But that's not the behavior we want here, we want it to just accept that the process has died, and maybe pass an alert to some process for logging or monitoring purposes. That's a built-in option, so it was just an argument in our declaration of the Supervisor in the first place.

The key thing to notice there is that anything that causes that child to crash will resolve the same, safe, way, from unpredicted packets, to the processor core it's running in being struck by a meteor. The other, perfectly fine child processes will keep chugging along, doing their own thing. Likewise, the Supervisor and Listener are protected from each other's failings. If the Listener fails, the top-level application supervisor will replace it, and likewise for the Supervisor for all the connection handlers.

This synnergy of fault tolerance and concurrency is the key idea of Erlang, and by extension Elixir. It lets you code the pretty path, and accept that there are failure modes you can't or don't want to bother anticipating.

Re:Strong arrows: a new approach to gradual typing by Aerbil313 on Thursday September 21, 2023 @10:07PM (#37607039)
Thanks for the detailed response. There’s no other mainstream language which has this fault tolerance built-in, right?
Re:Strong arrows: a new approach to gradual typing by OkayPhysicist on Monday September 25, 2023 @02:39PM (#37648569)
Definitely nothing in the mainstream. The closest you get is a couple of Actor-model libraries for Java and C#, but since languages weren't built from the ground up around it, you end up with a lot of jagged edges that simply don't exist in Erlang or Elixir. Outside of the functional paradigm, there are a lot of things you can express that simply cannot be translated into a distributed environment.

The other "in the same ballpark" thing that is much more mainstream is microservice architecture. They aim for the same goal, of achieving concurrency-modeled parallelism and fault tolerance by translating a system into a distributed one, but since microservices tend to be hacked together with a variety of languages with no intrinsic support for the paradigm, you end up with an "ad hoc informally-specified bug-ridden slow implementation of half of Erlang."

There's a few projects even further outside the mainstream than Erlang and Elixir that are taking a swing at it, but they're all extremely obscure, and IMO haven't yet demonstrated any novelty worth sacrificing the vast libraries available on the BEAM.