The story of how I developed a programming language

Hi Habr! My name is Ildar. I am 29 years old. I have been programming since 2003. In his life he created 4 frameworks and a programming language. In this post I will share my experience, insights that I received while developing the programming language BAYRELL Language. I apologize in advance for possible syntactic and punctuation errors in the text and the lack of pictures.


History of creation


I started creating BAYRELL Language in the summer of 2016. Then I found out about the angular and react. They impressed me with breakthrough technologies. I then developed websites in PHP and used Twig as a template engine. And I wanted to try Angular. I began to look for how you can tie Angular to Twig.


In general, Twig + Angular works, but there was a blinking effect. The page was rendered through Twig on the server, passed to the client, and Angular was already rendered there. And the page, while being rendered by the client, it blinked. And then I thought, is there a client-server template engine, but one that works in PHP and JavaScript?


I searched the Internet, everyone recommended using NodeJS as a server, or a V8 engine in PHP, or a micro service architecture: backend in PHP, frontend in NodeJS. Only here is bad luck. I made websites on WordPress, Yii2. And on the hosting, there was no support for NodeJS or V8. Then the idea came up, to write a cross-language template engine.


I started to do it. Wrote in a month in PHP, then in another month, wrote in JS. And he quickly realized that supporting two languages โ€‹โ€‹was difficult at the same time. If a bug appeared, then it had to be fixed both there and there. Very quickly, the versions of the template engines became different, and diverged in functionality. I had a desire to add Python. I realized that developing a template engine separately for each language is very difficult. Then another idea came up. Find a translator of languages, and convert the template code into PHP in JS and Python.


PHP to JS. . . PHP JS. , PHP JS . JS , PHP . JS console.log, PHP var_dump. Runtime , . , , , .


. , . TypeScript, CoffeeScript, Dart, Babel, JavaScript. , , JS, PHP, Python ..


BAYRELL Language.


, . 0.3 2018 . . , , .


, . , JS . 0.8.3.



  • BAYRELL Language PHP, NodeJS, JavaScript;
  • HTML ;
  • ;
  • api;
  • ;
  • ;
  • ;
  • (pipe);
  • async/await;
  • , memorize;
  • ;
  • ;

.


BAYRELL Language Runtime , Full Stack . , API, .



, . , .


:


npm install -g bayrell-lang-compiler

:


git clone https://github.com/bayrell-tutorials/clear-project
cd clear-project
git submodule init
git submodule update

:


bayrell-lang-nodejs make_all
bayrell-lang-nodejs make_symlinks

:


bayrell-lang-nodejs watch

, nginx document root web .


:




HTML


:


  • PHP JS.
  • .
  • Direct HTML DOM Virtual DOM.

, .


, LayoutModel, ( ). โ€“ . render, HTML . JS ( , ..) . , , , . , , RenderDriver.


RenderDriver LayoutModel, requestAnimationFrame. render , HTML DOM. render VirtualDOM, HTML.



(). , , . , , . , , Lisp, Haskell, F#, , , .


. , , , , Dependency injection, , . , . .


, , (), private , setName(), getName(). . . .


, . , . , .


, , .



BAYRELL Language. .


โ€“ , (). . , . , , . , , , , . . , .


โ€“ . , . , . , .


: , memcached .. 12 .


, . ? , . - , . . , , , , , , , , , .. , , ยซยป .


. , , , . , , , , . . . . , .


, . โ€“ , . , , .


:


  • , , . , , .
  • , , - , , . .
  • , , . . .

, . , , , , () .


, .


โ€“ :


  • , .
  • .
  • , .
  • .
  • .

, . , , . HTML , , .


โ€“ . โ€“ , . , . . .


BAYRELL Language:


/**
 * Sum a + b
 */
lambda int sum(int a) => int (int b) use (a) => a + b;

:


fn sum = int (int a) => int (int b) use (a) => a + b;

map, reduce, array_filter (php), pipe.


, pipe. , . pipe Linux .


:


ls -la | grep .txt

pipe. txt. , , , txt.


BAYRELL Language pipe. :


User user = new User()
	|> User::setName('John')
	|> User::addEmail("john@example.com")
;

:


User user = new User()
	-> setName('John') 
	-> addEmail("john@example.com")
;

, addEmail, , , email ยซjohn@example.comยป . , , . .


Pipe .


.


. FaaS โ€“ .



BAYRELL Language Frontend: JavaScript, , . Ajax Backend.


:


MessageRPC msg = await @->sendMessage
(
	new MessageRPC
	{
		"api_name": "App",
		"space_name": "ApiInterface",
		"method_name": "getDocument",
		"data":
		{
			"document": "/ru/" ~ prefix,
		},
	}
);
Document document = msg->isSuccess() ? msg.response : null;

, REST Api . REST CRUD. , , , , - , , . HTTP (GET,POST,PUT,DELETE) .


, , D-BUS . , . , .


. , CRUDInterface. , , , . API.


, : WebSocket, DBus, RabbitMQ. Ajax API.



, , ++, C#, Python, Java, PHP . , , .


, :


  • . . 4 , , .
  • , .
  • , . .
  • , ?
  • , .

, , . . .


BAYRELL Language


, , (Java, Python, C#, C++, NodeJS, JavaScript, Go, Lua). . BAYRELL Language, . , , . , . - .


, . Language Binding. dll, . , , .


, , , .


, FaaS .


. , . . , , . , . , , . . Git.


. , , 2-3 . , , , .


TODO List



, , - , .


.


, .


.


All Articles