Live data from Hacker News

Rails 5.0: Action Cable, API mode, and more

weblog.rubyonrails.org

131–140 of 225 posts

Re: Rails 5.0: Action Cable, API mode, and more

#131
post #92

Earlier quoted context omitted.

Elixir has no native array syntax nor any array functions in the stlib so arrays are basically second class citizens rather than completely absent. Ask not why I need them but why anyone might need them if the Elixir is supposed to be a general purpose language. Why does Clojure need them or Ruby or Python (lists)? If I want to process data as a large indexed array Elixir isn't going to help me and some Elixir devs h…

> Elixir has no native array syntax nor any array functions in the stlib There is no native array syntax, but there are array functions in the stdlib: http://erlang.org/doc/man/array.html

That's Erlang. I meant native as in Elixir syntax and the Elixir stdlib.

Re: Rails 5.0: Action Cable, API mode, and more

#132
post #105

Earlier quoted context omitted.

if you need constant time access by index to a sequence of fixed size elements you can use binaries. if you want constant time access to a sequence of fixed size you can use tuples. if you want both you can get close with maps using integer keys or with trees (which i believe are used by clojure behind the scenes for arrays)

If it comes to that I can just use Erlang's implementation but my question is why the omission in Elixir when arrays are supported in Erlang? With Elixir's excellent macro support surely an Elixir wrapper around Erlang's arrays wouldn't be so difficult?

Elixir wrappers that don't significantly enhance what Erlang is already exposing are discouraged within the Elixir community. As I type this, I realize that this might enrage you even more than the lack of arrays ever could. :)

Re: Rails 5.0: Action Cable, API mode, and more

#133
post #85

Concurrency aside, why is Elixir preferred over Ruby when it doesn't even have a native array implementation? No, lists and tuples are no substitute nor are maps with numeric keys as Jose has suggested. If you want an array in Elixir your only option is Erlang's implementation which ain't pretty - http://erlang.org/doc/man/array.html . When I raised this issue in the mailing list and on IRC the response was invariabl…

In all your replies, you haven't given concrete example of "I need arrays because tuples or lists can't do X". Complaining in the abstract isn't helpful. If Elixir had arrays, why would that be better than using other enumerables like lists or tuples?

It would be better because lists are not accessible by index and tuples are only designed for small amounts of data.

Re: Rails 5.0: Action Cable, API mode, and more

#134
post #79

I personally really love using Rails. It's been very productive for me over the past several years I've been able to make a living off of this. I see a lot of comments here about Elixir/Phoenix. Is the performance gain really that big? I currently serve 2-3 mil requests on Rails per day on around $200 worth of servers with at least one database call per request. In defense of Rails, there are so many libraries out th…

Are you doing anything with persistent connections? ActionCable won't be able to hit the same scale as Phoenix Channels (2 million usable active connections). That's a pretty big deal.

Re: Rails 5.0: Action Cable, API mode, and more

#135
post #94

Earlier quoted context omitted.

That saving of $150 is equivalent to one hour of pro dev work time. It's hardly worth converting unless Elxir / Phoenix is much more productive and maintainable.

> That saving of $150 is equivalent to one hour of pro dev work time. Fair point, unless you have more customers. Then it can start to add up quickly. And by customers it means requests as well. Being able to handle large traffic spikes and continous connections is a game change from what I found. Moreover. A huge benefit is using the BEAM VM, I use Erlang (but same VM) and I have seen major advantages being able to…

If we are talking web apps, all this great beam features don't mean much if your database doesn't have them. Today, scaling and providing redundacy is the easy part for a web app in most languages, having fault tolerance in the database is much harder.

Re: Rails 5.0: Action Cable, API mode, and more

#136
post #75

Earlier quoted context omitted.

So NIH is the appealing factor of Elixir according to this slide?

No. In a Rails system you've got Rails running, maybe across X number of instances with Unicorn or whatever, sitting behind nginx. If you want to have a long-running request or websocket you've typically used Go or Node or Elixir. If you need to store state between requests you may be using Redis. For background jobs and general async things you've probably got something like Sidekiq. Erlang already has an http serve…

I'd love to see an active record (npi) of that 2m active web sockets. It's trivial these days to make 2m connections (it's just a RAM problem), but marshalling data between them is the non-trivial problem, as is actually having active data crossing those sockets.

Re: Rails 5.0: Action Cable, API mode, and more

#137
post #52

Earlier quoted context omitted.

I'm still fairly new with Elixir/Phoenix (as I think most of us still are), but so far I feel intuitively that it's more maintainable and I admit that I don't have the experience or numbers to back that up yet. There are some things that you simply must use other tools for in Rails, because it can't maintain state like Erlang can. Once you start adding in these other things, you're no longer just a "Rails app" but yo…

I would love to see someone take a deep dive into why their Phoenix thing is "so much faster" than with Rails. I mean really look at the whole stack from the VM, to different pieces of the framework like views and DB interaction. Erlang definitely does concurrency well, but it is not that much faster than Ruby in terms of "raw speed". I'd be fascinated to see someone actually do the work and look at where Phoenix is…

It sounds like you're undervaluing concurrency. Concurrency is huge for a web application. If you were say doing image manipulation or other DSP where you needed "raw speed" you'd want to choose a language like C, Go, Rust. But in a web application you're handling hundreds, thousands, to millions of requests per second; concurrency is crucial for that kind of throughput. A developer on my team did some quick benchmarks and found that that Phoenix gives an order of magnitude better performance than Rails. Thats not negligible.

Re: Rails 5.0: Action Cable, API mode, and more

#138
post #22

Looks like now's a good time to mention that the Ruby on Rails Tutorial book has already been updated for Rails 5: http://railstutorial.org/book Sales actually just launched on Tuesday (announcement here: https://news.learnenough.com/rails-5-edition-of-rails-tutori... ), and you can pick up your copy of the new 4th edition here: http://railstutorial.org/code/launch That link includes a 20% launch discount, which expi…

I love Dr Hartl's pedagogy - it reminds me of the Feynman Lectures in terms of presentation of information. I worked through the book over the course of a few weeks, then wrote a rails project on contract from scratch quite comfortably.

Re: Rails 5.0: Action Cable, API mode, and more

#139

Earlier quoted context omitted.

This falls apart when you need multiple scopes as it can't tell how to group the 'AND' and 'OR's. The new Rails syntax avoids this problem.

That isn't a problem in Sequel, as you can pass a complex expression to #or, in which case it works as you would expect it to: Post.where(id: 1).or(Sequel.&({:id=>2}, {:name=>'Foo'})) # SELECT * FROM posts WHERE ((id = 1) OR ((id = 2) AND (name = 'Foo')))

Yay, Jeremy Evans spreading some Sequel knowledge ^_^

Big fan of Sequel; it's super sleek. As a side-note to Jeremy's comment, while (i guess) he used Sequel.& to demonstrate that OR and AND conditions can be combined freely, there are more succinct ways of expressing that particular query:

  # Using the a "virtual row" block:
  Post.where(id: 1).or{(id =~ 2) & (name =~ 'Foo')}

  # Or, if you don't fancy that kind of block magic, simply passing a Hash, 
  # the same way as with .where
  Post.where(id: 1).or(id: 2, name: 'Foo')

Re: Rails 5.0: Action Cable, API mode, and more

#140
post #52

Earlier quoted context omitted.

I'm still fairly new with Elixir/Phoenix (as I think most of us still are), but so far I feel intuitively that it's more maintainable and I admit that I don't have the experience or numbers to back that up yet. There are some things that you simply must use other tools for in Rails, because it can't maintain state like Erlang can. Once you start adding in these other things, you're no longer just a "Rails app" but yo…

I would love to see someone take a deep dive into why their Phoenix thing is "so much faster" than with Rails. I mean really look at the whole stack from the VM, to different pieces of the framework like views and DB interaction. Erlang definitely does concurrency well, but it is not that much faster than Ruby in terms of "raw speed". I'd be fascinated to see someone actually do the work and look at where Phoenix is…

From what I've read in the comments so far, you won't see it thinking in terms of speed of Erlang vs Ruby. It sounds like the gains come from baked in behavior, so that "Rails + Redis" or "Rails + Redis + nginx" is equivalent to Phoenix alone. I'm still only reading about this, though. No Elixir experience here.
Post reply on HN