This is part 2 of me talking about why AI chooses good technology when you create a new project with an LLM. In this one I will talk about the basic API frameworks that LLMs gravitate towards. As always this is a very surface level view of these frameworks and the most correct answers will be incredibly deep, too deep for this beginner’s explanation.
You can check out the two templates I’ll be using at these links
API Template
Cursor Prompt: “Please create an extremely barebones nodejs project in the `api-template` folder”
Cursor, being the diligent little worker it is, created a new Node.js project with the following technologies: node js, express, and typescript.
What is Node.js
Node.js is a runtime environment for JavaScript. When JavaScript was first written, it was intended to be run in a web browser. It became so popular with libraries, guides, and online resources that developers wanted to be able to use the language for non-browser based activities. Enter Node.js. Node.js lets you run JavaScript scripts outside of the browser, letting people who are familiar with this language for front end purposes build their own backends. Additionally, Node.js is fast, and uses an event-driven, non-blocking I/O model, capable of handling a bunch of concurrent network requests which means it scales really well.
Node.js is incredibly popular and you can’t go wrong with choosing it as your run time environment. Easy to set up, mountains of available resources and tutorials and Stack Overflow posts.
What is Express
Express is a framework that runs in Node.JS. It lets you build API’s quickly and, eventually, richly. It has all kinds of support and integrations that make building complicated systems easy and maintainable.
Lets take authentication for example: let’s say you only want users who are signed in to be able to edit their own posts. To do this you can create a “middleware” function which runs on every route and will reject the request if the user is not signed in.
I mean actually what you do is install passport and just follow the guide for the bearer token strategy but that’s for a later post. Generally you want to use popular packages that already exist wherever you can.
Summary
To use a very basic analogy, if your web application is a meal then Express is the frying pan and Node.JS is the stove. You don’t have to use a frying pan or stove to cook your meal, but if you know how to use them you might as well. And stoves are incredibly popular, you have a better chance of finding a job if you know the cooking equipment that most kitchens use.https://blog.anarchistsghostwriter.com/blog
Want to know more?
Leave a Reply