Sean is Coding #5: Into the Backend with Python
This week we switched to Python and started building servers and APIs using Flask.
Contents:
Progress Report
Bug Report
Surf Report
Tweet Report
Progress Report
And just like that, our third week of bootcamp at Rithm School has come and gone and this was a big one.
We switched from JS to Python and from frontend to backend
We started building servers and APIs using Flask, a backend web framework for Python
We spent a lot of time thinking about type safety and ways to be really diligent about ensuring we’re passing and working with the right kinds of data before we get to deep in implementation.
Python
We waded into the wild world of backend this week, exchanging JavaScript for Python and the browser console for the Terminal.
One major takeaway I have from this week is that it is a lot easier to learn a programming language when you’re not also learning programming at the same time.
Python is similar enough to JavaScript that it didn’t really feel like we needed to slow down in terms of learning new concepts just because we were looking at it through the lens of a different language.
So far, coding in Python is a bunch of fun. That it was designed from the ground up to be a fully-fledged programming language really makes it feel a lot richer out of the box. I’m particularly liking:
Doctests — The idea that you can just build self-documenting unit tests directly into your functions is insanely satisfying.
Errors — There is no undefined in Python! When you request something that isn’t there, or is an incorrect type, you just get an error. I feel like I can get things done so much more quickly now.
Methods — There are so many more methods available in the standard Python API that you need to build from scratch or by importing other libraries in JavaScript. Some of my faves are zip(), title(), and sorted().
Flask
We also dove into the Flask framework and started building server-side APIs for the first time. This is one area where I’m relieved to be coming in with some background from Ruby on Rails. The concept of constructing endpoints as routes was thankfully already familiar to me, so I could focus my attention on teasing out the details of how Flask works.
Bug Report
It’s hard to put my finger on one bug in particular since this week was also the week we started to dive more deeply into testing frameworks and test-driven development.
With all the API work we’re doing, I’ve been doing most of my debugging work by dropping breakpoints into my app and exploring the variable environment at different places in the thread of execution.
Just yesterday, my partner and I were building an online Boggle game, and we wrote a view function that would generate a UUID for a new Boggle game and assign it to a new game instance with a freshly shuffled board.
@app.post("/api/new-game")
def new_game():
"""Start a new game and return JSON: {game_id, board}."""
game_id = str(uuid4())
game = BoggleGame()
games[game_id] = game
return jsonify({"game_id": game_id, "board": game.board})
What looks like 4 lines of code was actually about 50 lines of debugging requests via iPython and pdb to play around with the data available at the time of request. I’m finding that I actually really love the exploratory / investigative nature of this aspect of the work! Maybe I’ve got a future in backend yet!
Surf Report
Some of my favorite links from this week.
Why was there a run on Silicon Valley Bank. A solid explainer for the uninitiated like me on how something so big could go so bad so quickly.
Cascadia Code Font. I discovered this font for my VS Code editor earlier in the week and it’s quickly taking over as the default font on most of my notes / writing apps. I never thought I’d turn my back on iA Writer, but this font really slaps! Check out the cursive stylistic set for italics, too. Chef’s kiss.
LLMs are not going to destroy the human race. I’m about 90% through Nick Bostrom’s Superintelligence, a book that is not making me feel good about our ability to handle an AI future. This article makes me feel a bit better about the near term.
Build Your Own AI Chatbot with ChatGPT API. Guide for building a chatbot with the ChatGPT API in Python. The transition to AI will be on par with the transition to mobile: It’s going to swallow everything, and I honestly think it’s never been a better time to learn to code.
Tweet Report
Some of my favorite tweets from this week. My timeline filters out any tweets that mention Elon Musk.
Speaking of AI, here’s a great chart showing the landscape of VC investment in AI at the moment.
Best take I’ve heard yet on Peter Thiel’s role in the run on SVB:
I really hate it when I agree with David Sacks, but he’s right. There were many ways SVB could have avoided this outcome, but one lesson we should all take away is that we need guardrails for banks to ensure banks are managing our liquid assets responsibly.