Live data from Hacker News

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

phoenixframework.org

171–180 of 249 posts

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

#171
post #139

Earlier quoted context omitted.

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

Not GP, but: You can't use trivially use [] dereferencing notation with structs, or, for that matter get_in or put_in, without first making it access protocol compliant (which maybe you shouldn't do? I haven't figured that out for myself yet). A common use case for me is initializing a GenServer with a kwl, which is nice for your code prettiness, but you'd like to also support maps, because that fits with how the int…

Making the conversion from/to Map and (keyword) list explicit makes sense, as they have very different access patterns: keyword lists really are not suited for random access unless very small.

And in general Erlang and Elixir have very little automatic type conversions, if any.

But maps and structs are interchangeable, I don't get why using one or the other would make your GenServer code any different. A struct is just a map with an additional field called "__struct__".

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

#172

Earlier quoted context omitted.

A live chat app is its sweet spot. It runs on the same Erlang VM that Whatsapp used to scale to hundreds of millions of users on under 30 machines and very few employees.

Excuse my lack of knowledge, but I was always under the impression that websockets are not that scalable since you are opening 1:1 connections.

Thst not true in the Elixir ecosystem. The numbers I see on my 5$ droplet are sth I haven't seen before. And that after writing 5% of code that i usually had to write in other stacks.

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

#173

Earlier quoted context omitted.

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

Don't Perl and PHP both predate Java? By quite a bit in Perl's case.

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

#174
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'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 complai…

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

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

#175
post #120

Earlier quoted context omitted.

I feel your pain on SPA's.... I feel like code velocity drops on small teams. What about LiveView/Phoenix made the process more enjoyable - let's call it 'less painful'?

Oh, yeah, here we go: 1. Tooling, yeah, you gotta have node installed, but that's pretty much the last time you have to touch it. I'm not anti-node or anti-js by any means, but the tooling around them often turns me off. Getting to do front-end work without _having_ to think about 'em is a breath of fresh air. 2. Less duplication of effort. I don't need to define schemas twice... once in the "backend" and once in the…

For point #2, it gets even worse if you're doing GraphQL. Another layer of data abstraction on the backend to update and worry about and another layer on the frontend as well (using Apollo, etc)

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

#176

Earlier quoted context omitted.

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

What I want hear on static types vs dynamic is how it plays out on a team of say 30 to 100 people. I love JavaScript when it's just me but I much prefer types when using someone else's code because they provide guidance that otherwise isn't there.

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

#177
post #133
post #112

Earlier quoted context omitted.

I'm the author of Gleam, a statically typed language on the BEAM. What you've said matches my findings. Messages can be typed, however hot code upgrades cannot be. For Gleam we've sacrified hot code loading in exchange for types, which I think is a good trade for most use cases.

Hi, thank you for contributing! I have gotten into the functional programming paradigm conceptually from working with react/redux. We do all of our development work using TypeScript, rather than JavaScript. Typescript isn’t really static typing, but more like type assertions on top of a dynamic language, but hot reloading works fine and is a core component of the workflow, especially with the ability to maintain stat…

Not touching on the reasons why the type system and hot code reloading are complex in the BEAM, but the hot code reloading dev workflows in other languages and the BEAM one are two completely different beasts.

Erlang/OTP was designed for systems where the amount of acceptable downtime is 0, you don't want phone calls failing because you have to fix a bug, the solution is a system where you can replace parts of it running live, if you replace a module all processes currently running it will still work normally but any new call to the module will use the updated version of it.

https://blog.appsignal.com/2018/10/16/elixir-alchemy-hot-cod...

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

#178

Earlier quoted context omitted.

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.

Don't Perl and PHP both predate Java? By quite a bit in Perl's case.

FWIW: Perl, 1987. PHP & Java, 1995.

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

#179
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…

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

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

#180

Is there a tutorial or course I can purchase like beginner to all the way to deployment on Digital Ocean or something like that ?

Elixir : https://pragprog.com/book/elixir16/programming-elixir-1-6 Phoenix : https://pragprog.com/book/phoenix14/programming-phoenix-1-4 Deployment : https://www.youtube.com/playlist?list=PLZZkJeUxu6QmO83Z1esRh...
Post reply on HN