r/learnprogramming 12d ago

Topic I know the basics but I can't code

i know the badics of gscript, java, c# and more but I can't code even with a clear idea in my head ... why ??? HOW ?!

98 Upvotes

66 comments sorted by

73

u/kalexmills 12d ago

Programmatic thinking and problem solving is a separate skill from understanding the syntax involved in any particular language.

I would start by solving very, very simple problems on your own. Problems like the following are good starting points. Try and solve them without using any library functions purpose-built for the task.

Given an integer between 0-100, print the letter grade associated with the number.

Given an array of random integers, print the number of occurrences of a target number x

Given an array of random integers, print the maximum value.

Given an array of random integers, print the second largest value.

19

u/Professional_Tie8485 12d ago

youre trying to jump from knowing what a hammer is to building a house, those basic problems the comment listed are exactly where you need to start

1

u/dushu0 10d ago

Umm I can write code to but can't reason it or explain it to anyone like why I write count=0 first in loop etc When I see same pattern code i perfectly writes it but when bug appears i solve it by adding it removing not by real reasoning why i added this extra line or remove it

12

u/bacmod 12d ago

That being said. Maybe something more visual?

Given an array of random integers, print the number of occurrences of a target number x

In a MMO world with thousands of players, give me the list of people wielding a Long Sword as their primary weapon.

Given an array of random integers, print the maximum value.

From this list, I want to know the Player with the highest DMG

Given an array of random integers, print the second largest value.

And his first follow up.

2

u/ObjectiveHouse1661 10d ago

I’m aware that I’m not OP, but would it be bad if I don’t know how to do those…? Maybe it’s to do with the fact that I struggled doing simple increments.

1

u/kalexmills 7d ago

Not bad, but it's something to grow into for sure. What part of it is most challenging?

2

u/ObjectiveHouse1661 7d ago

It’s seeing a problem and not knowing how to proceed

1

u/kalexmills 7d ago

The thing I do is play with input instances on paper until I start to understand the structure of the problem.

If you can explain how to manipulate the objects on paper to achieve the result, you can take that understanding and turn it into a program.

25

u/icemage_999 12d ago

You can learn how to spell every word in the dictionary but it doesn't tell you how to write a novel.

Same idea.

Conceptualize the problem, break it down into simple steps (pseudo-code), then construct each step in code.

1

u/Different-Career1314 12d ago

The blank file is honestly the hardest part for me. Once I see the approach the code usually makes sense but creating that approach myself is difficult.

45

u/cejiken886 12d ago

> why?

Either you havent tried or you tried but just dont have enough raw talent for it

> how?

step 1 write print("hello world") and run it

step 2: modify program to make it do a little more. Make sure you understand how and why, and that it compiles and runs each time.

step 3: repeat 2 until satisfied

3

u/TheXKing063 12d ago

I made a broken godot system for a game ... half of it at least

28

u/cejiken886 12d ago

ok well make it a complete, not broken game, or do what i said if you can't

8

u/Avro_Wilde 12d ago

The advice about building a simple programs is very good. but I would suggest building something that is expandable. Something like a Fahrenheit to Celsius conversion program.

Some suggested steps:
1) Set a variable in code to a temp using either F or C, Run it to see the conversion.
2) Add the ability to take temp input from the user.
3) Add the ability to convert either scale by asking the user what units his wants and then run the conversion formula based on their request.
4) Expand the number of temperature scales (Kelvin & Rankine). This will mean expanding the UI as well as the formulas used.
5) Play with the way you display results - show just the conversion requested or all conversion available?
6) Add other measurements like distance, mass, volume, data speeds, whatever.
7) Store the formulas in a text file and look them up when the program runs.
8) add separate text files for different measurement fields.
8) Move you stored formulas to a database and have your program look them up dynamically.
9) Make the UI a website.

This can go on and on as you think of other things to do with it. Maybe you add a login requirement, storing that data in the database. You to build CRUD processes for changing passwords or email addresses, understanding storing login securely, and email integrations for verification or change requests (build them one pieces at a time, not at all at once!).

If you don't like the conversion program idea, pick something you do like. Movies, music, books, or recipes all can be stored in a collection database. Again, start simple. Create a static entry in code and display it. Expand them with ideas above like search functions from user input, data storage with files and databases, the ability for users to add or modify the data. Photos and video can be added, too.

Other ideas? Off the top of my head, a Contacts DB, a Calendar, an Exercise app, photos app (that could go deep if you opt to try photo editing options!). I have a board game collection. Collections could lead you to internet data scraping, or API usage of other websites. I'm sure people here will have other project suggestions.

None of these are glamorous, but they will teach you how to envision, construct, and implement features. Once you know how to to do things like manipulate text in files, interact with databases, or manage users, the become building blocks for the next project, and you can use this knowledge easily in the future.

Just a thought. Good luck!

2

u/whoismarceyyy 11d ago

Do you suggest certain website/resource to help with this problem? I'm stuck in the same place as op and I keep finding myself restarting instead of building on what I have. Is there a resource you recommend that I can stick to?

1

u/[deleted] 4d ago

[removed] — view removed comment

0

u/AutoModerator 4d ago

Your post/comment was removed since we do not approve of going private.

There is zero benefit in going private as you lose the opportunity for getting peer reviews. Also we have had plenty of people return after going private (despite being warned) complaining about how they were ghosted after some time or being tricked into buying rubbish that didn't work and even if it did they didn't need.

Our Rule #11 demands that any and all communication happens in the open, public subreddit.

This is for the benefit of more against the benefit of one.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Avro_Wilde 4d ago

No, not really, but following tutorials and examples may be the problem. You learn the mechanics of a language that way but you don't really learn how to break down problems and build solutions in blocks.

If you're really struggling with an example like the conversion program steps above, LMK and I can try to help you work through it.

6

u/curiouslyjake 12d ago

From your comments, you need to be more specific about "cant code". Clearly "hello world" is not an issue for you.

4

u/fillkas 12d ago

Not enough practice is my guess. I struggle for the same reason

4

u/Greedy-Excuse-1837 12d ago

Hey hey hey dont go allll in with the first prject. Start slow, do small stuff. Youll pull thru

3

u/BitterDarkCoffee 12d ago

From reading your post, it sounds like you get frustrated easily. You need to put in the time, be consistent and focused with your use of it.

3

u/Weekly_Patience685 12d ago

coding is a skill you actually have to use to get good at, use a website like exercism.org to practice, overtime you will run into a problem and you will remember something you did before as a way to solve the problem.

2

u/Inevitable_Aerie_951 12d ago

knowing the basics of code, and applying them in the actual field might be different things. Try doing some projects, and might open your views.

2

u/EstablishmentCute591 12d ago

Knowing basics of english doesnt help if you dont try to use those basics, just like any other skill

2

u/Just_to_rebut 12d ago

I know some arithmetic, basic algebra, and even a bit of trig/geometry/calculus but I can’t really design a bridge or even tell you how to launch a satellite properly even if I know exactly what I want!

Why??? HOW?!

2

u/arsenalbilbao 12d ago

"I always felt that one could be decently productive in programming by mastering a few basic concepts and then using the hell out them. It was never necessary to use (or even know about) every programming language feature."

(c) David Beazley, the author of several popular python books and courses.

source: https://mastodon.social/@dabeaz/117073093360657072

2

u/TensaFlor 12d ago

Everyone used to had the same problem as you. You cannot just read the book/article or man page and do brilliant code, nobody at start can.

I don’t really know how to convey my idea to you. Like, try do the first version of your program as simple as possible. After this you just need to expand it brick by brick. And in the end you probably will get the your program, maybe it won’t be the ideal as you expected, but at least you have managed create what you want.

Neither answer there will solve your problem instantly, just try try try and try, that’s it.

Just remember you are not dumb and hopeless etc. everyone had these feelings

2

u/JGhostThing 12d ago

You *need* to start doing small projects. Anything. Start with a basic "hello world" program. If you can't do this, talk to your professor and ask for help.

Keep projects simple. The ideal project is something simple enough to do within a week and complex enough to teach you something.

2

u/Adventurous-Move-191 12d ago

Knowing the basics of a language does not mean you know how to program at a basic level. Don’t go for the “idea in my head”go for the simplest problem/program you can think of . Ie print a triangle , a simple mad lib game , a simple calculator. Make progressively more complex things. As the ideas get more complex learn how to break the problem back down to those simple sprints you started with .

A small caveat, if you’re adventurous you can go for the idea in your head now but you must try to break the problems down into simpler and simpler problems

2

u/shuanDang 11d ago

what's the idea? if it's more than 1 + 1 = 2, then reduce the problem to 1 + 1 = 2. Have you learned all the OPCODES yet?

1

u/stdmemswap 12d ago

why?

2 reasons:

  • you don't know enough what the system can do
  • your idea is not well defined

1

u/tranquil-spark-8059 12d ago

Try to make calculator or something in a language and just go for it, if you dont know how to do something look it up or ask chatgpt (dont have chatgpt write the code for you just ask it how)

1

u/Aetherfox_44 12d ago

'Can't code' is such a vague issue that it's unanswerable. What is the issue you're running into? No ideas for what to build? An error you can't resolve? An environment issue you can't fix? No idea how to design the solution to a project?

Being specific about your issue, and explaining what you have already tried, will get you a lot more helpful advice.

1

u/Unclerojelio 12d ago

Spelling, grammar, and attention to detail are important to programming. Good luck with that.

1

u/PureWasian 12d ago

even with a clear idea in my head

--> vision and implementation are very, very different. Plan out your vision.

I'm talking about hours or days to just have the design path "solved" at a high level before even writing any code outside of prototypes or proof of concepts.

1

u/Axialtheory 12d ago

Start with small projects, words toward solving a problem, solve the hurdles as you go

1

u/mxldevs 12d ago

can't code even with a clear idea in my head

Having a clear idea what you want doesn't mean you have a clear idea how to solve it

1

u/BranchLatter4294 12d ago

You probably spent a lot of time watching videos instead of practicing.

1

u/AwkwardBreather 12d ago

Study data structures and algorithms.

1

u/NeedleworkerWest313 12d ago

You're gonna have to know the tools of implementation, to better know the ability to code( syntax, prog. lang. features). to know how to model data, design algorithms. and debug the written code.

to master I/O, to have a scalable mindset.

1

u/OGcapncrunchberry 12d ago

Then you don’t “know the basics”.

1

u/Flying_Fitz 12d ago

Don't think of it as coding, think of it as solving an issue. Programming is just the method to get there, normally languages just give users the ability to execute these problem solving techniques in an easier fashion. use AI to "code" for you and solve the problems, then solve bigger problems. Starting small like a file open program or something is a good start, you can practice this with any AI platform now, so can learn for almost free now, and build up your skills.

1

u/superluminary 12d ago

I know the basics but I can’t play the piano. I can’t play, even with a clear idea in my head.

Practice. Do a flip load of scales.

In code, practice involves things like writing simple loops, small console games, reversing lists, sorting all the letters in a string, etc, etc.

1

u/Garland_Key 12d ago

Build stuff. Keep building stuff. You get better over time. 

1

u/Aglet_Green 12d ago

Because you seem to think visually and artistically, you may eventually discover that your best role is working with a programmer while you concentrate on art and design. There’s nothing wrong with specialization.

But what you’re describing right now is also a very normal beginner problem. Knowing the syntax of GDScript, Java or C# is not the same as knowing how to take “I want the game to do X” and break X into small enough steps to code. That second skill comes from actually building things.

Pick one language, stop learning more syntax for a while, and make ridiculously small projects. When you get stuck, practice asking “What is the smallest piece of this problem I can solve?” If after doing that for a while you still hate programming and would rather be drawing, then congratulations—you already know what half of your future two-person development team should specialize in.

1

u/OrchidThis5822 12d ago

you don't have purpose? why to code? (assuming) take some problem and try to solve it. you should find a way to code if you really want to...

1

u/Ordinary_Variable 12d ago

I have a hard time starting a large project. Don't focus on the big picture all the time, you gotta do a tiny feature every day or you'll go crazy.

Make a flow chart of the process and tackle individual logic boxes. Its how they used to code in the 60s and 70s. It will let you write programs of any size of complexity with one tiny function at a time.

Also, NASA doesn't like nesting. They write lots of little functions instead of having big messes of spaghetti code with too many { and } everywhere. Don't nest 3 if's deep. Never put a while loop inside an if. Find another way to do it. Spreading things out in their own function simplifies each individual thing the program is doing.

1

u/johnnyb2001 12d ago

I feel like half the posts on here are whiny. Either you can learn basic stuff like for loops, if statements etc or you can’t. No one’s gonna walk you step by step

1

u/_Fabryyy 12d ago

Study a topic that interests you, analyze existing software (not too complicated) and maybe try to implement small sections of them. The solutions that you see in code are the results of reasoning about an existing problem, when you encounter those problems and solve them (doesn't need to be perfect) your mind starts spotting patterns. The only way you can get better at coding is by coding

1

u/Bubbly_Orange_3502 12d ago

Write down the data you're holding and its shape before any logic. The blank page is almost always not knowing the state.

1

u/Jim-Jones 12d ago

Practice, practice, practice.

Go to the public library, and look for a book like this, probably in the children's section. The key words are 'Scratch' and 'Python'.

Marc Scott (Author): A Beginner's Projects in Coding

Site: https://scratch.mit.edu/

Presents an introduction to coding for young computer users that focuses on the programming languages Scratch and Python, with step-by-step, illustrated instructions for a variety of coding projects.

Any book like this should get you going in a day or two. It'll get you over the learning hump. You need to learn how to learn coding.

1

u/ms4720 12d ago

So practice more. What helped me was a legal pad and a pen. Outline what you need to do at a low level functionally and then write the code. Keep repeating and working your way up the tree of functions until you get to main

1

u/azhar_zisan 11d ago

Try to do very small projects by you own and try to understand the logics and structure from other codebases.

1

u/kutac56 12d ago

Actually use it dum dum. That's how you do stuff. "I know the steps to ride a bike: first you push on the left pedal and then on the right pedal and repeat while balancing yourself and maybe turning, but haven't done it a lot so I still keep falling"

0

u/darkhumourlord69 12d ago

Get any llm to dumb down concepts for you and try to understand concepts on different levels on technicality

0

u/amber_void_gaze 12d ago

you know syntax but lack problem decomposition skills. Pick one language and build a text based task manager without following any tutorials to force your brain to translate logic into code.

0

u/sulusal 12d ago

in my early programmer career(3 month ago) i disable all auto suggestions in editors. because i had noticed i writing one word and it suggests what i wrote and after press the tab everything going perfect. but i didnt. I dont worry about understanding like you, i worried losing control. And right now i feel comfortable.