Skip to content

Commit

Permalink
Правки и перевод кокументации + ограничение для playground
Browse files Browse the repository at this point in the history
  • Loading branch information
rsashka committed Mar 23, 2024
1 parent 9b5ae96 commit 70055ae
Show file tree
Hide file tree
Showing 161 changed files with 3,234 additions and 24,439 deletions.
32 changes: 17 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# История версий
# Version history

## [Релиз v0.4 (в разработке)](https://github.com/rsashka/newlang/tree/dev)
## [Release v0.4 (23.03.2024) - current version](https://github.com/rsashka/newlang/releases/tag/v0.4.0))

Версия c новым вариантом препроцессора, который может изменять входные данные непосредственно во время синтаксического анализа исходного кода.
## New features and changes in the syntax of NewLang v0.4
- Reworked the definition of object types using [prefix naming (sigils)](https://newlang.net/docs/syntax/naming/)
- Interrupting the execution flow and returning can now be done for [named code blocks](https://newlang.net/docs/ops/throw/).
- Simplified the syntax for importing [native variables and functions (C/C++)](https://newlang.net/docs/types/native/)
- Stabilized the syntax for [initializing tensor, dictionary, and function argument values](https://newlang.net/docs/ops/create/#comprehensions) with initial data.
- Added built-in macros for writing code using keywords in a [DSL style](https://newlang.net/docs/syntax/dsl/)

### Новые возможности и изменения в синтаксисе NewLang v0.4
- В лексер встроен новый препроцессор для анализа макросов.
- Изменены префиксы у макросов и модулей. Теперь [префиксы](https://newlang.net/en/syntax.html#prefix) у модулей обратный слеш **\\**, а у макросов собачка **@** как аннотации в Java.
- Синтаксис создания макросов [унифицирован](https://newlang.net/en/syntax.html#macro) с остальными операторами создания объектов.
????????? - Упрощенный синтаксис доступа к полям объекта
?????????? - Возможность выводы текста после обработки препроцессора (все макросы раскрыты).
## New compiler features (nlc)
- Completely redesigned the macroprocessor.
- Reworked the compiler architecture with division into parser, macroprocessor, syntax analyzer, interpreter, and code generator.


### Разное в NewLang v0.4
- Новая версия [сайта](https://newlang.net/)
- Раздел c документацией на Английском
- Выполнен переход на clang 16
## Miscellaneous
- The documentation [website](http://newlang.net) has been translated to [Hugo](https://gohugo.io/) and made bilingual.
- Instead of binary builds, a section [Playground and example code](https://newlang.net/playground/) has been added to the website for small experiments.
- Transition to clang-16 has been completed (transition to clang-17 and newer is planned after full implementation of coroutines and support for extended floating-point number formats).
- The number of project contributors has increased to more than one!

------

## [Релиз v0.3 (07.11.2022) - текущая версия](https://github.com/rsashka/newlang/releases/tag/v0.3.0)
## [Релиз v0.3 (07.11.2022)](https://github.com/rsashka/newlang/releases/tag/v0.3.0)

### Новые возможности и изменения в синтаксисе NewLang v0.3

Expand Down
154 changes: 54 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,90 @@

*NewLang* is a universal high-level programming language. The main feature of the language is a simple, logical and consistent syntax, based on a strict system of grammar rules. With the help of macros the language syntax can be easily extended to a more familiar form based on keywords. Tensor calculations and rational numbers of unlimited precision are supported at the level of language syntax and basic data types without the use of additional libraries.

Current version 0.3 of 07.11.2022 ([New in current version and release history](/en/versions.html))
Current version 0.4 of 23.03.2024 ([New in current version and release history](https://github.com/rsashka/newlang/releases/tag/v0.4.0))

## Main properties and features of the language:

- Ability to work both in interpreter and compiler mode*.
- Dynamic and static typing with the possibility of explicitly specifying types.
- Static typing is conditionally strict (there is no automatic type conversion, but conversion between some data types is allowed. For example, an integer may be automatically converted into a real or rational number, but not vice versa)
- Automatic memory management
- OOP in the form of explicit class inheritance and "duck typing".
- Several types of functions are supported at the syntax level (normal and pure functions without side effects)
- Optional and named parameters of functions
- It is possible to insert the code in the implementation language (C/C++)*
- Easy integration with already existing software libraries (including import of native variables, functions and classes from C/C++)
- Has a REPL [read-eval-print loop](https://wikipedia.org/wiki/REPL)
- The ability to work both in interpreter and compiler mode **\***.
- Dynamic and static typing with the ability to specify types explicitly.
- Static typing is conditionally strong (there is no automatic type casting, but conversion between some data types is allowed. *For example, an integer can be automatically converted to real or rational, but not vice versa.*
- Automatic memory management without garbage collector **\***
- Object-oriented programming in the form of explicit class inheritance and "duck typing" **\***
- Several types of functions (regular and pure functions without side effects) are supported at the syntax level of the language
- Optional and named function arguments
- Direct insertion of C/C++ code is possible **\***
- Easy integration with existing software libraries (including import of native variables, functions and classes* from C/C++).
- There is a <a href="https://en.wikipedia.org/wiki/REPL">REPL (read-eval-print loop)</a>
- Symbolic calculations **\*\***

---
*) This feature is planned to be implemented when creating the compiler.
**\***) These features are planned for implementation when the compiler is created.

**\*\***) Symbolic calculations are supported at the syntax level, but not implemented.
---
[Language syntax](/en/syntax.html)

[Detailed description of the type system](/en/types.html)
---
[Language syntax](http://newlang.net/docs/syntax/)

[Detailed description of the type system](http://newlang.net/docs/types/)

### Example of "Hello world!" script in NewLang language
[Operators and control structures](http://newlang.net/docs/ops/)

```bash
#!../output/nlc --eval
[Playground and example code](https://newlang.net/playground/?id=1)

hello(str) := {
# Import and call the standard function printf
printf := :Pointer('printf(format:FmtChar, ...):Int32');
printf('call: %s', $str);
$str;
};
### Example of "Hello world!" script in NewLang language

```python
#!../output/nlc

hello('Hello, World!');
print('Hello, world!\n');
```

Output:

```bash
call: Hello, World!
Hello, World!
```python
Hello, world!

14
```

## Why do we need *NewLang*?

All modern programming languages constantly develop (complicate) their syntax as new versions are released. It is a kind of payment for appearance of new features and is perceived by users as a natural phenomenon.
## Why do we need NewLang?

But it is also a serious problem because with release of versions new keywords and syntactic constructions are added, which inevitably raises the entrance threshold for new users. Another consequence of this process is a constant increase of complexity of development and support of already created software products, when the old code is finalized using already new standards.
All modern programming languages have a constant development (complication) of syntax as new versions are released.
This is a kind of payment for the emergence of new features and is perceived by users as a natural process.

With *NewLang* the complexity of language constructions is naturally limited by dividing the language syntax into two parts - this makes it easier to learn and use.
But at the same time it is also a serious problem, since with the release of versions new keywords and syntactic constructions are added, which inevitably raises the entry threshold for new users.

*Base Syntax* - for writing programs in object-oriented (imperative) and declarative styles, which is based not on reserved keywords, but on a system of strict [grammar rules](/en/syntax.html). It is possible to extend the basic syntax by using macros. *Expanded syntax* - program inserts in the implementation language (C/C++) when the basic syntax becomes insufficient.
Another consequence of this process is the constant increase in the complexity of developing and supporting already created software products, when the old code is being finalized using the already new standards.

Another inconvenience of modern languages is that most of them were created before the era of machine learning, so tensor calculations in them are implemented as separate libraries. The same applies to calculations with unlimited precision, which also require additional library functions.
NewLang naturally limits the complexity of language constructs by splitting the syntax of the language into two parts, making it easier to learn and use.

In *NewLang*, tensor calculations and rational numbers of unlimited precision are available "out of the box". They are supported at the syntax level for writing literals of corresponding types, and simple arithmetic data types are scalars (zero-dimensional tensors). The implementation of tensor calculations is based on [libtorch](https://pytorch.org/) and rational numbers using [OpenSSL](https://github.com/openssl/openssl/blob/master/crypto/bn/README.pod).
Basic syntax - for writing programs in object-oriented (imperative) and declarative styles, which is based not on reserved keywords, but on a system of strict grammar rules. It is possible to extend the basic syntax through the use of macros.
Extended syntax - program inserts in the implementation language (C/C++), when the main syntax becomes insufficient.

### Example of calculating the factorial 40 in NewLang
Another disadvantage of modern languages is that most of them were created before the era of machine learning, therefore, tensor calculations are performed in the form of separate libraries.
The same applies to calculations with unlimited precision, which also require the use of additional library functions.

```bash
#!../output/nlc --eval
NewLang has tensor calculus and unlimited-precision rationals out of the box.
They are supported at the syntax level for writing literals of the corresponding types, and simple arithmetic data types are scalars (tensors of dimension zero).
The implementation of tensor calculations is based on the library libtorch, and rational numbers using OpenSSL.


### Example of calculating factorial 40 using DSL syntax

```python
#!../output/nlc

fact := 1\1; # Rational number without precision restrictions
mult := 40...1...-1?; # Get iterator for multipliers from 40 to 2
[mult ?!] <-> { # Cycle until the iterator data runs out
fact *= mult !; # Get the current multiplier and go to the next iterator element
fact := 1\1; # Rational number 1 (no precision limit)
mult := @iter( 40..1..-1 ); # Iterator from range for factors from 40 to 2
@while( @curr(mult)) { # Loop until the iterator data runs out
fact *= @next(mult); # Get the current multiplier and move to the next iterator element
};

fact # Print the final result
@assert(fact == 815915283247897734345611269596115894272000000000\1);

fact # Return final result
```

Output:
Expand All @@ -82,65 +94,7 @@ Output:
815915283247897734345611269596115894272000000000\1
```

#### Downloading binary builds

- [Windows Binary Builds and Tests](https://github.com/rsashka/newlang/releases/download/v0.3.0/nlc_win_64.zip)
- [Ubuntu binary builds and tests](https://github.com/rsashka/newlang/releases/download/v0.3.0/nlc_lin_64.tar.xz)
- You will need shared libraries libLLVM-15 and libtorch ([archive with libraries for Windows](https://github.com/rsashka/newlang/releases/download/v0.3.0/nlc_dll.zip)), ([archive with libraries for Ubuntu](https://github.com/rsashka/newlang/releases/download/v0.3.0/nlc_so.tar.xz)) to run binary builds.

## Compiling the project from source

### Preparing repository

- Download the sources [https://github.com/rsashka/newlang](https://github.com/rsashka/newlang)
- Download and deploy archive [libtorch](https://pytorch.org/) in directory *contrib* (PyTorch Build: Stable (1.13.*) -> Your OS: Linux -> Package: LibTorch -> Language: C++ / Java -> Compute Platform: CPU -> Download here (cxx11 ABI):
[libtorch-shared-with-deps-1.13+cpu.zip](https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.13.0%2Bcpu.zip)
- Activate and download submodule sources (`git submodule init && git submodule update`)
- In the directory *contrib* run the file `build.sh`
- In directory *src* run file `compile_syntax.sh` to generate parser and lexical analyzer files. You may also need to install the utilities *flex* and *bison* (flex 2.6.4 and bison (GNU Bison) 3.7.4)

### Build

- Unit Tests (newlang-unit-tests): In the *src* directory, run the `make CONF=UnitTest` command.
- Interpreter (nlc): in the *src* directory, run the command `make CONF=Debug`.

---;

Builds are done with the usual make utility, but the build files are generated automatically in the outdated version NetBeans 8.2. This is the only universal development environment with Makefile support "out of the box", while the current Apache NetBeans version does not provide full support for C/C++ development. Started a gradual transition to using VSCodium editor (analog of VSCode, which cleaned up telemetry from Microsoft) and generation of build skips using smake, but this process is not completed yet.

## Feedback

If you have any suggestions for developing or improving NewLang, [writing](https://github.com/rsashka/newlang/discussions).


## Roadmap

### Макропроцессор

[x] - Минимальный варинат с одним термином без анализа аргументов (для реализации keyword based синтаксиса)
[ ] - Поддержка именованных аргументов (аналог макропроцессора С/С++)
[ ] - Поддержка типов у аргументов макроса
[ ] - Шаблоны в идентификаторах макросов (поддержка импорта модулей, определения переменных, функций и классов для создание DSL)
[ ] - Поддержка Simple Python DSL - выполнение простых скриптов Python как собственного кода

### Синтаксис
[ ] - Контроль множественных типов у аргументов функций <:Type1, :Type2, :Type3>
[ ] - Контроль возвращаемых типов у функций
[ ] - Ссылки на объекты в синтаксисе и коде
[ ] - Константные объекты в синтаксисе и коде
[ ] - Документирующие комментарии в коде

### Функциональные возможности
[ ] - Поддержка ООП
[ ] - Импорт нативных С/С++ типов Struct\Union\Enum
[ ] - Импорт С++ переменных (namespace + mangled имена)
[ ] - Импорт С++ функций (namespace + mangled имена)
[ ] - Импорт С++ объектов


## Доп. возможности
[--] - Менеджер пакетов conda (mamba)
[--] - Поддержка jupyter notebook



Loading

0 comments on commit 70055ae

Please sign in to comment.