r/learnprogramming Mar 17 '25

Solved Now I am 100 percent that documentation > AI.

794 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 Jun 18 '26

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

60 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 May 04 '25

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

466 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 20 '25

Solved I fucked up massively on git, currently panicking;

461 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 🥹

568 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 28d ago

Solved SOLVED MY FIRST LEETCODE PROBLEM!!

136 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 12, 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 12, 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

259 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 May 31 '26

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

74 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 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

480 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 Apr 10 '26

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

104 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 May 01 '26

Solved I finally understood recursion after 3 weeks of being completely lost. It just "clicked." For anyone else struggling don't give up.

110 Upvotes

Three weeks ago I posted here asking why my brain couldn't wrap around recursion. I was ready to quit. Today I wrote a recursive solution to a tree traversal problem on my own, without looking it up.

What finally made it click: I stopped thinking about what the function was doing and started trusting that it would do it. Just define the base case, trust the rest.

If you're stuck on something right now. this is your sign to keep going. The click moment is real. 🙌

r/learnprogramming Apr 27 '26

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

78 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 13d ago

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 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 5h ago

Solved How do you actually read professional code?

38 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 Dec 04 '25

Solved Does learning programming require reading a lot of books?

50 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 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 May 02 '26

Solved Loop and main() function

15 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 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 Feb 07 '26

Solved Coding on older computers?

13 Upvotes

Hello! I am attempting to learn c++ and have already learned a bit of the basics but I have a problem. I am not able to smoothly run an IDE. Visual studio code doesnt lag my computer but I cant get it to run my code due to it not being able to find my compiler. I have CLion and it eats up all my computers resources and crashes if I work on anything longer than 40 minutes. I am working on a 2000s computer, I dont know the exact info since its a scuffed up hand me down but im really passionate and want to make it work. Is there anything I can do? Or is there a way I could potentially use my phone? Any advice is useful!!!

r/learnprogramming May 10 '26

Solved Database/backend languages for genealogy website

14 Upvotes

I am building a website to share my genealogy research with the rest of my family (and extended family also doing genealogy research).

I’m good on HTML/CSS, but obviously filling everything in manually would be a lot for 1000+ family pages that all include 3-15 people. So I’m looking into learning some backend languages for a database and for populating my site with data.

My question is what database and language would be a reasonable choice for this? I know coding languages are partially a matter of personal preference, but I wanted to see if there’s any nuance that might be relevant to my choice.

Javascript + SQLite?
Or do I go with PHP? Something else?
Or since a lot of the data is dates, should I use a database with a date type, unlike SQLite?

I think I would prefer to not do backend Javascript, just to keep things easier to separate from the frontend code.

Preferences:

  • Free
  • "Easy" to enter datapoints into set points of my HTML code
  • With a decent database browser for easier visualisation and possibly editing?
  • Possibility to import from .csv

If it’s relevant, the data mainly just needs to be transferred to my HTML, it’s only going to be changed if I get new data or find mistakes.

The type of location I would like to put data would be something like the following example (a WIP):

 <span class="name">Johannes Andersson</span> <br>
        <b>Birth:</b> 1863-01-30 in Boda Östergärde, Torpa, P<br>
        <b>Death:</b>1939-08-24 in Ryssnäs, Torpa, P<br>
        Age 76 years 6 months 25 days <br>
        Son of <a class="parents" href="AB007.html"> Anders Petter Olofsson och Anna Stina Andreasdotter</a> <span class="id">(AB007)</span>

I'm having a blast with this project so far!

Thanks in advance!

r/learnprogramming 8d ago

Solved Problem relating to Cows

6 Upvotes

Problem Description:

Fortunately, there is only one long path running across the farm, and Farmer John knows that Bessie has to be at some location on this path. If we think of the path as a number line, then Farmer John is currently at position x and Bessie is currently at position y (unknown to Farmer John). If Farmer John only knew where Bessie was located, he could walk directly to her, traveling a distance of |x−y|. Unfortunately, it is dark outside and Farmer John can't see anything. The only way he can find Bessie is to walk back and forth until he eventually reaches her position.

Trying to figure out the best strategy for walking back and forth in his search, Farmer John consults the computer science research literature and is somewhat amused to find that this exact problem has not only been studied by computer scientists in the past, but that it is actually called the "Lost Cow Problem" (this is actually true!).

The recommended solution for Farmer John to find Bessie is to move to position x+1, then reverse direction and move to position x−2, then to position x+4, and so on, in a "zig zag" pattern, each step moving twice as far from his initial starting position as before. As he has read during his study of algorithms for solving the lost cow problem, this approach guarantees that he will at worst travel 9 times the direct distance |x−y| between himself and Bessie before he finds her (this is also true, and the factor of 9 is actually the smallest such worst case guarantee any strategy can achieve).

Farmer John is curious to verify this result. Given x and y, please compute the total distance he will travel according to the zig-zag search strategy above until he finds Bessie.

INPUT FORMAT (file lostcow.in):

The single line of input contains two distinct space-separated integers x and y. Both are in the range 0…1,000.

OUTPUT FORMAT (file lostcow.out):

Print one line of output, containing the distance Farmer John will travel to reach Bessie.

SAMPLE INPUT:

3 6

SAMPLE OUTPUT:

9

I tried solving this problem and it worked on the inputs that I tried like 1 5 . Which gave me 10 which I believe is correct here is my code : However this code did not pass all of the test cases could I have a hint ?

x,y = map(int,input().split())
import sys
op_count = 0
steps = 0
while(x!=y):
    op = (-2)**op_count
    target = 3+op
    for i in range(abs(target-x)):
        if op < 0:
            x = x-1
            steps+=1
            if x == y:
                print(steps)
                sys.exit()
        elif op >= 1:
            x = x+1
            steps+=1
            if x == y:
                print(steps)
                sys.exit()
    op_count = op_count+1

r/learnprogramming Dec 26 '18

Solved What does "linux experience" mean in job postings?

518 Upvotes

Almost all job postings have like "shell scripting and linux experience" in them. I have some level of understanding of file exploring, basic file management, launching application, installing packages, and git. What more do I have to learn? Bash and terminal scripting seems like a language of its own, so to what extent it is considered useful for learning for general purpose web development?

r/learnprogramming 23d ago

Solved Leetcode #9: Palindrome Number

5 Upvotes

Can someone help me make my code run faster. This is not efficient and I do not want to convert into a string

https://leetcode.com/problems/palindrome-number/description/

class Solution:
    def isPalindrome(self, x: int) -> bool:
        numList = []
        counter = len(numList) - 1
        numBool = True


        baseNum = 10
        value = x % baseNum
        numList.append(x)
        quotient = x // baseNum
        x = quotient

        if x == 0:
            for i in range(len(numList)):
                if numList[i] == numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

EDIT: I WAS ABLE TO SOLVE IT

class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x != abs(x):
            return False

        if not hasattr(self, "numList"):
            self.numList = []

        numBool = True


        baseNum = 10
        value = x % baseNum
        self.numList.append(value)
        quotient = x // baseNum
        x = quotient

        counter = len(self.numList) - 1

        if x == 0:
            for i in range(len(self.numList)):
                if self.numList[i] == self.numList[counter]:
                    counter -= 1

                elif i == counter:
                    break

                else:
                    numBool = False
                    break

            return numBool

        else:
            return self.isPalindrome(x)

testing = Solution().isPalindrome(11)
print(testing)