Major new Golf version is out that adds status-safety

All the new features and fixes for Golf 397 can be found here. Though one feature in particular is important. I am talking about "status safety". Golf is already memory safe, and has been from the early days. However, another common source of errors and application faults is not checking the status of whatever you're doing. Golf statements always have an optional status you can check. But what happens when you don't? Well, say you're reading some text from a file and this text is used later on to perform important functions. So if the read fails, so will the rest of your program, often miserably. To avoid that, Golf will now always check a "negative" status of any statement that you're not checking yourself. So if you're obtaining the status, Golf won't do anything. But if you're not, Golf will check if the statement failed in a way that may cause trouble. Now, the exact way how this is done depends on the statement, its functionality, and its results. Most of this "sanity" check is done at compile time - proper code is generated, and only the minimum necessary run-time checks are done. In addition, Golf statements typically do a lot, they are kind of like "magic boxes" that will substitute tons of code you'd write otherwise. So, these checks happen rarely, only at the end tail of statements, and thus consume very little performance-wise. Between memory-safety and this safe-status feature, Golf can be your friend in writing safe high-performance web services and applications, as well as command-line programs and application servers.

Apr 15, 2025 - 05:27
 0
Major new Golf version is out that adds status-safety

All the new features and fixes for Golf 397 can be found here.

Though one feature in particular is important. I am talking about "status safety".

Golf is already memory safe, and has been from the early days. However, another common source of errors and application faults is not checking the status of whatever you're doing.

Golf statements always have an optional status you can check. But what happens when you don't?

Well, say you're reading some text from a file and this text is used later on to perform important functions.

So if the read fails, so will the rest of your program, often miserably.

To avoid that, Golf will now always check a "negative" status of any statement that you're not checking yourself. So if you're obtaining the status, Golf won't do anything.

But if you're not, Golf will check if the statement failed in a way that may cause trouble. Now, the exact way how this is done depends on the statement, its functionality, and its results.

Most of this "sanity" check is done at compile time - proper code is generated, and only the minimum necessary run-time checks are done. In addition, Golf statements typically do a lot, they are kind of like "magic boxes" that will substitute tons of code you'd write otherwise. So, these checks happen rarely, only at the end tail of statements, and thus consume very little performance-wise.

Between memory-safety and this safe-status feature, Golf can be your friend in writing safe high-performance web services and applications, as well as command-line programs and application servers.