this post was submitted on 03 Jun 2025
31 points (84.4% liked)
Technology
1148 readers
73 users here now
A tech news sub for communists
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
This is possible but I doubt it. It's your usual CRUD web application with some business logic and some async workers.
So then you do write a bunch of boilerplate such as HTTP endpoints, database queries, and so on.
Not really. It's Django and Django Rest Framework so there really isn't a lot of boilerplate. That's all hidden behind the framework
I'd argue that most of the code is conceptually boilerplate, even when you have a framework to paper over it. There's really nothing exciting about declaring an HTTP endpoint that's going to slurp some JSON, massage it a bit, and shove it n your db. It's a boring repetitive task, and I'm happy to let a tool do it for me.
What I'm trying to say is that for Django, especially Django Rest Framework, you don't even declare endpoints.
DRF has a
ModelViewSet
where you just create a class, inherit from MVS and set themodel
to point to your Django ORM model and that's it.ModelViewSet
already has all the implementation code for handlingPOST
,PUT
,PATCH
andDELETE
.There is no boilerplate.
There isn't anything that an LLM would add to this process.
I've used Django before and I disagree. 🤷
Around which parts of Django? Because Django has generic class based views that do exactly the same thing, where all you do is set the model attribute. Then the generic view class you inherited from has the implementation. Especially if you use a
ModelForm
Here's what a typical Django enpoint might look like for handling a json payload with some user information and storing it in the db:
then you'll probably need to add some serializers
then you'll have to add some views
next you have to define URL patterns
This is all just a bunch of boilerplate. And with LLMs, you can just give it a sample JSON payload you want and this stuff just happens.
Going through as I go:
validate_email
does not need to exist, since model fields by default haveblank=False
meaning they must have a value. This should be picked up byModelSerializer
already, since it is using the model.validate_username
doesn't do anything that couldn't be accomplished by usingMinLengthValidator
- and in addition it should not exist inserializers
- it belongs directly in the declaration of the field inmodels
.On the subject of your view code:
That whole code can be thrown out and replaced with:
So, honestly I don't know what to think of your example of "boilerplate" beyond the fact that you don't quite grasp Django and Django Rest Framework well enough to understand how to implement things properly, without repeating yourself. I also think some of your code like
verbose_name
andverbose_name_plural
is not an example of "boilerplate". I would also argue thatordering
is something that should be implemented via OrderingFilter so that the API client can pick different orderings as part of the GET request.I think a full example could be reduced to something like:
So really the only "boilerplate" here is how many of the fields from
UserProfile
you want to expose via the REST API and how many are read only? That's not something an LLM can decide, that's a policy decision.So really, I wonder what it is that you are expecting an LLM to do? Because this small example doesn't have much to it and it does a LOT just by leveraging DRF and leaving you to just define your business logic and objects. If you can't be bothered to even think about your models and what data you are storing, I don't know what to say to that, beyond the fact that you just don't want to code even the easiest things yourself?
The point is that the LLM can produce 90% of the code here, and then you might need to tweak a couple of lines. Even with your changes, there's still very obviously a non trivial amount of boilerplate, and you just can't bring yourself to acknowledge this fact.
Where?
Where is the boilerplate?
That whole code is boilerplate that I originally generated using an LLM from the following query
write a django endpoint for handling a json payload with user information and storing it in the db
. After you making it concise, it's still over 40 lines of code.Three thoughts.
Firstly:
write a django endpoint for handling a json payload with user information and storing it in the db
And yet this LLM failed to consider just using the built in
contrib.auth.User
which already stores this information. What about extending the Auth user model?Secondly:
This means that any of this supposed "boilerplate" (you are not even using the right term, more on that in a second) is just AI slop that doesn't even do a half decent job of what you have been arguing, around getting rid of "boilerplate" that is inconvenient. It is the LLM itself that is creating all this supposed boilerplate!.
Thirdly:
I don't understand what you think "boilerplate" is. Because 40 lines of code where you define a model, the fields that are serialized through the REST API, and the REST API implementation is not boilerplate. Boilerplate is defined as "sections of code that are repeated in multiple places with little to no variation." (Wikipedia). Where is the "repeated in multiple places" in this example? If we even took this example further and extended it to other
model
s - where would the duplication be? The fact that you inherit fromModelViewSet
? That you inherit fromModelSerializer
? There is no boilerplate here! If anything the boilerplate is insideModelSerializer
andModelViewSet
, but that's object oriented design! You're inheriting from those classes so you don't have to do it yourself!.It's boilerplate because it's just lines of code that are spelling out a repetitive pattern that you end up having to mindlessly write over and over. The fact that you continue to refuse to acknowledge this blows my mind to be honest.
And again, I ask you, where is that mindlessly writing over and over code? I have even gone through the trouble of trying to see the problem from your perspective, by looking at
ModelViewSet
andModelSerializer
where if you squint really hard you could maybe make a case that it is repetitive, but in code that is object oriented, you can't just say that "oh inheriting from some big class that does 98% of the actual implementation is boilerplate" - because literally all you are doing is inheriting fromModelViewSet
and setting three whole fields that are specific to your model. Is three lines boilerplate, when they determine how the entire class behaves and if it works or doesn't work? I would argue not.I'm sorry, I should not assume that this sort of code does not require a significant cognitive effort to write from some people.
Ah, here we are again. Now you passive aggressively say that I'm just stupid. So, now, who is doing the "low effort trolling" that you claim anyone who disagrees with you does?
Incredible.
So which is it, is this code that's meaningful and interesting to write that requires cognitive effort from a human, or is it boilerplate?
It's neither boilerplate, nor is it interesting code. So I'm unsure what your point is, or why it is being asked as an either-or type of question where I have to pick one. I would appreciate you explaining it further.
As an aside, I had to spend time taking something that you got out of an LLM to get it to the point where it's small and boring.
I suppose if you want to spend all your mental energy fighting with an LLM and telling it "no, that's not quite right, why did you make more work for yourself when there was a much easier way to do it", that is certainly one way to spend precious mental energy. It does seem to be a common pattern that many people have already shared, where they spend lots of time fixing what the LLM generated, and many report that it sucks all the enjoyment out of the creative process.
At least when I have to do the "no, that's not quite right" with a junior engineer, I am helping someone grow in their career and sharing what I have learned over 20+ years in my craft, and that I am giving back to the next generation, as repayment to the generation that taught me.
LLMs are dead labor. They destroy the future of young engineers and replace with a parody that makes similar mistakes, has to be corrected, just like a junior engineer, but there is no life in it. Just a simulation of one. It destroys joy.
It ultimately doesn't matter whether this type of code falls into your definition of boilerplate. As you admit, it's not interesting code that anybody wants to write. It's not intellectually engaging, it's not enjoyable to regurgitate it time and again, and it needs to be written.
You didn't actually bother reading the article in the submission did you?
That's certainly your opinion, and it's quite obvious that there is absolutely nothing I could say to change it.