RimStone examples
Updated on 2025-11-11. Always use the latest RimStone version to run these examples.
- 34000 requests per second on a modest laptop
This example shows how to create and start an application server, and how to connect to it and make requests from a C client (or from any language that supports C API extension). Create new directory for the RimStone server and also for C API client: ...
- Using Vim color schemes with RimStone
RimStone installation comes with a Vim module for highlighting RimStone code. After installing RimStone, run this to install the Vim module: ...
- Example of auto status checking with RimStone
When talking about safety in programming, it is memory safety that usually takes the spotlight. However, here we'll touch on another common safety issue that typically causes application logic errors, meaning your program won't function correctly. It's about checking the status of any kind of statement that provides it. Not checking the status could mean that the result of a statement isn't correct, yet your program is proceeding as if it were. Of course, this is bound to cause problems, and this is true for any programming language. ...
- Random numbers in RimStone
Generating random numbers is important in a wide range of applications. For instance, session IDs often use random numbers; they are also used in generating passwords; another example is load balancing where (say instead of round-robin), the next available process to serve a request is chosen randomly; some applications (like gambling) depend on random qualities; any kind of simulation would heavily rely on random numbers; financial and polling applications use random samples to determine outcomes and policies. The list of possible uses is pretty long. ...
- How is memory organized in RimStone
RimStone is a memory-safe language. A string variable is the actual pointer to a string (whether it's a text or binary). This eliminates at least one extra dereferencing and a memory read (such as the case in many other languages); it makes RimStone memory performance very close to C. ...
- More than one table in a database transaction in MariaDB
Here you'll learn how to use a database transaction to insert/update into multiple tables; so that if any of those fail, the entire transaction is cancelled (rollbacked), and if they all succeed, the transaction is committed as a whole, atomically. ...
- Use C language API to talk to RimStone Server
RimStone application server can be accessed via C API. Most programming languages allow for C linkage, so this makes it easy to talk to RimStone server from anywhere. The Client-API is very simple with just a few functions and a single data type. It's also MT-safe (i.e. safe for multi-threaded applications). ...
- RimStone is a different kind of programming language
Over the past 50 years, many general-purpose programming languages became more complex due to the constant influx of new features (some of which are great, while others are a "feature creep"). Just look at some major programming languages in their early days, versus the latest incarnations. From a distance, it may look like you switched from riding a bicycle to flying a passenger jet with a few hundred knobs, buttons and readout consoles. Arguably, the language structure covers many more usage patterns, yields additional power, and safety has improved, but the complexity and the learning curve has increased too. While in the beginning there was lots of pitfalls due to the lack of features and safety, in the end there's a minefield due to an overcrowded feature-scape that's paralyzing to deal with and often not quite understood by anyone on the team. ...
- Hello World in the command line
Create a directory for your Hello World application and then switch to it: ...
- Security of web services
The security of web services is a broad subject, but there are a few common topics that one should be well aware. They affect if your web application, or an API service, will be a success or not. ...
- Cookies in RimStone applications, plus HAProxy
Cookies are used in web development to remember the state of your application on a client device. This way, your end-user on this client device doesn't have to provide the same (presumably fairly constant) information all the time. A "client device" can be just a plain web browser, or it can be anything else, such as any internet connected device. ...
- What if toolkit library is missing?
You can choose to not install any toolkit libraries when you setup RimStone (see install-rimstone). So what happens when at some point you write code that requires one of those libraries? ...
- Hello World in RimStone
In RimStone you write service providers (or request handlers). So Hello World would be one such request handler. ...
- Web service Hello World
To access a RimStone service on the web, you need to have a web server or load balancer (think Apache, Nginx, HAProxy etc.). ...
- Fast JSON parser with little coding
RimStone's JSON parser produces an array of name/value pairs. A name is a path to value, for instance "country"."state"."name", and the value is simply the data associated with it, for instance "Idaho". You can control if the name contains array indexes or not, for instance if there are multiple States in the document, you might have names like "country"."state"[0]."name" with [..] designating an array element. ...
- Calculate mortgage amortization and total interest
This example shows using math functions to compute an amortization schedule for a mortgage, as well as total interest. It shows how much interest vs principal is paid each month. ...
- Using Regex in RimStone
Regex (or "REGular EXpressions") is a powerful way to search strings, as well as to replace parts of strings. It makes it easier to reliably do so, since regular expressions are usually short; at the same time there's a learning curve in becoming proficient. However, given that regex is ubiquitous, it is worth learning at least some of it, as it can come handy. ...
- Web framework for C programming language
RimStone has an "extended" mode, which allows for C code to be used directly. Normally, this is not allowed, but if you use extended-mode statement in your .rim file, then you can call C code from it. ...
- What is web service
Web service is code that responds to a request and provides a reply over HTTP protocol. It doesn't need to work over the web, despite its name. You can run a web service locally on a server or on a local network. You can even run a web service from command line. In fact, that's an easy way to test them. ...
- Functions and parameters in RimStone
In RimStone, there are no "functions" or "methods" as you may be used to in other languages. Any encapsulation is a request handler - you can think of it as a simple function that executes to handle a request - it can an external request (i.e. from an outside caller such as web browser, web API, or from a command-line), or internal requests from another handler in your application. ...
- How to create a RimStone application
To create a RimStone application, use "-k" option of rim utility: ...
- Reverse string: recursion in RimStone
This example will reverse a string, i.e. turn it around so that it's like in the mirror. This will be done by using recursion; of course it can be done in other ways too, but this will demonstrate the use of recursion to manipulate a string. For a different recursion example (that calculates a factorial of a number), see article-recursion-factorial. ...
- How to debug RimStone programs with gdb
Debugging information is always included regardless of how you make your application; what varies is the amount of debugging info included. You can compile your RimStone application normally: ...
- Cache server in 30 lines
This is a cache server that can add, delete and query key/value pairs, with their number limited only by available memory. ...
- What is an application server
Every RimStone application is built as both an application server and a command-line program. You can use both, depending on what's the nature of your application. Some programs are meant to be used in scripts, or executed directly from command line. Others need to stay in memory and execute user requests as servers. The nice thing is that they both work the same, meaning you can run from command line anything that an application server does, and vice versa. This is also handy for testing; it makes writing tests for an application server much easier because you can run such tests in a plain bash script. ...
- Introduction to RimStone
RimStone is a new programming language and framework for developing web services and web applications. It is: ...
- Call web service from web service: stacking them up
A web service doesn't necessarily need to be called from "the web", meaning from the web browser or via API across the web. It can be called from another web service that's on a local network. ...
- SQLite with RimStone
This example will create a service that inserts key and value into SQLite table. It's tested from command line. ...
- Messaging between C client and server
This example shows how to exchange messages between RimStone server and a C API client (see Client-API). The client uses FastCGI binary protocol to communicate with the server. SEMI messaging is used as a format of messages. In this example, a client sends 10 variable length message to the server (meaning each has a different number of key/value pairs); the server then gets each key/value and replies in kind. The client displays the result. ...
- Multi-tenant SaaS (Notes web application) in 200 lines of code
This is a complete SaaS example (Software-as-a-Service) using PostgreSQL as a database, and RimStone as a web service engine; it includes user signup/login/logout with an email and password, separate user accounts and data, and a notes application. All in about 200 lines of code! You can have multiple users sign up and create and manage their own notes. ...
- More than one table in a database transaction in SQLite
Here you'll learn how to use a database transaction to insert/update into multiple tables; so that if any of those fail, the entire transaction is cancelled (rollbacked), and if they all succeed, the transaction is committed as a whole, atomically. ...
- Web services with MariaDB
Create a directory for your project, it'll be where this example takes place. Also create RimStone application "stock": ...
- How to build a Web Service API
This article will show a simple shopping web API with basic functions, such as adding customers, items and orders, as well as updating and deleting them. It's easy to write and easy to understand with RimStone; that's the reason code doesn't have much in a way of comments - there's no need. ...
- Memory safety: what about performance?
Memory safety guards against software security risks and malfunctions by assuring data isn't written to or read from unintended areas of memory. Preventing leaks is a separate feature that's important for web services which are long-running processes - memory leaks usually lead to running out of memory and crashes. ...
- First In First Out (FIFO) example
RimStone has built-in FIFO list type. You can create a FIFO variable and then store key/value string pairs in it, which you can then read back in the order you put them in. You can also rewind the FIFO list and obtain the same key/value pairs over and over again if needed. ...
- More than one table in a database transaction in PostgreSQL
Here you'll learn how to use a database transaction to insert/update into multiple tables; so that if any of those fail, the entire transaction is cancelled (rollbacked), and if they all succeed, the transaction is committed as a whole, atomically. ...
- How to get the web page source code programmatically
Fetching a web resource (including web page source) is a one-liner in RimStone. First, create a new application ("get-page" here): ...
- Cache as a web service
This example shows Apache as the front-end (or "reverse proxy") for article-tree - it's assumed you've completed it first. Three steps to setting up Apache quickly: ...
- Web file manager in less than 100 lines of code
Uploading and download files in web browser is a common task in virtually any web application or service. This article shows how to do this with very little coding - in less than 100 lines of code. The database used is PostgreSQL, and the web server is Nginx. ...
- Encryption: ciphers, digests, salt, IV and a hands-on guide
Encryption is a method of turning data into an unusable form that can be made useful only by means of decryption. The purpose is to make data available solely to those who can decrypt it (i.e. make it usable). Typically, data needs to be encrypted to make sure it cannot be obtained in case of unauthorized access. It is the last line of defense after an attacker has managed to break through authorization systems and access control. ...
- Calculate factorial: recursion in RimStone
Computing factorial is commonly used to demonstrate recursion in a programming language, and this example will do that. For a recursion example that manipulates a string, see article-recursion-reverse-string. ...
- Hello World as a Service
Writing a service is the same as writing a command-line program in RimStone. Both take the same input and produce the same output, so you can test with either one to begin with. ...
- How to send email with RimStone
This example shows how to send email with RimStone. The web service you'll create here is very simple and it will display an HTML form to collect info needed to send email, such as "From" and "To" (the sender and the recipient emails), the Subject and of course the Message itself. Once user clicks Submit, email is sent. ...
- How to write distributed applications
Distributed computing is two or more servers communicating for a common purpose. Typically, some tasks are divvied up between a number of computers, and they all work together to accomplish it. Note that "separate servers" may mean physically separate computers. It may also mean virtual servers such as Virtual Private Servers (VPS) or containers, that may share the same physical hardware, though they appear as separate computers on the network. ...
- Here's what installing RimStone looks like
The installation script is "riminst.sh". It installs RimStone in a location folder ".rimstone" (under home directory), so a base installation does not require sudo. However, some external components do. For instance, if you want to access a database you'll need a database access library, or to use regex expressions you'll need PCRE2 library etc. These are industry-standard tried-and-true Free Open Source libraries; using them helps with reliability and safety. These libraries are called "toolkit" libraries for obvious reasons. You don't have to install them immediately, but rather only when you need them. When you build an application that needs one of them, RimStone will ask you to install it, along with the instructions on how to do it. ...
- Statements in RimStone
RimStone is a new programming language and framework for developing web services and web applications. The reason for RimStone is to make software development easier and more reliable. ...
Examples
examples
See all
documentation
Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.