DEV Community

ma2mori
ma2mori

Posted on

When Asked How to Learn Programming, This Is My Answer

How Should I Learn Programming?

I sometimes get asked this question, and my answer is simple.

"Build the same app (theme) multiple times using different methods."

Why Build the Same Thing Repeatedly?

A common failure in programming learning is "tutorial fatigue."

You build a chat app with React, then an e-commerce site with Rails, then a blog... If you're only following tutorials, you've barely learned anything. Something might be working, but you don't feel like you could build it from scratch.

Instead, I think it's more effective to focus on one thing, like a ToDo app (though it could be anything).

When you build with the same theme, the requirements are clear so you can focus on the technical differences. You can compare with your previous implementation and gradually increase complexity. It also shows your growth clearly as a portfolio.

Recommended Learning Steps

Step 1: Build with Plain HTML + PHP

Start from the simplest approach.

// todo.php
<?php
session_start();
if (!isset($_SESSION['todos'])) {
    $_SESSION['todos'] = [];
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['task'])) {
        $_SESSION['todos'][] = $_POST['task'];
    }
}
?>
<!DOCTYPE html>
<html>
<body>
    <form method="post">
        <input type="text" name="task">
        <button type="submit">Add</button>
    </form>
    <ul>
        <?php foreach ($_SESSION['todos'] as $todo): ?>
            <li><?= htmlspecialchars($todo) ?></li>
        <?php endforeach; ?>
    </ul>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

You'll touch on the basic mechanisms of web apps like form submission and session management.

Step 2: Add Persistence with Plain PHP + MySQL

Move from sessions to a database.

// todo_db.php
$pdo = new PDO('mysql:host=localhost;dbname=todo', 'root', '');

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['task'])) {
        $stmt = $pdo->prepare("INSERT INTO todos (task) VALUES (?)");
        $stmt->execute([$_POST['task']]);
    }
    if (isset($_POST['delete'])) {
        $stmt = $pdo->prepare("DELETE FROM todos WHERE id = ?");
        $stmt->execute([$_POST['delete']]);
    }
}

$todos = $pdo->query("SELECT * FROM todos")->fetchAll();
Enter fullscreen mode Exit fullscreen mode

You can understand SQL basics, database connections, and CRUD operations in their raw state.

Step 3: Rebuild with Laravel

Try using a framework.

// routes/web.php
Route::get('/todos', [TodoController::class, 'index']);
Route::post('/todos', [TodoController::class, 'store']);
Route::delete('/todos/{id}', [TodoController::class, 'destroy']);
Enter fullscreen mode Exit fullscreen mode

You'll learn MVC pattern, routing, migrations, and ORM.

Step 4: Deploy on a Rental Server

Try deploying what you've built.

# .htaccess configuration
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Enter fullscreen mode Exit fullscreen mode

Upload via SFTP to a rental server (about $5/month), configure custom domains, install SSL certificates, manage environment variables with .env files - you'll gain knowledge necessary for production operations. This might also be when you encounter the evil complex UIs of domain registrar services.

I recommend researching SQL injection and XSS before going public and reviewing your entire source code.

Step 5: Build with Laravel (API) + Vue.js

Try separating backend and frontend.

// TodoList.vue
export default {
  data() {
    return {
      todos: [],
    };
  },
  mounted() {
    fetch("/api/todos")
      .then((res) => res.json())
      .then((data) => (this.todos = data));
  },
};
Enter fullscreen mode Exit fullscreen mode

You'll learn API design, CORS, asynchronous processing, and component design.

Step 6: Build with Spring Boot + React

Test if you can do the same thing in a different language.

@RestController
@RequestMapping("/api/todos")
public class TodoController {
    @GetMapping
    public List<Todo> getTodos() {
        return todoService.findAll();
    }
}
Enter fullscreen mode Exit fullscreen mode

You'll learn statically typed languages, DI containers, and annotations.

Step 7: Build a CI/CD Pipeline

Implement automatic deployment with GitHub Actions or CircleCI.

# .github/workflows/deploy.yml
name: Deploy
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Build and Deploy
        run: |
          npm run build
          npm run deploy
Enter fullscreen mode Exit fullscreen mode

Automatic test execution, build, and deployment on push. You'll learn about using production and staging environments, rollback strategies, and security scanning (vulnerability checks for dependencies).

Step 8: Continuous Feature Addition

With your favorite tech stack, implement user authentication, real-time sync, tagging, search functionality, mobile app version, etc.

Or you might try setting up regular backups and implementing error monitoring tools.

By this point, you'll have acquired the foundations of development.

Why a ToDo App?

Some people say "Building a ToDo app won't teach you much," but they're wrong.

ToDo apps include CRUD operations (Create, Read, Update, Delete), state management, list display, form processing, and data persistence - all the basic elements needed in real work.

Every app basically starts with CRUD operations.

You don't have to stick with a ToDo app though. Any theme you want to build repeatedly is fine.

Learning Resources

Django Girls Tutorial

https://tutorial.djangogirls.org/en/

I really recommend this. It's a tutorial for Python and the Django framework, but its value goes beyond learning language and framework usage.

This tutorial starts with "How does the Internet work?" It explains command line usage with a "the black screen isn't scary" approach. It explains from the level of "What's a folder?" and "What's a file?" and even includes what to do when errors occur. Like "Don't panic if you see this error."

It's written in friendly, conversational language and conveys the message that "programming isn't difficult."

Even people who want to learn PHP or Java should read this first. You'll gain knowledge needed regardless of language - basic programming concepts, how web apps work, and how to set up development environments.

It's a tutorial for building a blog app, but once you understand it, you'll be able to build at least a ToDo app in any language.

After studying for a while, if you read it again, you'll better appreciate how it explains things at just the right level of detail for beginners.

Official Documentation

When you're stuck, checking official documentation first is usually fastest.

Books

Surprisingly, there are quite a few technical books available on Kindle Unlimited, so I recommend it. Universal books may be a bit pricey, but they last long. Buying used is also an option. A recent book, "Tidy First?", not only covers important concepts but also introduces many immediately useful tips, so I recommend it for beginners.

YouTube

Search for "Laravel Todo" or "React Todo" and you'll find tons of tutorials.

Udemy

About $15 during sales. If you've struggled with environment setup, following along with videos might be better. Some instructors frequently answer questions while others don't respond at all, so check carefully before purchasing.

About Schools and Mentors

Honestly, I don't think most people need them.

Looking into it, there seem to be services where designated mentors answer questions for about $10/month, but you tend to develop a dependency mindset of "asking someone."

I also don't recommend expensive schools. With $5,000, you could buy a MacBook Air, 50 technical books, and still have change left over.

Some might think schools are better because they provide job placement support, but consider the downside of choosing from jobs the school introduces. I think you'll be more satisfied if you take time to search for companies to work at without relying too much on others' opinions and apply yourself.

For problems difficult to solve on your own, ask AI. It responds instantly even at midnight.

About Development Environment

For PCs and such, almost anything works (though you basically need a Mac if you want to build and publish iOS apps). Buy a used laptop for about $200, buy $50-100 worth of memory to upgrade it, and it'll last 2-3 years. You can usually find upgrade methods by searching the model number on YouTube. If you want to minimize initial costs, you can significantly reduce expenses by using cloud development environments like Cloud9 or Codespaces, or VDI services like Amazon WorkSpaces from a cheap tablet.

However, many technical articles only verify operation on Mac, so if you have the budget, you might consider a Mac.

I don't spend much on hobbies, and while I use a provided MacBook Pro for work, for personal use I was using a used Dynabook until recently. As it gradually started shutting down randomly and became harder to charge, I bought a Mac mini. It's comfortable but quite expensive.

When You Feel Like Giving Up

Programming learning is lonely. But that's okay.

Struggling with errors, poring over documentation, trial and error. This process is important.

If it gets really tough, take a week off. Step away from programming and come back. That's fine. If you start learning with C# and find it difficult, try touching another language like JavaScript. What's important is being able to continue and finding it at least somewhat interesting.

Summary

In the end, it's all about getting your hands dirty.

When asked "How should I learn programming?", I answer:

"Build the same app (theme) multiple times using different methods."

Even if each version is simple, if you can explain in your own words why you built them in that order and what you learned, that becomes a respectable portfolio. It shows more potential than a seemingly rich e-commerce site built following tutorials that you can't explain the contents of.

Rather than reading popular but incomprehensible advanced books and feeling like you've studied, it's better to learn gradually while coding, periodically stopping to read books to systematically organize your knowledge. Reading books isn't the goal - it's a means to broaden your judgment range during design and implementation.

You don't need expensive tuition. All you need is time to code.

Top comments (0)