What is a class in programming — the blueprint code uses to stamp out objects

Here's a funny thing. Ask AI to write a game in Python — and you'll almost certainly see class Player. Ask for a site in React — and there may be no classes at all. Same model, same task: "make a character".
It's not the model being moody. A class is one way to organize code. In some places it's central, in others it has nearly gone out of fashion. Let's figure out what it is and how to read it.
What a class is, in plain words
A class is a blueprint. It describes what things of a certain kind will be like. What properties they have and what they can do.
The blueprint itself does nothing. You can't drive a car's blueprint. But you can build as many real cars from it as you like. Identical in design, but each with its own color and mileage.
Those "built cars" are called objects in code. There's a full breakdown in the article on what an object is. In short: an object is a set of named data, like { name: "Anya", score: 120 }.
What a class looks like in code
Here's a simple player class in JavaScript:
class Player {
constructor(name) {
this.name = name
this.score = 0
}
addPoints(points) {
this.score += points
}
}
const anya = new Player("Anya")
const max = new Player("Max")
anya.addPoints(50)
Let's take it apart.
class Player— we declared a blueprint named Player. Class names are usually capitalized.constructor— the assembly instructions. It runs when a new object is created. Here it stores the name and sets the score to zero.this— "the very object being built right now". For Anya,this.nameis "Anya"; for Max, it's "Max".addPoints— a skill every player will have. Functions inside a class are called methods.new Player("Anya")— build a new object from the blueprint."Anya"goes into the constructor as a parameter.
After anya.addPoints(50), Anya has 50 points and Max still has zero. One blueprint, but the objects live separately.
Why classes exist at all
Imagine there aren't two players but two hundred. Without a class you'd write two hundred identical objects by hand. And copy the scoring function into each.
A class removes that repetition. You write the logic once — and everyone has it. And if you find a bug in addPoints, you fix it in one place. For all two hundred players at once.
There's a less obvious detail too. Methods aren't copied into every object. They live in one place — on the class — and the objects refer to them. So two hundred players don't hold two hundred copies of addPoints in memory. But properties like name and score belong to each one.
The second benefit is order. A player's data and everything you can do with it sit side by side. No hunting through the project for where the score gets changed.
Why some projects use classes everywhere and others don't
Here's the answer to the opening puzzle.
- Python, Swift, Kotlin, Java, C# — classes are at the center of everything there. Game characters, app screens, data models — almost all described with classes. AI writes them by default here.
- Modern JavaScript and React — the custom there is to build code from functions and plain objects. Old React components were classes; new ones are functions. So AI rarely writes classes for the web.
Neither approach is "more correct". They're different traditions of different languages. But it's useful to know which one your project follows. If AI suddenly drops a class into functional React code, that's a reason to ask. Same as with any odd piece when you're reading code from AI.
Where you'll meet classes
- Built-in tools.
new Date(),new Map(),new URL(...)— these are all classes built into JavaScript. You use them even if you've never written one. - Errors.
new Error("something went wrong")— also an object from the Error blueprint. - Mobile apps. In Swift and Kotlin, every screen and every data model is often a class.
How is a class different from an object?
A class is the description; an object is a concrete thing created from it. There's one Player class, but as many player objects as you like.
What is inheritance?
It's when one class takes another as its base and adds its own. For example, class Boss extends Player can do everything a player can, plus something extra. Handy, but long inheritance chains quickly tangle code.
Do I have to learn classes if I code with AI?
Writing them yourself — not necessarily. Reading them — yes: the words class, new and this show up in other people's code all the time. Without them, half the errors will look like riddles.
The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.





