4 ms·
I always miss DJRF when using languages other than Python
by tschellenbach 10y ago
I always miss DJRF when using languages other than Python
- jpdlla 10y agoThis. I've recently been working with a large project using Node. I find myself constantly thinking about how I'd build it if I were using DRF.
- aikah 10y ago> This. I've recently been working with a large project using Node. I find myself constantly thinking about how I'd build it if I were using DRF. You wouldn't need to think about promises or callbacks at first place, which would make things way easier. That's the main reason I gave up NodeJS for Go when working with APIs. Async programming is noise. CSP is a better paradigm.
- Cyph0n 10y agoScala, Akka, and Play say hi!
- findjashua 10y agoDon't you still need Futures for async stuff in order to not block the thread, or is each request handled by a lightweight 'fiber' (erlang process/goroutine)?
- Cyph0n 10y agoThat's correct, blocking operations within an actor need to be wrapped in a Future[1]. But Akka itself can be extremely performant if the bulk of your processing is non-blocking. Any non-blocking or long-running operations should be executed in a separate thread pool (if there are many), or just a separate thread. [1]: http://doc.akka.io/docs/akka/2.4/general/actor-systems.html#Blocking_Needs_Careful_Management http://doc.akka.io/docs/akka/2.4/general/actor-systems.html#...
- misiti3780 10y agoisnt DRF built into rails basically (never used rails)
- ralmidani 10y agoLast time I checked, in Rails there's no Controller class that has all the built-in functionality of a DRF ViewSet. For example, you still have to perform the DB queries for every action yourself, rather than just define a queryset and serializer for the entire class and let the framework handle the rest (no pun intended).
- misiti3780 10y agoi was under the impression that you can add :json to your controllers and they return "serialized" data.
- ralmidani 10y agoSomeone please correct me if I'm wrong, but my understanding is in Rails you still need to define every action in the controller. With DRF, you just inherit from a ModelViewSet, declare the queryset and serializer on the class (or have methods return them if you need custom behavior), and you're good to go. It makes prototyping so much easier, and adding filters and permissions is very straightforward.
- pmontra 10y agoYou are correct. Maybe the DRF for Ruby is grape https://github.com/ruby-grape/grape/blob/master/README.md https://github.com/ruby-grape/grape/blob/master/README.md but I never used it. I just fill in the standard scaffolded REST methods in the controllers with queries and write json views (Rails and Django have different terms and concepts, MVC vs MVT.)