From The Challenges - Lisp
Exploring the software engineering lessons we can learn from the solutions I've seen.
Hi this is John with this week’s Coding Challenge.
🙏 Thank you for being one of the 89,438 software developers who have subscribed, I’m honoured to have you as a reader. 🎉
If there is a Coding Challenge you’d like to see, please let me know by replying to this email📧
Welcome To Coding Challenges - From The Challenges!
In this Coding Challenges “from the challenges” newsletter I’m sharing some of the common mistakes I see software engineers make when tackling the Coding Challenges.
I’m sharing both the mistakes people make and some thoughts on how you can you avoid making the same mistakes when taking on the coding challenges or when writing software professionally. Sometimes we have to make mistakes to learn from them, somethings we can learn from other people’s mistakes, then make our own new ones! 😀
Recapping The Build Your Own Lisp Interpreter Coding Challenge
In the build your own Lisp interpreter coding challenge the goal was to write an interpreter for the Lisp programming language.
Lisp is a general-purpose, multi-paradigm programming language suited for a wide variety of industry applications. It is probably most widely know for being the programming language built into the Emacs editor. It was used to build Hacker News (Paul Graham is a Lisp fan), Grammarly, Circle CI (actually using the modern dialect Clojure) and Boeing also use Lisp.
🚨Would You Like To Learn Go By Building Coding Challenges! 🚨
I’m running the Coding Challenges Learn Go By Building Live Course again in September.
It is a live course that runs for three working weeks from September the 15th to the October the 3rd. During the course I’ll introduce you to ever aspect of Go that you need to build the following five real-world projects (based off five of my coding challenges):
🏗️ cat - By building cat you learn how to build and run command line programs in Go.
🏗️ sort - By building sort you learn how to use Go's data structures and control flow to implement sort.
🏗️ curl - By building curl you learn how to write network clients in Go.
🏗️ wc - By building wc you learn how to process text data and handle locales with Go.
🏗️ Memcached (Capstone Project) - By building a Memcached server clone you learn how to build efficient network servers in Go.
Having built these five real-world applications you will be well equipped to take on new projects in Go!
Check out the Coding Challenges Learn Go By Building Live Course for full details and to sign up.
If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
Refer a friend or colleague to the newsletter. 🙏
Sign up for a paid subscription - think of it as buying me a coffee ☕️, with the bonus that you also get 20% off any of my courses.
Buy one of my self-paced courses that walk you through a Coding Challenge.
Join one of my live courses where I personally teach you Go by building five of the coding challenges or systems software development by building a Redis clone.
Five Common Mistakes Software Engineers Make Solving The Lisp Interpreter Coding Challenge
I’ve pulled together this list of common mistakes from the hundreds of submissions I’ve been sent privately and the many shared in the Coding Challenges Shared Solutions GitHub Repo.
Mistake 1 - Not Writing Tests
Most of the solutions to the Lisp interpreter coding challenge that I’ve seen have tests, but some don’t and that is, in my experience, a big mistake. Why? Because even for a small language like Lisp or C the number of possible programs you can create is infinite. Therefore to validate the correct performance of your interpreter (or compiler) you’ll need a lot of tests.
How many tests? Well, for example the most recent version of the JavaScript (ECMAScript) language has over 50,000 tests! And the standards committee (TC39) still does not believe it is complete! If you’re curious you can find the test suite in the Test262 Github repo.
Mistake 2 - Not Building A Lexer/Scanner
Building an interpreter is the perfect project to learn about building a lexer/scanner and a parser. I think it’s a mistake to then use find and replace or regex to reformat code so you can simply split on spaces to then parse the code.
Yes it’s a ‘clever’ solution. No it’s not getting the most out of completing this coding challenge. If you want to learn about building a lexer/scanner check out the excellent book Crafting Interpreters, chapters 4 and 16 will show you how.
Mistake 3 - Using The Same Name As A Builtin Function
I’m always hesitant to call a function the same name as a function that is builtin to a programming language. There’s two reasons why:
It can be confusing for either someone else maintaining the code or even ourselves in 6+ months time when we come back to the code.
If the function you re-use the name of is something like Python’s
eval
it might cause strange, or even security-related bugs.
Mistake 4 - Not Learning Lisp / Doing This Project!
After you’ve mastered one programming language, learning another, different one can help broaden your skillset, showing you different techniques and idioms. I think Lisp is a great example of that and you’re missing out if you don’t learn a bit.
Mistake 5 - No Project Organisation
I was shown a few projects where the code, tests (if they existed) documentation and other assets were all in the top level directory. Nothing was organised.
It’s trivial to create a few folders, say:
.
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── README.md
├── src
│ └── main.rs
├── docs
└── lispscripts
To organise the project and it makes it much easier for someone else to pick up the project. Or even for you to, in 6 to 12 months time.
Request for Feedback
I’m writing these coding challenges and this new from the challenges series to help you develop your skills as a software engineer based on how I’ve approached my own personal learning and development.
What works for me, might not be the best way for you - so if you have suggestions for how I can make these challenges more useful to you and others, please get in touch and let me know. All feedback greatly appreciated.
You can reach me on Bluesky, LinkedIn or through SubStack
Thanks and happy coding!
John
P.S. If You Enjoy Coding Challenges Here Are Four Ways You Can Help Support It
Refer a friend or colleague to the newsletter. 🙏
Sign up for a paid subscription - think of it as buying me a coffee ☕️ twice a month, with the bonus that you also get 20% off any of my courses.
Buy one of my courses that walk you through a Coding Challenge.
Subscribe to the Coding Challenges YouTube channel!