Apex is Java-like language that automates backend logic into applications on Salesforce – a popular cloud-based CRM owned by the US company with the same name.
What is the nature of Apex as a programming language? What are its benefits and downsides? Who might be interested in learning it and why?
But first let’s talk Salesforce.
WHAT IS SALESFORCE?
In 2018 Gartner named Salesforce the best PaaS (platform as a service solution) for business. In 2019 it was recognized as the world leader in the CRM market for the past 6 years.
Today Salesforce is implemented by more than 150,000 companies, including Sony, Financial Times, Toyota and many other well-known global brands.
Salesforce is dynamically developing not only the CRM direction, but also the entire platform ecosystem. According to a study of the IDC (international consulting company), in 2022 the Salesforce platform has created near 3 million jobs worldwide, developers' positions included.
HOW IS APEX USED ON SALESFORCE?
Salesforce uses Apex, a strongly typed object-oriented programming language with a Java-like syntax, for server-side development. Apex code is stored in the format of classes and triggers. A class is a template for creating Apex objects, and a trigger is code that is executed before or after a database call. Also, Salesforce uses its own language for data management. It is similar to SQL and called SOQL.
WHAT ARE THE BENEFITS OF APEX:
Apex teaches you how to write optimal, resource-efficient code
Writing resource-efficient code in Apex is not a whim or a recommendation, but a must. Salesforce is a cloud-based platform, therefore the software resources for each client are limited by license. In other words, the resources you have at your disposal as a developer on Salesforce platform are limited.
Execution of code that violates the limits will result in a system error and rollback of the transaction. Therefore, Salesforce guidelines on how to write optimal code are quite specific.
It can be considered as an Apex benefit, because from the very beginning you get used to writing optimal code that manages cloud resources wisely. A good way for beginning developers to start optimizing their code.
Apex teaches you unit testing and test-driven development
75% of Apex code must be covered by unit tests before porting it to a PROD environment. Therefore, you learn to create test classes from the very start. It's a useful technique for changing the way you look at your code, forced to keep in mind all the test writing.
The Salesforce goes further in this regard and advocates starting with unit tests first. It helps you better understand all the user scenarios that your future code should handle. Therefore, Apex is the programming language that leaves you no choice: you immediately learn the best practices and a conscious approach to the development process.
Apex has unified and up-to-date documentation collected on the Salesforce Portal
Salesforce is developing Apex as the primary language of the platform, so all updates and documentation are in one official portal – Apex Developer Guide.
It contains all the system classes and methods with their purpose and application described in detail. This way you can easily find an answer to every question while training.
Apex has out-of-the-box database access
A huge plus for a beginning Apex developer is an easy database access. Data base can be entered from anywhere in the code, it does not require additional settings or connections.
Apex is 90% Java. You can work with Java after developing on Apex
Salesforce built Apex based on Java syntax with small differences caused by platform specifics. If you look at the methods of working with primitives and collections, they are very similar to Java. Therefore, by learning Apex you also learn Java. And it works vice versa. If you decide to move into Java development, you won’t have to start from scratch.
WHAT ARE THE DOWNSIDES OF LEARNING APEX?
Basically, there is one main flaw.
Apex is applicable to Salesforce products only
Unlike Java, Python, and other cross-platform languages, Apex can only be used for development on the Salesforce.com platform. Despite the variety of Salesforce products, you are limited to its stack.
WHO WILL BENEFIT FROM LEARNING APEX?
Beginners in programming, looking for a two-in-one bonus (Java and Apex);
Salesforce admins who want to switch into development;
Experienced developers who want to know the specifics of programming on the Salesforce platform.
IN A NUTSHELL
Apex is a great way to start if you want to learn proper coding. Salesforce rules and guidelines will walk you through the best practices of Object-Oriented programming that you will be able to implement in any other language later. However, it is better to look in other directions if:
- you are not planning to grow professionally as a Salesforce specialist;
- your English is not there yet. It can complicate any programming language learning, but Apex in particular.