Live data from Hacker News

Elixir for Humans Who Know Python

hibox.live

151–160 of 198 posts

Re: Elixir for Humans Who Know Python

#151
post #106

No offense to TFA author, but I don't think this is doing to sell Elixir to Python people. In fact, I have serious doubts as to whether most Python lovers would be willing to set aside their beliefs and practices to learn the Elixir way. Perhaps Phoenix and LiveView will be the gateway drug, but even to reach that point requires a lot of effort to understand functional programming and Elixir. Python has some function…

The Phoenix docs don't look like they even hold a candle to Django. I spent 5mins in it and still don't know how to define a model. I eventually figured out a doc section called "Ecto" - so i had to know what ecto was to find it. Then, in those docs I still don't know how to define models. Do they expect me to manage my database and schemas separately and generate the models from that? That's completely opposite what…

You might be interested in the relatively new Ash Framework that builds on top of Phoenix and has much more built in: https://ash-hq.org/

Re: Elixir for Humans Who Know Python

#152

Earlier quoted context omitted.

I’ve never used Ecto outside of a Phoenix app, so yes, in my mind the line between them was blurry. Thanks for pointing out my mistake! A very recent real-world challenge I ran into was having to coordinate updates and diffs to all the files involved and keeping them in sync while doing local development (before deployment but also while working on fixing a very subtle bug). Every time I changed the migration file (e…

It is totally fine to get spoiled if you consider it is better :D Your case about structure.sql is interesting. It would be nice if we could automate it somehow but, if we simply tried to re-run a changed migration, then the migration would likely fail because the other operations in it (such as adding fields), you already exist, no? Do you have any suggestions/ideas on how to tackle this? We could have a "mix ecto.m…

Hmmm, if we’re willing to accept a dependency on git than it might be interesting to write a `mix ecto.migration.rerun` that rolled back any migrations that are untracked or dirty according to git, then re-ran them. That would simplify a pain point I encounter when I’m iterating on a migration because sometimes I rollback too far accidentally and finding the right argument to rollback feels like a chore. The nice thing is that could be prototypes outside of ecto quite easily.

Re: Elixir for Humans Who Know Python

#153
One thing I love about Elixir's syntax is that virtually everything is a call, take the if statement:

  if condition do
    IO.puts "true"
    :yes
  else
    IO.puts "false"
    :no
  end 
is just a call to the *Kernel.if/2* macro:

  if(true, do: (IO.puts("true"); :yes), else: (IO.puts("false"); :no))
I was joyous when I realized I could pipe stuff into a case statement.

Re: Elixir for Humans Who Know Python

#154

Earlier quoted context omitted.

Thanks! FWIW, structure.sql is not needed in Ecto either. You must do that when: 1. You want to start discarding migrations (because you have too many) 2. You had an existing database Are those never a "trigger" on Django side? I appreciate the opportunity to learn!

TIL you actually don’t need structure.sql for Ecto! In that case, discarding migrations on a large running app seems like a not-always-good practice, right? FWIW, my experience with Ecto has always been in joining existing codebases that are already big. I do also want to add that Django can kind of do the reverse of auto-generating migrations: it can “inspect” an existing database and generate Python classes that al…

Inspecting a database and coming up with models is a frequent pain point that I see new elixir devs experiencing. I’d love to see someone take a stab at generators for that. I wonder if someone would do an integration for https://ash-hq.org/ that does that.

Re: Elixir for Humans Who Know Python

#155
post #89

No offense to TFA author, but I don't think this is doing to sell Elixir to Python people. In fact, I have serious doubts as to whether most Python lovers would be willing to set aside their beliefs and practices to learn the Elixir way. Perhaps Phoenix and LiveView will be the gateway drug, but even to reach that point requires a lot of effort to understand functional programming and Elixir. Python has some function…

"Python has some functional capabilities, but in my experiences with Python devs, those are little used and even shunned. Imperative, mutating loops are the Python way; and to suggest otherwise is to hear "But why would I need that? This (long functions with mutations everywhere and loops) is fine."" Thank God I'm not stuck with low talent clowns like that. Writing highly functional python isn't hard anymore, especia…

> Thank God I'm not stuck with low talent clowns like that

Woah! Python’s a multiparadigm language. Using loops and mutation is a perfectly fine way to write Python code. For sure there are some kinds of code that lend themselves to a functional style, but equally, there are other cases where mutation is the more straightforward approach.

Re: Elixir for Humans Who Know Python

#156

Earlier quoted context omitted.

> LiveView can’t handle spotty connections, I thought? LiveView handles it just fine. If the websocket disconnects for some reason it will automatically re-establish itself when the connection is restored. You can also use the built-in JS module to do client-side things when you don't need backend support. I use Alpine.js (PETAL stack) and I like it a lot. If you have a very complex client-side need, it's also pretty…

>> LiveView handles it just fine. If the websocket disconnects for some reason it will automatically re-establish itself when the connection is restored. What the parent means is that, because state is kept on the server with LiveView, and events that change that state are processed by the server, if your connection is lost, then you may find that even basic things, such as having a dialog open when you click a butto…

You also might see full page refreshes when the heartbeat fails which can be very annoying.

Re: Elixir for Humans Who Know Python

#157
As someone who first came to Elixir from Erlang background, but also someone who has to work a lot with Python and hates every second of it... I'd need a completely different set of arguments.

I don't like Ruby-like syntax. Not having something to separate expressions other than whitespace is a big turn-off for me. Something I also hate about Python. Something that a lot of forced Python programmers also see as a turn-off.

Another, and perhaps superficial impression I got from Elixir is that it's Web-centric. I don't care about Web and have a strong distaste for everything that touches it. Python first appeared under the spotlight due to its Web framework, Zope, which kind of set the stage for that. Web had and still has a huge influence on how Python ecosystem developed, and that wasn't a good influence. I'd need an argument that says that Elixir is good outside of Web.

I strongly believe that development speed is only in a very small part due to the language, and in a very big part due to how well you know the language. So, trying to convince me that the language is good because you could shave off a few minutes on a trivial task isn't going to convince me it's good. Working with large old programs is where productivity tools really matter because that where the bulk of my work goes to.

But, really, I could never see the appeal of Elixir, when compared to Erlang. So, there's that. Also, I don't think it's worth it selling new technologies to Python programmers. Overwhelmingly, Python programmers are there either because it's popular and they like it, or because it's popular and they don't like it. Even in my first steps in Python world in early 2000's, I already knew there are better things than that. Quality was never a concern here, unfortunately.

Re: Elixir for Humans Who Know Python

#158

Earlier quoted context omitted.

It seems like the basis for your comment is weird stack tribalism that you’ve very evidently bought into, rather than anything actually…worth discussing. It then comes as no surprise that throughout your entire comment you didn’t seem willing you yield any ground to Python or Django at all. It then comes as no surprise that your assertions about Django are counter to my experience, as someone that by the sound of thi…

It is perhaps utopia but it would be nice if we could discuss those topics without falling into camps. For example, I could argue for hours about the benefits of immutability, but I still believe that imperative loops are clearer than functional ones. There is even a repository with solutions for nested traversals in different languages and the Python one is my preferred by some margin: https://github.com/josevalim/n…

If only functional languages with immutable variables had some kind of "unsafe" section where you could actually mutate stuff...

Rust approach looks good btw, with "let" making immutable vars and longer "let mut" for mutable variables

Re: Elixir for Humans Who Know Python

#159
post #96

Earlier quoted context omitted.

That does seem like the same arguments that are made prior to just about anything becoming mainstream though. I'm not saying it means nothing that python has so much mindshare, but the same could have been said to pythons predecessors as well. You're right about commercialization not being about technical excellence, in the short term. In the medium and long term, it's the advantages of recent technical excellence th…

It's also the same arguments that are made prior to things falling by the wayside. Not that I think Elixir will ever fall away, just that it won't go fully mainstream.

Very true, maybe it's not a strong predictor either way.

Re: Elixir for Humans Who Know Python

#160
post #132

I've been using Elixir with Phoenix and Liveview at my job for the past three months as part of a small team building a non-trivial web app ( https://duffel.com/links ). I'm mostly a front-end developer and was brought in to handle the UX side. Prior to this project I've spent the last 5+ years in the React world. I found a lot of what the author says to be true. I'm used to the nightmare that is managing front-end d…

> Whenever I jumped into the JS world it often felt like I was fighting against Phoenix I've had the same experience and this is something I've tried to tackle recently. I've started working on LiveSvelte which allows you to plug in Svelte components directly into your LiveView, while still being able to push events to the server with a `pushEvent` function on the client. I've only started working on it this week but…

That looks fantastic, thanks for sharing!
Post reply on HN