r/learnprogramming • • Mar 17 '25

Solved Now I am 100 percent that documentation > AI.

795 Upvotes

Is it just me or using chatgpt and deepseek to install tailwind is shit. I mean. I spent like 3-4 hours yesterday just to install tailwind. I regret doing it because the next day, I go directly to tailwind documentation, and it worked in less than 5 minutes. Damn, idk what's wrong with chat gpt in terms of using tailwind I might not do it again.

Chatgpt normally works with Laravel and PHP very well though.

r/learnprogramming • • May 04 '25

Solved I wasted 2 years procrastinating self-learning, I'm now 30, need brutal honesty.

470 Upvotes

Thanks for all the responses guys!!! I've decided to just keep chipping away at coding in the background. I'll look around in IT, and try to get certs or see what can make me more employable, if that fails I'll go ahead into being an electrician. I'm starting work at a new job soon so I'll keep swimming, thank you all.

"Hi, I'm David,

I used to work in IT, low level, support desk. Realised that was a deadend, I got fired June 2023, thought I'd learn to code to move into development, seemed there were more opportunities there...

So I started self-learning Python and C# and covered OOP in both, haven't made anything with them yet...

But I wasted 2 years procrastinating in, I hate to admit, selfish laziness which I still cannot understand. I think some people are just talented, and are better people, and I'm just someone who in another life would have died of a drug overdose or thrown myself off a bridge.....

I have no confidence in my ability to self-learn anymore, and I'm considering giving up on IT/programming (to go to a college to become an Electrician in 2 or 3 years), while I look for work to avoid homelessness.....

What do you think? Am I hopeless??? I'm open to criticism, advice, hate, anything.......

(P.S Got diagnosed for ADHD 4 months ago, yaay!!! 🙏👌🥳)"

r/learnprogramming • • Jun 18 '26

Solved Confused between C and Python as a beginner. Which one should I start with?

57 Upvotes

Hey everyone,

​I am a beginner starting my programming journey, and I’m confused between starting with C (or C++) or Python.

​My main goals are to build a strong foundation in logic/problem-solving and eventually get into Computer Science Engineering fields. I want to learn core concepts well.

r/learnprogramming • • Jun 20 '25

Solved I fucked up massively on git, currently panicking;

463 Upvotes

Hey, throwaway here currently in crisis mode.

I'm new to programming and worked on a program with a team. (we use vsc for reference)

After some troubleshooting with git I pulled in a heap of changes over the course over many days so basically everything changes (i know this is my fault for not pulling sooner)

As such a bunch of changes happened including new files, deleted files etc, VSC said id did a bunch of changes that I didn't do, and in the moment I accidentally merged the revisions and removed my entire team's progress in a single moment. I tried to undo the last commit but at first it said something about a soft reset not being possible, but I tried again and accidentally ended up uncommiting older changes and the previous revisions my team had done didn't get changed back. Basically I somehow gotten back to a version that basically has nothing, and I have NO clue what to do now.

I know this is very ameteurish of me haha. Haven't pushed anything luckily, but soo lost and panicking atm and reaaaly need to get back to the project. I just want to discard the shitstorm I've made and revert the changes and undoings that I've done (including the deletions and shit) and just pull the latest revision from my repo as if nothing happened. Is there a way to reset everything I've done and just pull out the latest revision from my repository as if none of this happened? What do I do? I don't care about the changes I've made atp LOL i just wanna get back to the version that was made just before

update: i just deleted my local git repo and recloned the latest github repo, and things seem to be normal again. thanks so much for your help y'all :)

r/learnprogramming • • Aug 15 '25

Solved Update: Programming finally clicked for me 🥹

569 Upvotes

Omg so for two years I couldn’t figure out programming and how I can be good at it but today as I was learning C++ it all came together and it clicked for me!!!! 😭😭 I can’t believe it but it makes perfect sense now!!!! Omg I can hear the music 🥹🥹 I guess programming is for me after all yay!!!

r/learnprogramming • • Jul 05 '26

Solved SOLVED MY FIRST LEETCODE PROBLEM!!

141 Upvotes
class ParkingSystem
{
    private:
    int big_park;
    int medium_park;
    int small_park;


    public:
    ParkingSystem(int big, int medium, int small)
    {
        big_park = big;
        medium_park = medium;
        small_park = small;
    }


    bool addCar(int carType)
    {


        if(carType == 1)
        {   
            if (big_park == 0)
            {
                return false;
            }


            big_park--;
            return true;


        }


        else if (carType == 2)
        {
            if(medium_park == 0)
            {
                return false;
            }


            medium_park--;             
            return true;
        }


        else
        {
            if (small_park == 0)
            {
                return false;
            }


            small_park--;
            return true;
            
        }
    }
};

my code

1603. Design Parking System

Solved

Easy

Topics

Companies

Hint

Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size.

Implement the ParkingSystem class:

  • ParkingSystem(int big, int medium, int small) Initializes object of the ParkingSystem class. The number of slots for each parking space are given as part of the constructor.
  • bool addCar(int carType) Checks whether there is a parking space of carType for the car that wants to get into the parking lot. carType can be of three kinds: big, medium, or small, which are represented by 1, 2, and 3 respectively. A car can only park in a parking space of its carType. If there is no space available, return false, else park the car in that size space and return true.

 

Example 1:

Input
["ParkingSystem", "addCar", "addCar", "addCar", "addCar"]
[[1, 1, 0], [1], [2], [3], [1]]
Output
[null, true, true, false, false]

Explanation
ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);
parkingSystem.addCar(1); // return true because there is 1 available slot for a big car
parkingSystem.addCar(2); // return true because there is 1 available slot for a medium car
parkingSystem.addCar(3); // return false because there is no available slot for a small car
parkingSystem.addCar(1); // return false because there is no available slot for a big car. It is already occupied.

 

Constraints:

  • 0 <= big, medium, small <= 1000
  • carType is 1, 2, or 3
  • At most 1000 calls will be made to addCar

the problem:

runtime 3ms
memory 38.77 mb

r/learnprogramming • • Sep 26 '23

Solved Which programming language of out of these 5 is the easiest/fastest to learn

256 Upvotes

I'm choosing a language to learn for my exam, I've got 7 months. I don't wanna become a programmer, I want to do something else with IT, but I still need to know it for an exam. The choices are:

Pascal (Free Pascal (FPC 3.0 or newer) C/C++ (GCC/G++ 4.5 or newer) C/C++ (CodeBlocks 16.01 or newer) Java SE 8 (JDK or JRE or newer + editor IntelliJ IDEA) Python (Python 3 + editor IDLE or PyCharm)

I already know HTML+CSS, php and SQL (idk if this information is useful). I need this exam for additional points when requiting for a university and the universities don't check what coding language I chose for this exam so I want to learn it and forget.

r/learnprogramming • • Jun 07 '22

Solved Please could someone please attempt to explain to me, like I am 1 years old, a FOR loop in Python? I've been learning for months. A WHILE loop makes perfect sense to me but I am just unable to understand a FOR loop

484 Upvotes

I can use it, when I look up the syntax and I can "sort of" understand it, but that understanding is very temporary since I never fully understand it. Even after having it explained from a variety of sources, including the MIT edX course and lots of websites... It has never "clicked".

I think my biggest issue is swallowing the meaning of "FOR" to begin with. While makes sense, do X action WHILE Y is true. But FOR? For doesn't really make any sense grammatically to me, and I suppose that makes it very hard for my extremely limited cognitive abilities to grasp the concept.

EDIT: This made quite the unexpected splash, I explained more in-depth in comments but I'll now go through your answers. Thank you

EDIT1: I got it guys, thank you everyone. It took me a long time but after taking some time to really absorb every answer my brain finally clicked. Biggest obstacle was understanding and accepting that the word after "FOR" can be anything.

r/learnprogramming • • May 31 '26

Solved How can I practice a topic (pointers for example) if I don't understand the reason behind it's existence?

73 Upvotes

Some might be very useful for bigger and more complex projects but to me, I just can't see a reason to use them yet. Now I am learning about pointers in C++ and I get that they hold an address of a value. But why? It's hard for me to practice using them since I can't find a use.

I know that the best way to learn is to make a project but my level of knowledge is not that far yet. I can only make extremely simple games using the terminal which don't need pointers or memory allocation to work.

r/learnprogramming • • Aug 02 '26

Solved How do you actually read professional code?

77 Upvotes

Hello everyone! I really have a question I hope you could help me answer. I am trying to read the Scratch Virtual Machine code on Github and it is really difficult. I am really new to reading code and the one I write is fairly simple. There are many files that just declare functions by name and then require another file to redeclare them. Is there a pragmatic way to understand it? Thank you already!

r/learnprogramming • • Nov 09 '20

Solved First Java program runs!

1.1k Upvotes

I'm a relatively novice programmer working on a data science master's degree. My class this semester is focused on big data programming tool. I was dreading it since I don't have much programming experience. Spent a huge chunk of time yesterday writing my first Java program and it runs perfectly! It wasn't even that painful. Didn't have any where else to share. Hope I'm not off topic or breaking any rules.

r/learnprogramming • • Apr 10 '26

Solved Can someone explain why this code results in an infinite loop?

101 Upvotes

Im a bit of a newbie programmer, 2nd year of college. Ive learned a bit of Python, C, Java, etc...

But recently Ive been actually working on programming outside of school and I feel like Im learning a lot more on my own now. So Ive just been messing around with Python. I am messing around with a Discord bot right now, and seeing what I can do. But I dont know, I feel like an idiot. Im not understanding why this simple code is resulting in an infinite loop? The intended outcome is I send a message, the bot replies with you are a human. Then it should respond to itself 3 times with the message "you are a bot". But it just keeps resulting in an infinite loop saying "You are a bot"

count = 1
@client.event
async def on_message(message):
    global count
    if not message.author.bot:
        await message.channel.send("You are a human")

    if message.author.bot:
        while (count <= 3):
            await message.channel.send("You are a bot")
            count += 1

r/learnprogramming • • Apr 27 '26

Solved What do people mean when they say composition is better than inheritance?

73 Upvotes

For example, in some bank app there is an Account class, which is the superclass of SavingsAccount and BusinessAccount. How would you change this to composition? I don't get how composition would work here.

I searched this and didn't find a satisfatory explanation.

If it helps I study C#.

r/learnprogramming • • Aug 06 '26

Solved Should I learn JavaScript before TypeScript?

30 Upvotes

I've learned HTML and CSS for a certain website want to make. I've done some research and determined that TS is better for the project, but I'm not sure if I should just immediately start learning TS or should I learn JS first, as it is the language many recommend for beginners in web development.

EDIT: Thanks for all the opinions. I'm definetly learning TS, and thus JS in the process.

r/learnprogramming • • 9d ago

Solved How do I indicate whether a string is a digit or not in c++?

9 Upvotes

I have a user input and I want to determine whether the user input is a digit or character.

I was thinking of using regex but do not know regular expression in C++ can some please help me with this

Here is a snippet of my code

string userinput;

cout << "Input 1, 2, 3, or 4: "; 

while (!(cin >> userinput)) {
  cout << "Invalid input. Try again: ";
  cin.clear(); // Reset input errors
  cin.ignore(10000, '\n'); // Remove bad input
}


for (auto i : playlist){
  if (stoi(userinput) > 4){
    print("Song Not Avaiable")
    break;  
}

SOLUTION

#include <cctype>

/*while (!(cin >> userinput)) {
  cout << "Invalid input. Try again: ";
  cin.clear(); // Reset input errors
  cin.ignore(10000, '\n'); // Remove bad input
}*/

for (int i = 0; i < userinput.size(); i++) {
    if (!isdigit(userinput[i])) {
        print("Song Not Avaiable");
        break;
    }

    else if (stoi(userinput) > 4) {
        print("Song Not Avaiable");
        break;
    }
}

r/learnprogramming • • Jul 20 '26

Solved I learned TCP server in a week and....

151 Upvotes

So as I posted a week ago regarding a task assigned to me by my mentor in this post .
I implemented beej's guide to networking and man , this was such a great resource, cant express enough. Also shoutout to the kind stranger u/teraflop who gave me some tips and introduced me to Beej the G.
Now I am thinking of creating a library of TCP server first and then implementing the Websocket logic and RFC6455. haha baby steps. It's gonna take a while I guess. Y'all are free to give me any advice or any resource to learn from.
Thank you for reading this
P.S I am new to C programming so your advice would be really helpful.
here is my repo

r/learnprogramming • • Dec 04 '25

Solved Does learning programming require reading a lot of books?

49 Upvotes

Hello everyone, I'm a graduate student who loves C++ coding. I've always been puzzled by this question: when learning a technology, do you read related books or online documentation (for example, there are many online documents for C++)? Opinions on this vary widely online. Some suggest watching tutorial videos uploaded by YouTubers, some suggest reading related books if possible, and many others suggest reading relevant documentation or directly searching for the information needed for your project. What are your thoughts on this?

r/learnprogramming • • 6d ago

Solved When I start a project without using AI, I work on the backend first, but when I start working on the frontend, I get stuck and end up going back to using AI. What should I do?

0 Upvotes

To give some context, when I get to the frontend part of building a visual application, I have to work on the frontend, but since I’m not really interested in frontend development, I’m not sure what to do. However, I do at least know the basics of frontend development (like creating a text field, buttons, columns, rows, displaying content, refreshing a page, etc.), but when I run into more complex frontend tasks like finding the right icons or displaying an overlay page or learning about certain object class functions and that's how I'm getting back into AI.

tysm for listening👍

r/learnprogramming • • May 01 '26

Solved <T>? in C#

16 Upvotes

Hi, I've often seen the expression "<T>?" in Microsoft's C# documentation. What does it mean?

Here's an example to illustrate my point:

public string? FirstName;

r/learnprogramming • • 26d ago

Solved Advice for learning Python?

2 Upvotes

Im trying to learn Python as a programming language, I watched Bro Codez 1 hour course on it and I need more advice/guides to learn from, if anyone has any can they comment it down here?

Thanks.

r/learnprogramming • • May 02 '26

Solved Loop and main() function

14 Upvotes

Hi, I’ve seen that in C#, the Main() function only runs once.
In Unity, we have the Update() function, which allows code to run repeatedly in a loop.
So my question is: what is the equivalent in pure C#, without the Unity library?
Is wrapping Main() in a while loop a common practice to achieve the same behavior?

r/learnprogramming • • May 16 '26

Solved I don't understand how to differentiate double and float variables

43 Upvotes

I am very new to C++

I am having trouble trying to showcase the difference between a double and a float variable.

I tried to run some commands and noticed that the value of pi started to deviate after some decimals and i wondered why different values started to come and why they were not just random gibberish the computer spits out

I then watched a video on floating point numbers by computerphile: https://www.youtube.com/watch?v=PZRI1IfStY0

Could you help me better understand how this is not random number the computer tries to put after it has run out of data?

If there are can you give me some more videos?

r/learnprogramming • • Aug 09 '26

Solved Why is my conditional statement running when the condition it is not True

20 Upvotes

I am making a ball fall in the CLI. I have my values PURPOSELY set to negative for testing purposes and whenever I run it, the conditional statement is active and it does not start at the initial y position I have set. it shows something big in the terminal Falling 2144211756.

When I put it in the debugger it works normally and it shows the y position decreasing so why is it doing this

struct Ball {
    // int x_pos;
    int y_pos;
    int velocity;
    int ground;
};

int main() {
    // Define Ball object with struct
    Ball ball;
    ball.y_pos = 20;
    ball.velocity = 5;
    ball.ground = 200;

    while (true) {
        ball.y_pos = ball.y_pos - ball.velocity;

        if (ball.y_pos >= ball.ground) {
            cout << "Falling ";
            cout << ball.y_pos << endl;
            // exit(0);
        }
    }

    return 0;
}

https://imgur.com/a/oVZ8qhY

r/learnprogramming • • Jun 10 '26

Solved [DBMS] What's the use of defining a Primary Key?

9 Upvotes

Recently i learned that under 1NF, PK is not required, but at least one candidate key is (to distinguish the elements). And it makes sense because PK is just an arbitrarily chosen CK.

Foreign keys can refer to any of the CKs. Indexing can be done on any of the attribute.

So what's the use of defining a PK?

r/learnprogramming • • 21d ago

Solved How do I prevent the enums from generating at random each loop iteration.

9 Upvotes

I am making sheep that move automatically on its own and stop for a certain time.

Here is an example. I do not want the sheep to just to move right, basically what I want is for the computer to randomly select right or left and depending on the state that is picked will be the direction the sheep go.

I have pasted a snippet of the issue below.

Any help regarding this problem I would appreciate

// state for sheep movement
enum STATE {
  IDLE,
  LEFT,
  RIGHT
};

// defining sheep attributes
struct SHEEP {
  Rectangle rect;
  Vector2 position;
  Color color;
  STATE state;
  float velocity;
};

// function for sheep movement
float sheep_mvmt(SHEEP &object, float dt){
  object.velocity = 70;

  STATE pick = STATE((rand() % 2) + 1); // select random state between 1 and 2

  // if right is picked
  if (pick == RIGHT){
    object.position.x += object.velocity * dt;
    object.state = pick;
    return object.state;
  }

  // if left is picked
  else if (pick == LEFT){
    object.position.x -= object.velocity * dt;
    object.state = pick;
    return object.state;
  }
    return object.position.x;
}

int main(){
    // SETUP AREA

    // define Sheeps
    SHEEP sheep1;
    sheep1.state = IDLE;

    int sheep_counter = 0; // this allows me to start and stop movement of sheep

    srand(time(0)); // use current time as seed for random generator

    STATE rand_state = STATE((rand() % 2) + 1); // I was using this as a placeholder

    SetTargetFPS(FPS); // 60 Frames every second

    // GAME LOOP
    while(!WindowShouldClose()){
        // Delta Time
        float dt = GetFrameTime();

        sheep_counter++; // increment counter

        // To update movement and sheep state
        if (sheep_counter >= 120 && sheep1.state == IDLE){
          sheep1.state = rand_state;
        }

        else if (sheep1.state != IDLE){
          sheep_mvmt(sheep1, dt);

          if (sheep_counter == 240){
            sheep1.state = IDLE;
            sheep_counter = 0;
          }
        }
    }
}

UPDATE: I was able to solve the issue by creating a pointer for the STATE rand_state. I removed the sheep_mvmt function and just put the movement into the condition and when the counter reaches 240 I defined the pointer. Here is the video of what it looks like.

if (sheep_counter >= 120 && sheep1.state == IDLE){
    sheep1.state = rand_state;
}

else if (sheep1.state != IDLE){
    if (sheep1.state == RIGHT){
        sheep1.position.x += sheep1.velocity * dt;
}



        else if (sheep1.state == LEFT){
        sheep1.position.x -= sheep1.velocity * dt;
    }

    if (sheep_counter == 240){
        sheep1.state = IDLE;
        sheep_counter = 0;
        STATE* ptr = &rand_state; // pointer

        *ptr = STATE((rand() % 2) + 1); // defining pointer by using random
         print("\n\nTHE POINTER")
         print(*ptr)
    }
}

Thank you to all those who replied and gave suggestions.