Hacker News new | ask | show | jobs
by matsemann 1371 days ago
Why is that magic always hated when it comes to Java, but praised when Django or Ruby on Rails do it?
2 comments

Maybe 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.
I 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?
> 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%20o..., §5.11

Java 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.
I 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.
> Also java projects tend to grow way larger reply

It's the latter. Java is more likely to be used by a large companies. Django is more likely to be used by startups and SMB's (as well as by students and side projects).

Forums like HN and Reddit are disproportionately populated by students, and younger developers who are typically more interested in discussing tech for their personal projects than their day jobs.

If your mindset is oriented around tech that is optimized for one-man projects or tiny teams, then you are likely to reject tech that is optimized for large teams in large companies.

> Forums like HN and Reddit are disproportionately populated by students, and younger developers

Are you sure? Are there any demographics stats on that?

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

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

What does the object have to do with http status codes? It completely entangles the HTTP layer with the database model.
So we should also get rid of `.orElseThrow()` (by default a `NoSuchElementException`)?
If it was .orElseReturn404 then yeah. My point is HTTP codes have no place outside of HTTP endpoints
Sweeping generalisation or what?