16 ms·
Lovely Week with Elixir
- aloukissas 6y agoWelcome to the λ-side! We've been using Elixir and loving it for 3+ years.
- mostlysimilar 6y agoI love Elixir. Phoenix makes web development a pleasure and LiveView is even more exciting. I would love to find a job doing it.
- ketzo 6y agoDude, LiveView is wild. It feels kind of magical, and I think people are gonna start adopting slowly, then all at once. There's an awesome blog post on their website. where Chris McCord, creator of Phoenix, builds a real-time Twitter clone in 15 minutes. https://www.phoenixframework.org/blog/build-a-real-time-twitter-clone-in-15-minutes-with-live-view-and-phoenix-1-5 https://www.phoenixframework.org/blog/build-a-real-time-twit...
- bcrosby95 6y agoGod I hope so. I loved Erlang and OTP when I tried it back in the late 00s and it never really caught on, despite many of its strong points being what most websites would look for. Hopefully with the focus on the web and the fresh coat of paint Elixir has given the ecosystem it will eventually gain more adoption. But I still have my doubts because despite looking more mainstream than Erlang, it's still kind of a "funny language".
- ketzo 6y agoYeah, it does have that stigma. It certainly did for me; "Why the hell are there colons before these variables..?" It's funny how much the first languages you learn (for lots of people, Java/C/JS) have such an impact on what "feels weird," when every programming language is basically magic anyway.
- dnautics 6y agoWell, Ruby and Julia and scheme, I think?) all have those same colons too, so it's not totally crazy. It's the post- colon that's strange (but Ruby has those too)
- pmontra 6y agoIn a JSON world post colons are normal :-) and we've been living there for ages. Ruby added x: y as a short form for :x => y
- heipei 6y agoI've been watching Elixir/Phoenix/LiveView from the sidelines, reading just enough to salivate a little but still left with the feeling that my use-cases wouldn't be adequately covered by it. Which kind of SPAs wouldn't work well in LiveView? I'm working on an app in Ember right now where a lot of data is fetched by the client asynchronously and then either showed once its fetched or only when the user pushes a button. How would the latter be possible with LiveView? Can you push data to the client that's only show on client-side interaction? Do I still need a client->server->client roundtrip to toggle a "visible" flag to show said data? I just don't understand how "smart" the client side of LiveView is.
- dnautics 6y agoThe spas that won't work are the ones that need to keep state while offline. Everything else works pretty fantastic, and arguably better than most spas which need to do heavyweight xhr Json or grpc calls, though if you can have a persistent grpc connection over websocket you might be competitive performance-wise.
- ketzo 6y agoI'm honestly not sure. I would ask on the Phoenix [1] forums -- they're pretty active, including a lot of responses from Phoenix's creator, Chris Mccord. [1] https://elixirforum.com/c/phoenix-forum https://elixirforum.com/c/phoenix-forum
- pythonaut_16 6y agoThe biggest "homerun" case for LiveView is all of the forms where you'd typically do server side rendering then add a bit of JavaScript for the few dynamic pieces you need. Think about what you might typically see in a Ruby on Rails app. Lots of Ruby generating the views, a bit of JavaScript for client-side whatever. LiveView can be used for way more than that, but I think replacing "glue" JavaScript is the most slam-dunk case.
- moreaccountspls 6y agoI'd love to hear your opinion on this https://news.ycombinator.com/item?id=23252862 https://news.ycombinator.com/item?id=23252862 if you have any experience.
- enraged_camel 6y agoControversial opinion: the "magic" is why I'm staying away. It's the same reason I stopped coding in Ruby/Rails: too much magic. But I'm also a full-stack developer and I'm not afraid to write JavaScript. I realize not everyone is on the same boat, and LiveView might cater to them.
- elixirdev 6y agoLiveView is a nightmare from a deployment point of view. LiveView stores state on the server associated with the web socket connection. If the web socket connection disappears which is what will happen during a deployment then the user's state will disappear. The value of LiveView is not having to write javascript but the only way to preserve any non-complicated state in LiveView when the web socket disappears is to write javascript. It is only recently that LiveView added support to automatically preserve form input values across a state crash. [https://github.com/phoenixframework/phoenix_live_view/blob/master/CHANGELOG.md https://github.com/phoenixframework/phoenix_live_view/blob/m... | Recovery form input data automatically on disconnects or crash recovery] Prior, to 0.7.0 if the web socket died while you were typing input values in a form then the page would reload and all your input into the form would be wiped out.
- josevalim 6y agoYou are right that state is transient but JavaScript is not the only option. For transitions and screens, you can use live navigation. For forms there is automatic recovery (as you mentioned). Another option is to persist the state on the server. For example, go back to the Twitter timeline example. Imagine that you want to do a banner that says "N tweets unread - click here to expand them". You could keep this counter in the LiveView but if you reconnect the counter will be lost. But you can also solve this by storing a pointer to the last shown tweet on the DB. Then if you reconnect, you can compute how many tweets are pending. If you are doing a multi-step wizard you can persist each step on the DB too, etc. Depending on the use case, this could even yield further benefits, such as automatic synchronization between devices. I.e. if you read some tweets on your phone, you can automatically bump the "last shown index" on all devices. Or start the wizard in one place and finish it elsewhere. That's the point of LiveView, you can build interactive applications that are more server-centric. Some of those features are new but that should be no surprise, it is still pre-1.0 software. Even as we add new features, you may still have to (or want to) rely on JS on many scenarios, and that's totally fine.
- kuzee 6y agoKamanahealth.com is hiring, remote-first, and doing a lot to help combat covid. I don't work there, just got got an email from a friend noting that they are looking for Elixir devs. https://www.notion.so/Kamana-is-Hiring-644e0dd0eb2d433daf7a7ff8f0dc4e93 https://www.notion.so/Kamana-is-Hiring-644e0dd0eb2d433daf7a7...
- lawik 6y agoLiveView will take some time to really get general acceptance and will probably always be somewhat controversial. Both for server roundtrips and because it is so oddly specific and doesn't have a comparable solution in most other languages. But it is fantastic where it fits, truly.
- moreaccountspls 6y agohttps://news.ycombinator.com/item?id=20383814 https://news.ycombinator.com/item?id=20383814 exists, so I'd expect it to catch on in other languages if it really is a killer app. I don't know how well such a thing would work without OTP though.
- dnautics 6y agoYeah if you have a minor miscode/footgun in blazor you're really not gonna have a good time. If you have a minor miscode in liveview, OTP's got your back.
- QuinnWilton 6y agoMy team at Synopsys is hiring. We were recently acquired by them, and we build dynamic security analysis tools in Elixir, and make heavy use of Phoenix and GraphQL through Absinthe. We're also open to remote work, and have offices in most large cities. The job posting is a little bit generic, but it's specifically for my team: https://sjobs.brassring.com/TGnewUI/Search/Home/Home?partnerid=25235&siteid=5359#jobDetails=1511023_5359 https://sjobs.brassring.com/TGnewUI/Search/Home/Home?partner... Feel free to reach out to me (my website is in my profile) if you want more info!
- peruvian 6y agoI really like Elixir and Phoenix. I just wish I had more reasons to use them!
- ketzo 6y agoStarted a little CRUD-app project in Phoenix (Ruby on Rails to Elixir's Ruby), and my expectations have been totally surpassed. It's pretty amazing. Working with Elixir is really cool, too, coming from C++ & JS backgrounds. Pattern matching feels like a programming technique from the future.
- ninjakeyboard 6y agoElixir is decent and I've worked with it a fair amount in production systems... Mostly Rubyists seem to really click with it. And ruby idioms are all over it - you can taste its history and proximity to ruby's ecosystem. As a scala dev that ended up working with elixir for a couple years, my opinion is that a typesafe elixir-like language would really bring BEAM back into the mainstream. Akka is alright but it's shoehorned onto the JVM. BEAM is good as long as you don't need to do heavy computation, but lack of type-safety (need to use dialyzer?) means that shit breaks in prod that the compiler would have caught. And yes, you can mitigate this with boatloads of testing and data-validations with ecto or whatever. But every time we broke shit that a compiler would have caught I cringed. It's a great path for rubyists to move to Elixir/BEAM and every rubyist should give it a whirl! I'm back working on scala and akka.
- thomasfortes 6y agoAs someone that uses elixir for webapps and ocaml/reasonml for frontend work, I hope that https://gleam.run https://gleam.run gets traction, seems like a nice BEAM language with types that is evolving quickly.
- QuinnWilton 6y agoI want to echo Gleam [0] as a project to watch out for. It's still very early, but it's evolving quickly, and has a big focus on providing ergonomic tooling. It's an ML inspired, statically typed language that compiles down to Erlang, and supports interop with the existing ecosystem. This means that you get access to ADTs, type inference, etc, while still being able to lean on OTP for your concurrency primitives. There's also examples of calling it from Elixir, so there's the option of falling back to statically typed Gleam for an especially gnarly piece of code, and calling it from your Elixir application [1]. I wouldn't necessarily recommend this for commercial apps yet, but Gleam today is about as usable as early-Elm was, in my opinion. The project is also very welcoming to new contributors, and Louis (the language's creator) does a great job of curating a list of beginner friendly issues to tackle in the compiler. I've been spending my evenings learning Rust by adding onto the language, and it's been a ton of fun. If you want to help out, there's a fairly active IRC channel on Freenode, in #gleam-lang :) [0] https://gleam.run https://gleam.run [1] https://dev.to/contact-stack/mixing-gleam-elixir-3fe3 https://dev.to/contact-stack/mixing-gleam-elixir-3fe3
- crusso 6y agoIf you're interested in using Elixir, jump right into Phoenix with LiveView. It is fantastic for prototyping new tools. Once you learn the basics of LiveView, it's ridiculously easy to create the web UI that interacts with your Elixir back-end. For a while I was using Phoenix<>Elm as my stack and I enjoy programming in Elm. But there's a lot of boilerplate you have to tediously connect for every input and output on both sides of the server and client. LiveView eliminates all that boilerplate by letting you write templates in Elixir that are macro-compiled to javascript. Getting rid of that boilerplate eliminates time writing it as well as time debugging the extra complexity that boilerplate introduces.
- mahaqmi 6y agoI really hope there's a book covering more in depth on how to use LiveView. Im a little bit of a noob in programming and mostly learn using book for the first few steps. A lot of my coworker asking me to learn through docs as it seems to be more "full" but I found it's a bit steep learning with it compared to book that usually hold your hand through each concept. This is how I learnt Go web programming about 8 months ago.
- gstipi 6y agoHave a look at the free Phoenix LiveView course by Pragmatic Studio: https://pragmaticstudio.com/phoenix-liveview https://pragmaticstudio.com/phoenix-liveview (I'm not affiliated with them). The first six of eventually 15 lessons are already available and they really helped me grasp the basics. I've already implemented a few small tools using LiveView - it's a real breath of fresh air!
- deleted 6y ago[deleted]
- Thaxll 6y agoThe fact that it's a dynamic language make problems similar to Node / Python, can't dev serious backend services without a strongly type language. Not saying you can't, but you will have a lot of issues overtime that would have been catch at compile time.
- Ndymium 6y agoElixir is a relatively strongly typed language, but it's not statically typed.
- yesco 6y agoHaving used all three in backend systems, I definitely disagree that they have the same problems. Elixir is strongly typed but lacks static typing, in exchange it has a powerful pattern matching system that more than makes up for this problem in my experience. But fundamentally the issues caused by lacking static typing is different from the problems caused by being weakly typed like python and node systems are.
- throwaway894345 6y agoPython is strongly typed. I fully believe that Elixir lacks the same problems, but not because of strong vs weak. If I had to guess, I would put think that it's because Python code is more likely to be mutable than Elixir, but that's just a guess.
- jjnoakes 6y agoIn my experience python is strongly typed as well - unless you meant something more nuanced?
- acrispino 6y agoThe BEAM VM, whether using Elixir, Erlang, or another languages, has been successfully used to implement telecommunication switches, chat services (WhatsApp), and plenty of other "serious backend services."
- 6y ago
- biggestlou 6y agoI learned Elixir a few weeks ago as a quarantine self-improvement project and pretty much loved it. There are some warts, as in any language. As someone who's primarily worked in Go and Java in the past and has also been learning Rust I don't super love the optional typing thing, and I end up missing higher-level data constructs like interfaces and traits. But there are some great language features, like guards and pattern matching, that are hard to give up when you go back to other languages. Plus it's great to have OTP goodies like GenServer at your fingertips if you run into performance bottlenecks (which you may not!). The OTP APIs are a bit weird coming from other languages but not too bad. Other things I've liked: 1. Ecto is simply the best DB library I've encountered in any language. I'd almost recommend learning Elixir just to be able to use Ecto. 2. Plug provides great HTTP ergonomics highly reminiscent of Go's context-based middleware approach. Having direct access to the full request/response lifecycle is a win. 3. Phoenix is nice because it's essentially just Plug with some convenient helpers on top. Strikes a really nice balance between configuration and convention by letting you use only what you need. Haven't tried LiveView as I'd prefer to handcraft my own JS but probably worth a shot. 4. Absinthe is the best GraphQL framework I've encountered after many others in other languages left me completely cold.
- izelnakri 6y agoYou’ve just summarized my thoughts on Elixir after using it(and still loving it) for years. Thanks :)
- lindgrenj6 6y agoCheck out the Elixir "protocol" feature, it's similar to interfaces: https://elixir-lang.org/getting-started/protocols.html https://elixir-lang.org/getting-started/protocols.html
- Grimm1 6y agoI was just about to say, protocols fill the interface slot pretty well
- QuinnWilton 6y agoProtocols + the Typeclass library [0] makes for some of the most extensible Elixir code I've worked with. [0] https://github.com/witchcrafters/type_class https://github.com/witchcrafters/type_class
- ashton314 6y agoThe BEAM is a huge win: having lightweight threads means you can often do away with things like Redis for job queues and PubSub stuff. I love this answer on StackOverflow by Elixir's creator: https://stackoverflow.com/questions/32085258/how-can-i-schedule-code-to-run-every-few-hours-in-elixir-or-phoenix-framework?rq=1 https://stackoverflow.com/questions/32085258/how-can-i-sched... So simple. Something that would require a job queue and a job runner fades away into a piece of the OTP application tree. When it crashes, it will even come right back up! Phoenix feels a little too heavyweight for really small projects—maybe I'm spoiled having used Mojolicious's [0] single-file web servers. (Example on the linked page.) But for anything slightly larger, Phoenix scales really well. I work on a decently-large application in Phoenix for work and it's been an absolute joy to work with this langauge. Typing could be better. Though, Dialyzer does a decent job of catching type errors. That's saved my neck on more than one occasion. [0]: https://mojolicious.org/ https://mojolicious.org/
- PascalW 6y agoI don't really understand this sentiment of not needing a queue system. This is not much different from spawning a thread in Java to delay the email sending. For any serious application you want a job like that to be persisted so you can guarantee it runs even if your application is restarted. I know that Erlang/Elixir is designed for stateful applications and if you have a cluster and do hot deploys this is less of a problem, but who does that? Most Elixir applications I've seen are deployed as stateless systems just like any Ruby, Python, Node etc systems.
- polmuz 6y agoHaving a queue means you have a distributed system. How do you handle network problems, errors/retries, back pressure? OTP has excellent idiomatic tools for all that and more.
- jeremyjh 6y agoElixir developers who need a queue generally reach for Rabbit (which any language can use), or something backed in a database like rihanna[1] or honeydew[2]. Rolling your own distributed system is very much a last resort, and despite its excellent concurrency characteristics the BEAM still lacks basics such as a battle-tested raft implementation. [1]https://github.com/samsondav/rihanna https://github.com/samsondav/rihanna [2]https://github.com/koudelka/honeydew https://github.com/koudelka/honeydew
- jetpackjoe 6y agoI got really excited about discovering a new progamming language, Phyton, for a second... but after some searching, I think that's just a typo
- sgadimbayli 6y agothanks!
- adamzapasnik 6y agoAnother person who liked Elixir, cool :) Btw. If anyone is interested, I'm working on prettier plugin for html l?eex files. Probably gonna publish it next week.
- udfalkso 6y agoThat sounds lovely. Thanks for building that! Followed you on twitter, pls let me know when it's live.
- sjm 6y agoI built the API for a side project in Elixir/Phoenix a couple years ago making use of Phoenix WebSockets, and it was truly mindblowing how much you could get done with such a little amount of code.
- deleted 6y ago[deleted]
- fredwu 6y agoI wrote two blog posts before on Elixir: The first piece is longer, on my journey learning Elixir and building machine learning libraries. https://fredwu.me/blog/2016-07-24-i-accidentally-some-machine-learning-my-story-of/ https://fredwu.me/blog/2016-07-24-i-accidentally-some-machin... The second piece is shorter, on Elixir’s functional aspect and how doctest changes the way I code. https://fredwu.me/blog/2017-08-07-elixir-and-doctest-help-writing-better-programs/ https://fredwu.me/blog/2017-08-07-elixir-and-doctest-help-wr...
- aloukissas 6y agoThe only downside I've found with Elixir is that because of the language and runtime internals, it doesn't really lend itself to power serverless/lambda functions (like Python, Ruby, Go, etc).
- namelosw 6y agoElixir and Phoenix are living proof that functional programming can be easy - most of the time you just play with struct and functions, that's basically it. No need to pay attention to monads and type classes. On the other hand, it also reflects functional programming is also more straightforward than Object-oriented programming because it's more objective to just model the data, than modeling the data and procedures at the same time. If you have two people writing the same thing, there's a much larger chance they'll yield similar or identical results.
- ldd 6y agoI had an excellent week with Elixir building a really silly game: https://hn.lddstudios.com/ https://hn.lddstudios.com/ MIT Licensed. Source: https://github.com/ldd/hn_comments_game https://github.com/ldd/hn_comments_game
- sgadimbayli 6y agoAwesome! If you are up for reviewing each other's code, ping me!
- jonnycat 6y agoLike the author, I'm really truly loving Elixir. I recently wrote up some of my experiences with Elixir/Phoenix coming from a Ruby/Rails perspective - https://medium.com/swlh/3-months-with-elixir-phoenix-2810f653f887 https://medium.com/swlh/3-months-with-elixir-phoenix-2810f65.... Curiously, unlike most others here, I'm not completely loving Ecto. I appreciate the philosophy and get changesets, but I'm finding the query syntax clumsy.
- throwaway286 6y agoThe job market for Elixir is pretty small. Sure, there are a couple of people here responding with specific listings, but still. I was hoping it would have ramped up by now but it seems that it's going to stay a niche player.
- pythonaut_16 6y agoI think it's healthy but small, and growing.
- pmarreck 6y agoElixir: So good that your team simply won’t believe your claims https://ekarak.com/2020/05/16/of-elixir-phoenix-and-analogies-to-the-prime-directive/ https://ekarak.com/2020/05/16/of-elixir-phoenix-and-analogie...
- flowers111 6y agoLooks like elixir is gaining more and more traction :)