Programming
9 September 2016

Концепт языка программирования 5-го поколения. Часть 3

Всем привет. Предыдущие две публикации сопровождались комментариями «Это все уже было». Я провел некоторые изыскания и предлагаю вашему вниманию еще одно видео. Первые 4 мин. 20 сек. содержат только новое, чего я не нашел в других фреймворках. Остаток видео — то что уже где-то есть, но я сделал это лучше (проще и удобнее).

Данное видео — концепция, это не ПО готовое к употреблению. Это публикуется здесь, чтобы быть улучшенным.



Транскрипт под катом.

Hi everyone!
Today I will show you a short presentation about G5. The first step is aspect-oriented programming.
It's not classical in G5, let's have a look at it.
Here is a simple method with some business logic. It’s short and understandable.
But programs usually contain other aspects
For example, business restrictions.
Another aspect is checking for system errors.
Don’t forget about error handlers.
Sometimes you need logger for debugging.
Aspect of documentation is very important too.
Aspect of the optimization, it can make your source code disgusting, but you really need it.
Let’s also add aspect of business errors and some metadata for unit tests.
And now, you can do at least two things with the aspects.
First, you can hide the aspects from the screen using this buttons.
Secondly, you can disable compilation of any aspects, for example debug and optimization.
You can define your own aspect, for example aspect of the security.
You can use annotations for one or several methods or special constructions with the template of the source code.
Specification language: it’s designed for distributed applications.
The first part of it is “entities”. They are like data contracts, but better.
You can define business structures with them, and then use it in the source code of several applications.
Thera are no data types of G5, so you can use it with any programming languages.
Specification language is not a part of the source code; it’s only metadata for the compiler, and I’m using annotations instead of inheritance.
You can define any public or private fields and methods in your classes.
You can change types for the main fields, but they must be compatible with the types of the entity.
You can set the main fields as public or private, as you wish.
You can even rename fields.
You can’t delete the main field, but you can ignore it.
And of course you can’t change business restrictions.
Well, Entities help you to control data structures in distributed applications without common base classes.
Your applications are not related anymore, and this is more reliable way to create enterprise solutions.
Specification language is an aspect of the design; you can hide it and disable compilation for it.
The second part of the specification language is API.
You can describe your API using WSDL or any other languages. Here is an example for USDS.
I defined two structures and a function and now I will create a server for this API.
In this case the compiler will use annotations to create additional methods for the class “MyServer”.
This is very fast and simple way to create a server application.
The next part is library specifications.
I will show you an example of how to create a plugin for the application using specification language.
I defined description of the library, two classes.
Now, I can create realization of this specification.
The compiler will use annotation to store function names in the library file.
Any methods without the annotations won’t be visible in the library.
I will import my plugin dynamically.
The compiler will again use the annotation to create additional methods — fabrics of the Business class and first class.
You can use the same way to import standard Windows or Linux dynamic libraries.
Chapter three — Declarative programming using widgets.
There are many widgets in G5, I will show you four of them.
The first one is a text widget.
You can use any symbols inside it.
You can define this text field as translatable and set any text encode.
The next one is a source code widget.
It’s very similar to the text widget, but it has syntax highlighting and macros.
You can use the macros to change the source code in the widget, and then you can compile the code in runtime and execute it.
The third example is a widget for user interfaces.
Just draw a window as you wish and then you can use it’s elements in the source code.
G5 contains many other widgets: for databases, for regular expressions etc. You can also create a new widget for G5.
The last example is a widget “Report”.
This widget can contain the source code.
It’s also a part of the file “main.code”, so the widget can use the local variables and functions of the file.
The widget can request data for itself and change report formatting.
You can save the report in PDF, HTML or any other format.
And here is the result.
Chapter four, Language oriented programming.
You can create your own domain-specific programming language using G5.
Thera are at least two possibilities for DSL in G5.
The firs one is you can define new language semantics. Let’s have a look at it.
Here is a class with an array inside. You can set the element’s value using this method.
But it looks not good. The batter way is using an access operator.
I will define this constriction using the keyword “Semantics”.
The first part is the code template, and the second part is realization.
I wrote only for lines and it works now.
What about more complex constructions?
For example, a cycle in this style.
And again, I’m defining the template and it’s realization. Seven lines and it works too.
Another useful thing is physical variables.
You can define it and use in your functions and methods.
You can also define several variables and relations between them.
The values will be converted correctly after that.
Conversions between physical variables and G5 types are possible too.
The compiler controls all wrong conversions.
Well, create new semantics and widgets, use physical variables and you will get a powerful domain-specific language.
That's all for today.
If you like this presentation, please share the video with your friends.
I’m ready to answer any questions, please contact me at this email address.
Thank you for your attention.

-24
4k 23
Comments 24
Top of the day