3 ms·
Why is that magic always hated when it comes to Java, but praised when Django or Ruby on Rails do it?
by matsemann 4y ago
Why is that magic always hated when it comes to Java, but praised when Django or Ruby on Rails do it?
- tcbasche 4y agoI think most senior or experienced Python developers tend to steer clear of Django. It's just that you don't hear about it because it's mostly junior / less experienced developers writing about Django online. edit: having said that, I wish we would be more skeptical of magic frameworks like Django in the Python community at least. Things like 'get_object_or_404'[1] should be burned to the ground. [1] https://docs.djangoproject.com/en/4.1/topics/http/shortcuts/#get-object-or-404 https://docs.djangoproject.com/en/4.1/topics/http/shortcuts/...
- cutler 4y agoSweeping generalisation or what?
- mwcampbell 4y ago> Things like 'get_object_or_404'[1] should be burned to the ground. Why? A shortcut like that is useful all the time when writing URL handlers (views in Django).
- tcbasche 4y agoWhat does the object have to do with http status codes? It completely entangles the HTTP layer with the database model.
- vault 4y agoSo we should also get rid of `.orElseThrow()` (by default a `NoSuchElementException`)?
- tcbasche 4y agoIf it was .orElseReturn404 then yeah. My point is HTTP codes have no place outside of HTTP endpoints
- tartoran 4y agoMaybe it’s different flavors of magic. One is intuitive, one is inpenetrable without being an expert or early on in the project lifecycle. Also java projects tend to grow way larger.
- kaba0 4y agoJava projects growing way larger are likely just survivorship bias — python apps of similar sizes would just crumble, while java’s static typing gives enough stability against that.
- tartoran 4y agoI wasn’t disputing that java can grow larger codebases for various reasons: static typing and so on. What I am saying is that these systems do become impenetrable after a while and that magic that once is very welcome becomes the death arrow of obfuscation because while well meaning and useful at first, combined with a bunch of design patters and framworks it becomes a hot mess nobody wants to maintain.
- ubertaco 4y agoI dunno, this sort of thing seems intuitive to me: @POST @Path("/widgets/{widgetId}") public Widget getWidgetById(@PathParam("widgetId") Long widgetId) { // ... } ...where the sort of `method_missing` magic that Rails uses is _far_ less intuitive. Since when can I just call a method that doesn't exist, and expect the language to contrive what it thinks is a sensible definition on the fly?
- mananaysiempre 4y ago> Since when can I just call a method that doesn't exist, and expect the language to contrive what it thinks is a sensible definition on the fly? Since Smalltalk-76 introduced[1] doesNotUnderstand: ? I understand you didn’t really ask a question, but then I didn’t really give an answer (though the article’s discussion is fairly interesting). I guess my point is that there’s a distinction between a facility one finds unintuitive and a facility that’s newfangled and (therefore) outrageous. Even when the first category probably includes a good number of outright stupid ones. [1] http://worrydream.com/refs/Ingalls%20-%20The%20Evolution%20of%20Smalltalk.pdf http://worrydream.com/refs/Ingalls%20-%20The%20Evolution%20o..., §5.11