Becoming a developer is tricky and understanding what order to learn things in can seem like a minefield. Understanding whether you should learn algorithms before programming is one of those difficult decisions.
Different people provide their version of the ideal journey, while others decry it as nonsense.
The decisions you need to make can lead to analysis paralysis and then you end up not starting your programming journey at all.
Overall, you should learn programming before starting on algorithms. It will give you better context into how they are used day-to-day and applied to solve problems in the language that you are using.
However, purists believe you should learn algorithms first because programming should be learned in a language-agnostic way. So you learn the concepts rather than the language.
Let’s explore what an algorithm is and why learning algorithms before programming may not be the best idea.
What is an algorithm?
An algorithm is a function that transforms an inputted data structure and outputs it into a different data structure.
In a broader sense, algorithms allow us to do things the most optimal way. They are the ‘how’ of transforming data.
They follow a set of steps or processes to solve a specific problem and return the data accordingly.
Some common examples of algorithms you’ll likely have to learn and recreate in job interviews include:
- Array splitting
- String Reversal
- Max character calculator
- Anagram checker
- Fizz Buzz
- Vowels finder
There are thousands more than all solve unique problems. But the simple ones get you off to a good start and help you to start thinking algorithmically.
Learning Algorithms before programming: Is it worth it?
Learning to code takes a while and once you have grasped the basics the hard work really starts.
You have to figure out how to put it all into practice and solve real-life problems with the knowledge you have.
Part of the problem solving will require you to know data structures and algorithms. There is a debate around whether you should learn algorithms before even starting to learn to program.
Let’s take a look at some reasons why it probably isn’t worth learning algorithms before you can program and why you should instead focus on learning your chosen language.
1. Job dependant
Whether you need to focus on programming or algorithms first will depend on the type of job you’re aiming to get.
A lot of developer roles that revolve around building websites never require the software engineer to know algorithms or data structures. However, more technical app-focused roles may need to you have an understanding of how to manipulate and work with data structures.
So think about what area of software development you want to go into. If it’s a less technical, website or design-focused role don’t worry about picking up algorithms.
2. Front end Vs Back end
As we discussed earlier, the type of job you have will dictate the level of algorithms you need to know.
Back-end developers are more likely to run into the types of performance issues that require knowledge of algorithms. So, if you are heading down this route you need to at least brush upon them.
The advancements in web technologies have meant more and more data is pushed through our browsers. The day-to-day of a web developer has changed a lot over the last 15 years. Performance, caching, and memory are all big parts of front-end developers working days whereas they used to be very different.
However, some front-end roles don’t focus on this at all. So you are more likely to need algorithms as a back-end developer than a front-end developer.
3. Nail the basics first
I’d argue that spending too much time on algorithms before you have learned a programming language is a waste of time. You won’t have any context in which to apply your new knowledge and it may confuse you more.
It’s best to nail the basic concepts of programming first and then go from there. That way you have a foundation of knowledge to build upon and be able to practice with.
Purists who think every developer should all be language agnostic will disagree but I’m not sure how practical their approach is. if you want to quickly learn HTML or Python, or any other language, taking time away from it to study algorithms may be detrimental.
You shouldn’t neglect algorithms altogether but spend your time learning a language first.
Pick up a language and have some fun building stuff and solving small problems. Then get after data structures and algorithms when things make a bit more sense.
4. An impossible task
There are literally thousands of different algorithms and data patterns for you to study and learn.
Picking up all of them is an impossible task.
If you try and learn them without any prior context you’d essentially be trying to memorize random functions. Rote learning is never a great way to acquire knowledge and it won’t make you a better programmer in the long run.
Web development is not easy at the best of times, without subjecting yourself to trying to memorize thousands of algorithms.
Also, trying to improve the performance of algorithms isn’t a great idea if you have no concept of how to write a function in the first place.
5. A problem-based approach
Many software engineers take a problem-based approach to learning algorithms.
Essentially, you learn and focus on a particular algorithm as you encounter a problem that needs solving. You then slowly accrue the knowledge as you become more experienced.
You focus on programming then learn the algorithm as necessary. It means you never take on an algorithm without the contextual knowledge to be able to handle it.
Some problems just require you to build something. Others require complex manipulation of data arrays and objects. Take a problem-based approach means you tackle the problem that is in front of you, rather than just learning algorithms before programming for the sake of it.
Doing it this way allows you to start simple and essentially learn the two side by side. You take what you learned in practical content and then apply it to solve a specific issue with an algorithm.
Many developers also brush up on their algorithm knowledge when applying for new jobs as they are common in technical interviews.
Day-to-day your job is going to require you to know which algorithms are good for solving a particular problem, not necessarily the theory behind them.
Why are algorithms and data structures important?
Tech-focused companies look for different things in their developers than small IT firms.
If you intend to get a job at a company that’s working on the cutting edge be prepared to learn algorithms and data structures. Knowledge of these is often the difference between working at a FAANG company and working for a design-focused agency.
However, as we have discussed throughout the article. You should:
- Learn and master a programming language first
- Then proceed to learn data structures and algorithms
Companies put a huge emphasis on algorithm knowledge at hiring time so they are incredibly important if you want to land a top job.
Aside from getting hired, algorithms and data structures are important because they allow us to manipulate data.
These specific functions allow us to manipulate, transform, and analyze data sets to better solve a problem. They make our code more efficient and follow the core principles of coding (DRY code, KISS, etc)
Best places to learn algorithms
I didn’t put much effort into algorithms until I was job hunting. Then I signed up to all the usual sites, some of which I have listed below, and hit them hard.
The resources below will give you a structured approach to learning algorithms and put you under some time pressure to solve the issues.
In some ways, they gamify the process which makes it fun and means the information sticks.
FullStack Cafe is a fantastic resource for full-stack, web, and mobile development.
Not only do they have a section specifically for data structures and algorithms but they have an enormous database of interview questions.
Every language has a range of free questions & answers open to beginners, then as you progress you’ll need to sign up to get access to the more challenging stuff.
So many of the React questions I got asked in my recent round of interviews were up on FullStack and helped me during the application process.
LeetCode is one of the world’s most popular technical interview platforms. They have tonnes of information on data structures and algorithms and plenty of free questions for you to practice.
Their coding problems are split into easy, medium, and hard, with the number of each depending on the language.
The premium subscription gets you access to questions that companies answered plus the solutions to all the problems.
HackerRank has grown in popularity over the last five years and is the platform that a lot of companies use to stage their tests.
Companies like Stripe, LinkedIn, and DropBox all use HackerRank for hiring. It means they have the exact questions and answers you are likely to be asked in your interview.
They gamify their problems and offer puzzle-based questions which are great to get you thinking outside the box.
Coderbyte is a well-organized platform that is perfect for new developers looking to land their first big job.
Their range of questions will prepare you for anything when the technical interview rolls around.
The starter courses and interview kits are great for anyone needing that edge at interview time.
As a self-taught developer, I am a huge fan of Udemy. They offer a range of amazing courses from talented tutors.
Among them, Colt Steele is up there with the best. His teaching style is fantastic and he always takes the time to explain the concepts. He breaks everything down and simplifies it which is perfect for beginners.
Understanding the “correct” order to learn to code in is tricky enough. There is so much to take in and new technologies always emerge.
When starting don’t learn algorithms before programming. You need to learn a language first to have some context to apply the concepts. Nail the basics and then you can start shifting some attention onto learning algorithms.
Algorithms are incredibly important but you need to understand basic programming concepts before diving in.