Studying Programming is more fun than actually Programming.
Posted by ThatWontCutIt@reddit | learnprogramming | View on Reddit | 34 comments
I've been studying Java for the past five months, primarily using textbooks. Once I felt comfortable with the language, I started working on projects. My first project, a server-client NIO-based application, was an eye-opener. The code was a mess—I could barely tell what called what or what did what, and making changes felt like a guessing game. Strangely, the method names I came up with actually helped a bit.
After that experience, I started studying Design Patterns. I liked the concepts, but I noticed something interesting. When I asked ChatGPT to suggest exercises for practice and compared the code it wrote to mine, the difference was striking. My code was overly bloated with patterns. While it was easy to modify, it wasn’t easy to read. Meanwhile, GPT’s code was simpler, clean, and still easy to change.
I tried over and over to write code that was as elegant as GPT's, but I kept failing. Now, whenever I try to write code on my own, I quickly get frustrated. I’ve found myself in this loop where reading about coding—like APIs, paradigms, and concepts—is far more engaging than actually writing code.
What do you think is the issue, and how can I overcome it?
Key-County6952@reddit
I'm not personally aware of any way to study programming that isn't actually programming
mraees93@reddit
I enjoy both. I practice while studying something new
TrueSonOfChaos@reddit
Strongly disagree - programming is way more fun than studying APIs from A-Z.
thma_bo@reddit
Totally agree, programming is so much fun. Solving problems or finding a fun project is awesome.
Code code does not came from reading but from writing ugly code and learn from it.
notrandomatall@reddit
Yeah, building things is the bees knees. A series of problem solving induced endorphin releases followed by a completed project you’re (sometimes, somewhat) proud of? Damn hard to beat.
bahcodad@reddit
The mutt's nuts, even
aqua_regis@reddit
What you encountered is typical.
When you learn something new, you tend to use it, especially with Design Patterns it quickly leads to "programming around the patterns" style, which results in cluttered code.
LLMs have it easy in that manner as they can access a plethora of properly programmed code, final results of countless iterations. See the point?
You did everything on your own, which, due to lack of practice and experience led to the code you created. LLMs have access to resources that went through multiple refactorings leading to better code.
You have to start doing the same. Follow the "make it work, make it pretty, make it fast" pattern and start refactoring your code.
You have realized where your shortcomings are. Now it is time to work on exactly that. And improving that can only happen with more practice.
For now, do not focus on learning new things. Focus on improving your existing skills. Hone what you have. Then, step up and learn the next. Rinse and repeat.
You can use AI as guide, but don't fool yourself into taking the code from AI as "instant genius" code. Similar to looking at github repositories and admiring the code there. Also this code went through plenty iterations and refactorings to get to the state you see.
As a fun experiment, pick a larger project on github and then go back in its commit history. See from where it started and see how it evolved. You'll be in for quite some surprise.
LLMs see the final (or at least the stage at which they were trained) stage, which naturally shows more elegant, better code.
MaverickGuardian@reddit
LLM generated code might look great but it contains tons of errors and dangerous bugs. Taking neat examples and randomly combining them doesn't make quality code.
kumaku@reddit
thank you. great comment.
readeral@reddit
This. Refactoring definitely brings growth.
Underhill42@reddit
The issue is that you lack experience. And the only solution is years of practice. Same as any other skill.
Do you think you could study music theory for five months and then compose at the level of Beethoven? Study art theory for a few months and paint at the level of Michelangelo? Study business theory and run a large corporation competitively?
Of course not!
The AIs are drawing on a huge body of reference material created by people with decades of experience. Even if their results are distinctly lacking compared to a really good programmer, and potentially fundamentally flawed in ways that can really bite you in the ass, they're still going to blow the socks off of any beginner.
And you'll be a beginner for many years - there are no shortcuts to getting good. Even incredibly gifted beginners take years before they start composing code that a professional would be willing to take credit for.
So don't try to measure yourself against experts when you're just starting out.
Oh and:
There's absolutely nothing strange about that. Choosing good, descriptive method (and variable!) names has long been accepted as one of the single biggest things you can do to make your code easier to understand. Name your methods to describe what exactly they're doing (usually a phrase of several words), and your variables to express the context and expectations of the data they hold (usually 2-3 words) and it will be much easier to keep track of what exactly things are doing.
With a good naming convention and short lines of code, the code will usually read almost like a sentence describing exactly what it's doing. Which leaves your comments free to explain WHY you're doing it. And as a rule of thumb, make sure to write at least one line of concise, high-level descriptive comment for every few lines of code.
Think of comments as street signs for your code - when you want to change something in code you haven't looked at in a while, you don't want to have to slog through all the code to find the spot that needs changing - it's much easier if you can just skim through the comments to quickly get to the right general area.
As a beginner it can even be helpful to write the comments BEFORE you write the code: e.g. when composing a function start with the comments giving a high-level breakdown of the steps you'll need to go through to accomplish the task, and only once you're sure you've got all the basic steps in place do you go back and fill in all the code that does the work between them. E.g. as a simple dumb example with terrible variable names:
Sure, it's pretty obvious with only a moments thought WHAT the code is doing - but you'd have to read the entire previous section to figure out WHY it needs to be done. And it might not be obvious.
The corollary is that it's VERY important to keep your comments up to date whenever you change the code, which is greatly helped by keeping them high level enough that it takes major changes to make them wrong. The "WHY" is also generally a lot less likely to change than the "WHAT", so that helps too.
Detailed "WHAT" comments are really only necessary when doing something cryptic. Which can occasionally yield dramatic performance improvements, but as a rule is just a sign that you're trying to do too much at once.
redditscrat@reddit
I used to be just like you. I was afraid of writing messy code, so I kept reading books, studying best practices, and writing small code snippets. While this helped initially, when it came to real-world projects, my code was still a mess. After going through a painful period, I realized I had been living in my comfort zone for too long - just studying the same concepts and patterns over and over again.
That's when I decided to change my approach. I started looking for real-world problems to solve and began reading actual projects on GitHub instead of just following tutorials and crash courses. This shift made a huge difference in my development. I learned that you shouldn't be afraid of making mistakes - writing messy code is actually a necessary step on the path to writing clean code. In fact, making more mistakes will help you improve faster.
The key is to step out of your comfort zone and face real challenges head-on. The more you practice with actual problems, the better you'll become at writing clean, efficient code.
Watchful_Actions@reddit
KTS - Keep Things Simple
More often than not, programmers tend to over abstract codes and love incorporating that newest/coolest concept they just picked up or learned everywhere. The problem with this is that you end up with lots of unnecessary bloat, and thus end up with a spaghetti mess.
Start your code off with the thought of keeping things simple in mind rather than thinking what design pattern you can implement. Refactor the code you write by simplifying it as much as possible, akin to simplifying a Math equation.
Hope this helps! Happy coding 🤓
EdwardElric69@reddit
Personally it's the opposite for me.
I enjoy learning something, especially if it's so thing I can use in projects.
There's no better feeling when you understand something you've learned and applied it.
Or noticing that you used to do something that took 5 lines of code and now you're just returning 1 line of code that does the same thing but better.
Negative_Baseball293@reddit
This comment sums it up
GPU_Resellers_Club@reddit
Literally the opposite of me. I fucking hated studying to get my CS degree, working has shown me that actually did choose right, I love writing code.
Dilie@reddit
It is because learning programming in my opinion is a process where you constantly understand the theory and using it in practice for example in projects.
If you have been programming for 5 months don't beat yourself up too much. The skill takes time to level.
Ethereal_Isabela@reddit
You’re probably overthinking it. Patterns are great, but if you try to force them into every line of code, you’ll end up with a spaghetti-pattern monster. GPT has the advantage of knowing when not to overcomplicate things, which is a skill that comes with practice. My advice: build more, fail more, and focus on learning how to debug and refactor. Writing code you hate is just part of the journey. It means you’re improving.
Overall-Win2081@reddit
This is super common! Learning and applying are two different beasts. When you’re studying, everything feels clean and logical, but when you start coding, you’re suddenly dealing with edge cases, messy implementations, and debugging. The key is to embrace the chaos. Focus on building small, simple projects first, and let the design patterns emerge naturally as you need them. You don’t need perfect code on day one. It’s all about iteration. Keep at it, and it’ll get easier!
Based-Department8731@reddit
No, I disagree. I really don't miss spending all weekend doing an exercise in programming, I'd rather do it during the workday and get paid good money for it.
Starberrytwist@reddit
If you are know how to use Chat GPT. Then him what to do next..
v0gue_@reddit
Oh man... wait till you get on the job. I'd quit my dev job right now if it meant I could get paid half my salary to do nothing but learn about programming
Single_Exercise_1035@reddit
Try building the code using test driven development, TDD leads to succinct and elegant code as it's built up piece meal from tests that define the codes functionality.
RiverRoll@reddit
Writing good quality code is challenging while just reading about coding is easy, so you get discouraged by feelings such as the fear of failure or the blank page paralyisis. And you don't always get the luxury of being able to easily compare your code so you can tell how good you did, getting to see other implementations is a great opportunity to grow.
Designer_Currency455@reddit
I found the opposite. Learning clean code and shit is insanely fun
probability_of_meme@reddit
I'd say don't fall into this trap (even though I still battle it myself). There's always a more elegant way to do it, but it elegance only gets you so far in the real world. Finding the right balance between elegant and maintainable is something that improves with time.
At this point, if it works and it's at least moderately efficient - you can say it's good enough.
AloHiWhat@reddit
It can be equally fun because you anal6ze and create code while thinking. I do not know what you mean studying programming, what is that ? How do you study programming. By programming ?
Aggressive_Ad_5454@reddit
Reality: the world is a solid half-century into the Information Age, and most real-world programming tasks are maintenance tasks.
Old, working, debugged, profitable, code tends to be messy. Because of the special cases patched in as they were discovered. Because the people developing the code needed to get the special cases implemented quickly without reworking the whole thing. Because standards and fashions in development change over time.
Textbooks, tutorials, and AI output tend toward showing “happy path” examples. So those examples look more elegant than real-world stuff.
akthemadman@reddit
I think you might have discovered that there are a lot of snake oil sellers in the world of Java. You overcome that by reverting to what you did before: figuring things out for yourself.
Without concrete examples it is hard though to have an interesting discussion on the specific aspects you have made a judgement. Over the years I have changed my opionion about different approaches several times, so depending on where exactly you are at your learning, different arguments might be more insightful.
akthemadman@reddit
I would love to see some code of yours and the counterpart of GPT that you find more elegant. That might spark an interesting discussion.
house_of_klaus@reddit
I'm a C programmer, not Java, but I think these concepts should still apply. I was a full-time mentor up until a couple weeks ago (moved back into production). I see this a lot from the trainees, and what I usually tell them is to learn about and follow the Single Responsibility Principle (SRP) and Separation of Concerns (SoC) in order to keep their code readable and maintainable. SRP means that each function should essentially be doing one thing, while SoC is essentially keeping code organized into different files and classes based on their purpose. So file handling code might go in FileIO.java, calculation methods might go in Math.java. Additionally, you typically want to keep your functions under 100 lines. If they are over 100, you're likely breaking SRP and should refactor. Lastly I see a lot of people trying to put all their code in main(). Try to avoid doing that. With all that said, these few things alone can help a lot in keeping your code neat and tidy.
Substantial-You-8587@reddit
Coding for fun was always more interesting for me than doing it as a job. Because now, you gotta make what someone else wants.
0dev0100@reddit
Seems like what has happened is you've been given tools, and now you are offering with them.
As you keep playing with them you'll find that some tools work well in some places and not others. Still a valuable tool to have but not the right tool for {thing}
no_brains101@reddit
The computer is not even a junior dev. But it has the code of thousands of experts that it wields with no understanding. It will LOOK better for now.
Also, part of the problem is that its code does always look believable, even when it's wrong.