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.

hello.olm:

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

httptest.ol:

load "hello.olm"
show("Listening 0.0.0.0:8080... 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)
show(hello)
show(number)

Scope output:

Hello Oytun
2

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.

Functions

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

def main = fn(param){
    return param
};

main("Hello!"); 
# => main function result:"Hello!"

Literals

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

literal example(param){
   println(param)
}

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

Now we can begin to learn scope definitions.

O Language: Getting Started (Part 2)

Installation

Click download link and select your own system or package after setup your development environment path to extracted path. If you need to If you want to do development, you can install golang and extract the codes with this command;

go get -v github.com/olproject/olang

and run

olang(.exe) (-r) (-d=true [debug mode])

Thats it.

Files

Olang files is to simple. Default file extension “.ola”. Let’s start by examining the programming language example.

def hello = fn(name){
  return "Hello, "+name+"! Welcome to O-lang!"
}
def result = hello("Oytun")
show(result)

Run:

$ chmod a+x test.ol
$ ./test.ol

or

$ olang test.ol

Output:

Hello, Oytun! Welcome to Olang

Continue reading “O Language: Getting Started (Part 2)”

O Language: Getting Started (Part 1)

System Oriented Functional Programming Language (SOFPL)

SOFPL is a specific structure that interprets each line separately and outputs the result. Shorten the functions performed in normal programming languages. For example, you can do the functions you can do in 10 lines with a line. It is up to you to determine what you will do in 9 lines. 🙂

In addition, you can start the process on the system, you can open the port and start data transfer. Simple socket software and transaction management functions are available and developed.

Continue reading “O Language: Getting Started (Part 1)”