this post was submitted on 03 Jun 2025
31 points (84.4% liked)

Technology

1148 readers
101 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
[–] yogthos@lemmygrad.ml 16 points 4 weeks ago (2 children)

I'd much rather the slop generator wastes its time doing these repetitive and boring tasks so I can spend my time doing something more interesting.

[–] footfaults@lemmygrad.ml 21 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

wastes its time doing these repetitive and boring tasks

To me, this is sort of a code smell. I'm not going to say that every single bit of work that I have done is unique and engaging, but I think that if a lot of code being written is boring and repetitive, it's probably not engineered correctly.

It's easy for me to be flippant and say this and you'd be totally right to point that out. I just felt like getting it out of my head.

[–] yogthos@lemmygrad.ml 17 points 3 weeks ago (2 children)

If most of the code you write is meaningful code that's novel and interesting then you are incredibly privileged. Majority of code I've seen in the industry is mostly boring and a lot of it just boilerplate.

[–] footfaults@lemmygrad.ml 10 points 3 weeks ago (1 children)

meaningful code that’s novel and interesting then you are incredibly privileged

This is possible but I doubt it. It's your usual CRUD web application with some business logic and some async workers.

[–] yogthos@lemmygrad.ml 8 points 3 weeks ago (1 children)

So then you do write a bunch of boilerplate such as HTTP endpoints, database queries, and so on.

[–] footfaults@lemmygrad.ml 7 points 3 weeks ago (1 children)

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

[–] yogthos@lemmygrad.ml 5 points 3 weeks ago (1 children)

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.

[–] footfaults@lemmygrad.ml 2 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

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 the model to point to your Django ORM model and that's it. ModelViewSet already has all the implementation code for handling POST, PUT, PATCH and DELETE.

There is no boilerplate.

There isn't anything that an LLM would add to this process.

[–] yogthos@lemmygrad.ml 3 points 3 weeks ago (1 children)

I've used Django before and I disagree. 🤷

[–] footfaults@lemmygrad.ml 2 points 3 weeks ago (1 children)

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

[–] yogthos@lemmygrad.ml 6 points 3 weeks ago (1 children)

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:

from django.db import models

class UserProfile(models.Model):
    username = models.CharField(max_length=100, unique=True, help_text="Unique username")
    email = models.EmailField(unique=True, help_text="User's email address")
    full_name = models.CharField(max_length=255, blank=True, null=True, help_text="User's full name")
    date_joined = models.DateTimeField(auto_now_add=True, help_text="Date when the user profile was created")
    is_active = models.BooleanField(default=True, help_text="Designates whether this user should be treated as active.")

    def __str__(self):
        return self.username

    class Meta:
        ordering = ['-date_joined']
        verbose_name = "User Profile"
        verbose_name_plural = "User Profiles"

then you'll probably need to add some serializers

from rest_framework import serializers
from .models import UserProfile

class UserProfileSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserProfile
        fields = ['id', 'username', 'email', 'full_name', 'date_joined', 'is_active']
        read_only_fields = ['id', 'date_joined']

    def validate_username(self, value):
        if not value:
            raise serializers.ValidationError("Username cannot be empty.")
        if len(value) < 3:
            raise serializers.ValidationError("Username must be at least 3 characters long.")
        # Add any other custom username validation rules here
        return value

    def validate_email(self, value):
        if not value:
            raise serializers.ValidationError("Email cannot be empty.")
        # Django's EmailField already provides good validation,
        # but you can add more specific rules if needed.
        return value

then you'll have to add some views

from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
from .models import UserProfile
from .serializers import UserProfileSerializer

@api_view(['POST'])
def create_user_profile(request):
    if request.method == 'POST':
        serializer = UserProfileSerializer(data=request.data)

        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        else:
            return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
    return Response({"error": "Method not allowed"}, status=status.HTTP_405_METHOD_NOT_ALLOWED)

next you have to define URL patterns

from django.urls import path
from .views import create_user_profile

urlpatterns = [
    path('users/create/', create_user_profile, name='create-user-profile'),
]

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.

[–] footfaults@lemmygrad.ml 2 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

Going through as I go:

  • validate_email does not need to exist, since model fields by default have blank=False meaning they must have a value. This should be picked up by ModelSerializer already, since it is using the model.
  • validate_username doesn't do anything that couldn't be accomplished by using MinLengthValidator - and in addition it should not exist in serializers - it belongs directly in the declaration of the field in models.
    • That way, you are validating this field regardless of it being used for the REST API or the web application

On the subject of your view code:

That whole code can be thrown out and replaced with:

class UserProfileViewSet(viewsets.ModelViewSet):
    queryset = UserProfile.objects.all()
    serializer_class = UserProfileSerializer
    permission_classes = [IsAccountAdminOrReadOnly]

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 and verbose_name_plural is not an example of "boilerplate". I would also argue that ordering 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:

from django.db import models

class UserProfile(models.Model):
    username = models.CharField(
        max_length=100, 
        unique=True, 
        help_text="Unique username", 
        validators=[MinLengthValidator(limit_value=3)]
    )
    email = models.EmailField(unique=True, help_text="User's email address")
    full_name = models.CharField(max_length=255, blank=True, null=True, help_text="User's full name")
    date_joined = models.DateTimeField(auto_now_add=True, help_text="Date when the user profile was created")
    is_active = models.BooleanField(default=True, help_text="Designates whether this user should be treated as active.")

    def __str__(self):
        return self.username
from rest_framework import serializers
from .models import UserProfile

class UserProfileSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserProfile
        fields = ['id', 'username', 'email', 'full_name', 'date_joined', 'is_active']
        read_only_fields = ['id', 'date_joined']
from rest_framework import viewsets
from rest_framework.permissions import IsAccountAdminOrReadOnly
from .models import UserProfile
from .serializers import UserProfileSerializer

class UserProfileViewSet(viewsets.ModelViewSet):
    queryset = UserProfile.objects.all()
    serializer_class = UserProfileSerializer
    permission_classes = [IsAccountAdminOrReadOnly]
from rest_framework import routers

router = routers.SimpleRouter()
router.register(r'users', UserProfileViewSet)
urlpatterns = router.urls

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?

[–] yogthos@lemmygrad.ml 3 points 3 weeks ago (1 children)

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.

[–] footfaults@lemmygrad.ml 1 points 3 weeks ago (1 children)

, there’s still very obviously a non trivial amount of boilerplate,

Where?

Where is the boilerplate?

[–] yogthos@lemmygrad.ml 3 points 3 weeks ago (1 children)

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.

[–] footfaults@lemmygrad.ml 0 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

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 models - where would the duplication be? The fact that you inherit from ModelViewSet? That you inherit from ModelSerializer? There is no boilerplate here! If anything the boilerplate is inside ModelSerializer and ModelViewSet, but that's object oriented design! You're inheriting from those classes so you don't have to do it yourself!.

[–] yogthos@lemmygrad.ml 4 points 3 weeks ago (1 children)

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.

[–] footfaults@lemmygrad.ml 0 points 3 weeks ago (1 children)

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.

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 and ModelSerializer 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 from ModelViewSet 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.

[–] yogthos@lemmygrad.ml 4 points 3 weeks ago (1 children)

I'm sorry, I should not assume that this sort of code does not require a significant cognitive effort to write from some people.

[–] footfaults@lemmygrad.ml -1 points 3 weeks ago (1 children)

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.

[–] yogthos@lemmygrad.ml 4 points 3 weeks ago (1 children)

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?

[–] footfaults@lemmygrad.ml -1 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

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.

[–] yogthos@lemmygrad.ml 4 points 3 weeks ago

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.

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.

You didn't actually bother reading the article in the submission did you?

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.

That's certainly your opinion, and it's quite obvious that there is absolutely nothing I could say to change it.

[–] bennieandthez@lemmygrad.ml 7 points 3 weeks ago* (last edited 3 weeks ago)

Absolutely, coders should be spending time developing new and faster algorithms, things that AI cannot do, not figuring out the boilerplate of a dropbox menu on whatever framework. Heck, we dont even need frameworks with AI.

[–] freagle@lemmygrad.ml 12 points 4 weeks ago (1 children)

It's more that the iterative slop generation is pretty energy intensive when you scale it up like this. Tons of tokens in memory, multiple iterations of producing slop, running tests to tell it's slop and starting it over again automatically. I'd love the time savings as well. I'm just saying we should keep in mind the waste aspect as it's bound to catch us up.

[–] yogthos@lemmygrad.ml 14 points 3 weeks ago (1 children)

I don't really find the waste argument terribly convincing myself. The amount of waste depends on how many tries it needs to get the answer, and how much previous work it can reuse. The quality of output has already improved dramatically, and there's no reason to expect that this will not continue to get better over time. Meanwhile, there's every reason to expect that iterative loop will continue to be optimized as well.

In a broader sense, we waste power all the time on all kinds of things. Think of all the ads, crypto, or consumerism in general. There's nothing uniquely wasteful about LLMs, and at least they can be put towards producing something of value, unlike many things our society wastes energy on.

[–] freagle@lemmygrad.ml 10 points 3 weeks ago (1 children)

I do think there's something uniquely wasteful about floating point arithmetic, which is why need specialized processors for it, and there is something uniquely wasteful about crypto and LLMs, both in terms of electricity but also in terms of waste heat. I agree that generative AI for solving problems is definitely better than crypto, and it's better than using generative AI to produce creative works, do advertising and marketing, etc.

But it's not without it's externalities and putting that in an unmonitored iterative loop at scale requires us to at least consider the costs.

[–] yogthos@lemmygrad.ml 10 points 3 weeks ago (1 children)

Eventually we most likely will see specialized chips for this, and there are already analog chips being produced for neural networks which are a far better fit. There are selection pressures to improve this tech even under capitalism, since companies running models end up paying for the power usage. And then we have open source models with people optimizing them to run things locally. Personally, I find it mind blowing that we've already can run local models on a laptop that perform roughly as well as models that required a whole data centre to run just a year ago. It's hard to say when all the low hanging fruit is picked, will improvements start to plateau, but so far it's been really impressive to watch.

[–] freagle@lemmygrad.ml 4 points 3 weeks ago (1 children)

Yeah, there is something to be said for changing the hardware. Producing the models is still expensive even if running the models is becoming more efficient. But DeepSeek shows us even production is becoming more efficient.

What's impressive to me is how useful the concept of the stochastic parrot is turning out to be. It doesn't seem to make a lot of sense, at first or even second glace, that choosing the most probable next word in a sentence based on the statistical distribution of word usages across a training set would actually be all that useful.

I've used it for coding before and it's obvious that these things are most useful at reproducing code tutorials or code examples and not at all for reasoning, but there's a lot of code examples and tutorials out there that I haven't read yet and never will read. The ability of a stochastic parrot to reproduce that code using human language as it's control input is impressive.

[–] yogthos@lemmygrad.ml 4 points 3 weeks ago (1 children)

I've been amazed by this idea ever since I learned about Markov chains, and arguably LLMs aren't fundamentally different in nature. It's simply a huge token space encoded in a multidimensional matrix, but the fundamental idea is the same. It's really interesting how you start getting emergent properties when you scale something conceptually simple up. It might say something about the nature of our own cognition as well.

[–] darkernations@lemmygrad.ml 4 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

You mentioned Markov Chains; for a laymen with regards to mathematics (one would need to brush up on basic calculus) would you know any good books (I was thinking textbooks?) or resources to better understand maths with view to gain a better understanding of LLMs/GenAI later down the line?

[–] yogthos@lemmygrad.ml 4 points 3 weeks ago (1 children)

A few books that are fairly accessible depending on your math level.

Basic Math for AI is written for people with no prior AI or advanced math knowledge. It aims to demystify the essential mathematics needed for AI, and gives a broad beginner-friendly introduction.

https://www.goodreads.com/book/show/214340546-basic-math-for-ai

Mathematics for Machine Learning is a bit more academic than Hinton's book, and it covers linear algebra, vector calculus, probability, and optimization, which are the pillars of LLM math.

https://www.goodreads.com/book/show/50419441-mathematics-for-machine-learning

Naked Statistics: Stripping the Dread from the Data is phenomenal for building an intuitive understanding of probability and statistics, which are often the most intimidating subjects for beginners.

https://www.goodreads.com/book/show/17986418-naked-statistics

[–] darkernations@lemmygrad.ml 3 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

Thank you for taking the time for that reply and reading list; very much appreciated!!

[–] yogthos@lemmygrad.ml 3 points 3 weeks ago (1 children)
[–] darkernations@lemmygrad.ml 3 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

I edited my original comment to leave out partly why I posted it but there's no point in self-censorship as the thread has devolved into tone policing and strawmanning; just further evidence of how privileged Westerners are and those who benefit from Western hegemony.

AI under capitalism is coming for all our jobs due to automation as predictably estimated by multiple learned marxists but instead of taking the scientific socialist approach of understanding why; ie capitalism not technology in itself and we should use the technology to progress socialism for the betterment of humanity, there is bad-faith reactionary Nietzschean takes and so much self-importance on why allowance should be made for their hypocritical sensibilities and that they should be considered part of the vanguard despite wilfull ignorance when I suspect their class conciousness on the world stage is woefully inadequate for those who call themselves marxists.

Well done for continuing to post despite the spiteful ignorance.

(I personally asked about the Maths because AI is coming for my job too and I want to better understand the technology, and I feel for me, this is a more serious path to do this. Marxism is a science and we should not be burying our heads in the sand. Thanks again. Also the dialectical dispatches blog are interesting reads too)

[–] yogthos@lemmygrad.ml 6 points 3 weeks ago

I very much agree with all that. Interestingly, we're seeing exactly the same behavior from liberals when it comes to topics like the war in Ukraine. In both cases, people just want to ignore the basic facts of the situation in favor of a comforting narrative. Yet, it's completely self defeating behavior because material reality can't simply be wished away. We have to engage with the world the way it is to make sound plans and decisions about the future. I understand why people feel threatened by this tech, but pretending that it doesn't work or that you can boycott it out of existence is not rational.