O Language: Build 4.1

A new version has been released for that language. A number of critical updates and fixes have been made in this release. Fixed unknown IDENTIFIER and similar critical problems in function definitions. In addition, the replace function has been added.

This function can be used to change strings and change strings;

def test = "test"
def test = replace(test, "test", "olang")
#=> olang

You can reach the details of the latest version via this link.

Web site: O Language

O Language: First Router

The router socket structure was created with the intention of creating an API over the HTTP/S protocol and exchanging data through the socket. In web based projects it is possible to write web server quickly and easily. In addition, the API can be created in micro-services.

hello.olm (as hello module):

def hello = fn(name){
 return "Hello, "+name+"! Welcome to Olang"

router.ola (as router script):

load "hello.olm"

def config = {
 "GET" : {
 "/" : "Welcome to the O-Lang Router!"
 "/:name" : hello("{{.name}}")

show("Listening Ctrl+C to exit.")
router("8080", config);

GET method test:

~> curl -X GET localhost:8080
Welcome to the O-Lang Router!

POST method test (oytun as parameter value for name [ :name => {{.name}} ]):

~> curl -X POST localhost:8080/oytun
Hello, oytun! Welcome to Olang

As you can see in the example, we wrote a web micro service using port 8080 via get and post methods.

O Language: HTTP Example Socket

The HTTP socket allows the HTTP protocol to be displayed on the web using any port. You can use the http(path, port, response) function to easily create an http socket.


def hello = fn(name){
 return "Hello, "+name+"! Welcome to Olang"


load "hello.olm"
show("Listening Ctrl+C to exit.")
http("/", "8080", hello("Oytun"));

First we loaded our “hello” module with load. Later in the hello() function on the 8080 port to provide this output. When we enter port localhost:8080 from our browser or curl, the result will be;

~> curl localhost:8080
 Hello, Oytun! Welcome to Olang

Now we can display the socket by connecting to 8080 port via HTTP. In the following lessons we will learn how to create routers and render pages on them.

O Language: Scopes or Classes

The scope structure is similar to class structures. All the functions defined in scope form subfunctions of a scope. In this way you can clustering by writing functions in the main scope.

Scope definition:

scope example {
 def hello = fn(x){
  return "Hello "+x
 def subone = fn(x){
  return x+1

Scope call:

def hello = example::hello("Oytun")
def number = example::subone(1)

Scope output:

Hello Oytun

Great now you are ready to write a simple web socket.

O Language: Functions and Literals

The only difference between functions and literatures is that one of the brackets can be operated without parentheses. In this way you can define your own definitions.


The system has function definition function. These functions can be used many times.

def main = fn(param){
    return param

# => main function result:"Hello!"


You benefit by creating static functions directly in the system literature.

literal example(param){

main "Hello!"
# => main literal result:"Hello!"

Now we can begin to learn scope definitions.