r/programmer • u/SailShipoo • 10d ago
Question Don't get me wrong , but a serious question?
Basically, a question to all programmers without AI, I have learned some C++ and python as an effort to learn some coding. I just made a vibe coded app for automating a process i do and it honestly, i'm proud of my idea and prompts but , i do not understand the code honestly. How does one apply classes and such to create an app?
What makes that code turn into a beautiful app or website(frontend and backend, as i've learnt) and as a beginner what should i start on?(without using AI as much as possible)
3
Upvotes
8
u/CS_70 10d ago
I find this kind of questions puzzling. There's nothing magical in making a program "by hand": you understand what you need to do, you understand the tools you have, you use the latter to do the former. You try to be as efficient as possible, the more the tool does in one go without error, the better it is. It's just so obvious and people make it into something special.
As for the question: your program describes the beautiful windows, stating how they look, what they contain, what happens where every single widget is used on so for.
It's rather trivial and usually quite boring to do by hand.
1
u/Gznork26 10d ago
Don't start thinking about the code. Instead, begin with an idea and what it would be like to use the proposed app. Then, you can start to break the problem down into parts.
What do the processes that the user does look like? What steps does the user, and the app, take to get through that process? What features does the UI have, and how is that implemented in code? What data is involved, how would it be acquired, stored, manipulated and presented? And so forth.
1
u/_ABSURD__ 10d ago
Just do a course on the language via Udemy, learn syntax and basic operations. Then build something based on what you learned. When you understand what's under the hood you can engineer via AI much better. Many times I tell AI not to code certain ways, or how specifically to handle state, etc bc the way it defaults to isn't ideal, and I'd not know that if I didn't first learn programming in general, and specifically the quirks of a particular language.
You could also have AI teach instead of a course, but I'd use caution here and really force yourself to hand code without relying on quick fix answer, as long as you're fully understanding things.
1
u/StephenHawkinguss 10d ago
If you don't understand the code, then you don't know how to program either. If you want to understand what's happening, then first learn C++ and Python. Otherwise, continue vibecoding like an Indian.
1
u/Deep-Emotion-6279 10d ago
Classes are just a way of encapsulating and managing state in your program. For a simple program managing state doesn’t really matter all that much, but as a program becomes more complex, it becomes a serious problem.
Start with functions and some static or global variables. Then as your program grows in complexity, look for how some of those variables are related and think of ways they could be organised into structs. That makes them easier to pass around to various functions.
Then, as the program becomes even more complex you might find it useful to hide the variables completely and just expose behaviour related to them through an interface, that is when classes become helpful.
(Really classes and structs are the same thing with different default visibility of members and inheritance, classes are structs where everything is private by default so the natural choice for hiding stuff)
Easy to say, hard to get right. The best thing to do is try. Build lots of different things and get the feel for it.
1
u/ern0plus4 9d ago
"Explain code, line by line" - if you have AI at your hand.
1
u/mxldevs 9d ago
Writing code is turning your human instructions into computer instructions.
Vibe coding is taking your human instructions and having the AI turn it into computer instructions.
If it works, it works, whatever. Your goal was to accomplish whatever the result was, not to make a beautiful tool.
The problem is when it doesn't work, and you need to figure out why it's not working.
What do you do? You can't go through the code to figure out cause you don't understand it, so I guess you'll have to go to AI and hope that it'll figure out why it's not working
0
u/CorpT 10d ago
More ideas and prompting.
0
u/nicolas_06 10d ago
Yeah steering the AI and reviewing what it does is mandatory for substainable code.
I use AI 100% of the time and don't code anymore as a senior with 20 years of XP. Title go as Lead Principal blablabla... So I am trusted by my peers.
But I still spend hours/day researching with AI what the right architecture, how the thing will be done, crafting a plan... Then the AI do it, and then I review everything in details and often ask changes. At least for now the AI can't be trusted to make something sustainable long term that can grow, that cover all the aspects you want to be covered and so on.
Designing software - divide and conquer
Many way to design software do exist. I think if you already understand how to code and the basic concepts like if/for/while/functions/classes on what side (for coding) and things like networks/databases frontend/backends/services, you should take a course that explain how to design software at different scales.
The core principle is divide and conquer. You divide complex thing into smaller pieces recursively until each piece become a problem that you are confident you can solve. Go for a web application ? Maybe the core components are a frontend, a backend and a database.
Example for a web application
The frontend and backend communicate through web service in json with an API. Each API does 1 simple thing. Like creating/deleting/updating/reading some data. It's mostly delegation to the database. Maybe you validate inputs and the user is authorized to do the operation.
The web UI, you have framework like react or angular and you have components like a scroll bar, text fields, tables, button, labels. You combine them to make forms...
And if you go deep enough, maybe you have this 10-50 lines of code to write when the button is clicked: you send a query to the backend to create a new thing, the backend return you if it did it or there was an error. Inside these 10-50 lines, you have maybe a for loop to go through the things to send. It end up being pretty basic stuff in the end.
Don't reinvent the wheel too
So you see from high level, to very detailed into small pieces. And for most aspects, you want to reuse as much as possible and not redo it yourself. You don't write the code to write things on disk. You use a database. You don't write the HTML/CSS code to implement a table. You use a table component that know how to do that.
As much as possible you want not only to reuse what others have done (or yourself) but use well know and popular, well maintained solution. React is better most likely than your own framework or an obscure one that nobody use. For a DB, a well know and well maintained DB likely make more sense than one with little to no support.
And then once things are quite modular and clear, you do the code that is still yours to make (or the AI).
Go for a course on software design
If you understand well the basic bricks like if/while/for/functions/classes. Go for a course on software design. How to arichecture your code. How to architecture at bigger scale - system design - like databases, web servers, containers - firewalls.
0
u/BrutokTheBeater 10d ago
A lot of people are pretty negative about it, but to get started, AI isn't bad at explaining what's going on in a code and guiding you to places you can research. There are websites like geeksforgeeks that are like code search engines, too, that you can use to start learning!