Hey everyone! I started dipping my toes into smalltalk, right after reading a quote from Kent Beck stating that to really understand Object Oriented Programming you need to learn smalltalk.
My journey into Smalltalk has been more than just learning a new language; it’s been a shift in how I think about programming. One of the most profound takeaways has been the realization that objects aren’t just data structures with attached functions; they’re a powerful tool for abstraction, completely reshaping how we represent both data and code.
Beyond Data and Code: The Object as a Unifying Concept
In smalltalk the only conceptual tools available are objects and messages. Objects are just things that respond to messages.
In most programming languages, you have data (like numbers or text) and then you have code (like instructions that do stuff with that data). They’re kind of like separate teams working together. But in Smalltalk, it’s a whole different ball game. Everything – and I mean everything – is an object. It’s like all the teams merged into one super-team, where everyone has their own special skills and works together seamlessly.
This means that even things we normally think of as “just data,” like the number 5 or the word “hello,” are actually objects with their own built-in abilities. And the “code” that does stuff with that data? That’s inside the objects too, as little “missions” they can carry out.
This might sound a bit abstract, but it’s actually super helpful. It lets us think about our code at a much higher level. Instead of getting bogged down in the nitty-gritty details of how data is stored or how functions work, we can just focus on how these little objects interact with each other.
Objects as Building Blocks: Making Code Feel Like LEGOs
This object-centered approach makes it so much easier to model real-world things in our code. Imagine you’re building a program for a library. You’d have books, members, librarians – all sorts of things. In Smalltalk, each of these becomes an object. A “book” object has information like its title and author and actions it can perform, like being borrowed or returned.
This makes coding feel a lot like building with LEGOs. You have all these different pieces (objects), each with their own unique properties and abilities, and you can combine them in creative ways to build amazing things. It makes the code much more intuitive and easier to understand, because it mirrors how we think about the real world.
Hiding the Mess: Objects as Neat Little Packages
One of the coolest things about objects is how they hide complexity. When you want an object to do something, you just send it a message. You don’t need to know how it does it; you just need to know what you want it to do.
Think of it like ordering a pizza. You tell the pizza place what you want, and they take care of all the details: making the dough, adding the toppings, baking it in the oven. You don’t need to know how they do all that stuff; you just care about getting your delicious pizza. Objects work the same way. They handle all the messy details internally, so you can focus on the bigger picture.
A Shift in Perspective: From Procedures to Interactions
Smalltalk’s object-centric approach encourages a shift in perspective from thinking about procedures and algorithms to thinking about interactions between objects. Instead of writing long sequences of instructions, you define how objects collaborate to achieve a desired outcome. This leads to more modular, flexible, and maintainable code.
Exploring Smalltalk has been like taking a step back to see the bigger picture of OOP. It’s helped me understand the core principles in a way that I hadn’t before. It’s not about classes and inheritance (heck, javascript didn’t even need them before!); it’s about creating objects that communicate with each other through messages, manage their own state, and use callbacks to orchestrate complex interactions.
If you’re looking to deepen your understanding of OOP, I highly recommend giving Smalltalk a try. It might seem a bit different at first, but trust me, it’s worth the effort. You might just have a few “aha!” moments of your own. And as always feel free to ask questions or leave comments below!