Phuc's Portfolio AI,Blog AI,Technology Part 1: What AI Can and Can’t Do in Web Software Engineering

Part 1: What AI Can and Can’t Do in Web Software Engineering



DeepAI Generated Image

Please note this is AI generated content, that was manually queried, and accuracy is not guaranteed. So please read at your own risk. Hopefully it has some useful info, like researching it yourself.

Series Overview & Rationale

In this series we will explore, in depth, what AI-written code (via large language models, code generation tools, “copilot”-style assistants, etc.) means for web software engineering. We’ll examine:

  1. What AI code generation can and can’t replace
  2. The advantages: speed, consistency, scaffolding, error detection
  3. The disadvantages and typical pitfalls, especially subtle ones
  4. Comparative error patterns (AI vs human) and what future looks like

In each part we’ll include code examples and concrete scenarios, especially in web languages (JavaScript/TypeScript, Python, Node.js, etc.), to ground the discussion.

✅ Coming Up:

Part 1: What Can AI Really Do in Software Engineering?
→ Capabilities, current state, and boundaries of AI in code generation

Part 2: The Advantages of AI-Written Code
→ Efficiency, speed, cost-saving, and accessibility

Part 3: The Dark Side of AI-Generated Code
→ Common errors, hallucinations, and security flaws

Part 4: Human vs AI Code — What the Future Holds
→ Direct comparisons, strengths, limitations, and the hybrid future

Introduction

AI has moved from automating spreadsheets to suggesting code snippets, writing whole functions, and even refactoring large repositories. Tools like GitHub Copilot, ChatGPT, Amazon CodeWhisperer, and TabNine are helping developers write software faster than ever.

But what can AI really do in web and software engineering today? Where does it succeed—and where does it fall short compared to human developers?

This article explores the actual current capabilities and limitations of AI in code generation. We’ll use real examples from common web technologies (JavaScript, Python, HTML, etc.) to show when AI excels—and when it stumbles.


🔧 1. What AI Can Do Well

LLM-powered tools have improved rapidly in the last few years. AI is no longer just suggesting variable names—it can now generate full routes, database queries, testing suites, and even deploy scripts.

✅ 1.1 Generate Boilerplate Code (e.g., Express or Flask)

Let’s take a prompt given to ChatGPT:

“Generate an Express.js route that fetches a user by ID using MongoDB.”

AI-Generated Code:

const express = require('express');
const router = express.Router();
const User = require('../models/User');

router.get('/users/:id', async (req, res) => {
  const user = await User.findById(req.params.id);
  if (!user) return res.status(404).json({ error: 'User not found' });
  res.json(user);
});

module.exports = router;

✅ What works:

  • Clear, valid syntax
  • Correct use of async/await
  • Follows Express conventions

AI is highly effective at generating CRUD endpoints and MVC boilerplate for Node.js, Django, Flask, etc.


✅ 1.2 Translate Between Languages (e.g., JS → Python)

Prompt:

“Convert this Python function into JavaScript.”

def double(nums):
    return [n * 2 for n in nums]

AI Output:

function double(nums) {
  return nums.map(n => n * 2);
}

Translation across languages works well with simple functions. However, deeper differences (like async behavior or type systems) may trip AI up, as we’ll see later.


✅ 1.3 Basic Frontend Components

Prompt:

“Write a React component that displays a list of items.”

AI Output:

function ItemList({ items }) {
  return (
    <ul>
      {items.map((item, i) => <li key={i}>{item}</li>)}
    </ul>
  );
}

This is perfectly usable React code for simple UIs. However, AI often:

  • Uses indexes as key props (a performance smell)
  • Ignores accessibility best practices (e.g., ARIA roles)

✅ 1.4 Generate Unit Tests

Prompt:

“Write Jest tests for a function that checks if a number is prime.”

AI Output:

test('returns true for prime number', () => {
  expect(isPrime(7)).toBe(true);
});

test('returns false for non-prime number', () => {
  expect(isPrime(8)).toBe(false);
});

🟢 AI-generated tests are a great starting point, though they often lack edge case coverage (like negative numbers or 0).


⚠️ 2. What AI Still Can’t Do Well

AI makes confident guesses. But that’s also its greatest weakness.

Let’s explore some real examples of where AI-generated code goes wrong.


❌ 2.1 Inventing Non-Existent APIs

Prompt:

“Fetch a user from the database using Mongoose.”

AI Output:

User.findByEmail('[email protected]'); // ❌ Error

🚫 findByEmail is not a real Mongoose method unless you defined it yourself. AI often hallucinates methods it thinks “should exist.”

🧠 Human coder: would check the docs or write:

User.findOne({ email: '[email protected]' });

❌ 2.2 Overlooking Security Logic

Prompt:

“Create a login route using Express and MongoDB.”

AI Output:

router.post('/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await User.findOne({ email });
  if (user.password === password) {
    res.send('Logged in');
  } else {
    res.status(401).send('Invalid');
  }
});

🚨 HUGE problem: Plaintext password comparison!

🧠 A human would use bcrypt.compare() and never store raw passwords.


❌ 2.3 Can’t Understand Business Logic

Prompt:

“Write logic to calculate discounted price for a subscription.”

AI Output:

function getDiscountedPrice(price, discount) {
  return price - (price * discount);
}

Looks okay… but what if:

  • Discount is a flat $ amount?
  • Discount is 100% but user is in a trial?
  • There are minimum price thresholds?

AI doesn’t know your business rules unless explicitly told.


❌ 2.4 Poor Type Safety or Incorrect Inference

Prompt (in TypeScript):

“Create a function that returns a user’s full name.”

AI Output:

function getFullName(user) {
  return `${user.first} ${user.last}`;
}

⚠️ Error-prone if user is not typed.

🧠 Better:

function getFullName(user: { first: string; last: string }): string {
  return `${user.first} ${user.last}`;
}

⚖️ 3. AI Coding Strengths vs Human Coding Strengths

TaskAI StrengthHuman Strength
Boilerplate & syntax✅ Fast & accurate✅ Understands context
Business logic❌ Shaky✅ Domain expertise
Security & compliance❌ Often flawed✅ Deep awareness
Architecture & planning❌ Limited✅ High-level reasoning
Refactoring legacy systems⚠️ Sometimes helpful✅ Strong judgment
Writing doc/tests✅ Drafts quickly✅ Knows what matters
Error debugging❌ Often wrong✅ Precise troubleshooting

🔮 4. Where the Boundary Is Moving

AI capabilities are rapidly evolving:

  • Context-aware IDEs (e.g. Copilot Workspace) can understand entire projects
  • Test generation tools like CodiumAI are learning to infer behavior
  • Code Review AIs (e.g., DeepCode, Sonar) catch stylistic and security issues

But ultimately, AI is not yet creative or judgmental. It’s still better as a coding assistant, not a replacement.


💬 5. Final Thoughts

AI-written code is here to stay—but it’s not here to replace human developers. Its power lies in:

  • Speeding up development
  • Handling repetitive coding tasks
  • Acting as an assistant, not an architect

Developers should focus on system thinking, security, and problem-solving, while using AI to handle boilerplate and accelerate output.


📚 Sources & Further Reading

  1. GitHub Copilot Documentation
  2. OpenAI Blog: Codex
  3. Stack Overflow Developer Survey 2023
  4. AI Coding Tools Benchmarks (Stanford CRFM)
  5. OWASP: Top 10 Web App Security Risks

✅ Next Up:

Part 2: The Advantages of AI-Written Code → Efficiency, collaboration, education, and productivity.

Source: ChatGPT

Leave a Reply

Your email address will not be published. Required fields are marked *