A new article by Ars Technica suggests spaghetti code is far less useful than the traditional code that compiles to static code and provides a convenient and extensible way to execute code.
“When you want to execute your application, you need a way to communicate with it.
For example, you might want to communicate to the UI a list of all the items on your app, or to the backend a list with a timestamp of how long it took to execute,” it explains.
“These kinds of messages are a fundamental part of any good web application.
To ensure these messages are delivered reliably, you can’t just rely on a message queue, but instead need to use some kind of messaging system that provides a way for a user to request that a message be delivered.
This type of message system is called a Message Queue.”
The article goes on to explain how to implement a message system using spaghetti code.
“However, it’s not always easy to write spaghetti code for a number of reasons: a) you can run into trouble if you’re not careful about the code that’s being used to build the spaghetti code; b) spaghetti code has been known to break applications; and c) there’s a large number of spaghetti code libraries available.
So, if you want a straightforward way to run a spaghetti code program, you may want to use a library that’s been around for a long time.”
“Other common frameworks include jQuery, Bootstrap.js, Bootkit, and other common libraries.”
It continues: “In the case of spaghetti, the spaghetti that’s used in a framework is usually called the runtime.
When a runtime is compiled and executed, the runtime compiles the code, and then executes the code in a way that will not cause spaghetti code errors, so it will always be a static library.”
The articles conclusion suggests that the use of a runtime to compile a spaghetti-like code is a good practice, but it doesn’t recommend that the developer use it as a default method of running a spaghetti application.
“You can also use the runtime to execute static code that has been designed for the framework that you’re working with,” it concludes.
“For example, if a user is creating a new application, they can simply specify the runtime and a message will be delivered to the runtime that will contain the code for the app.”