Live data from Hacker News

Build a real-time Twitter clone with LiveView and Phoenix 1.5

phoenixframework.org

61–70 of 249 posts

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#61
post #14

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 pe…

> 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.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#63
post #14

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 pe…

> 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 f…

Static 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.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#64
post #14

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 pe…

> 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 f…

> 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.

As someone who has been writing Elixir professionally for 4-ish years, and who is otherwise about as big of a proponent of static types as is possible, this is simultaneously my biggest critique of Elixir, and also a critique that has ended up being more theoretical than not. I wish that it were statically typed, but in practice that hasn't been slowing me down.

Part of the reason for that is that while Elixir is dynamically typed, I've found that it's possible to pretend it is a statically typed language if you squint just right. By that, I mean making judicious use of typespecs [0], dialyzer [1], Norm [2], and just generally constraining the way you write code to mirror the sorts of code that you'd write in a language that offers algebraic data-types, like Haskell. I've been meaning to put together a blog post on what I mean by this, because I often hear people talking about how unusable Dialyzer is, so I feel like my team is a rare example of a large production app that requires that Dialyzer typechecks on every build. This makes large-scale refactoring of our app almost (but not quite) as easy as it would be in Haskell.

The macro system in Elixir also means that it's possible to write libraries like typeclass [3], that offer compile-time guarantees (using compile-time property tests!) that your implementations correctly implement a given interface. I think that as the language evolves, we'll be seeing a lot more examples of macros that move runtime logic into the compilation step, to offer compile-time guarantees and safety. For example, a few weeks ago, I prototyped an experimental library in a few hours that added support for compile-time OCaml style parameterized-modules. [4]

Obviously, all of these techniques don't get you quite as far as proper static typing would (though the Whatsapp team is working on static types for Erlang! [5]), but the rest of the language and the ecosystem is just so well thought out, that I've been okay with that!

[0] https://hexdocs.pm/elixir/typespecs.html

[1] https://github.com/jeremyjh/dialyxir

[2] https://github.com/keathley/norm/

[3] https://github.com/witchcrafters/type_class

[4] https://github.com/QuinnWilton/daat/

[5] https://www.facebook.com/careers/jobs/229713254864749/

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#66
post #43

Earlier quoted context omitted.

> 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?

Yup, launching soon. Probably will open source it too.

Any way to get updates when this happens?

Edit: Saw the link to your blog below https://medium.com/build-ideas/

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#67
post #14

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 pe…

Are there any good tutorials to get started? What major sites are currently using Elixir?

Discord and Pinterest use Elixir at a massive scale. Discord in particular has been writing a great technical blog about the process.

On a smaller scale Feedback Panda very successfully bootstrapped to a 55k MRR SaaS and was aquired in under 2 years: https://youtu.be/vaXp81OxxK0

Edit: Not to be too self-promotional, but AFIK I've created more free Elixir-learning screencasts than anyone on YouTube. I cover a pretty broad range of topics from total beginner to some fairly niche things: https://youtu.be/z1nKbzZiRtY

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#68
post #46
post #14

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 pe…

I 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 templ…

If you are interested in a React like component library built on top of LiveView you should check out Surface http://surface-demo.msaraiva.io/

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#69
This is by far the most amazing demonstration of framework capability that I've ever seen. I'm stunned.

HOW do you manage to broadcast only the minuscule change of a number to all of the connected clients with server side rendering? I'm trying to wrap my brain around it.

Re: Build a real-time Twitter clone with LiveView and Phoenix 1.5

#70

Earlier quoted context omitted.

correct. I was just wondering if it also has inbuilt http server as well to process things like static files etc or is that completely on 3rd party tools like nginx (which I love btw). Kinda like in Golang where you could technically use the static file server but I always use nginx for those things.

Cowboy is Elixir's built-in HTTP server. You can configure things like Nginx or Haproxy as you would with most other frameworks.

It's more an Erlang http server used by Phoenix ;)
Post reply on HN