10 ms·
I was a Rails user for almost a decade. I switched to Phoenix/Elixir 3 years ago. Elixir is a super simple language. It has no OO concepts and everything is fun
by neya 7y ago
I was a Rails user for almost a decade. I switched to Phoenix/Elixir 3 years ago. Elixir is a super simple language. It has no OO concepts and everything is functions first. In fact, it's so good that I started teaching it for universities. All my production web applications are now fully on Elixir.
Elixir is one of those languages where everything has been done perfectly as of the time of this comment. When I say perfect, I mean, there has been never once in my career where I hit a roadblock due to the language's limitation or complexity or flawed assumption. I faced this with other languages, but not Elixir.
I'm currently a full time consultant writing, teaching and deploying production apps for clients in Elixir. Most of my apps have served my clients well beyond my contractual agreement. It's almost deploy and forget because of Phoenix. It also scales amazingly well. It's extremely performant.
I just re-wrote the entire crappy mess Wordpress core in Elixir and enjoyed the process. In any other language, I wouldn't be saying the same. It's really an enjoyable language that forces you to rethink the way you write code. Don't be put off by this statement, I mean that in a really good way. And once you start thinking interms of functions, you just won't touch any of those terrible OO programming paradigms (Eg. writing for loops, nesting conditionals, etc.). You will start writing maintainable, beautiful code.
You will appreciate Elixir a lot especially if you have a background in horrible programming languages like Javascript. You will literally start finding ways to use Elixir in your entire stack like I am. It's that good.
Enough said. Give it a shot.
- mwcampbell 7y ago> I just re-wrote the entire crappy mess Wordpress core in Elixir and enjoyed the process. That sounds useful. Do you plan to make a product out of that?
- neya 7y agoYup, launching soon. Probably will open source it too.
- codegeek 7y agoIf you want to compete with WordPress, you should open source it.
- jeremy_k 7y agoAny way to get updates when this happens? Edit: Saw the link to your blog below https://medium.com/build-ideas/ https://medium.com/build-ideas/
- DavidPP 7y agoDo you have somewhere we can register/watch to be notified ? Also interested here.
- neya 7y agoYou can follow my updates here as the other commenter has mentioned. Thanks! https://medium.com/build-ideas/ https://medium.com/build-ideas/
- yachtman 7y agoCan you explain in your own words for elixir where the balance between "joy" (productivity, flow, whatever you want to call it) and what you call "rethinking the way you write code". As another example of a functional oriented language that prides itself in the same thing look at Haskell. I wouldn't say most people think that Haskell is an easy or productive language (that is until after you have years of experience under your belt), but it definitely forces you to rethink how you code. Scala is another example, but draws the line at a different place. How is where elixir draws the line preferable in your opinion?
- lostcolony 7y agoSo as someone who worked in Erlang (and is familiar with Elixir), I can answer that a little bit. They hit a sweet spot. Enough rigor, enough limitation, at the language level, to force you to do things "the right way" for a broad swath of problems (there are certain problems they're poorly suited for), but enough simplicity and freedom to keep a minimal learning curve, and minimal runtime complexity to figure out issues. The focus on fault tolerance also means once you learn to use the app structure, with supervisors, you mostly have just one concern for reliability ("how do I start this into a known, good, consistent state?"), rather than hundreds ("what happens if -this- fails? Or that? Or that other thing?"). Haskell and Scala both have a huge surface area to learn before you're productive, let alone anything approaching fault tolerant, and even after years of use, there's still a lot of hidden gotchas with them. I've seen teams take Erlang, and their very first project just...worked. None of their lessons learned caused production issues, and no weirdness; the three issues that made it to prod I can even think of were, variously, one that wasn't user facing (just a log entry indicating something wasn't handled right; supervisor took care of it), one where performance started to slow (and it was due to having written an O(N^2) algorithm accidentally, and not testing at higher loads than production), and one where a low level C driver made an unnecessary reverse DNS lookup that, when the caches flushed, caused things to hang, which became an issue when load increased, and which should have been circuit broken (but which instead caused a failover to another node). I've never had that experience with another language. The ramp up time to productivity was longer, the production issues caused by us missing something about the language were more frequent, the production issues caused by us failing to expect or handle a failure condition were more frequent, etc. That said, Elixir and Phoenix do raise the bar a little. Elixir has a larger surface than Erlang (only a few concepts, but a lot of ramifications when it comes to macros if you haven't used them in other languages), and Phoenix is reliant on a fair bit of magic so you need to read the docs and it may take a little bit of work to feel happy with things. But even when I knew nothing about it, picking it was easy because of the experience I had with Erlang.
- perseusprime11 7y agoAre there any good tutorials to get started? What major sites are currently using Elixir?
- innocentoldguy 7y agoThe Elixir video courses at https://pragmaticstudio.com/ https://pragmaticstudio.com/ are the best available, in my opinion. There are some free tutorials available and some other good paid courses, to be sure, but I think Mike and Nicole over at Pragmatic Studio offer the most complete and easy-to-follow courses available. The cost-to-value ratio of their courses is really good, I think. I'm not affiliated with them in any way. I'm just a happy customer.
- conradfr 7y agoI don't know why you're downvoted, I did the Elixir course and it was useful and well done.
- barefootford 7y agoHaven't done their Elixir course but can vouch for their Ruby/Rails stuff. They just really value simplicity and sweat the details more than most instructors. Great stuff
- xenihn 7y agoThanks for the recs. If you're willing to share what other paid courses you consider good, I'd appreciate it!
- bmelton 7y ago> any good tutorials? https://elixir-lang.org/learning.html https://elixir-lang.org/learning.html - Start here. It starts off kind of abstract, and then works its way into the concrete (from my experience) -- but is very easy to pick up. > What major sites? Last I heard, Discord was serving ~5 million concurrent users, and that was well before compelled isolation. Bleacher Report is also using Elixir, and serving something like 100k requests per minute just to mobile clients. Bet365 handles as much as 100k monetary transactions during a big sporting event like a Champions League final.
- mattste 7y agoI 100% agree about Elixir and its surrounding ecosystem being almost perfect. It's insane how simple the building blocks are and how easy the code is to read and write. Here are a few pain points I've ran into: 1. Typespecs leave something to be desired compared to other type systems 2. Maps vs structs and easily using one in place of the other Things that my team would like to see: 1. Components in addition to templates as a first-class citizen in Phoenix. My team loves React because of the component model even though we hardly use an insane amount of interactivity.
- joerichsen 7y agoIf you are interested in a React like component library built on top of LiveView you should check out Surface http://surface-demo.msaraiva.io/ http://surface-demo.msaraiva.io/
- benzible 7y agoSeconding the recommendation to check out Surface! From the docs: Surface is a server-side rendering component library that allows developers to build rich interactive user-interfaces, writing minimal custom Javascript. Features: * An HTML-centric templating language with built-in directives (:for, :if, ...) and syntactic sugar for attributes (inspired by Vue.js). * Components as modules - they can be stateless, stateful, renderless or compile-time. * Declarative properties - explicitly declare the inputs (properties and events) of each component. * Slots - placeholders declared by a component that you can fill up with custom content. * Contexts - allows a parent component to share data with its children without passing them as properties.. * Compile-time checking of components and their properties. * Integration with editor/tools for warnings/errors, syntax highlighting, jump-to-definition, auto-completion (soon!) and more.
- jswny 7y agoHey, just a friendly Elixir user here! Could you explain why you think that maps vs. structs is a pain point? I found this interesting because I personally really like how they are so similar, because you can almost always manipulate a struct like a map, just like you'd expect. It lets you use standard operations for working with structs.
- neya 7y agoThank you HN. If you're interested, I'm actually documenting my journey as a consultant building ideas on Elixir at https://medium.com/build-ideas/ https://medium.com/build-ideas/ Thank you.
- mcintyre1994 7y ago> When I say perfect, I mean, there has been never once in my career where I hit a roadblock due to the language's limitation or complexity or flawed assumption. I faced this with other languages, but not Elixir. This is pretty amazing praise! Are many of the other languages you've used strongly typed? That's the thing that gives me pause - I feel like I rely on the compiler a lot in languages where it can do a lot for me, and that I'd be really frustrated managing a large project without it. I'm not sure what other languages you have a lot of experience with, but does anything in Elixir stand out to you as the reason dynamic typing works well there? I think dynamic typing is the main reason I nod along with "horrible programming languages like Javascript", for instance.
- AlchemistCamp 7y agoStatic typing is far from a panacea. Don't forget that the rise of Perl and PHP, and then later Ruby and Python was in response to statically typed languages like Java. There are trade-offs.
- conradfr 7y agoTo be fair PHP, while still dynamic, has eventually evolved to be (optionally) a strict and strongly typed language.
- mcintyre1994 7y agoI agree, I wasn't trying to imply otherwise. It's just that static typing is the first thing that looks like a theoretical trade-off of Elixir based on my experience, and I was curious why it doesn't feel that way in practice.
- AlchemistCamp 7y agoStructs and pattern matching help quite a bit.
- paultannenbaum 7y ago
- olah_1 7y agoI actually agree with every pain point that Dave Thomas described in his talk[1] and is outlined in the Component github repo[2]. Sadly, it's unclear to me if anyone else is as passionate and willing to continue the effort. Nonetheless, it put to words exactly what I hated about genservers and such. [1]: https://www.youtube.com/watch?v=6U7cLUygMeI https://www.youtube.com/watch?v=6U7cLUygMeI [2]: https://github.com/pragdave/component https://github.com/pragdave/component
- dnautics 7y agoI loved his complaints about genservers (and his complaints about nomenclature), and it made me settle on my own genserver structure. I think the hard thing about dave thomas' component is that it just doesn't have enough buyin in the community to make it "its own thing". I wish it did though. But on the other hand, if elixir had diverged too much from erlang it would have made people angry...
- olah_1 7y agoIt's unfortunate. Because when fresh eyes take a look at Elixir, it's hard to miss that the whole genserver pattern feels like a workaround / anti-pattern. I remember thinking, "This feels messy..." but not really knowing why. And I was brand new and barely a developer! But I think you nailed it. It's because of the Erlang continuity.
- bmelton 7y ago> And once you start thinking interms of functions, you just won't touch any of those terrible OO programming paradigms Also worth noting (because Elixir was strange and new for everyone at some point) that a lot of what used to be mind-boggling to me in earlier versions of Elixir/Phoenix have become relatively commonplace when dealing with things like React or modern Javascript. If you've ever handled a JS promise for something as simple as a `fetch()` query and processed results, you _already understand_ how to build code in functional components. There's much less difference between fetch(url) .then(results => doSomething()) .then(results => doSomethingElse()) and doSomething() |> doSomethingElse() than it looks like at first blush.
- toastal 7y agoUnlike a Promise, I hope you can cancel processes in Elixir
- jhgg 7y agoYou can kill them. Just like processes on your computer!
- capableweb 7y agoYou can cancel a Promise by using AbortController and its AbortSignal, still experimental but supported in most browsers already.
- toastal 7y agoI'll stick to Futures for; Futures work everywhere now and aren't immediately invoked when called with new.
- capableweb 7y agoNot sure exactly what futures you're referring to as there are no "native" futures in any browser (that I know of) so they are either implemented on top of Promises or by using callbacks, and still doesn't solve the problem of cancellation...
- pdpi 7y ago> And once you start thinking in terms of functions, you just won't touch any of those terrible OO programming paradigms This sort of absolutism does nobody any favours. Functional zealotry is every bit as bad as OO zealotry.
- deleted 7y ago[deleted]
- throwaway286 7y ago>Elixir is one of those languages where everything has been done perfectly as of the time of this comment. Including GenServers? I find writing GenServers to be needlessly painful. Their syntax is one of my least favorite things about Elixir.
- kotutku 7y agoWhy is that? The GenServer API very similar to Erlang version. You can add your own abstractions with macros on top of that if you like.
- nickjj 7y ago> When I say perfect, I mean, there has been never once in my career where I hit a roadblock due to the language's limitation or complexity or flawed assumption. I faced this with other languages, but not Elixir. That is interesting. I've gone from Geocities pages to ASP Classic, PHP, WP, Rails, Flask and have been dabbling with Elixir and Phoenix for a bit. So far LiveView (and some bits of Elixir in general) has been the only time in my career where I felt like I'm seriously struggling hard to understand how things come together and how to solve real but fairly common web dev problems without asking for help (mainly with LV). I've had to ask for help on IRC / the forums an embarrassing amount of times. Where as with Rails and Flask almost everything except the most crazy problems were solvable with a little bit of Googling and self exploration. Now, I'm not saying Elixir and Phoenix is bad at all. I'm still happily using it to build my next big project (for all of the reasons that everyone else uses it for), and the Programming Phoenix book is a great learning resource for building regular web apps with Phoenix, but there's nothing like that for LiveView. But on the bright side, Chris (the author of Phoenix) and Jose (the author of Elixir) are remarkably responsive to help the community. Lots of other folks are super helpful too. That and once things start to click, you can write some really pleasant looking code and actually understand what it does a few months later.
- freehunter 7y agoI agree. I’ve tried learning a ton of times but I always hit something I don’t understand and struggle to find help except asking. I think because it’s such a niche language still. With Rails there aren’t a lot of questions left to ask. They’ve already been asked and answered. That’s not the case with Elixir and especially Phoenix.
- anthony_doan 7y agoIt sounds like you're mostly backend and struggle with the blending of backend/frontend with liveview?
- nickjj 7y agoI haven't had extensive front-end experience writing React code but I've been around the block with JS. I'm pretty familiar with the event model of "hey guys, I want to do something on click, so let me wire up this handler which executes X when Y happens". The struggle is mainly around the nuisances of how certain things work with LV and what the implications are of using X vs Y with practical examples. I wrote a forum post asking for help about this the other day at https://elixirforum.com/t/concrete-examples-of-when-to-use-live-patch-live-redirect-push-redirect-push-patch/30751 https://elixirforum.com/t/concrete-examples-of-when-to-use-l.... Then there's other things like wanting to do authentication. I know in theory you'll need to create a controller action to create / delete the session and there's phx-trigger-action to submit a LV form to a controller but there's no code examples anywhere on how to pull this off and get a "current_user" like you normally would with a non-LV set up. But authentication is one of the most important things in any app.
- winrid 7y agoWait, for loops and nested conditions is an OO concept? What does Elixir do instead?
- winrid 7y agoIt seems since Elixir is purely functional you don't mutate things. So basically you use tail call optimised recursion for everything. Neat.
- anthony_doan 7y agoRecursion lol. Erlang does it too. If you want to have state you do recursion and call itself with the updated value. fn me(iter) -> me(iter+1) end
- didibus 7y agoIt's not OO per say, but it is an imperative concept, OO is almost always imperative.
- dnautics 7y agoI'll say Elixir isn't perfect. There are a few annoying bits that won't be changed due to backwards compatibility, that 98% of people won't run into. For example: a = [foo: "bar", foo: "baz"] Keyword.get(a, :foo) #==> gives you "bar" a[:foo] #==> gives you "bar" my_struct = struct(SomeStructWithFoo, a) my_struct.foo #==> gives you "baz" But really, this minor, minor inconsistency is near the top of my list of complaints, so... Take that into consideration. Also, if you start coding in Elixir a lot, you will write better Javascript by importing good practices in from Elixir.
- 1_player 7y agoWhat's the problem there? A map has unique keys, a keyword list is just a list of {atom, term}, so there might be duplication. They are similar but they are not the same thing and are not to be used in the same places.
- dnautics 7y agoThe problem is that it violates the principle of least surprise. Thankfully this sort of thing is not rampant in Elixir, and I discovered the example only after something like 50k lines of very joyful code.
- pookeh 7y agoHow is the IDE support and in particular the refactoring assistance? If I rename something do I have to find and replace or will language service tools handle that for me? Speaking as someone who just did a very large refactoring of a large (100k+) codebase. Statically typed languages and tools around them help a ton there but not sure how it would work with Elixir.
- cgb223 7y agoHow’s the speed? Is it as performant as technologies like Django / Ruby?
- heisenzombie 7y agoAs with anything benchmarking is hard and "performance" is not a 1 dimensional thing. That said, there are some ways in which Phoenix/LiveView is extremely "scalable". For example, pushing messages to 2 million simultaneous websocket connections: https://www.phoenixframework.org/blog/the-road-to-2-million-websocket-connections https://www.phoenixframework.org/blog/the-road-to-2-million-... ... and running on the BEAM gives all sorts of exciting horizontal scaling possibilities on top of that.
- dep_b 7y agoI think calculations are it's weak point, but for the typical message passing application like Twitter it's fast and incredibly scalable.
- PopeDotNinja 7y agoI love Elixir, but tha language is not super simple. The learning curve is actually rather steep. Writing Elixir like it's easy is probably creating technical debt hell that's going to fall over the moment a system is under non-trivial load. It's all fun and games until someone who didn't know who write a GenServer doesn't understand why everything starts timing out after 5 seconds.
- rhlsthrm 7y agoI'm a full-stack Typescript dev (React, Node.js, etc.). Lately I've been more intrigued by functional programming. I feel like I've gone pretty deep into OO and classes, inheritance, etc. Looking back, I feel like there is a better way to structure that, and the glimpse of functional programming that I've seen seems to help with this boilerplate. I've heard only good things about Elixir/Phoenix, so I'm thinking about picking it up for my next project. One thing about JS/TS is that the ecosystem is well developed, especially on the deployment side. For side projects especially, I like to minimize my dev ops configs and utilize "serverless" type stuff (i.e. Zeit/Vercel, FaaS, etc). I haven't seen much of this in Elixir-land, but hey, maybe that's an area I can help innovate in.