/r/learnprogramming

Photograph via snooOG

A subreddit for all questions related to programming in any language.

Welcome to LearnProgramming!


New? READ ME FIRST!

Posting guidelines

Frequently asked questions

Subreddit rules

Message the moderators


Asking debugging questions

If you need help debugging, you must include:

  1. A concise but descriptive title.
  2. A good description of the problem.
  3. A minimal, easily runnable, and well-formatted program that illustrates your problem.
  4. The output you expected, and what you got instead. If you got an error, include the full error message.

See debugging question guidelines for more info.

Asking conceptual questions

Many conceptual questions have already been asked and answered. Read our FAQ and search old posts before asking your question. If your question is similar to one in the FAQ, explain how it's different.

See conceptual questions guidelines for more info.

Other guidelines and links

  1. Frequently asked questions
  2. Asking homework questions
  3. Asking for code review
  4. Answering questions
  5. Learning resources
  6. Other communities

Subreddit rules

1. No unprofessional/derogatory speech

  • Follow reddiquette: behave professionally and civilly at all times. Communicate to others the same way you would at your workplace. Disagreement and technical critiques are ok, but personal attacks are not.

Abusive, racist, or derogatory comments are absolutely not tolerated.

See our policies on acceptable speech and conduct for more details.

2. No spam or tasteless self-promotion

In short, your posting history should not be predominantly self-promotional and your resource should be high-quality and complete. Your post should not "feel spammy".

Distinguishing between tasteless and tasteful self-promotion is inherently subjective. When in doubt, message the mods and ask them to review your post.

Self promotion from first time posters without prior participation in the subreddit is explicitly forbidden.

3. No off-topic posts

  • Do not post questions that are completely unrelated to programming, software engineering, and related fields. Tech support and hardware recommendation questions count as "completely unrelated".

Questions that straddle the line between learning programming and learning other tech topics are ok: we don't expect beginners to know how exactly to categorize their question.

See our policies on allowed topics for more details.

4. Do not ask exact duplicates of FAQ questions

  • Do not post questions that are an exact duplicate of something already answered in the FAQ.

If your question is similar to an existing FAQ question, you MUST cite which part of the FAQ you looked at and what exactly you want clarification on.

5. Do not delete posts

  • Do not delete your post! Your problem may be solved, but others who have similar problems in the future could benefit from the solution/discussion in the thread.

Use the "solved" flair instead.

6. No app/website review requests or showcases

  • Do not request reviews for, promote, or showcase some app or website you've written. This is a subreddit for learning programming, not a "critique my project" or "advertise my project" subreddit.

Asking for code reviews is ok as long as you follow the relevant policies. In short, link to only your code and be specific about what you want feedback on. Do not include a link to a final product or to a demo in your post.

7. No rewards

  • You may not ask for or offer payment of any kind (monetary or otherwise) when giving or receiving help.

In particular, it is not appropriate to offer a reward, bounty, or bribe to try and expedite answers to your question, nor is it appropriate to offer to pay somebody to do your work or homework for you.

8. No indirect links

  • All links must link directly to the destination page. Do not use URL shorteners, referral links or click-trackers. Do not link to some intermediary page that contains mostly only a link to the actual page and no additional value.

For example, linking to some tweet or some half-hearted blog post which links to the page is not ok; but linking to a tweet with interesting replies or to a blog post that does some extra analysis is.

Udemy coupon links are ok: the discount adds "additional value".

9. Do not promote illegal or unethical practices

  • Do not ask for help doing anything illegal or unethical. Do not suggest or help somebody do something illegal or unethical.

This includes piracy: asking for or posting links to pirated material is strictly forbidden and can result in an instant and permanent ban.

Trying to circumvent the terms of services of a website also counts as unethical behavior.

10. No complete solutions

  • Do not ask for or post a complete solution to a problem.

When working on a problem, try solving it on your own first and ask for help on specific parts you're stuck with.

If you're helping someone, focus on helping OP make forward progress: link to docs, unblock misconceptions, give examples, teach general techniques, ask leading questions, give hints, but no direct solutions.

See our guidelines on offering help for more details.

11. Don't ask to ask.

  • Ask your questions right here in the open subreddit. Show what you have tried and tell us exactly where you got stuck.

We want to keep all discussion inside the open subreddit so that more people can chime in and help as well as benefit from the help given.

We also do not encourage help via DM for the same reasons - that more people can benefit

12. Low Effort Questions

  • Do not ask easily googleable questions or questions that are covered in the documentation.

This subreddit is not a proxy for documentation or google.

We do require effort and demonstration of effort.

This includes "how do I?" questions

13. No AI (chatGPT etc.) generated messages/comments. No questions about chatGPT/AI generated code.

  • Such posts/comments will be removed without warning and the poster of ai generated content will be instantly banned.

/r/learnprogramming

4,155,627 Subscribers

6

I think I just found a reason to shut myself up, stop complaining and start studying more.

While trying to learn how to program using the internet, I would always feel anrgy because there was never a straightforward tutorial. I always need to search on multiple sources, forums, videos. But then I thought and said to myself: "You didn't want to go to college. They probably teach everything you need to know there but you don't want to go. That is why you have to seek so many different sources. If you don't want to pay for college, shut up and keep searching on the internet instead!"

So that is what I am going to keep doing.

Also, I would like to know from those who went to college here, am I right on this thought?

13 Comments
2024/12/13
19:02 UTC

0

Learning Coding with a Mobile App

So I'm a 1st year BS Information Technology student and I'm wondering if the app "Programming Hub: Learn to code" is good for learning C (this is the language our program is also teaching us). I am currently struggling a lot with the activities handed to us by our professors and I am not good at creating programs based on the problem exercises they give us. I can't really solve them without asking ChatGPT for help. So I'm thinking of using the app I mentioned to learn more about coding along with the resources our school provides plus the youtube tutorials. Is the app a good help? Or are there better ways (or apps) that can help me with my problem?

2 Comments
2024/12/13
18:37 UTC

1

Can someone suggest any computer field related to somehow finance ??

hello guys i m persuing CS from SPPU.....i just want to be in a computer field which is related to finance....

correct me if i am wrong ...

DOES BLOCKCHAIN IS RELATED TO FINANCE???

4 Comments
2024/12/13
18:34 UTC

1

Security Tips for Python Program: How to Close Vulnerabilities?

Hey everyone,

I built a small Python program that runs locally and pseudonymizes/anonymizes data. It also has database interfaces, and so far, everything works fine (no crashes or errors šŸŽ‰).

Now Iā€™m wondering: How can I make sure itā€™s actually secure?
Iā€™m not an IT expert and donā€™t know much about ā€œclean codingā€ or security standards. But since it handles sensitive data, I want to make sure there are no vulnerabilities.

Questions for you:

  • Any best practices for something like this?
  • How can I test if everything is secure?
  • What should I watch out for with database interfaces?

Iā€™d appreciate any tips you have!

Thanks a lot šŸ™Œ

0 Comments
2024/12/13
18:23 UTC

1

What interesting things and realizations have happened, or are happening, at different stages of learning from you?

What's the coolest thing you've had happen in your mind during the zen phase of learning? I've recently learned declarative programming, although I still sin with imperative programming, I can't get out of the habit of writing a complete algorithm from scratch. It looks especially dumb when I find a one-line implementation later.

1 Comment
2024/12/13
18:14 UTC

1

Question about using C and C++ files together

There was an interesting problem (for me) with C and C++ files that was fixed in a way I don't understand. I would love it for someone to explain a little bit how this actually works (and if it's proper usage):

Basically I have C library that needs to run some C++ class's code. But the C file does not include any C++ files.

myCFile.c:

SetSwitchValue( 0 );

myCFile.h:

#include "extern.h"

extern.h:

extern void SetSwitchValue( unsigned char value );

The .cpp files:

Connector.cpp:

#include "Connector.h"
extern "C" void SetSwitchValue( unsigned char value ) {
  // some code
}

Connector.h:

extern "C" void SetSwitchValue( unsigned char value );

That's the setup and it compiles. Nowhere in the C source and header files is Connector.h ever included. When I did add #include "Connector.h" directly in myCFile.h without going through extern.h, there were errors, mainly:

Connector.h:18:8: error: expected identifier or '(' before string constant
   18 | extern "C" void SetSwitchValue( unsigned char value );

Why is this the case? Why does one work when the other doesn't? What's happening with the compiler?

Thanks in advance!

(Edited in an error I received).

2 Comments
2024/12/13
17:56 UTC

16

Tutorials vs Documentation: What Works for You? šŸ¤”

So, my friend hit me with this: ā€œReal programmers learn from documentation, not tutorials.ā€ šŸ§‘ā€šŸ’»

I am not a beginner.

But honestly, I feel like I understand concepts better when watching tutorials. They give me a step-by-step breakdown, and I can follow along without feeling overwhelmed. On the other hand, diving straight into documentation feels intimidating and too abstract sometimes. šŸ˜“ but documentation has more content than tutorials .

What do you think? Is it a bad practice to rely on tutorials?

Iā€™m curious about your learning styles?

Do you stick to documentation from the start? Do you mix tutorials and documentation? Or do you have a completely different approach?

30 Comments
2024/12/13
17:33 UTC

1

For spring microservices is it more common to use cloud services like service bus and api gateway or springs built in cloud features?

Seems like these are both valid ways to build microservices.

0 Comments
2024/12/13
17:11 UTC

10

I'm tired of Front-End Development. I've lost my passion and need something more exciting.

TL;DR: I'm a first-year computer science student who's been learning front-end development for two years, but I'm burned out from working on layouts and animations. I want to explore something more engaging with possibility to build huge projects.

Hi, I'm a first-year computer science student from Poland. I've been learning front-end development for about two years, on and off. I know HTML, CSS, and JavaScript well. I also know how to work with SQL databases using PHP and have a basic understanding of React. Thanks to my college and high school, I've learned the syntax and general basics of C++ and Python, though I havenā€™t tried applying them to practical projects yet. I've just made some easier console apps and solved few leetcode problems with these two.

Over the past few years, Iā€™ve completed many web projects, starting with simple forms, followed by Odin Project exercises like Tic-Tac-Toe, and even larger websites, such as a fully usable gym site with login system or an online store with huge database.

The problem is that constantly choosing matching fonts, centering divs, and adding dark modes has become exhausting. It feels like the only thing left for me is learning more libraries and frameworks to make my code faster and my websites prettier. But creating smoother button animations no longer gives me satisfaction, to the point where nowadays, I only log in once every few days to do one or two LeetCode problems.

Iā€™m the kind of person who loves expanding projects and adding new features. The project Iā€™ve spent the most time on was a console-based RPG game in Python. I worked on it every day for weeks, adding new bosses and weapon upgrades, and to this day, itā€™s the most exciting thing Iā€™ve ever worked with.

Next year, Iā€™ll have to choose a specialization for my college (I don't know about the USA computer science, but in Poland there is something like specialization where you have to choose what exactly do you want to learn). The options are: Software Engineering and Mobile Technologies, Cybersecurity, and IT Systems Implementation. Obviously, Iā€™m 99% sure that I am going to choose the first option since Iā€™ve already spent hundreds of hours coding. Do you think itā€™s a good idea to start learning Kotlin/Java now to prepare for mobile technologies? Or do you have other suggestions for a learning path that could bring me joy and excitement? I have never been good at math and physics, so probably gamedev, or machine learning are not the best ideas for me.

8 Comments
2024/12/13
16:59 UTC

5

Resources to learn DSA with practical applications? Ex: building auto completion with Trie, etc

Everything seems to be too dry and abstract, whereas building something which is actually useful helps to understand far better.

I'm not a cs grad, doing for some general knowledge.

I wish to find some more examples alongside:

  1. alpha beta pruning for chess engine
  2. trie for auto completion

And such, which can serve both theoretical and practical purposes, tired of generic examples spread all over the internet.

2 Comments
2024/12/13
16:44 UTC

0

Issue with hosting Project on GitHub

Hello to everyone,
Im pretty new to web dev and working with GitHub(still a learner). I made a project using Node.js using Express.js and i included EJS for templating. I waas working with Axios for aking HTTP requests as well. (It was a homework so i needed to use those technologies)
Im done with project and i wanted to post in on my GitHub account, did everything as i should, but when i opened the link oh GitHub it shows error 404.
Apparently GitHub cant work with EJS because its not a static file?? or at least thats what ChatGPT is saying.
Does anyone have some tips or knows what is the best way to fix this issue?

Thanks in advance all, and sorry for my English.

1 Comment
2024/12/13
16:27 UTC

2

Best resources to learn Python (ultimately, machine learning)?

Hey people, hope you're having a great day;

I wanted to ask which are the best resources out there for learning and mastering python, i started with R since my field would be data analysis and prediction projects (i guess ultimately neural networks [i apologize for my apparent ignorance, that's why i'm here]) but i found out Python has everything R can do and much more.

As of right now i have already taken the Introduction and Intermediate Python courses on DataCamp, i plan to go ahead with Data Manipulation with pandas and matplotlib, to then go for Statistics in Python and ultimately Introduction to Machine Learning in Python; i am also planning to participate in Kaggle tournaments but i just want to make sure this is the right track.

(I have seen the first few videos of CS50, but i don't like my rhythm being dependent on a video, i have my own pace and would like better to learn in the most practical way, i need to see the objective or the functionality of something in order to fully understand; i know CS50 has its own environment and its own mini projects for learning but i need something more dynamic, to me, the best way to learn is by fucking up.)

My ultimate goal is literally to be a problem solver, i want to be able to build projects regardless of the field, be it marketing, marine biology, trading, economics, optimization of any kind, etc. As you can probably guess i am pretty new to this, i barely started this journey on december 10th.

I do not want to discard any alternative, be it learn other languages, go to another platform, or rectify my idea of what i need to do in order to achieve my goal; i live in a country where data science and programming is really neglected and want to show people within my reach how big this field is and how it will be the future of everything, i have always thought that in 5 years, not knowing how to program will be the equivalent to not knowing how to read in medieval times.

All feedback is appreciated, be it negative or positive.

Thank you

6 Comments
2024/12/13
16:27 UTC

1

Is blockchain worth learning??

Hey guys i am newbie and wanna know that blockchain is really worth learning ??

suggest me a better course with certification

23 Comments
2024/12/13
15:46 UTC

0

Learn Python in 1 week?

Iā€™ve got an exam in 1 week that I haven't studied for enough in programming 2(python).

I know there are plenty of AI tools made to help you learn things. But Iā€™m not totally sure how to make the best use of them.

Can you share how you would utilize AI tools to learn programming in 1 week? Canvas? Custom GPT's? Specific prompts? I am looking for something that helps you actively learn.

Thanks!

15 Comments
2024/12/13
15:01 UTC

3

something like batch thatdoesn't require admin rights

I ve written code in R ( like python). I want non coders to execute it without accessing R through batch file. but we dont have admin right. is there another way?

9 Comments
2024/12/13
14:59 UTC

2

#define GPIO_PORTF_DATA_R (*((volatile unsigned long *)0x400253FC))

I hate pointers and need someone to explain this to me

first of all this is pulled from tm4c123gh6pm.h file made by texas instruments for that tiva c model

using Standard C 99

this makes GPIO_PORTF_DATA_R handled as a normal Variable in the code, my issue is, i dont understand how is this done through this pointer configuration

and i want to know how to call suh an address Variable in a function

like for example setBit( * uint32_t DeclarationMightBeWrong , uint8_t shiftingBit){}

and how do i assign it to another variable?
Register* = &GPIO_PORTF_DATA_R; ?

again i hate pointers

5 Comments
2024/12/13
14:45 UTC

1

Pulling my hair out with this Google API

Iā€™m building a webapp to create and issue digital passes, and so far iā€™ve got it set up to issue the passes but the custom fields I want to add are added to the back of the pass in the details, and not shown visibly on the front.

Anyone dealt with creating passes with the Google Wallet API? Any pointers would be much appreciated!

I release this is a long shot but I would really love some help! Claude and ChatGPT are both stuck in doom loops trying to figure it out.

Thanks!

0 Comments
2024/12/13
14:36 UTC

4

Whatā€™s your experience level and how often are you using Google/GenAI for questions?

Recently started a new role as a data analyst. Although Iā€™ve been writing code since 2020, I still sometimes feel like a newbie, especially when I go back to using a language I havenā€™t used in a long time. How often are you using Google, GenAI, and what are you generally looking for answers to?

8 Comments
2024/12/13
14:07 UTC

3

What did I do wrong?

Iā€™m seriously considering of going to a coding bootcamp next year and just started learning python on the sololearn app. Iā€™m currently stuck on a practice test just because it didnā€™t exactly teach me how to implementing the input().

ā€”To those learning on that app, be aware of spoiler/solution for the following!ā€”

Iā€™ve tried everything. So how do I supposed to ask the user for input, storage it in the name variable, and display it on the screen?

It provided two input examples ā€œTomā€ ā€œBobā€ With expected outputs being Tom and Bob, obviously.

I wrote like this:

#Ask the user for input and store it in a variable name = input() name2 = input()

#Display the user input on the screen print(name) print(name2)

I keep getting an EOF error. Help! šŸ˜…

I even tried name = input(ā€œEnter your name:ā€)

Snake cases too

Edit: These both input() and both print() are supposed to be in new string but Reddit arranged it wrongly. Also these large bold sentences were supposed to be statements lol

4 Comments
2024/12/13
13:39 UTC

23

I just want to learn programing and I need a reason.

Iā€™ve always wanted to learn programing but I canā€™t find a good reason to. I did my BA in civil engineering but didnā€™t like it and I sucked at it. So I became an English teacher because I enjoyed it and it was the only other thing I was good at. Iā€™m 35 now and Iā€™m full of passion for making things. For doing something fun and learning new things. I really like music and Iā€™m learning how to olay the electric guitar. Iā€™m learning a new language other than English( First language is Farsi). I love playing video games and at one point wanted to learn C++ to make video games but I didnā€™t. Now, Iā€™m thinking of learning how to make websites so I can promote and boost my wifeā€™s business.

Iā€™ve been learning Python for a few days and Iā€™m really enjoying it. Iā€™ve been told that Python is an easy and a very useful language to start with. But I just donā€™t know what I can do with it. How will it ever be useful for me? Should I just go for web development?

61 Comments
2024/12/13
13:05 UTC

1

Frustrating doubt

class Solution {

public:

int hammingWeight(int n) {

int count=0;

while(n!=0){

if((n|1)==n){

count++;

n = n>>1;

}

}

return count;

}

};

Please tell me why its not working, count + (n&1) will work obviously but why not this? where's the problem? Is there any specific example or just somethinggggg....

2 Comments
2024/12/13
12:54 UTC

2

How to decide folder structure / architecture for a project to scale?

Hello all,

I'm a Backend Developer and trying to do some basic projects I've seen in roadmap.sh with Typescript/Node.

Every time I start a project, I know what I can do to handle the program's logic flow. For example, I have to take arguments from the user from the CLI, transfer these arguments to the Business logic, and then transfer the data to the database/write them on a file. I usually approach it like the classical structure:

src
-- config
-- models
-- services
-- utils
index.ts 

The thing is, I don't know how to separate these logics to different services/ managers/ utilities/ functions etc. How can I learn this? Most of the project tutorials just simply says "I'll create the ExpenseService" but doesn't tell you why it's a service or a manager. God, I can't even seperate what's a manager and what's a service.

I can't even create a folder structure, and the more I think about it, the more complex it gets. If you read this far, thanks in advance.

2 Comments
2024/12/13
12:53 UTC

0

Odin and App Academy Open

I have completed the foundation of both Odin and App Academy Open. I really like the structure of AAO, but it seems to lack in complex full-fledged projects.

So is it a good idea to complete AAO, and then do all the projects in Odin for learning and portfolio purposes? Thanks.

Also, opinions on App Academy Open are welcome from those who have completed it.

0 Comments
2024/12/13
12:46 UTC

2

How do I interpret duplicate?

I have this homework "problem no. 3" and I have no clue what the correct interpretation of duplicate should be.

"The first number shall be duplicated according to the value of the second number.
A third number shall be created by multiplying the value of the second number to 6
Display the sum of all three numbers using f-strings. Follow the format of the output below:
The sum of all three numbers are sum., where sum is the sum of all three numbers."

if my input is 3,5. Should my output be

3*5+5+5*6
or
33333+5+5*6

at first i thought it was the first one but they used "third number shall be created by multiplying the value of the second number to 6" If they already used "multiply" here why not also the first one instead of duplicate

4 Comments
2024/12/13
11:57 UTC

3

Looking for like-minded people in Python, Machine Learning and Flask to learn and create projects together

Hello everyone!

My name is Nicholas, I am 18 years old and I live in England. I'm looking for people who want to learn, share knowledge and work on projects together. I am open to communicate with people from anywhere in the world, but it would be great if it was mostly people from England, as I would like to be able to meet in person in the future.

I'm learning Python and want to improve my skills with others who already know a bit of the language. My goal is to create projects, share experiences and grow together.

Besides Python, I am also interested in Machine Learning and am looking for people who want to get into this field or are already involved in it to work together on projects and share knowledge. I also want to learn and discuss statistics - would be happy if someone joins.

If anyone is interested in Frontend or Backend (e.g. Flask), that's welcome too. This will give us the opportunity to create quality web interfaces for our projects.

I would also like to add that I am not a native English speaker, and by working in this community I aim to improve my spoken English. I am open to communication, and I think it will help all of us to learn and grow together!

I plan to use Discord for communication and collaboration, so if you want to improve your skills in Python, Machine Learning, Flask or statistics, we'd be happy to work together!

If you're interested, drop me a line in the comments or private messages. I would be glad to meet you and start working on projects together!

My discord channel: https://discord.gg/P4BpbPhU

1 Comment
2024/12/13
11:53 UTC

3

Need some basic JS web dev project ideas!

Hey everyone,

I'm a beginner in JavaScript web development and I'm looking for some project ideas to practice my skills. I've covered the basics like HTML, CSS, and JavaScript fundamentals.

I'm looking for something that's not too complex but still challenging enough to learn new things.

Here are some of the things I'm interested in:

  • Interactive web pages: Creating dynamic pages with user input and real-time updates.
  • Simple games: Building small browser-based games like tic-tac-toe or a number guessing game.
  • Data visualization: Using libraries like Chart.js or D3.js to create visualizations.
  • Web applications: Developing basic web apps, like a to-do list or a simple note-taking app.

Any suggestions or ideas would be greatly appreciated!

Please feel free to share any resources or tutorials that might be helpful.

Thanks in advance!

8 Comments
2024/12/13
11:14 UTC

4

What are some important Coding languages to start learning first ?

Currently i just started to learn HTML I'm not sure how long it's gonna take before i can move on the next language which I'm thinking C++ and then JavaScript, i don't really have a fix goal on what project i want to do, perhaps something like web design or making apps or even cybersecurity which i know nothing on that other than i see it everywhere and that is it in high demand, i would also appreciate some resources where to learn for free that contains practice projects.

26 Comments
2024/12/13
10:04 UTC

1

How do I make an optimized find primes before n algorithm?

The Algorithm for finding if a number is prime is pretty easy, that one is just looping through all the numbers up to the square root of that number and checking if thereā€™s a mod that returns 0. To find all primes up to n you just check each number before n 1 by 1 with our prime finding algo. This is O(n^2) time. Seems easy enough. However, My friend has challenged me to possibly do it in O(n log n) or even O(n) time. I am not sure where to begin though. In order to improve the time to n log n which is what Iā€™m aiming for, I need to find a way to either optimize the determine if prime algo, or the algo for looping through the numbers before n into log n time because both of that are O(n) right now. Anything you can tell me to get me started? Like I donā€™t want the whole algo I just want some hints if that makes sense.

4 Comments
2024/12/13
10:03 UTC

0

Is it a good idea to start the Odin project when I am learning a different programming language in university ?

I am in my first year of university and we are doing Java. Itā€™s just a basic intro to comp sci course, nothing I have not already done in high school. I really want to start the Odin project as I have heard a lot of good things but I also often hear itā€™s not a good idea to learn 2 programming languages at the same time. Would it be a problem for me to be doing JavaScript html css on my own for the Odin project and personal projects when university will have me doing Java for school projects or Should I just stick to Java?

6 Comments
2024/12/13
08:32 UTC

0

Analyzing messages with algorithm (AI?)

Hello. I have a large JSON file with an array of text messages describing specific topic in a simmilar-ish format that looks something like this:

Date: 12.12.2024 15:00
Coordinates: ...
Model: ...
Status: ...

It's written by different people and can be inconsistent, "Date" might be called "Time" or it might be split into 2 lines "Date" and "Time", there might be "-" intead of ":", extra spaces, grammar mistakes ect.

Is there a good way analyze texts to extract relevant data? It needs to be run locally.

16 Comments
2024/12/13
07:33 UTC

Back To Top