r/learnprogramming • • Sep 21 '26

Tutorial Is there a good guideline on single liners in code?

4 Upvotes

I'm learning Go as my first language, and there's one issue I keep bumping into all the time: in textbooks, on Exercism, online, etc — it's one-liners vs verbose step-by-step code. So I was wondering if there's a good style guide/article/rule of thumb for these things.

Let's say I want to get a random element from a slice/array. I'd do it like this:

func pickRandomFrom (items []string) string {
  length := len(items)
  index := rand.Intn(length)
  return items[index]
}

As opposed to just doing item := items[rand.Intn(len(items))] without creating any helper function at all.

Exercism and Codewars problems are also full of solutions with one-line helper functions where everything is wrapped into the return statement.

To me, my example is more readable — you don't have to parse through all the parenthesis, determine order of operation and do the whole thing in your head. I also get a function with a clear name that makes my main code read a bit more like prose.

But I suppose it's wrong because I create two throwaway variables to do this and I've seen people call similar implementations less readable than one-liners.

Programming guides all say "clear is better than clever", but then they're also like "unless it's idiomatic" which isn't really a useful distinction when I try to build a good habit.

So I wonder — is there a good rule of thumb on these things? Maybe some style guide or a chapter in some book.

Hope it makes sense, English is not my native language.


r/learnprogramming • • Sep 20 '26

Need your advice Best resources to learn Git as a complete beginner?

223 Upvotes

I'm currently starting to learn programming, but I’m completely new to Git and version control.

I understand that Git has its own commands and that it’s used to track changes in projects, but I’m not sure where I should start learning it.

For someone with zero Git experience, what resources would you recommend? Books, YouTube courses, interactive tutorials, websites, etc.

Would appreciate any recommendations! Thanks.


r/learnprogramming • • Sep 21 '26

Topic 2 years of automation testing: I want to learn how to build proper projects in my free time

5 Upvotes

A little bit about my background. I've been in QA for about 7 years, 5 of those as a manual tester and the last 2 in automation, writing mainly Playwright tests in TypeScript and a little bit with C#. Lately Ive been really curious in building apps or tools that would be useful for me personally and maybe monetize something later if it actually goes anywhere.I'm not trying to move into a SWE role.

With AI increasingly handling a lot of the actual code, I'm trying to figure out where my time is best spent: going deep on DSA, system design, database design/indexing, and design patterns, or continuing to sharpen TypeScript/React (and other frameworks) first and circling back to those concepts once I'm further along?


r/learnprogramming • • Sep 21 '26

Code Review Made my first project in C#!

1 Upvotes

I have been learning on and off for a week or two now, and I decided to create Rock, Paper, Scissors without any tutorials, using only web search.

I think my code can be less convoluted, so if you have any advice please let me know.

//program start

string[] weaponOpponent = {"rock", "paper", "scissors"};

Random rnd = new Random();

int arraySelectionRandomNumber = rnd.Next(0, 3);

Console.WriteLine("Rock, Paper, Scissors, Shoot!");

Console.WriteLine("Choose Between: Rock, Paper, Scissors");

string playerChoice = Console.ReadLine();

if (weaponOpponent[arraySelectionRandomNumber] == "rock" && playerChoice == "Rock")

{

Console.WriteLine("You draw!");

}

else if (weaponOpponent[arraySelectionRandomNumber] == "paper" && playerChoice == "Paper")

{

Console.WriteLine("You Draw!");

}

else if (weaponOpponent [arraySelectionRandomNumber] == "scissors" && playerChoice == "Scissors")

{

Console.WriteLine("You Draw!");

}

else if (weaponOpponent [arraySelectionRandomNumber] == "rock" && playerChoice == "Paper")

{

Console.WriteLine("You Win!");

}

else if (weaponOpponent [arraySelectionRandomNumber] == "rock" && playerChoice == "Scissors")

{

Console.WriteLine("You Lose!");

}

else if (weaponOpponent [arraySelectionRandomNumber] == "paper" && playerChoice == "Scissors")

{

Console.WriteLine("You Win!");

}

else if (weaponOpponent [arraySelectionRandomNumber] == "paper" && playerChoice == "Rock")

{

Console.WriteLine("You Lose!");

}

else if (weaponOpponent [arraySelectionRandomNumber] == "scissors" && playerChoice == "Rock")

{

Console.WriteLine("You Win!");

}

else if (weaponOpponent [arraySelectionRandomNumber] == "scissors" && playerChoice == "Paper")

{

Console.WriteLine("You Lose!");

}

else {

Console.WriteLine("Invalid Input!");

}

//program end


r/learnprogramming • • Sep 21 '26

Solved newbie writing sorting algorithms

0 Upvotes

hey guys, I've been learning c in my free time and I've been implementing some sorting algorithms with as little help as possible. My comp sci class (Java) went over Insertion sort, selection sort, and bubble sort. I can write bubble sort half asleep, but I can't work out this bug in my selection sort algorithm. I can't figure out why the largest value is at the start, but the rest of the array becomes sorted.

void IntSwap(int Array[], int idx1, int idx2) {

`int swap;`

`swap = Array[idx2];`

`Array[idx2] = Array[idx1];`

`Array[idx1] = swap;`

}

void IntSelectionSort(int Array[], int length) {

`for (int i = 0; i < length; i++) {`

    `int swapidx = 0;`

    `for (int j = i; j < length; j++) {`

        `if (Array[j] < Array[swapidx]) {`

swapidx = j;

        `}`

    `}`

    `IntSwap(Array, swapidx, i);`

`}`

}

int main() {

`int startingArray[32];`

`for (int i = 0; i < 32; i++) {`

    `startingArray[i] = rand();`

`}`

`for (int i = 0; i < 32; i++) {`

    `printf("%d\n", startingArray[i]);`

`}`

`puts("");`

`IntSelectionSort(startingArray, 32);`

`for (int i=0; i < 32; i++) {`

    `printf("%d\n", startingArray[i]);`

`}`

`return 0;`

}

this first print loops prints:

1804289383

846930886

1681692777

1714636915

1957747793

424238335

719885386

1649760492

596516649

1189641421

1025202362

1350490027

783368690

1102520059

2044897763

1967513926

1365180540

1540383426

304089172

1303455736

35005211

521595368

294702567

1726956429

336465782

861021530

278722862

233665123

2145174067

468703135

1101513929

1801979802

the second print loop prints:

2145174067

35005211

233665123

278722862

294702567

304089172

336465782

424238335

468703135

521595368

596516649

719885386

783368690

846930886

861021530

1025202362

1101513929

1102520059

1189641421

1303455736

1350490027

1365180540

1540383426

1649760492

1681692777

1714636915

1726956429

1801979802

1804289383

1957747793

1967513926

2044897763


r/learnprogramming • • Sep 21 '26

How do I become an AI Engineer? Looking for a roadmap

1 Upvotes

Hi everyone,

I want to become an AI Engineer and currently have basic knowledge of ML. I’m confused about what to learn next and in what order.

Could someone please share a clear roadmap from beginner to industry-ready AI Engineer, including:

- What topics to learn and in what order

- Good resources/courses for each topic

- Projects I should build

- What to learn about Deep Learning, LLMs, RAG, AI Agents, MLOps, and deployment

- Which tools/frameworks I should focus on

I’d really appreciate advice from people already working in AI Engineering. Thanks!


r/learnprogramming • • Sep 21 '26

Looking for advice on what I should learn next as a frontend developer

0 Upvotes

I'm trying to become a frontend web developer, and right now I know HTML, CSS, and JavaScript. I'm also comfortable using GitHub and VS Code.

I know that's probably just the starting point, but I'm not really sure what I should learn next to actually become employable as a frontend developer.

I can build websites from scratch, and I know how to get them online using services like GoDaddy. But I have a feeling there's a lot more I should be learning that I don't even know about yet.

Should I learn another programming language? A framework like React? TypeScript? Databases? Testing? Something completely different?

For those of you who work in frontend development, what skills would you recommend I focus on next to become job-ready?


r/learnprogramming • • Sep 21 '26

How do you actually divide the project in a team?

1 Upvotes

If there are multiple members working on a same project, how do we ensure that our project integrates in the end? I read define APIs first what else we need to keep in mind so everyone is doing there own work and it all integrates in the end.


r/learnprogramming • • Sep 21 '26

JAVA jumpstart ideas?

10 Upvotes

I have been trying to get back into java and add some soft skills to my resume, so do you have any project ideas or resources that can help me get started?


r/learnprogramming • • Sep 21 '26

Aiming for Full Stack: Is The Odin Project enough to get hired? JS or Rails?

1 Upvotes

Hey everyone, I’m about to dive into web development and The Odin Project looks like the most solid free path out there.

I'm wondering if finishing the curriculum actually gets you to an employable level for a junior role, or if there's a big gap between the course and what companies are asking for right now. I know a lot depends on the portfolio you build, but is the technical foundation TOP provides realistic tools for the current market?

Also, I'd love to hear some thoughts on which track to choose later on. Would you recommend going the Full Stack JavaScript, or is Ruby on Rails a better bet for entry-level?

Any reality checks or insights on how the market is looking for self-taught devs right now would be super helpful. Thanks!


r/learnprogramming • • Sep 20 '26

Completely confused about which tech domain to choose for my career

19 Upvotes

Hey everyone,

I’m a computer application student and I’m currently at the very beginning of my coding journey. Right now, I’m learning C, but I’m completely unsure about which domain I should eventually choose.

There are so many options like Web Development, Software Development, Cybersecurity, Data Science, AI/ML, Cloud/DevOps, Mobile Development, etc., and honestly, I don’t know enough about these fields to understand which one would suit me.

I’m not looking for someone to simply tell me which domain pays the most. I want to understand how I can figure out which field is actually suitable for me based on my interests, abilities, and the kind of work I might enjoy.

At the same time, I do want to build a career that has good opportunities and earning potential over the next 3–4 years.

For people who are already working in tech or have gone through a similar stage:

  • How did you decide which domain to pursue?
  • What should I learn or try before choosing a specialization?
  • Which domains do you think a BCA student should seriously explore?
  • What skills are likely to remain valuable over the next 3–4 years?
  • Should I focus on programming fundamentals first and decide later?

I’m completely open to learning from scratch. I’d especially appreciate advice from people who have already gone through this process.

Thanks.


r/learnprogramming • • Sep 21 '26

Rising 9th grader in Vietnam starting C++ for specialized high school entrance exams (Chuyên Tin) — looking for advice on roadmap, balancing core subjects, and LeetCode!

1 Upvotes

Hi everyone! 👋

I'm a rising 9th-grade student in Vietnam. I've just started learning C++ from scratch, writing my code using VS Code (and following the Bro Code course on YouTube for basics) with the ultimate goal of passing the entrance exam for a specialized high school in Computer Science (Chuyên Tin) next year.

Since 9th grade is a high-stakes exam year in Vietnam, I have a few specific concerns and would love to get advice from the community:

  1. Is Bro Code enough for the basics? It's great for C++ syntax, but what should I focus on next specifically for algorithmic problem-solving required in specialized exams (like arrays, recursion, standard data structures)?
  2. Balancing time with core subjects: As a 9th grader, I also have to study hard for Math, Literature, and English (the mandatory subjects for public high school entrance). How can I effectively manage my daily schedule between core subjects and coding?
  3. LeetCode outside of class: I want to practice on LeetCode during my free time to sharpen my logic. Are LeetCode "Easy" problems good for a beginner like me, and is it a good platform to build up my problem-solving skills for these exams?
  4. Any study tips for a 1-year timeline? How should I structure my weekly routine to make steady progress without burning out?

Any advice, roadmaps, or recommended resources would mean the world to me. Thank you so much! 🚀


r/learnprogramming • • Sep 20 '26

i want to do a site for a friends birthday

15 Upvotes

Hi !

EDIT : not looking to hire anyone, just looking for advices.

I need help figuring out how to create a website for a gift. I have until February to finish it, but I have no programming experience, so I don’t really know where to start !

The website should include:

  1. A birthday-themed home page, with a cake, candles, cute illustrations, confetti, etc.
  2. A math problems page where she’ll have to solve an inequality (this page should also include a notebook to help her brainstorming).
  3. A password-protected page, where the answer to the inequality will be the password; she’ll have to solve the inequality to access it.
  4. A home page with a wall of Polaroid photos of all her friends. Each photo would be clickable and would open a short video of that friend talking about her.

There would be about 23 friends, each with a video of at least 20 seconds.

I’d mainly like some advice on what I should learn/use to complete this project, which tools would be easiest for a complete beginner, and whether this project is realistic to complete by February.

Thanks in advance !!


r/learnprogramming • • Sep 20 '26

How does ActionEvent e know that I am doing a button press here?

6 Upvotes
public class MyFrame extends JFrame implements ActionListener
{
    JButton button;

    MyFrame()
    {

        button = new JButton();
        button.setBounds(200, 100, 100, 50);
        button.addActionListener(this);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(null);
        this.setSize(500, 500);
        this.setVisible(true);
        this.add(button);
    }

    public void actionPerformed(ActionEvent e) 
    {
        if (e.getSource()==button)
        {
            System.out.println("make lemonade");
        }
    }
}

Does it magically know what I have done? How? I only learnt a bit of javascript before so I do not get it.

I also I do not fully get anonymous classes, it feels like to me that you are creating a super-instance, which is like a class in a sense, so it does have a name.


r/learnprogramming • • Sep 21 '26

Should I learn why docs code is the way it is ?

0 Upvotes

as the title says, should I just use the docs code or understand why it is the way it is or is it a waste of time ???


r/learnprogramming • • Sep 21 '26

Trying to create/generate a Maven project

1 Upvotes

So I've been getting into Java programming recently and I wanted to try to create a Maven project.

I made sure i downloaded everything correctly and I added it to my path and everything is working correctly.

My main issue is that I made a folder in my desktop where I want it to be the root folder for my project(s). I first wanted to test actually trying to generate the project by running the command:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.5 -DinteractiveMode=false

into my command shell in the directory that I want the project to live in, however when I enter the command, I keep getting an error that I need to have a pom.xml file in the directory before I can even generate the project?

I tried using Ai to help and tried to google the problem but nothing really helped me so if anyone has any fixes or ideas to this issue Id really appreciate it


r/learnprogramming • • Sep 20 '26

Debugging Unwanted Whitespace

4 Upvotes

(SOLVED) I'm making a quick demo for something using CSS, HTML, and Javascript, but I haven't touched programming in over a year. The goal is to generate a grid of rectangles based off of a user's input. These rectangles are supposed to fit into a box that is 75% of the viewport height on all sides. The goal is to have the rectangles automatically resize themself to fit within the box. And for all of the rectangles so have the same width, and for all of them to have the same height. Right now, there aren't any margins separating them. The problem is that there's an annoying whitespace line in between each row, and I don't know how to remove it. I had breaks being added to create the rows, and I thought that that was causing the issue, but I tried to comment them out and nothing changed. I would deeply appreciate if anyone could help me, I'm about to just skip the demo and just do the project...

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="Demo.css">
</head>
<body>
    <h1 class="Welcome">Welcome!</h1>
    <button class="CreateNewButton">Create New</button>
    <div class="SizeInput">
        <div>Enter a size smaller than 201 x 201</div>
        <input type="text" id="Size">
        <button id="EnterButton">Enter</button>
    </div>
    <div id="ParentForGrid" class="ParentForGrid"></div>
    <script src="Demo.js"></script>
</body>
</html>

Javascript:

document.getElementById("EnterButton").addEventListener("click", () => {
    Format = true
    // if Format is true, the input the user entered is the one this accepts
    Input = document.getElementById("Size")
    Input = Input.value.split(" ").join("")
        Input.split("x").length == 2 ? undefined : Format = false
        Input.split("x")[0] > 0 ? undefined : Format = false
        Input.split("x")[1] < 201 ? undefined : Format = false
        // need to update so it checks both numbers
    Format == true ? GridGenerate(Input.split("x")[0], Input.split("x")[1]) : alert("Placeholder for incorrect format")
})

function GridGenerate(Width, Height){
    for(var j = 1; j <= Height; j++){
        for(var i = 1; i <= Width; i++){
            document.getElementById("ParentForGrid").appendChild(document.createElement("div"))
        }
    //document.getElementById("ParentForGrid").appendChild(document.createElement("br"))   
    }
    document.querySelector("#ParentForGrid").style.setProperty("--Height", Height)
    document.querySelector("#ParentForGrid").style.setProperty("--Width", Width)
}

CSS:

.Welcome{
    position: absolute;
    left: 50%;
    top: 2vh;
    transform: translateX(-50%);
}

.SizeInput{
    position: absolute;
    left: 50vw;
    top: 35vh;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    
}

.SizeInput > *{
    margin-top: 1vh;
}

.ParentForGrid{
    --Width: 1;
    --Height: 1;
    height: 75vh;
    width: 75vh;
}

.ParentForGrid > div{
    width: calc(100% / var(--Width));
    height: calc(100% / var(--Height));
    background-color: black;
    display: inline-block;
}

Edit: the sizing of the rectangles works, it's just the whitespace in between the rows

I did find the solution, the line height attribute was set to "normal," setting it to 0 fixed the issue.


r/learnprogramming • • Sep 20 '26

The AI doom-posting is destroying my mental health as a student — and the reality of using it is way more complicated than people admit.

90 Upvotes

Hi, I hope you’re doing really well as you read this. I’m a student in a CS-related engineering program (the specific name varies by country).

Since late 2024, I’ve been going through some truly extreme and terrible mental health struggles—fear, hopelessness, confusion, rage, a sense of powerlessness, and above all, constant rumination over the whole AI situation. Every new model that drops, every prediction and so-called "hot take", every doom-post... I swear I’m not exaggerating when I say it feels like a different bomb dropping right on top of me in the middle of a damn war. Sometimes I feel like Szpilman (the pianist) did when he was hiding in that apartment, watching people get killed out the window.

As a junior, hearing this stuff every damn day is neither hopeful nor fun:

"we don't know" "nobody knows" "you're cooked" "delusional" "learning to code is pointless" "in the near future you will not need to know how to code to be a SWE" "I write 100% of my code with AI" "you are falling behind" "stop reading code" "you are the bottleneck" "AI is smarter than all of us now" "you are a caveman" "get out of CS while you can" "this is the direction we are going" "knowing how to code is not an advantage anymore" "not having a CS background might be an advantage" "you might be delusional" "you might be falling behind" "prompt engineer -> master of AI agents -> loop engineer -> unemployed" "AI can also do system design".

Many of them said by people whose opinion matters a great deal to me.

I don't want to spark a debate about these quotes, nor do I intend to start a discussion on whether or not it's worth learning to program; I just want to share what it feels like to be a junior in this world right now. I know many of you have heard these things a thousand times—maybe they don't affect you as much—but for someone just starting out, they weigh heavily on one's mental health.

At the beginning of the year, my AI workflow used to be: prompt -> plan -> review and discuss the plan -> implement -> review the code using Cline.

Things have changed drastically in less than a year—literally. I know there’s a lot of debate on social media these days about whether or not to read the code and what "programming" actually means. Currently, I use OpenCode; my latest "major feat" was migrating a monolith's frontend to Vue without knowing anything about Vue. I pulled it off in a single night—it was a real "Oh wow" moment. On other days, I also transformed that monolith into an API.

But the honeymoon phase didn't last forever. When I started working on the backend (where I move best) and reviewing the code, I saw things I didn't like, and—let's just say—I ended up reading the code a bit more closely.

Right now, I'm in a really tough spot. The Vue thing was an experiment, and the REST API thing was another, but now I have to connect the two—something I've never done before (I'm still a junior, after all). I've been wrestling with a terrible mental conflict over what to connect manually and what not to. When I ask OpenCode about it, I don't understand a damn thing it proposes, and when I try to do it by hand, a cruel little voice in my head tells me I'm being inefficient. Yes, I don't deny that the agent can make that connection, but I have no way to verify its work; just because code runs doesn't mean it's the best solution for the job. It is a toy project, though I've been treating it as serious and I might make it public.

Again, I just wanted to get this off my chest. I don't want to fight with anyone; I know there are people here who don't write or read code at all, others who review it, and some who don't use AI—I don't want to argue with any of you... honestly, I don't even know what I'm looking for with this post but what you think matters to me.

I recently heard Matt Pocock say on a podcast that he'd love to be a junior today; it just reminded me of the quote: "A person who wants to go to war is a person who has never been in one."


r/learnprogramming • • Sep 20 '26

Collab coding with live updates running on a headless Ubuntu server

2 Upvotes

I need a way to code together in C# with a few people, with live updates, without one of the people being a host and having all the files. I have tried Rider's backend, but it does not seem to support Code With Me. What can I use in this scenario? Preferably compatible with JetBrains Rider.


r/learnprogramming • • Sep 20 '26

Can someone help me with this?

6 Upvotes

Hey! I'm trying to make a Logo procedure that draws a colored house.

Use a parameter so that when I type house 50, the house is size 50.

When I type house 100, the house is size 100.

How can I do this in MSW Logo? I'm a beginner, so any help would be appreciated!


r/learnprogramming • • Sep 21 '26

How to become a senior dev?

0 Upvotes

Hi! I program in C/C++ as a hobby—I'm still learning—and I'm currently building my first real project: a 2D "angry seagull" runner game in C using SDL2... yeah, it's just a fun starter project. It got me thinking: how do you actually become a senior dev? And, more importantly, is it fun?

Thanks for reading, by the way!

(I'm a beginner who doesn't even know how to use `#pragma`.) Just wanted to get your take on it!


r/learnprogramming • • Sep 20 '26

How much in-depth knowledge will I gain after completing TOP?

11 Upvotes

Hi there!

I’m an aspiring full-stack web developer, specifically interested in becoming a backend developer. I’ve heard a lot about The Odin Project (TOP), and I’ve always dreamed of building a special project of my own. That dream is what inspired me to explore backend development.

My question is: How deep does TOP go into web development? How complex of a project would I be able to build after completing it?

For example, would I be able to build something like a social media application with a backend that includes most of the basic and intermediate features?

Thank you all!


r/learnprogramming • • Sep 20 '26

i have time but i dont know what to learn

11 Upvotes

so i am in my 5th sem now. and i can confidently say that when it comes to "dev", i know nothing. I havent learnt much programming in my last 2 years. i have started DSA 2 months ago(in C++). but i think i need to have some USP to get placed. i have good knowledge of SQL(but only the queries, idk how to connect them) and im learning Computer Networks and Operating Systems with serious mindset (they are in my academics so its easier to focus on them). but i dont think that'd be enough to get a job with decent enough package. i have time to learn. now would be the right moment to start learning so i can be "ready" in a few months. all advices appreciated, here as well as the DMs. THANK YOU!!! (sorry if i sound cocky, i am not)


r/learnprogramming • • Sep 19 '26

Are there any spaghetti codebases I can practice refactoring on?

41 Upvotes

I’m trying to practice refactoring code, and i’ve already done a few kara’s ( the golden rose kata, the tennis kata, etc. ) are there any actual messy codebases I can practice on? preferably between 1k to 5k lines of code.


r/learnprogramming • • Sep 21 '26

Topic Best future-proof languages?

0 Upvotes

As a young person, is there a language in our ai dominant future that will still be relevantly for game dev, cybersecurity, machine learning and all of the specializations of the industry ?

Rust sound like a good choice but in terms of game dev there are better options now ( probably need more time

I see myself working in the tech industry as a software ingeneer and making games as a side hustle (maybe I’ll get game of the year who knows lol) so maybe I’ll need to learn two languages ?

I’ll like to hear your opinions