/r/learnprogramming
A subreddit for all questions related to programming in any language.
If you need help debugging, you must include:
See debugging question guidelines for more info.
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.
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.
When posting some resource or tutorial you've made, you must follow our self-promotion policies.
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.
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.
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.
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.
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.
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.
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".
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.
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.
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
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
/r/learnprogramming
I am in my first year of engineering, all i have learned till now is C. So we got an assignment to create a word doc on any topic of our own wish related to 'OOP', i forgot about it and i have submission 2 days later, i dont know where to start, can anyone please guide me?, someone suggested me to do it on encapsulation as it is very similar to structure edit: sorry for the typo 'oops', just my habit kicked in
Hope you all like it and suggest ways to improve myself
link to channel: https://www.youtube.com/@BugSlay
Hi, I've created a class of button and want to apply a style to every button within this class. However, I'm a beginner with C# and XAML, and so I'm quite clueless as to how to create a style template that can be applied to the class as a whole, then built upon individually. Each of my attempts hasn't resulted in any build errors, but when the program is run, the button is just displayed in the default format.
If possible, I'd be really grateful for any suggestions as to what I can do, thanks!!
I've been pursuing a Computer Information Science degree since last fall, and I'm starting to lose motivation. This degree would be my second, and I started coding because it piqued my interest, and seemed like a good career change opportunity. I don't code for fun, I don't work on side projects. The extent of coding I get done is almost entirely schoolwork (and now work) based.
I recently landed a job as a Data Analyst and I get to code a bit at work which is satisfying, but I find my motivation for school and coding is gone. I worry that I wasn't in love with coding, I was in love with the idea of adding skillsets until I found a new job. How can I find out if coding/software development is truly for me?
Hi everyone! I'm in my 3rd year of CS and looking to dive into mobile app development. I have moderate experience building web projects using React, Node, and Express. What would be a good tech stack to start with for mobile apps? Any frameworks, tools, or tips you’d recommend for a beginner? Appreciate any guidance !
I saw a video about RollerCoaster Tycoon video game that is written Assembly, where the video creator stated that it's very fast due to this. If all compiled languages that are compiled into machine code and note some intermediary code like Java bytecode, why there are differences in performance between them?
I'm doing course from University of Michigan on Coursera, about API in Python.
Task is to get plus code for "University of Arkansas". In example they give "South Federal University" and plus code is "6FV8QPRJ+VQ". My code gives out the same thing. Yet my answer about "University of Arkansas" is incorrect.
I know my code is full of flaws, I just need the answer.
Here is my code(I use PyCharm):
import urllib.request, urllib.parse
import json, ssl
# Heavily rate limited proxy of https://www.geoapify.com/ api
#serviceurl = 'https://py4e-data.dr-chuck.net/opengeo?'
serviceurl = 'http://py4e-data.dr-chuck.net/opengeo?'
# Ignore SSL certificate errorsa
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
while True:
address = input('Enter location: ')
if len(address) < 1: break
address = address.strip()
parms = dict()
parms['q'] = address
url = serviceurl + urllib.parse.urlencode(parms)
#print('Retrieving', url)
uh = urllib.request.urlopen(url, context=ctx)
data = uh.read().decode()
print('Retrieved', len(data), 'characters', data[:20].replace('\n', ' '))
try:
js = json.loads(data)
except:
js = None
if not js or 'features' not in js:
print('==== Download error ===')
print(data)
break
if len(js['features']) == 0:
print('==== Object not found ====')
print(data)
break
# print(json.dumps(js, indent=4))
lat = js['features'][0]['properties']['lat']
lon = js['features'][0]['properties']['lon']
print('lat', lat, 'lon', lon)
location = js['features'][0]['properties']['formatted']
print(location)
#print('Retriving', url)
data = urllib.request.urlopen(url).read()
#print('Retrived', len(data), 'characters')
js = json.loads(data)
plus_code = js['features'][0]['properties']['plus_code']
print("Place code = ", plus_code)
# print(json.dumps(js, indent=4))
# print('Place id', js['results'][0]['place_id'])
#University of Arkansas
builder.Services.AddControllersWithViews(options =>
{
options.Filters.Add(new Microsoft.AspNetCore.Mvc.AutoValidateAntiforgeryTokenAttribute());
});
If I have this code in my Program.cs-file ^^. Will all my Controller-methods automatically be protected from CSRF and XSS attacks by default? Or do I have to add:
[ValidateAntiForgeryToken]
... infront of all my methods?
I'm luckily not interested in using leetcode to get a job, I did like just hopping on once or twice a day and solving a small problem for a short amount of time.
My issue with leetcode is the difficulty ranges from 'this is a trivial problem' to 'oh if you know this trick its easy i guess, but who would know something so esoteric?', for example:
https://leetcode.com/problems/roman-to-integer/description/
is classified as an easy, but if you take a look at the solutions / commentary, I think the sentinment agrees this was far from easy, I found this out after about an hour+ of sinking into the problem.
Either way, what I'm asking for likely doesn't exist, but would be neat if it did.
I'm trying to store many mp3 files into a website's database. Is there a more efficiency way to do this?
Hi there! I'm mostly a C and x86_64 assembly dev who's been dabbling in Rust, but I had a random idea - write a very small project which I'm very familiar with, an LCG PRNG, once in a bunch of different languages.
A PRNG, if you don't know already, is a pseudo-random number generator, and is essentially a group of algorithms which define how computers generate "random" numbers. Note the quotes and the word pseudo because they aren't really random - they start with a seed value, which is often the time, then generate the next random number based on that, the next one based on that previous one, and so on. LCG, or linear congruential generator, is a very very simple algorithm for PRNGs (see the wikipedia page here: https://en.wikipedia.org/wiki/Linear\_congruential\_generator).
My concept is this: A very very simple program, a PRNG, implemented in various different languages (so far: x86_64 NASM assembly, C, C++, Rust, Java, Go, JavaScript, and Python), which makes for a very easy way to learn the syntax. No heavy commenting besides one at the start of the file and at the start of each function, no huge explanation, no complicated concepts of the language. Just the essential syntax.
Hopefully this is useful to at least one person. Please note that I am not an expert at all these languages, and as I've said near the start, most of my knowledge is in C and Assembly, meaning that some of the implementations in other languages may not be perfect. If you see something wrong, feel free to leave a comment or open a pull request.
Here's the link btw: https://github.com/UnmappedStack/PRNG-in-X
Sorry if this sounded spammy, that genuinely wasn't the goal and I believe I have complied with all the server rules.
It was working at one point, and all of the sudden it's not working anymore. I am not sure what changed, maybe I did something
Can anyone help me?
I am using the api to add videos to a youtube playlist
googleapiclient.errors.HttpError: <HttpError 400 when requesting` [`https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&alt=json`](https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&alt=json) `returned "Precondition check failed.". Details: "[{'message': 'Precondition check failed.', 'domain': 'global', 'reason': 'failedPrecondition'}]">
This is for a brand channel
hello there this may sound idoitic but for some reason i am not finding programming engaging and im getting lazy over it. I have good knowledge over some of the programming language like C++,C, python and little bit in java. so can you suggest me to make programming more addicting for me i want to make it my addiction..
Edit2: I've worded many parts of this post in a bad way, so now this is basically my conclusion/decision to hopefully clear up my question.
--How should I go about creating my own implementations of "data structures, methods, and algorithms"
before learning them?--
the main purpose of my post was to figure what I wanted. I thought I wanted to learn basic functions in C to try recreate data structures.
I've now come to realize that I only want to create my own implementations of existing data structs, algorithms, and methods.
I've decided to roughly to follow idea 2, and along with some suggestions/guides from others.
Yapp (this is just me yapping)
honestly the rest of my post from here has become a mess and confusion to anyone trying to read and know what I'm asking. I'm considering restructuring the whole thing to clean it up but that will probably make it worse.
I have my answer now and my post is [SOLVED] so I will just leave it alone.
thanks to everyone for the help, and suggestions. my wishes have been fulfilled and my gratitude shall be.., for as long as I remember.
---
Edit1: After reading some of the replies I have a better idea of my question
-what fundamentals (in C or other lang) like pointers, memory allocation, etc..
do I need to know to try create my own implementations of common data structures.
I will be learning them in my own time I would just like a rough list of which functions and concepts are used to make the data structures without learning the data structures themselves.
I know what I want but I don't know the right question but basically..
I want to try and create data structures (in C),
Without learning them or following a tutorial.
so no prior knowledge on how to make them but I know generally what they are (lists, arrays, dicts, ...) and the basic methods (append, insert, delete, etc..).
Sort of like re-inventing the wheel,, maybe?(idk).
If anyone (that's learnt data structures and such) thinks this is a fools errand and has an alternative suggestion they think is better please write. I'm open to suggestions and not absolutely set on this path.
I will be searching for materials and thinking of ways to do this. I'm just posting in here because it will be a lot easier for someone who already knows the structure and insights of data structures to tell me what is needed before I learn the data structures.
My first idea of navigating this is to learn the things you need to know to make/write data structures..
(pointers, the stack, and functions that work with those)
I don't know much of the things (functions, structures, etc) needed to write them,
because learning about those would probably include learning a data structure which I want to try
create myself without prior knowledge.
I will do some searching for those after this post.
- then choose a data structure and see what it does on the surface, basic input and output
and try to recreate the 'inner' code for the data struct and then the methods for that struct
edit1()
learn 1 or two of the basic data structures then look at a 3rd one and how it works but not how to implement it.
and create my own implementationand what it does from a surface level perspective and try to recreate the inner workings .
-some may think it's 'better' (more efficient) to just learn them and focus on how to utilise them. But this is just something I think will be fun..
If anyone would be so kind to humor me. I would be much obliged. ;)
side notes
programming is a hobby for me. I've briefly learned the basics of python3, and have done a handful of scripting projects(AHKv2). So I'm not really worried about trouble learning the fundamentals of C but more-so focused on knowing what I need to learn.
I am considering to do the same with sorting-algorithms and the like. if anyone has any comment on that but I think I'll save that for another time/post.
Is there anyone here who knows App Lab and can create an app for me?
Quick about me:
I am a self taught iOS developer and my main focus was learning about the massive apple frameworks and the language itself. I had no desire to do anything outside of iOS, so I spent all my time there.
I landed my first role as a junior iOS developer and boy do I regret not learning the computer science part of it. I knew nothing about CI/CD, the minimum on JavaScript, databases, networking, etc.. I still handled the job well and got by, but unfortunately is out-of-state developers were part of the mass layoffs.
I have an opportunity now to develop these skills before I go back in the workforce, but I do not know where to start. Any suggestions would be much appreciated, and any other experiences from iOS developers out there that might help. Thank you.
p.s. is it normal now for juniors not get much help from the seniors? I thought that was the point of being a junior.. a little mentorship. They told me those days are done..
I hereby salute you dear coding veterans. I would like to know what type of advice you would give to someone who would like to start coding 1- The tools that he can download (for free if possible XD even for the courses with certificates) 2- The mindset he needs to have and books he may read 3- The skills he should have beforehand 4- What he should more importantly start with
I know you have read such posts a million times but I do really need your help since I really would like to learn such a skill as I've always found it impressive and would like to give a huge shot
Well as the title says I’m 24 years old mechanical engineer, I currently work within my major so far it’s good fair payments etc, Since my graduation project has been ML related I got briefly introduced to python which i liked alot, I always read articles when I have the time about AI/ML/DATASCIENCE etc Is it worth it to self-learn those things with only 2-4 hours on my hand or will i be too late for the field by the time I get good at medium level concepts? or is there any other approach?
If they are good at programming and claim that they can make you a "master" at a certain concept, why they try so hard to make you buy a course instead of going out there and actually using their skills to get a real/more interesting software developer job... No hate tho just genuinely curious.
Hello everybody.
I'm a beginner in programming. I did some novice web development in my life but nothing crazy. I like to watch web development related content, and one word I hear a lot is "Framework", followed by examples such as React, Laravel, Next.js, Spring, etc...
I have several questions regarding that :
Thanks.
What should i cover to do good on c programming exam
Tomorrow 10am is my exam and i have covered syllabus till 1d array and basics of string and this Is syllabus
Final Examination Information Duration – 2 to 2:30 hours Format – Closed book in two parts Part-I (50% weightage) MCQ –covers the material from the whole course. Negative marking (+3, -1 for each question) Part-II (50% weightage) Questions in the form of writing short codes, fill in the blanks, compute the output of the code fragment, find error in the code, and a few descriptive questions. Topics:
Pointers, arrays, strings, relationship between pointers and arrays, array of strings, 2-d arrays, pointer to pointers. Structures. Functions, command line arguments, recursion, linked list. File handling, bitwise operators, function pointers, dynamic memory allocation
I’m planning on covering syllables first from college wallah playlist….should i?? And I don’t have any source for questions or should i just focus on covering syllables
I saw a post about breaking down problems while learning instead of just looking at the answer or using AI to solve problems. So I had an idea and asked code tutor on chat GPT to give me a problem and I solved it with pseudo code. Just typing it out and getting feed back for mistakes. Obviously typing on your phone code is a pain, the pseudo code makes it easier, and it’s good practice.
I just need some sort of guide because I feel overwhelmed with the amount of stuff available on the internet. Just a basic idea on what al I should learn and prioritize in a time frame would be very helpful. Thanks
How to get good at recursions and backtracking questions? like the ones where you generate some particular permutations and combinations based off some conditions already given cuz there's no way i can picture every step in my brain
I really struggle to make projects if they aren't actually used by real people.
I've made a lot of Roblox games because they actually get played, which is a huge motivator for me. I want to make projects that aren't games though, like apps and websites. Problem is, it feels like these are much less likely to get real users. And there is a lot more responsibility and money involved in those.
This is really demotivating for me. I just have a hard time making things without having a real user experience. Any advice?
I've been starting to learn Python and working on some data science, and the problem (more like a nice thing to have) is that when I create plots using matplotlib.pyplot
they are actually not centered.
What I mean by that is that the box that contains does not have the same number of pixels/same space around all the 4 edges of the picture.
A MWE of that is this:
import matplotlib.pyplot as plt
x = list(range(10))
fig, ax = plt.subplots()
ax.plot(x, x)
ax.set_xlabel("X axis")
ax.set_ylabel("Y axis")
fig.savefig("test.png")
If you check the number of pixels between any of the edges and the black box containing the data you can see that by default is not the same. I tried looking around for a way to fix that but what I've found is really complicated and out of reach right now.
It seems like it should be something that could be expected to be implemented. So is it there a short implementation of something like that?
Firstly, I am autistic. I've tried to learn java from more “traditional” languages (C# & Python), but I just can't understand java and OOP in general. I just want to learn enough to make Minecraft mods (Minecraft subs told me to post here instead), so does anyone have anything that could help me understand java? My main problems are with general OOP and Javas buses.
I’m learning to code through a course on udemy and when the instructor tells me to try to tackle a coding problem by myself, I immediately look at the solution then type the code by memory… when I get stuck again, I go back to the solution and back to the task. I even practice on previous coding challenges; doing them by memory, but I don’t look at the solution because the coding makes sense.
Is this an effective or ineffective way to learn programming?
So I came across https://github.com/codecrafters-io/build-your-own-x?tab=readme-ov-file#build-your-own-git and part of me wants to get into it and start doing a boat load of projects in my free time but these are all just tutorials... wouldnt that just lead me to tutorial hell?
I'm wanting to make projects to help me learn more about programming but feel these are all just tutorials and I wont learn as much as if I when off and tried to do it all myself. Just loaded up a IDE and tried to make a CML game with out following a tutorial..
I dont know im conflited.
I’m looking to start the 100 days of code by replit course, i am preparing for interviews in about 4-5 months. after i finish this course, what courses should i start? I want to build as much full stack knowledge as possible and of course acquire skills in the languages i will be learning. Thanks!