The word “Apex” stops a lot of beginners cold. It sounds like a serious programming language you need a computer-science degree to touch. It isn’t. If you’ve seen a little Java or JavaScript, Apex will feel familiar within an hour. And if you haven’t, it’s still one of the friendlier first languages, because Salesforce handles the hard parts (servers, databases, security) for you.
This post gets you from “I’ve never written Apex” to “I just ran my first class” with nothing but the org you already have.
What Apex actually is
Apex is Salesforce’s own programming language, and it runs on Salesforce’s servers — never in the browser, never on your laptop. You write it, save it to your org, and the platform runs it for you. That’s an important comfort: you can’t crash your computer or break the internet. The worst you’ll do is see a friendly error message.
You reach for Apex when point-and-click tools can’t express your logic — complex calculations, talking to outside systems, or processing many records at once. (When to use Apex versus clicks is its own decision; I cover it in Flow, Apex, or Clicks?.)
Where you’ll run it: the Developer Console
You don’t need to install anything to start. Inside Salesforce:
- Click the gear icon (top right) → Developer Console.
- In the Developer Console, open Debug → Open Execute Anonymous Window.
That window lets you run Apex instantly and see the result — perfect for learning. Paste this in and click Execute:
System.debug('Hello from Apex — my first line of code on the platform.');
Now open the Logs tab, find your run, and look for that line. That’s it — you just ran Apex. System.debug() is your best friend while learning; it prints a message to the log so you can see what your code is doing.
Your first real class
“Execute Anonymous” is a scratchpad. Real Apex lives in a class — a named container for your logic. In the Developer Console: File → New → Apex Class, name it Greeter, and write:
public class Greeter {
// A method: a named action the class can perform.
// It takes a name and returns a greeting.
public static String greet(String personName) {
return 'Welcome to Salesforce, ' + personName + '!';
}
}
A few things to notice, because they’re the whole grammar of Apex:
publicmeans other code is allowed to use this class.staticmeans you can call the method without creating an object first — fine for a simple utility like this.Stringbeforegreetis the return type — this method hands back text.String personNameis a parameter — the input the method needs.
Save it. Now go back to the Execute Anonymous window and call your class:
String message = Greeter.greet('Mustafa');
System.debug(message);
Run it, check the log, and you’ll see your greeting. You’ve now written a class, a method, passed an argument, and read a return value — that’s genuinely the foundation of everything in Apex.
The one habit that separates good developers early
When I learned, the temptation was to write more code faster. The better habit is the opposite: run small pieces often. After every few lines, drop in a System.debug() and check the log. You learn what the platform is actually doing instead of guessing. Twenty years of teaching taught me that understanding beats speed every single time — speed comes for free once you understand.
Where to go next
You now have the mechanics. The next thing most beginners build is a trigger — code that runs automatically when a record is created or changed — but before you write more code, learn when not to. A surprising amount of what beginners write in Apex should have been a Flow. Read Flow, Apex, or Clicks? next, then keep building through the Foundations category.
You wrote code that ran on an enterprise platform today. That’s not nothing. Keep going.