├── .gitattributes
├── .github
└── workflows
│ ├── actionlint.yml
│ ├── copyrights.yml
│ ├── jekyll.yml
│ ├── markdown-lint.yml
│ ├── pdd.yml
│ ├── reuse.yml
│ ├── typos.yml
│ ├── xcop.yml
│ └── yamllint.yml
├── .gitignore
├── .rultor.yml
├── CNAME
├── Gemfile
├── LICENSE.txt
├── LICENSES
└── MIT.txt
├── README.md
├── REUSE.toml
├── _config.yml
├── _layouts
├── default.html
├── post.html
└── static.html
├── _posts
├── 2022
│ ├── 10
│ │ └── 2022-10-19-placed-catalog.md
│ ├── 11
│ │ └── 2022-11-25-xmir-guide.md
│ ├── 12
│ │ ├── 2022-12-02-java-atoms.md
│ │ ├── 2022-12-22-adoption.md
│ │ └── 2022-12-22-declarative-while.md
│ ├── 06
│ │ ├── 2022-06-08-what-eolang-is-for.md
│ │ ├── 2022-06-09-get-rid-of-char.md
│ │ ├── 2022-06-09-memory-enclosure.md
│ │ ├── 2022-06-15-string-slice.md
│ │ ├── 2022-06-19-eoc-test.md
│ │ ├── 2022-06-27-number.md
│ │ └── 2022-06-28-fixed-version-of-objectionary.md
│ ├── 07
│ │ ├── 2022-07-04-switch.md
│ │ ├── 2022-07-15-placing-and-unplacing.md
│ │ ├── 2022-07-18-error-and-try-catch.md
│ │ └── 2022-07-18-pseudo-random.md
│ └── 08
│ │ ├── 2022-08-30-eo-cache.md
│ │ ├── 2022-08-30-parser-external-usage.md
│ │ └── 2022-08-31-new-while-dataization-result.md
├── 2023
│ ├── 10
│ │ ├── 2023-10-04-application-to-application.md
│ │ └── 2023-11-02-comparison-of-floating-zeros.md
│ ├── 11
│ │ └── 2023-11-15-this.md
│ ├── 12
│ │ ├── 2023-12-08-phi-and-unphi-mojos.md
│ │ └── 2023-12-19-tuple-varargs.md
│ ├── 01
│ │ ├── 2023-01-12-declarative-while-nested.md
│ │ └── 2023-06-22-daily-auto-pull.md
│ ├── 06
│ │ └── 2023-06-22-we-are-hiring.md
│ ├── 08
│ │ └── 2023-08-05-storing-objects-formed-differently-into-cage.md
│ └── 09
│ │ └── 2023-09-04-memory-as-container-for-real-data.md
├── 2024
│ ├── 04
│ │ ├── 2024-04-16-release-0-36-0.md
│ │ └── 2024-04-26-bye-bye-bool.md
│ └── 05
│ │ ├── 2024-05-02-phi-bound-only.md
│ │ └── 2024-05-02-rho-sigma-delta-lambda.md
└── 2025
│ └── 02
│ └── 2025-02-21-auto-named-abstract-objects.md
├── css
└── main.scss
├── images
└── fork-me.svg
├── index.html
├── renovate.json
├── robots.txt
└── static
├── 404.md
├── contents.md
└── papers.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Check out all text files in UNIX format, with LF as end of line
2 | # Don't change this file. If you have any ideas about it, please
3 | # submit a separate issue about it and we'll discuss.
4 |
5 | * text=auto eol=lf
6 | *.java ident
7 | *.xml ident
8 | *.png binary
9 |
--------------------------------------------------------------------------------
/.github/workflows/actionlint.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: actionlint
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | actionlint:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - name: Download actionlint
20 | id: get_actionlint
21 | run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
22 | shell: bash
23 | - name: Check workflow files
24 | run: ${{ steps.get_actionlint.outputs.executable }} -color
25 | shell: bash
26 |
--------------------------------------------------------------------------------
/.github/workflows/copyrights.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: copyrights
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | copyrights:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: yegor256/copyrights-action@0.0.8
20 | with:
21 | globs: >-
22 | **/LICENSE.txt
23 | **/*.sh
24 | **/*.yml
25 | **/*.yaml
26 | **/*.eo
27 | **/*.xmir
28 | **/*.xml
29 | **/*.xsl
30 | **/*.xsd
31 | **/*.ini
32 | **/*.java
33 | **/*.g4
34 | **/*.properties
35 | **/*.toml
36 | **/*.groovy
37 |
--------------------------------------------------------------------------------
/.github/workflows/jekyll.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: jekyll
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | jekyll:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: ruby/setup-ruby@v1
20 | with:
21 | ruby-version: 3.3
22 | bundler-cache: true
23 | - run: bundle config set --global path "$(pwd)/vendor/bundle"
24 | - run: bundle install --no-color
25 | - run: bundle exec jekyll build
26 |
--------------------------------------------------------------------------------
/.github/workflows/markdown-lint.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: markdown-lint
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | markdown-lint:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: DavidAnson/markdownlint-cli2-action@v19
20 | if: false
21 | with:
22 | globs: 'README.md'
23 |
--------------------------------------------------------------------------------
/.github/workflows/pdd.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: pdd
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | pdd:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: volodya-lombrozo/pdd-action@master
20 |
--------------------------------------------------------------------------------
/.github/workflows/reuse.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: reuse
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | reuse:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | if: false
20 | - uses: fsfe/reuse-action@v5
21 |
--------------------------------------------------------------------------------
/.github/workflows/typos.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: typos
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | typos:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: crate-ci/typos@v1.32.0
20 |
--------------------------------------------------------------------------------
/.github/workflows/xcop.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: xcop
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | xcop:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: g4s8/xcop-action@master
20 |
--------------------------------------------------------------------------------
/.github/workflows/yamllint.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | name: yamllint
6 | 'on':
7 | push:
8 | branches:
9 | - master
10 | pull_request:
11 | branches:
12 | - master
13 | jobs:
14 | yamllint:
15 | timeout-minutes: 15
16 | runs-on: ubuntu-24.04
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: ibiqlik/action-yamllint@v3
20 | with:
21 | config-file: .yamllint.yml
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | _site
2 | _temp/
3 | .bundle/
4 | .DS_Store
5 | .idea
6 | .idea/
7 | .jekyll-cache/
8 | .jekyll-metadata
9 | .sass-cache
10 | .yardoc/
11 | coverage/
12 | doc/
13 | Gemfile.lock
14 | node_modules/
15 | rdoc/
16 | vendor/
17 |
--------------------------------------------------------------------------------
/.rultor.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | # yamllint disable rule:line-length
5 | docker:
6 | image: yegor256/ruby
7 | install: |
8 | sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
9 | merge:
10 | script: |
11 | bundle exec jekyll build
12 |
--------------------------------------------------------------------------------
/CNAME:
--------------------------------------------------------------------------------
1 | news.eolang.org
2 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 |
4 | source 'https://rubygems.org'
5 |
6 | gem 'jekyll', '~>4.3'
7 | gem 'jekyll-feed', '~>0.17'
8 | gem 'jekyll-paginate', '~>1.1'
9 | gem 'jekyll-sitemap', '~>1.4'
10 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2022-2025 Objectionary.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included
13 | in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LICENSES/MIT.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2022-2025 Objectionary.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included
13 | in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [](https://github.com/objectionary/news.eolang.org/actions/workflows/jekyll.yml)
4 |
5 | Check this blog at [news.eolang.org](https://news.eolang.org).
6 |
7 | You are welcome to submit corrections to this blog. In order to do that,
8 | you will need [Ruby](https://www.ruby-lang.org/en/) 2.6+ and
9 | [Bundler](https://bundler.io/). Then, run this:
10 |
11 | ```bash
12 | $ bundle update
13 | $ bundle exec jekyll serve
14 | ```
15 |
16 | In a few seconds of building you should be able to see the blog
17 | at `http://localhost:4000`. Make your changes and refresh the page in the browser.
18 | You should see the changes.
19 | If everything looks fine, submit a pull request.
20 |
--------------------------------------------------------------------------------
/REUSE.toml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 |
4 | version = 1
5 | [[annotations]]
6 | path = [
7 | ".DS_Store",
8 | ".gitattributes",
9 | ".gitignore",
10 | "**.json",
11 | "**.md",
12 | "**.svg",
13 | "**.txt",
14 | "**/.DS_Store",
15 | "**/.gitignore",
16 | "**/*.csv",
17 | "**/*.jpg",
18 | "**/*.json",
19 | "**/*.md",
20 | "**/*.pdf",
21 | "**/*.png",
22 | "**/*.svg",
23 | "**/*.txt",
24 | "**/*.vm",
25 | "**/CNAME",
26 | "**/Gemfile.lock",
27 | "CNAME",
28 | "Gemfile.lock",
29 | "README.md",
30 | "renovate.json",
31 | ]
32 | precedence = "override"
33 | SPDX-FileCopyrightText = "Copyright (c) 2025 Yegor Bugayenko"
34 | SPDX-License-Identifier = "MIT"
35 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
2 | # SPDX-License-Identifier: MIT
3 | ---
4 | title: News About EO Programming Language
5 | email: team@eolang.org
6 | description: >
7 | Here we post most recent news about
8 | EO programming language and 𝜑-calculus
9 | baseurl: ""
10 | url: "https://news.eolang.org"
11 | twitter_username: objectionary
12 | github_username: objectionary
13 | markdown: kramdown
14 | author:
15 | name: "EO"
16 | email: team@eolang.org
17 | encoding: utf-8
18 | timezone: Europe/Moscow
19 | permalink: :year-:month-:day-:title.html
20 | exclude:
21 | - README.md
22 | - Gemfile.lock
23 | - Gemfile
24 | - Rakefile
25 | - LICENSE.txt
26 | - id_rsa.enc
27 |
28 | plugins:
29 | - jekyll-feed
30 | - jekyll-paginate
31 | - jekyll-sitemap
32 |
33 | paginate: 8
34 | paginate_path: "p/:num"
35 | excerpt_separator:
36 |
37 | feed:
38 | title: news.eolang.org
39 | subtitle: News about EO programming language
40 | path: rss.xml
41 |
42 | sass:
43 | style: compressed
44 | deploy_style: compressed
45 | compile_in_place: false
46 |
--------------------------------------------------------------------------------
/_layouts/default.html:
--------------------------------------------------------------------------------
1 | ---
2 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
3 | # SPDX-License-Identifier: MIT
4 |
5 | layout: default
6 | ---
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | {{ page.title }}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
41 | {{ content }}
42 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/_layouts/post.html:
--------------------------------------------------------------------------------
1 | ---
2 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
3 | # SPDX-License-Identifier: MIT
4 |
5 | layout: default
6 | ---
7 |
8 |
9 | {{ page.title }}
10 |
11 |
12 |
13 | @{{ page.author }}
14 |
15 |
16 |
17 |
18 | {{ page.date | date_to_string }}
19 |
20 |
21 |
22 | comments
23 |
24 |
25 | {{ content }}
26 |
27 |
28 |
51 |
--------------------------------------------------------------------------------
/_layouts/static.html:
--------------------------------------------------------------------------------
1 | ---
2 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
3 | # SPDX-License-Identifier: MIT
4 |
5 | layout: default
6 | ---
7 |
8 |
9 | {{ page.title }}
10 | {{ content }}
11 |
12 |
--------------------------------------------------------------------------------
/_posts/2022/06/2022-06-08-what-eolang-is-for.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-06-08
4 | title: "What EO is for?"
5 | author: yegor256
6 | ---
7 |
8 | [EO](https://www.eolang.org) is a new experimental programming language.
9 | EO is not planning to become a mainstream language—this is not what
10 | we want. Our main goal is to prove to ourselves that true object-oriented
11 | programming is practically possible. Not just in books and abstract
12 | examples, but in real code that works. That's why EO is being created—to
13 | put all that "crazy" pure object-oriented ideas into practice and
14 | see whether they can work.
15 |
16 |
17 |
18 | At the moment we use EO as an intermediate representation (IR) for
19 | static analysis. [Polystat](https://www.polystat.org) is the static
20 | analyzer that is using EO.
21 |
22 | We are planning to keep this blog running, to update you
23 | with all new features in the language. If you want to contribute
24 | too, just [email](mailto:team@eolang.org) us.
25 |
--------------------------------------------------------------------------------
/_posts/2022/06/2022-06-09-get-rid-of-char.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-06-09
4 | title: "We Got Rid of Object 'char'"
5 | author: Graur
6 | ---
7 |
8 | Since `0.23.6` version of [EO](https://www.eolang.org) we get rid of `char` object.
9 | We want to simplify core of the language and believe that this object can be easily replaced
10 | with its actual representation, i.e. an array of bytes.
11 | Now, if you want to get the character, you can just use `string` object instead.
12 | All of these examples are valid strings: `"\u0123"`, `"h"`, `"\t"`, `"\n"` and `"\07"`.
13 | We get rid of `string.char-at` and `bytes.as-char` objects.
14 |
15 |
16 |
17 | If you need to get one char from a string use `string.slice`.
18 | And use `bytes.as-string` instead of `bytes.as-char`.
19 |
20 | Please visit our [paper](https://arxiv.org/abs/2206.02585) to get more information.
21 |
--------------------------------------------------------------------------------
/_posts/2022/06/2022-06-09-memory-enclosure.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-06-09
4 | title: "Memory Can't Be Empty"
5 | author: yegor256
6 | ---
7 |
8 | Until version 0.23.7 it was possible to use
9 | [`memory`](https://github.com/objectionary/home/blob/master/objects/org/eolang/memory.eo)
10 | object just like this:
11 |
12 | ```
13 | memory > m
14 | m.write 42
15 | ```
16 |
17 | At the first line, a copy of `memory` was made and then labeled as `m`. This
18 | was a bug in the language. The object `memory` must not be copied if there
19 | are no arguments provided for the copying (application) operation.
20 |
21 |
22 |
23 | The right way since 0.23.7 is this:
24 |
25 | ```
26 | memory 0 > m
27 | m.write 42
28 | ```
29 |
30 | Here, the object `m` is a copy of `memory` with a single argument, which is
31 | called an "enclosure".
32 |
33 | We also deleted the attribute `memory.is-empty`, since `memory` is always
34 | not empty.
35 |
36 | The same changes were applied to the object
37 | [`cage`](https://github.com/objectionary/home/blob/master/objects/org/eolang/cage.eo).
38 |
--------------------------------------------------------------------------------
/_posts/2022/06/2022-06-15-string-slice.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-06-15
4 | title: "Introduced 'string.slice' Object"
5 | author: Graur
6 | ---
7 |
8 | Since 0.23.8 version it is possible to use
9 | [`string.slice`](https://github.com/objectionary/home/blob/master/objects/org/eolang/string.eo)
10 | object just like this:
11 |
12 | ```
13 | "Привет".slice 1 2
14 | ```
15 |
16 | Here, `slice` object returns "ри" string, which is a substring of "ри" string
17 | from the specified `start` position and with the length `len`.
18 |
19 | If above parameters will be out of bound, `slice` will return
20 | an `error` object instead of a new `string` object.
21 |
22 |
23 |
24 | Visit our [paper](https://arxiv.org/abs/2206.02585) to get more details.
25 |
--------------------------------------------------------------------------------
/_posts/2022/06/2022-06-19-eoc-test.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-06-19
4 | title: "Unit Testing with 'eoc'"
5 | author: yegor256
6 | ---
7 |
8 | There is [eoc](https://github.com/objectionary/eoc),
9 | a command line tool that helps you automate compilation, transpilation,
10 | and execution of simple EO programms. With this tool you can also
11 | create and execute unit tests. Just name them `*-test.eo` and add
12 | metas `+junit` to them.
13 |
14 |
15 |
16 | Say, you have a `program.eo` file, which does this:
17 |
18 | ```
19 | [] > name
20 | "Jeff Lebowski" > @
21 | [args...] > program
22 | QQ.io.stdout > @
23 | name
24 | ```
25 |
26 | You may want to create a unit test, which will check that your
27 | object `name` actually is the right name. Put it into the `program-test.eo`
28 | file (actually, you can pick any name of the file you like):
29 |
30 | ```
31 | +junit
32 | +alias name
33 | +alias org.eolang.hamcrest.assert-that
34 |
35 | [] > the-name-is-right
36 | assert-that > @
37 | name.length
38 | $.all-of
39 | $.greater-than 10
40 | $.less-than 100
41 | ```
42 |
43 | Then, simply say:
44 |
45 | ```
46 | $ eoc test
47 | ```
48 |
49 | The test will be found and executed.
50 |
--------------------------------------------------------------------------------
/_posts/2022/06/2022-06-27-number.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-06-27
4 | title: "Introduced 'number' Object"
5 | author: Graur
6 | ---
7 |
8 | Since 0.23.15 version it is possible to use
9 | [`number`](https://github.com/objectionary/home/blob/master/objects/org/eolang/math/number.eo)
10 | object just like this:
11 |
12 | ```
13 | # this is 7
14 | (QQ.math.number -7).abs
15 | ```
16 |
17 | It is a decorator of `int` and `float` objects with the following additional attributes:
18 |
19 |
20 |
21 | `is-int` - is this number is int (/bool)
22 |
23 | `is-float` - is this number is float (/bool)
24 |
25 | `xor` - bitwise xor operation, only for int (/int)
26 |
27 | `or` - bitwise or operation, only for int (/int)
28 |
29 | `and` - bitwise and operation, only for int (/int)
30 |
31 | `left` - bitwise left shift operation, only for int (/int)
32 |
33 | `right` - bitwise right shift operation, only for int (/int)
34 |
35 | `neq` - this number not equal to another number (/bool)
36 |
37 | `mod` - modulo operation (right now just for /int)
38 |
39 | `abs` - absolute value (/int or /float)
40 |
41 | `pow` - make this number power of another number (/int or /float)
42 |
43 | `as-float` - converts this number to float (/float)
44 |
45 | `as-int` - converts this number to int (/int)
46 |
47 | `as-string` - converts this number to int (/string)
48 |
49 | `signum` - sign of this number (/int of /float)
50 |
51 | Return values depends on type of provided number.
52 |
53 | Visit our [paper](https://arxiv.org/abs/2206.02585) to get more details.
54 |
--------------------------------------------------------------------------------
/_posts/2022/06/2022-06-28-fixed-version-of-objectionary.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-06-28
4 | title: "How to Compile Against a Fixed Version of Objectionary"
5 | author: yegor256
6 | ---
7 |
8 | When you compile your EO code, the compiler discovers which objects
9 | are "foreign" and tries to find them in [Objectionary](https://github.com/objectionary/home). It finds them,
10 | downloads, and then compiles locally. The problem is that the objects
11 | in Objectionary are not static: they get new versions very often.
12 | That's why, in order to stabilize your build you may want
13 | to use their fixed versions.
14 |
15 |
16 |
17 | Here is how, in your `pom.xml` (`hash` must include Git commit hash
18 | from [`objectionary/home`](https://github.com/objectionary/home)):
19 |
20 | ```
21 |
22 | [...]
23 |
24 | [...]
25 |
26 | [...]
27 |
28 | org.eolang
29 | eo-maven-plugin
30 |
31 | 0d94362
32 |
33 |
34 |
35 |
36 |
37 | ```
38 |
39 | If you use [`eoc`](https://github.com/objectionary/eoc),
40 | you can do it with the command line option:
41 |
42 | ```
43 | $ eoc --hash=0d94362 compile
44 | ```
45 |
46 | Full list of Git hashes of Objectionary is
47 | [here](https://github.com/objectionary/home/commits/master).
48 |
--------------------------------------------------------------------------------
/_posts/2022/07/2022-07-04-switch.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-07-04
4 | title: "Introduced 'switch' Object"
5 | author: Graur
6 | ---
7 |
8 | Since 0.23.16 version it is possible to use
9 | [`switch`](https://github.com/objectionary/home/blob/master/objects/org/eolang/switch.eo)
10 | object just like this:
11 |
12 | ```
13 | memory "swordfish" > password
14 |
15 | QQ.switch
16 | *
17 | password.eq "swordfish"
18 | "password is correct!"
19 | *
20 | password.eq ""
21 | "empty password is not allowed"
22 | *
23 | FALSE
24 | "password is wrong"
25 | ```
26 |
27 | Here, `switch` object returns "password is correct!", which is the first true case in this statement.
28 | The `switch` object consists of arrays with arrays of two elements: condition and return value.
29 |
30 | If the above parameters are missing, `switch` will return
31 | an `error` object with `msg` as a string message.
32 |
33 |
34 |
35 | Visit our [paper](https://arxiv.org/abs/2206.02585) to get more details.
36 |
--------------------------------------------------------------------------------
/_posts/2022/07/2022-07-15-placing-and-unplacing.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-07-15
4 | title: "Placing and Unplacing in JAR Artifacts"
5 | author: yegor256
6 | ---
7 |
8 | The entire process of packaging EO objects and atoms into JAR artifacts
9 | is explained in this blog post:
10 | [Objectionary: Dictionary and Factory for EO Objects](https://www.yegor256.com/2021/10/21/objectionary.html).
11 | It's pretty straight forward. However, there is one tricky situation
12 | related to placing compiled Java binaries into the JAR. This process
13 | may go wrong and sometimes it does. In version 0.24.0 of
14 | [our Maven plugin](https://github.com/objectionary/eo/tree/master/eo-maven-plugin) we
15 | introduced a pair of options for the `unplace` goal. Here is how they work.
16 |
17 |
18 |
19 | First, when you build a JAR artifact in your Maven project, you have some `.eo`
20 | sources in `src/main/eo` and some Java sources in `src/main/java`. They both
21 | are compiled into `.class` files into `target/classes`.
22 |
23 | Second, in order for your program to work, it needs `.eo` files for objects,
24 | which it finds in [Objectionary](https://github.com/objectionary/home). The files
25 | are "pulled" and then saved into `target/eo/04-pull`. Then, they also
26 | are compiled into `.class` binaries and also _placed_ into `target/classes`,
27 | mixing together with your files.
28 |
29 | Third, your program needs `.class` binaries from inside JAR artifacts,
30 | which some `.eo` objects point to by means of `+rt` meta. The artifacts
31 | are downloaded, unpacked, and then placed into `target/classes`.
32 |
33 | Finally, it's time to package your own JAR and release it to Maven Central.
34 | Obviously, we don't want all the files. previously placed into `target/classes`,
35 | to be packaged into the JAR. We only want those that were compiled from _your_
36 | source `.java` files. We don't even want those `.class` files that were
37 | compiled from the auto-generated `.java` from your `.eo` objects.
38 | We only want compiled _atoms_ to be in the JAR.
39 |
40 | The Maven plugin goal `unplace` cleans up the `target/classes` directory and
41 | removes unnecessary binaries, which were placed into it earlier. It understands
42 | which files to remove, thanks to the catalog it maintains during the entire
43 | build cycle, in `target/eo/placed.csv` file. The goal `unspile` adds more
44 | cleaning by removing `.class` files generated from your `.java` classes.
45 |
46 | However, sometimes they may make mistakes. For example, when a JAR artifact
47 | coming from Maven Central and your own Java files have the same classes. The plugin
48 | won't understand which of them to keep and most probably will delete both.
49 |
50 | To make its behavior fully explicit, you may use one of these two options (or both):
51 |
52 | ```
53 |
54 | [...]
55 |
56 | [...]
57 |
58 | [...]
59 |
60 | org.eolang
61 | eo-maven-plugin
62 |
63 |
64 | compile
65 |
66 | register
67 | assemble
68 | transpile
69 | copy
70 | unplace
71 | unspile
72 |
73 |
74 |
75 | EOorg/EOeolang/EOfoo/**
76 |
77 |
78 | EOorg/EOeolang/**.class
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | ```
88 |
89 | This configuration will ensure that only `EOorg/EOeolang/EOfoo/**` files
90 | will stay in `target/classes` before the JAR is packaged. Also, if for
91 | some magic reason `EOorg/EOeolang/**.class` will remain their, they will
92 | also be deleted.
93 |
94 | First, only what is mentioned in `keepBinaries` will stay.
95 | Second, what is mentioned in `removeBinaries` will be deleted.
96 |
97 | I think it's a good practice to use `keepBinaries` option in your
98 | library, just to be safe and sure that nothing aside from your compiled
99 | atoms get into the JAR.
100 |
--------------------------------------------------------------------------------
/_posts/2022/07/2022-07-18-error-and-try-catch.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-07-18
4 | title: "Introduced 'error' Object and new semantic of 'try' Object"
5 | author: Graur
6 | ---
7 |
8 | Since 0.25.0 version it is possible to use
9 | [`error`](https://github.com/objectionary/home/blob/master/objects/org/eolang/error.eo)
10 | object just like this:
11 |
12 | ```
13 | [x] > check
14 | if. > @
15 | x.eq 0
16 | error "Can't divide by zero"
17 | 42.div x
18 | ```
19 |
20 | Here, the object `error` causes program termination at the first attempt to dataize it.
21 | It encapsulates any other object, which can play the role of an exception that is
22 | floating to the upper level.
23 |
24 | The object `try` enables the catching of an `error` objects and extracting exceptions from them.
25 | For example, the following code prints "The 1th argument of 'int.div' is invalid: division by zero is infinity" and then "finally":
26 |
27 | ```
28 | QQ.try
29 | []
30 | 42.div 0 > @
31 | [e]
32 | QQ.io.stdout > @
33 | e
34 | []
35 | QQ.io.stdout > @
36 | "finally"
37 | ```
38 | The object `error` encapsulates the error message from `int.div` object and terminates the program.
39 |
40 |
41 |
42 | We can also throw the `error` through multiple nested `try` objects:
43 |
44 | ```
45 | eq. > @
46 | QQ.try
47 | []
48 | QQ.try > @
49 | []
50 | slice. > @
51 | "some string"
52 | 7
53 | 5
54 | [e]
55 | e > @
56 | []
57 | "first finally block" > @
58 | [e]
59 | e > @
60 | []
61 | "second finally block" > @
62 | "Start index + length must not exceed string length but was 12 > 11"
63 | ```
64 |
65 | Here, we get `TRUE` because `string.slice` object uses `error` object.
66 | Which encapsulates the error message "Start index + length must not exceed string length but was 12 > 11".
67 | The first `try` object throws up this encapsulated string to the second `try` object.
68 |
69 | In addition, you can add new behavior to catch errors, or just use them as is.
70 | For example, the following code prints "division by zero is infinity, please check the parameter"
71 |
72 | ```
73 | QQ.try
74 | []
75 | 3.div 0 > @
76 | [e]
77 | QQ.io.stdout > @
78 | e.slice 43 28
79 | []
80 | QQ.io.stdout > @
81 | ", please check the parameter"
82 | ```
83 |
84 | Visit our [paper](https://arxiv.org/abs/2206.02585) to get more details.
85 |
--------------------------------------------------------------------------------
/_posts/2022/07/2022-07-18-pseudo-random.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-07-18
4 | title: "Pseudo-random generation in EO"
5 | author: mximp
6 | ---
7 |
8 | EO library provides an ability to generate pseudo-random sequences.
9 | It's analogous to [Random](https://docs.oracle.com/javase/8/docs/api/java/util/Random.html) class
10 | in _Java_ or [random](https://docs.python.org/3/library/random.html) module in _Python_.
11 | Let's explore how this facility
12 | (exposed via [org.eolang.math.random](https://github.com/objectionary/home/blob/master/objects/org/eolang/math/random.eo)
13 | object) can be used in EO.
14 |
15 |
16 | [random](https://github.com/objectionary/home/blob/master/objects/org/eolang/math/random.eo) object
17 | available in `eo.lang.math` package since version `0.1.2`. It decorates `float`
18 | and represents a value from random sequence.
19 |
20 | Note that the generator is [pseudo-random](https://en.wikipedia.org/wiki/Pseudorandom_number_generator).
21 | In short, it means that generated sequence can be reproduced given initial seed value which is
22 | not what true randomness normally assumes.
23 | In most applied cases pseudo-randomness is perfectly
24 | enough. Hereafter terms _random_ and _pseudo-random_ will be used interchangeably.
25 |
26 | Single random value can be generated as follows:
27 | ```
28 | +alias org.eolang.math.random
29 |
30 | [args...] > app
31 | QQ.io.stdout > @
32 | QQ.txt.sprintf
33 | "Random value is %f"
34 | random.pseudo
35 | ```
36 | Here `random.pseudo` object represents `float` object with random value
37 | in range `0..1` (0 included, 1 excluded).
38 |
39 | An array of 5 random values can be generated like this:
40 | ```
41 | [args...] > app
42 | random.pseudo > rnd!
43 | reduce. > @
44 | list (* 1 2 3 4 5)
45 | *
46 | [a i]
47 | a.with rnd.next > @
48 | ```
49 | In this case first call to `rnd` generates new `random` object. Each consecutive call to
50 | `rnd.next` produces next `float` value in random sequence. Values produced by `random.next`
51 | are normally distributed in range `0..1`. Under the hood `random.next` uses
52 | [Linear congruential method](https://en.wikipedia.org/wiki/Linear_congruential_generator) to
53 | generate next random element.
54 |
55 | Initial seed can be used to reproduce the sequence of values generated by `random.next`:
56 | ```
57 | [args...] > equal-app
58 | eq. > @
59 | (random 3142).next.next.next.next
60 | (random 3142).next.next.next.next
61 | ```
62 | In this example `equal-app` will evaluate to `TRUE`. Moreover, corresponding elements
63 | (i.e. produces by the same number of `next` calls) of both sequences will be equal.
64 | However, in the following snippet different initial seeds will generate different sequences:
65 | ```
66 | [args...] > not-equal-app
67 | eq. > @
68 | (random 5938).next.next.next.next
69 | (random 3142).next.next.next.next
70 | ```
71 |
72 | More on _Random Generation_ read on [Wiki page](https://en.wikipedia.org/wiki/Random_number_generation)
73 |
--------------------------------------------------------------------------------
/_posts/2022/08/2022-08-30-eo-cache.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-08-30
4 | title: "Global EO Cache"
5 | author: mximp
6 | ---
7 |
8 | EO compilation process consists of several steps covered in details
9 | in [this blog post](https://www.yegor256.com/2021/10/21/objectionary.html). Most
10 | of the steps have various files (`.eo`, `.xmir`, etc.) as their input/output, and
11 | sometimes it's very handy to have them persisted somewhere for reuse between
12 | compilation runs. `~/.eo/` folder acts as such persistent storage.
13 | Let's have a closer look at its structure and how it is bound to compilation process.
14 |
15 |
16 |
17 | The folder has the following structure:
18 |
19 | ```
20 | ~/.eo/
21 | |-- pulled/
22 | |-- parsed/
23 | +-- optimized/
24 | ```
25 |
26 | Each subfolder can be considered as a local cache serving specific purpose. All caches
27 | store files based on version _git-hash_. For example `org.eolang.array` object source for version
28 | `0.27.0` within `Pulled` cache will be stored as `~/.eo/pulled/99b64cf/org/eolang/array.eo`,
29 | where `99b64cf` is git-hash for `0.27.0` version tag.
30 | Also, note that the file path corresponds to the package of the object.
31 |
32 | `Pulled` cache contains `.eo` sources downloaded from [Objectionary](https://github.com/objectionary/eo/blob/master/README.md)
33 | during [Pull](https://www.yegor256.com/2021/10/21/objectionary.html#pull) step.
34 | Every time `pull` step is executed it first checks presence of the file in `pulled` cache and would
35 | only go to remote _Objectionary_ in case it's missing locally. However, this behaviour can be adjusted by
36 | Maven `-U` option (see [Bypassing object cache](https://github.com/objectionary/eo/blob/master/eo-maven-plugin/README.md#bypassing-object-cache))
37 |
38 | `Parsed` cache stores parsed `.xmir` files produced during [Parse](https://www.yegor256.com/2021/10/21/objectionary.html#parse-) step.
39 | The structure of this folder is similar to `pulled` cache, namely it stores files based on hash+package:
40 | `parsed/99b64cf/org/eolang/array.xmir`
41 | An EO object discovered during previous compilation cycles and which has meaningful version
42 | (i.e. not like `0.0.0`, `*.*.*` or empty) before actually being parsed would be checked in
43 | `parsed` cache first. If it's found it will be copied to corresponding target. In case it's missing
44 | it would be parsed from EO source.
45 |
46 | `Optimized` cache is used during [Optimize](https://www.yegor256.com/2021/10/21/objectionary.html#optimize-) step and
47 | stores optimized `.xmir` files. It is functioning identical to `Parsed` cache.
48 |
49 | To summarize: `~/.eo/` folder represents local file cache for EO compilation artifacts to make
50 | the process more performant. It's possible that for further optimizations we will see more caches within `~/.eo/` in future.
51 |
52 | And of course to clean up all caches you can always execute (for Bash) `rm -rf ~/.eo` :)
53 |
--------------------------------------------------------------------------------
/_posts/2022/08/2022-08-30-parser-external-usage.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-08-30
4 | title: "Parser of EO as an External Java Library"
5 | author: yegor256
6 | ---
7 |
8 | EO parser is written in [ANTLR4](https://www.antlr.org),
9 | Java, and [XSL](https://en.wikipedia.org/wiki/XSL).
10 | It is packaged as a multi-module [Maven](https://maven.apache.org) project, in
11 | [objectionary/eo](https://github.com/objectionary/eo) GitHub repository.
12 | In order to compile an EO program to Java you may either use
13 | our [Maven plugin](https://github.com/objectionary/eo/tree/master/eo-maven-plugin)
14 | or our [eoc](https://github.com/objectionary/eoc) command line toolkit.
15 | Moreover, you can also use our parser programmatically in order to generate XMIR from EO.
16 | Here is how you do it in your Java/Kotlin/Clojure/Groovy/etc. project.
17 |
18 |
19 |
20 | First you need to put this dependency into `compile` scope (make sure you
21 | use the [latest](https://github.com/objectionary/eo/releases) version):
22 |
23 | ```xml
24 |
25 | org.eolang
26 | eo-parser
27 | 0.27.2
28 |
29 | ```
30 |
31 | Then, you need [Xsline](https://github.com/yegor256/xsline/) too (again, check the latest
32 | version [here](https://github.com/yegor256/xsline)):
33 |
34 | ```xml
35 |
36 | com.yegor256
37 | xsline
38 | 0.11.0
39 |
40 | ```
41 |
42 | Finally, you need [Cactoos](https://github.com/yegor256/cactoos/) and
43 | [jcabi-xml](https://github.com/jcabi/jcabi-xml):
44 |
45 | ```xml
46 |
47 | org.cactoos
48 | cactoos
49 | 0.54.0
50 |
51 |
52 | com.jcabi
53 | jcabi-xml
54 | 0.25.3
55 |
56 | ```
57 |
58 | Now, you are ready to parse a EO program to XMIR:
59 |
60 | ```java
61 | import java.io.ByteArrayOutputStream;
62 | import org.eolang.parser.Syntax;
63 | import org.cactoos.io.InputOf;
64 | import org.cactoos.io.OutputTo;
65 | import com.jcabi.xml.XML;
66 |
67 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
68 | new Syntax(
69 | "foo", // just a name to be put into XMIR
70 | new InputOf(Paths.get("test/foo.eo")),
71 | new OutputTo(baos)
72 | ).parse();
73 | XML xmir = new XMLDocument(baos.toByteArray());
74 | ```
75 |
76 | You can also parse it from a `String`: just give it to the
77 | constructor of `InputOf`.
78 |
79 | Then, you can send this XMIR through a default "train"
80 | of optimizing XSL stylesheets:
81 |
82 | ```java
83 | import com.jcabi.xml.XML;
84 | import com.yegor256.xsline.Xsline;
85 | import org.eolang.parser.ParsingTrain;
86 |
87 | XML after = new Xsline(new ParsingTrain()).pass(xmir);
88 | ```
89 |
90 | If you want to add a few extra XSL stylesheets to the train,
91 | here is how:
92 |
93 | ```java
94 | XML after = new Xsline(
95 | new TrClasspath<>(
96 | new ParsingTrain()
97 | "/org/eolang/parser/add-refs.xsl",
98 | "/org/foo/simple.xsl"
99 | ).back()
100 | ).pass(xmir);
101 | ```
102 |
103 | Here, `/org/eolang/parser/add-refs.xsl` is the XSL file available in classpath
104 | thanks to the `eo-parser.jar`, while `/org/foo/simple.xsl` is the XSL you
105 | have in your own project in `src/main/resources/org/foo/simple.xml`.
106 |
107 | If, instead of adding XSL stylesheets to the default collection,
108 | you want to use your own set of XSL stylesheets, do this
109 | (mind the usage of `empty()`):
110 |
111 | ```java
112 | XML after = new Xsline(
113 | new TrClasspath<>(
114 | new ParsingTrain().empty(),
115 | "/org/eolang/parser/add-refs.xsl",
116 | "/org/foo/simple.xsl"
117 | ).back()
118 | ).pass(xmir);
119 | ```
120 |
121 | That's it :)
122 |
--------------------------------------------------------------------------------
/_posts/2022/08/2022-08-31-new-while-dataization-result.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-08-31
4 | title: "New Dataization Result of While Object"
5 | author: Graur
6 | ---
7 |
8 | As in all other programming languages, an object [while](https://github.com/objectionary/eo/blob/8ba6cab2f06b1bf09ac1a9f5b1d6a101ecf53546/eo-runtime/src/main/eo/org/eolang/bool.eo#L55)
9 | is used to iterate over a set of statements while a condition is true.
10 | In [EO](https://github.com/objectionary/eo) this object not only does this,
11 | but is also dataized. And the result of such dataization was the number of iterations
12 | performed. Now this behavior has changed: the result of such dataization can now
13 | be any object (depending on the condition).
14 | It can be divided into two parts: when the condition is `TRUE` and when the condition
15 | is `FALSE`.
16 |
17 |
18 |
19 | When the condition is `TRUE` we get the result of the last dataization object in the `while` loop.
20 |
21 | When the condition is `FALSE` such dataization result becomes `FALSE`.
22 |
23 | Let's check it out with examples. In this case, the result of condition `x.lt 6`
24 | is `TRUE` for at least one iteration. So the result of dataization `when-true` object is `6`:
25 | ```
26 | [] > when-true
27 | memory 3 > x
28 | while.
29 | x.lt 6
30 | [i]
31 | seq > @
32 | x.write (x.plus i)
33 | x
34 | ```
35 |
36 | And in this case, the result of condition `x.lt 6` was never `TRUE`, that's why the result
37 | of dataization `when-false` object is `FALSE`:
38 | ```
39 | [] > when-false
40 | memory 10 > x
41 | while.
42 | x.lt 6
43 | [i]
44 | seq > @
45 | x.write (x.plus i)
46 | x
47 | ```
48 |
--------------------------------------------------------------------------------
/_posts/2022/10/2022-10-19-placed-catalog.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-10-19
4 | title: "EO Build Process: Placed Catalog"
5 | author: mximp
6 | ---
7 |
8 | As described in [this blog post](https://www.yegor256.com/2021/10/21/objectionary.html#place-)
9 | `place` step of EO build process copies compiled files from dependencies' JARs
10 | into `target/classes` folder to have them in classpath during compilation later.
11 | You can check [`PlaceMojo`](https://github.com/objectionary/eo/blob/master/eo-maven-plugin/src/main/java/org/eolang/maven/Place.java)
12 | class for exact logic of this step.
13 | All copied files are registered within "placed catalog," which is normally stored as
14 | `target/eo/placed.csv` file.
15 | Let's consider structure of the catalog in more details.
16 |
17 |
18 |
19 | Each entry within the catalog corresponds to a single file that has been copied.
20 |
21 | There are two kinds of entries. Entries of kind `class` corresponds to a file within JAR.
22 | It can be `.class` or `.xml` or any other type of file which needs to be within classpath
23 | during compilation.
24 | Another kind, `jar`, represents dependency JAR file whose content has been copied.
25 |
26 | Placed catalog stores the following attributes for each entry:
27 |
28 | * `id`:
29 | For `class`-kind it is absolute path to a copied file in target location.
30 | For `jar`-kind it is a JAR dependency reference constructed from Maven artifacts
31 | (e.g. `org.eolang/eo-strings/-/0.0.4`).
32 |
33 | * `related`:
34 | For `class`-kind relative path to a file within classpath.
35 | Empty for `jar` kind.
36 |
37 | * `dependency`:
38 | For `class`-kind dependency which the file was extracted from.
39 | Empty for `jar` kind.
40 |
41 | * `kind`:
42 | Type of the entry (see description above).
43 |
44 | * `hash`:
45 | For `class`-kind stores MD5 hash of the file content.
46 | Empty for `jar` kind.
47 |
48 | * `unplaced`:
49 | Contains `true` if the file was removed during `unplace` step
50 | (see [`UnplaceMojo`](https://github.com/objectionary/eo/blob/master/eo-maven-plugin/src/main/java/org/eolang/maven/Unplace.java)).
51 | Otherwise, it is set to `false`.
52 |
53 | The information from "placed catalog" can be useful when investigating
54 | "Class not found"-like issues during compilation. It can show what was added/removed
55 | from build's classpath.
56 | It also shows the origins of classes.
57 |
--------------------------------------------------------------------------------
/_posts/2022/11/2022-11-25-xmir-guide.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-11-25
4 | title: "XMIR, a Quick Tour"
5 | author: yegor256
6 | ---
7 |
8 | _Last updated at: 17.04.2025_
9 |
10 | XMIR is a dialect of [XML](https://en.wikipedia.org/wiki/XML),
11 | which we use to represent a parsed
12 | [EO](https://www.eolang.org) object. It is a pretty simple format,
13 | which has a few
14 | important tricks that I share below in this blog post. You may
15 | also want to check our [schema](https://en.wikipedia.org/wiki/XML_schema):
16 | [`XMIR.xsd`][xsd]
17 | (it is also [rendered in HTML](https://www.eolang.org/XMIR.html),
18 | which may be more readable for some of you).
19 |
20 |
21 |
22 | Consider this simple EO object that prints `"Hello, world!"`:
23 |
24 | ```
25 | # App.
26 | [] > app
27 | [x] > foo
28 | QQ.io.stdout > @
29 | QQ.txt.sprintf *1
30 | "Hello, %s\n"
31 | x
32 | foo > @
33 | "world!"
34 | ```
35 |
36 | If we parse it using the `EoSyntax` class from [eo-parser],
37 | we will get this XMIR (or very similar):
38 |
39 | ```xml
40 |
48 | # App.
49 | [] > app
50 | [x] > foo
51 | QQ.io.stdout > @
52 | QQ.txt.sprintf *1
53 | "Hello, %s\n"
54 | x
55 | foo > @
56 | "world!"
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | 48-65-6C-6C-6F-2C-20-25-73-0A
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | 77-6F-72-6C-64-21
81 |
82 |
83 |
84 | ```
85 |
86 | The `` is the root element, it will always be there, with
87 | a few mandatory attributes:
88 |
89 | * `ms` is how much time in milliseconds it took to parse the object
90 | and generate this XMIR file,
91 | * `time` is the time in [ISO 8601] format when the file was generated,
92 | * `version` is the version of the parser.
93 |
94 | The `` element contains the source code of the EO object,
95 | which was parsed, without any modifications, "as is."
96 |
97 | ## Errors and Warnings
98 |
99 | The `` element may have a list of problems discovered by the
100 | parser or any other optimizers, as `` elements. If there are no
101 | errors, the `` element should not exist in ``.
102 | For example, it may look like this:
103 |
104 | ```xml
105 |
106 | [...]
107 |
108 | There is an extra bracket
109 | The object 'x' is not found
110 | [...]
111 |
112 |
113 | ```
114 |
115 | The errors with the `warning` severity may more or less safely be ignored. The
116 | errors with the `error` severity will lead to failures in further compilation
117 | and processing. There could also be elements with the `critical` severity,
118 | which must stop the processing of the document immediately.
119 |
120 | ## Sheets
121 |
122 | The `` element contains a list of all
123 | post-processors that were applied to the document after is parsing.
124 | We process our XMIR documents using dozens of XSL stylesheets. That's why
125 | the name of the XML element. You may find something like this over there:
126 |
127 | ```xml
128 |
129 | [...]
130 |
131 | move-voids-up
132 | const-to-dataized
133 | stars-to-tuples
134 | wrap-method-calls
135 | [...]
136 |
137 |
138 | ```
139 |
140 | The names you see in the `` elements are the names of the files.
141 | For example, `wrap-method-calls` represents the
142 | [`wrap-method-calls.xsl`] file
143 | in the [objectionary/eo](https://github.com/objectionary/eo) GitHub repository.
144 |
145 | If no XSL stylesheets are applied to XMIR, the `` element should not exist
146 | in ``.
147 |
148 | ## Metas
149 |
150 | There may be an optional element `` with a list of ` ` elements.
151 | For example, if my source code would have this meta at the 3rd
152 | line of the source file:
153 |
154 | ```
155 | +alias foo com.example.foo
156 | ```
157 |
158 | We would see the following in the XMIR:
159 |
160 | ```xml
161 |
162 | [...]
163 |
164 |
165 | alias
166 | foo Q.com.example.foo
167 | foo
168 | Q.com.example.foo
169 |
170 | [...]
171 |
172 |
173 | ```
174 |
175 | Each ` ` element contains parts of the meta. The ``
176 | contains everything that goes after the `+` until the first space.
177 | The `` contains everything after the first space. There could
178 | be a number of `` elements, each of which containing the parts
179 | of the `` separated by spaces.
180 |
181 | ## Objects
182 |
183 | The `` element must contain only one ` ` element which represents an
184 | object being parsed. The ` ` element may have a few optional attributes:
185 |
186 | * `line` and `pos` are the number of the line where the object
187 | was found by the parser and the position in the line;
188 | * `name` is the name of the object, if the object has it;
189 | * `base` may refer to object formation that is being copied;
190 | * `as` is the name of the attribute which current object is bound to during the
191 | application
192 |
193 | There could be no other attributes.
194 |
195 | ## Special cases
196 |
197 | 1. The ` ` elements that have nested `` element with `name` which
198 | value is `λ` are **atoms**. Atoms must not have `base` attribute:
199 | ```xml
200 |
201 |
202 |
203 | ```
204 |
205 | 2. The ` ` elements with `base` attribute which value is `∅` are **void** attributes.
206 | Void attributes also must have `name` attribute:
207 | ```xml
208 |
209 |
210 |
211 | ```
212 |
213 | 3. **Data literals** found in the source code are presented with nested ` ` XML elements
214 | that contain text. Only elements with `base` attribute equal to `Q.org.eolang.bytes` may contain
215 | nested `` element with text.
216 |
217 | ```xml
218 |
219 | 48-65-6C-6C-6F-2C-20-25-73-0A
220 |
221 | ```
222 |
223 | 4. The `name` attribute of ` ` element may be **auto generated** by EO parser.
224 | In such case it's look like:
225 | ```xml
226 |
227 | ```
228 |
229 | Such `name` consists of several parts:
230 | - char `a` (ascii 97) that stands for "auto-generated"
231 | - char `🌵` that is just a pretty character prohibited by EO grammar
232 | - number `104` which is joined line and position of the place where
233 | the object is found.
234 |
235 | Such names are unique through entire XMIR.
236 |
237 | 5. If object is bound to a specific attribute not by name but by position, the
238 | `as` attribute may look like:
239 | ```xml
240 |
241 | ```
242 | Here the first character is `α` (alpha), the number `2` is the position of the
243 | attribute.
244 |
245 |
246 |
247 | This description of XMIR is not complete. If you want me to explain
248 | something else in more details, please post a message below this blog post
249 | and I will add the content.
250 |
251 | [xsd]: https://raw.githubusercontent.com/objectionary/eo/gh-pages/XMIR.xsd
252 | [eo-parser]: https://github.com/objectionary/eo/tree/master/eo-parser
253 | [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601
254 | [`not-empty-atoms.xsl`]: https://github.com/objectionary/eo/blob/master/eo-parser/src/main/resources/org/eolang/parser/errors/not-empty-atoms.xsl
255 | [`set-locators.xsl`]: https://github.com/objectionary/eo/blob/master/eo-parser/src/main/resources/org/eolang/parser/set-locators.xsl
256 |
--------------------------------------------------------------------------------
/_posts/2022/12/2022-12-02-java-atoms.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-12-02
4 | title: "How to Create a Java Atom"
5 | author: yegor256
6 | ---
7 |
8 | There are "atoms" in [EO](https://www.eolang.org) language, which are objects implemented by
9 | the runtime platform, not by a composition of other EO objects. Most
10 | notable examples of atoms are `int.plus`, `float.times`, and
11 | `bool.while`. Here is a quick intruction to creating your own
12 | atoms.
13 |
14 |
15 |
16 | Let's say, this is an EO program that uses your atom `md5` (it
17 | builds an [MD5](https://en.wikipedia.org/wiki/MD5) hash of a `string`):
18 |
19 | ```
20 | +package org.example
21 | +alias org.example.md5
22 |
23 | [] > app
24 | QQ.io.stdout > @
25 | md5
26 | "Hello, world!"
27 | ```
28 |
29 | Put it into `src/main/eo/org/example` directory and try to compile
30 | using our [Maven Plugin](https://github.com/objectionary/eo/tree/master/eo-maven-plugin):
31 |
32 | ```
33 | $ mvn clean compile
34 | ```
35 |
36 | The compilation will fail, because there is no atom definition yet.
37 | Create this file, with the atom and put it to `src/main/eo/org/example/md5.eo`:
38 |
39 | ```
40 | +package org.example
41 |
42 | [txt] > md5 /string
43 | ```
44 |
45 | Then, create a Java implementation of this atom in
46 | `src/main/java/EOorg/EOexample/EOmd5.java` file:
47 |
48 | ```
49 | package EOorg.EOexample;
50 | import org.eolang.*;
51 | import java.security.*;
52 |
53 | @XmirObject(oname = "md5")
54 | public class EOmd5 extends PhDefault {
55 | public EOmd5(final Phi sigma) {
56 | super(sigma);
57 | this.add("txt", new AtFree());
58 | this.add(
59 | "φ",
60 | new AtComposite(
61 | this,
62 | rho -> {
63 | String txt = new Param(rho, "txt").strong(String.class);
64 | byte[] bytes = txt.getBytes("UTF-8");
65 | byte[] hash = MessageDigest.getInstance("MD5").digest(bytes);
66 | return new Data.ToPhi(new String(hash));
67 | }
68 | )
69 | );
70 | }
71 | }
72 | ```
73 |
74 | Here, the `EOorg.EOexample` is the Java package that contains
75 | all atoms and objects of `org.example` EO package. The `EO` prefix
76 | is used in order to enable EO naming inside Java name space.
77 |
78 | The class `PhDefault` is the parent of all Java atoms and I strongly
79 | recommend you use it too. You class should implement a single argument
80 | constructor with a parameter of type `Phi`. If you don't have it,
81 | there will be a runtime error by reflection API: EO runtime won't
82 | be able to instantiate your class. The argument `sigma` you should pass
83 | to the constructor of the parent class `PhDefault`.
84 |
85 | Then, using `this.add()` you configure the attributes of the atom,
86 | which you can later use inside the code encapsulated by the instance of the `AtComposite`
87 | class.
88 |
89 | The attibute you add with `this.add("φ")` is the "body" of the atom.
90 | It will be evaluated when the atom will be dataized.
91 |
92 | Then, using the class `Param` you can get the value of any incoming attribute
93 | of your atom. The method `strong()` finds the attribute and dataizes it.
94 |
95 | The `new Data.ToPhi()` is the best way to return the result back to EO.
96 |
97 | The presence of `@XmirObject` annotation will help EO runtime to properly
98 | name your atom in the logs (you can omit this annotation).
99 |
100 | Now, let's create a unit test for the atom. Put this file
101 | into `src/test/java/EOorg/EOexample/EOmd5Test.java`:
102 |
103 | ```
104 | package EOorg.EOeolang;
105 | import org.eolang.*;
106 | import static org.hamcrest.*;
107 | import org.junit.jupiter.api.Test;
108 |
109 | public final class EOmd5Test {
110 | @Test
111 | public void calculatesHashString() {
112 | assertThat(
113 | new Dataized(
114 | new PhWith(
115 | new EOmd5(Phi.Φ),
116 | "txt",
117 | new Data.ToPhi("Hello, world!")
118 | )
119 | ).take(String.class),
120 | Matchers.equalTo("A6F5EC87EB4E9027295")
121 | );
122 | }
123 | }
124 | ```
125 |
126 | Then, make an EO test for your atom:
127 |
128 | ```
129 | +alias org.eolang.hamcrest.assert-that
130 | +junit
131 | +package org.example
132 |
133 | [] > calculates-hash-code
134 | assert-that > @
135 | md5
136 | "Hello, world!"
137 | $.equal-to
138 | "A6F5EC87EB4E9027295"
139 | ```
140 |
141 | Run them both using our Maven Plugin:
142 |
143 | ```
144 | mvn clean test
145 | ```
146 |
147 | That's it.
148 |
149 |
150 |
151 | You can find a good example of some atoms in the
152 | [`eo-files`](https://github.com/objectionary/eo-files) repository.
153 |
--------------------------------------------------------------------------------
/_posts/2022/12/2022-12-22-adoption.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-12-22
4 | title: "Object Adoption"
5 | author: yegor256
6 | ---
7 |
8 | In the recently released version [0.28.14](https://github.com/objectionary/eo/releases/tag/0.28.14)
9 | we introduced a new language feature, which is called "object adoption"
10 | --- because it allows changing of an object's parent. Every object in
11 | [EO](https://www.eolang.org) has a parent object, which is set to it when it's born
12 | (either formed or copied). Until the recent release it was
13 | not possible to change the parent object using EO language. However, it
14 | was possible to do this from inside an atom (through Java).
15 | Now, there is no special API inside Java, but the feature is available through EO.
16 |
17 |
18 |
19 | This is how an object is "formed":
20 |
21 | ```
22 | [id] > book
23 | "Object Thinking" > title
24 | ```
25 |
26 | This is how we make a "copy" of it:
27 |
28 | ```
29 | book 42 > b
30 | ```
31 |
32 | For both of them the parent is the root object `Q`. You can access it
33 | using the `^` identifier:
34 |
35 | ```
36 | QQ.io.stdout
37 | QQ.txt.sprint
38 | "The title is %s"
39 | b.^.book.title
40 | ```
41 |
42 | Now, it's possible to create a new copy of `book` with a different parent:
43 |
44 | ```
45 | book > x
46 | 42
47 | b:^
48 | ```
49 |
50 | Here, `^` (after the colon) is the name of the attribute to be bound to `b`.
51 | The `x` object created will have `^` bound to `b`.
52 |
53 | It is interesting to mention that now, with the help of this new object adoption mechanism,
54 | instead of this:
55 |
56 | ```
57 | a.if "left" "right"
58 | ```
59 |
60 | We can do this:
61 |
62 | ```
63 | bool.if
64 | a:^
65 | "left"
66 | "right"
67 | ```
68 |
69 | Also, we can take a closed object and re-bind its `^` attribute:
70 |
71 | ```
72 | b > y
73 | book:^
74 | ```
75 |
76 | Here, we create a copy of `b`, name it `y`, and reset the parent to the `book` object.
77 |
78 | The objects [`goto`](https://github.com/objectionary/home/blob/0.28.14/objects/org/eolang/goto.eo),
79 | [`bool.while`](https://github.com/objectionary/home/blob/0.28.14/objects/org/eolang/bool.eo)
80 | and
81 | [`try`](https://github.com/objectionary/home/blob/0.28.14/objects/org/eolang/try.eo)
82 | use object adoption mechanism. For example,
83 | when `while` dataizes the encapsulated body, it first adopts it:
84 |
85 | ```
86 | [] > foo
87 | memory TRUE > x
88 | x.while
89 | [i]
90 | ^.^.write FALSE > @
91 | ```
92 |
93 | Here, `^.^` points to the parent object of the parent object. The parent
94 | of the abstract anonymous object is the `while` object. The parent of `while`
95 | is `x`. However, it is not true until the dataization of the `while` starts.
96 | When the program starts, the parent of the abstract anonymous object
97 | is the `foo` object. It is the `while` object who adopts its copies after
98 | creating them.
99 |
100 | Thus, the `^` attribute is the only _mutable_ attribute in EO.
101 |
--------------------------------------------------------------------------------
/_posts/2022/12/2022-12-22-declarative-while.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2022-12-22
4 | title: "The WHILE Object Is Declarative Now"
5 | author: yegor256
6 | ---
7 |
8 | In the recently released version [0.28.14](https://github.com/objectionary/eo/releases/tag/0.28.14)
9 | we've changed the iterating algorithm of the
10 | [`bool.while`](https://github.com/objectionary/home/blob/0.28.14/objects/org/eolang/bool.eo#L51-L56)
11 | object. Until now,
12 | by our mistake, it was imperative. Now, it's
13 | [declarative](https://en.wikipedia.org/wiki/Declarative_programming).
14 | The difference is in the result of its dataization.
15 | The previous imperative version was "returning" a data object.
16 | The new declarative one returns the latest body of the loop (without dataization!).
17 | The difference is huge (thanks to it, many of our tests broke).
18 |
19 |
20 |
21 | This is how the iterating algorithm works now:
22 |
23 | ```
24 | while($, ^, x):
25 | var last := TRUE
26 | var i := 0
27 | loop:
28 | if (not dataized(^)) break;
29 | dataized(last);
30 | last := x(^ := $, α0 := i);
31 | i := i + 1;
32 | return last;
33 | ```
34 |
35 | Here, `^` is the parent of the `while` object, dataization of which returns a boolean value;
36 | `$` is the `while` object itself;
37 | and `x` is the object that is encapsulated
38 | by the `while` object --- the _body_ of the [loop](https://en.wikipedia.org/wiki/For_loop).
39 |
40 | Consider this simple loop:
41 |
42 | ```
43 | memory -1 > x
44 | while. > w
45 | x.lt 1
46 | [i]
47 | x.write i > @
48 | ```
49 |
50 | It is equivalent to the following:
51 |
52 | ```
53 | memory 0 > x
54 | seq > w
55 | x.lt 1 # TRUE (x=-1)
56 | x.lt 1 # TRUE (x=-1)
57 | x.write 0
58 | x.lt 1 # TRUE (x=0)
59 | x.write 1
60 | x.lt 1 # FALSE (x=1)
61 | x.write 2
62 | ```
63 |
64 | This may look counter-intuitive, but only because you may be used to imperative
65 | loops in Java or Python, where variables are mutable and evaluations are "eager."
66 | In EO we have the opposite paradigm: variables are immutable and, more importantly,
67 | evaluations are "[lazy](https://en.wikipedia.org/wiki/Lazy_evaluation)." Making the
68 | body of the loop affecting the condition of it --- this is what conflicts with the
69 | laziness nature of EO.
70 |
71 | An imperative algorithm checks the head of the loop (the condition) and then,
72 | if the head was true, it evaluates the body. If the head was false, the algorithm
73 | exits and returns nothing. This is how the [`while` statement](https://en.wikipedia.org/wiki/While_loop)
74 | works in C++, Java, and other object-oriented imperative languages.
75 |
76 | To the contrary, expecting the algorithm to be declarative and lazy would entail
77 | it 1) to return the result of the last evaluation of the body and 2) to not
78 | evaluate it. In other words, a declarative and lazy loop equals to its body,
79 | evaluated until the head is false.
80 |
81 | The new declarative version of the `while` object in EO behaves exactly this way:
82 | it dataizes the body only when the result of dataization may be ignored.
83 | The result of the last dataization in the loop
84 | is important because it is what the `while` object "is" --- it is the body
85 | of the loop after all pre-exit dataizations. In the example above, the `x.write 2` is
86 | what the `while` object is (and the `seq` object too). Since `memory.write` is
87 | what it writes into memory, the following holds:
88 |
89 | ```
90 | w.eq 2
91 | ```
92 |
93 | You may wonder, how is it possible to rewrite this code in order to make its flow of dataizations
94 | be the following (a traditional imperative expectation, which is almost what we've had in EO before
95 | the recent changes):
96 |
97 | ```
98 | memory -1 > x
99 | seq > w2
100 | x.lt 1 # TRUE (x=-1)
101 | x.write 0
102 | x.lt 1 # TRUE (x=0)
103 | x.write 1
104 | x.lt 1 # FALSE (x=1)
105 | nop
106 | ```
107 |
108 | The following code would work:
109 |
110 | ```
111 | memory -1 > x
112 | memory 0 > i
113 | while. > w2
114 | []
115 | if. > @
116 | x.lt 1
117 | seq
118 | x.write i
119 | i.write (i.plus 1)
120 | TRUE
121 | FALSE
122 | nop
123 | ```
124 |
125 | Here, we abuse the design of the `while` object: the body is `nop`, while the
126 | entire algorithm of the body and the condition are placed together into the
127 | condition. Don't do this. But it works.
128 |
--------------------------------------------------------------------------------
/_posts/2023/01/2023-01-12-declarative-while-nested.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-01-12
4 | title: "Declarative WHILE: nested example"
5 | author: mximp
6 | ---
7 |
8 | Previous [post](https://news.eolang.org/2022-12-22-declarative-while.html)
9 | by @yegor256 explained declarative WHILE nature.
10 | Let's examine more complex example when `while` objects are nested.
11 |
12 |
13 |
14 | Consider the following code:
15 |
16 | ```eo
17 | +alias org.eolang.txt.sprintf
18 |
19 | [] > nested-while
20 | memory 0 > x
21 | memory 0 > y
22 | seq > @
23 | while.
24 | x.lt 10
25 | [i]
26 | seq > @
27 | y.write 0
28 | while.
29 | y.lt 2
30 | [i]
31 | seq > @
32 | write.
33 | y
34 | y.plus 1
35 | write.
36 | x
37 | x.plus 1
38 | QQ.io.stdout
39 | sprintf
40 | "x=%d"
41 | x
42 | ```
43 |
44 | Here, we have two `while` loops one inside the other. Initially `x` is set to `0`.
45 | The outer loop continues while `x` lower than `10`. Inner loop executes its body
46 | twice every time it's dataized.
47 |
48 | So what do you think the `x` will be after dataization fo the whole program?
49 | The answer is `15` and here is why.
50 |
51 | Every time the inner `while` is dataized, `x` is incremented by `3`: two times as
52 | `while` iteration and one more time once the body is returned as a result. So the single
53 | outer `while` iteration increments `x` by three. The last true condition of the outer
54 | `while` would be after `3` iterations when `x=3*3=9`. The next iteration would set
55 | `x` to `12` which will stop the outer loop.
56 |
57 | After that, due to its declarative nature, the outer `while` will supply its body object, which
58 | will be dataized one more time as requested by `seq` object. And the body happens to be the
59 | inner `while`:
60 |
61 | ```eo
62 | [i]
63 | seq > @
64 | y.write 0
65 | while.
66 | y.lt 2
67 | [i]
68 | seq > @
69 | write.
70 | y
71 | y.plus 1
72 | write.
73 | x
74 | x.plus 1
75 | ```
76 |
77 | And we already know that this object would increase `x` by `3`. So the final value of `x` will
78 | be set to `15`.
79 |
80 | Sometimes it might be tricky to reason about the result when working with complex objects in EO.
81 | But it's only a matter of practice and getting used to its declarative nature.
82 |
--------------------------------------------------------------------------------
/_posts/2023/01/2023-06-22-daily-auto-pull.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-06-22
4 | title: "Automating the Pull of New Releases for EO Libraries"
5 | author: graur
6 | ---
7 |
8 | As a developer, keeping up with the latest releases of libraries is crucial to ensure that your code is
9 | up-to-date and optimized. However, manually checking for new releases can be time-consuming and tedious.
10 | That's why we've created an automated pull system for new releases of EO libraries in our
11 | [Home](https://github.com/objectionary/home) repository.
12 |
13 |
14 |
15 | The process of creating a release of EO libraries consists of three main stages: releasing the EO library,
16 | publishing it on Maven Central and on the GitHub of this library in the `gh-pages` branch, and adding EO objects from
17 | the `gh-pages` branch of this library to [Objectionary Home](https://github.com/objectionary/home) repository.
18 | Until recently, the last stage was performed manually with the help of a script that added modified files by the
19 | library's URL, after which a pull request was created. And that stage consisted of the following steps:
20 |
21 | 1.To create a pull request in `objectionary/home` by `pull.sh` script in a separate git branch (the name of the branch doesn't matter):
22 | ```shell
23 | ./pull.sh objectionary/eo
24 | ```
25 | This update all `.eo` files in `gh-pages` from `objectionary/eo`.
26 | It also changes the corresponding versions of the eo objects (e.g. from the `+version` metadata) in the `objectionary/home` repository.
27 |
28 | 2.To check and to remove manually either unused or old files. Script didn't do it.
29 |
30 | 3.To update `eo.version` in `pom.xml` in `objectionary/home`.
31 |
32 | 4.Finally, all `todo` must be removed manually.
33 |
34 | To avoid manual changes we created auto pulling daily run script. It runs once an hour every day to check for new releases of [Objectionary](https://github.com/objectionary/) libraries.
35 | If a new release is found, the script creates a new pull request with corresponding changes. This process ensures that our codebase
36 | is always up-to-date and optimized.
37 |
38 | The benefits of this automated system are numerous. First, it saves developers time by eliminating the
39 | need to manually check for new releases. Second, it ensures that our codebase is always up-to-date with
40 | the latest features and optimizations. Finally, it helps us maintain a high level of code quality by
41 | ensuring that we are using the most recent versions of our libraries.
42 |
--------------------------------------------------------------------------------
/_posts/2023/06/2023-06-22-we-are-hiring.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-06-22
4 | title: "We Are Hiring!"
5 | author: yegor256
6 | ---
7 |
8 | ATTENTION!
9 | We are also hiring interns (BSc and MSc students).
10 | Find me in Telegram, we will discuss:
11 | [yegor256](https://t.me/yegor256).
12 |
13 | [EOLANG](https://www.eolang.org) is an R&D project, where we create a new programming language
14 | in order to introduce new techniques of object-oriented programming.
15 | We believe that existing object-oriented languages, such as Java and C++,
16 | are not strong enough in their adherence to the object paradigm
17 | originally introduced by Alan Kay and earlier implemented in languages
18 | like [Smalltalk](https://en.wikipedia.org/wiki/Smalltalk) and
19 | [Self](https://en.wikipedia.org/wiki/Self_%28programming_language%29).
20 | Besides that, we expect to explore the possibility
21 | of using our new language as an intermediate representation in the
22 | process of optimization of mainstream languages. EOLANG is based on
23 | [𝜑-calculus](https://arxiv.org/abs/2111.13384), which is a formal
24 | foundation for it and potentially for other object-oriented languages.
25 |
26 | We have a few open positions in our team:
27 |
28 | * Java developer
29 | * C++ developer
30 | * Rust developer
31 |
32 |
33 |
34 | We expect you:
35 |
36 | * To be a hands-on programmer
37 | * To have a PhD (or MSc) degree in computer science
38 | * To demonstrate us your own clean code
39 | * To be an active open source contributor/author
40 | * To speak English fluently (intermediate is OK too)
41 | * To be ready to work full-time (5x8) in our office
42 | * To know UML and be able to explain yourself via diagrams
43 |
44 | You will get this from us:
45 |
46 | * Above-the-market monthly salary (plus bonuses)
47 | * All social benefits, incl. 28 days annual vacation, etc.
48 | * Challenging tasks and details-oriented management
49 | * An opportunity to become a known open source contributor
50 | * A limitless career path in a Fortune-100 company
51 | * Ability to work remotely from home
52 | * Inclusive discrimination-free workplace
53 |
54 | When you decide to apply, be prepared to share this data with us (this is what we pay attention to, in order of importance): years of experience (and company names); education degree (BSc, MSc, PhD, etc.); h-index; books; patents; open source projects; GitHub followers; industry certifications; English level; StackOverflow reputation; blogs and vlogs; non-for-profit activities; public speaking experience; Twitter followers.
55 |
56 | Apply to [jobs@eolang.org](mailto:jobs@eolang.org) (we reply to all emails).
57 |
--------------------------------------------------------------------------------
/_posts/2023/08/2023-08-05-storing-objects-formed-differently-into-cage.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-08-04
4 | title: "The CAGE Prohibits Storing Objects Formed Differently"
5 | author: maxonfjvipon
6 | ---
7 |
8 | In the recently released version [0.30.0](https://github.com/objectionary/eo/releases/tag/0.30.0)
9 | we've changed the writing mechanism of `cage` object. Until now, we could store and write to
10 | `cage` any object we wanted. But `cage` became smarter and stricter and can store only objects
11 | that have the same "form" now.
12 |
13 |
14 |
15 | A few words about "form" and "formation." Let's take a look at the code below:
16 |
17 | ```
18 | [name] > cat
19 | [] > voice
20 | stdout
21 | sprintf
22 | "Meow from %s"
23 | name
24 | ```
25 |
26 | This is a "formation" of the object `cat`. Here we can say that the "form" of object `cat` is "cat."
27 |
28 | ```
29 | cat "Lisa" > lisa
30 | ```
31 |
32 | Here object `cat` was copied and its free attribute `name` was set to "Lisa." Now we can say that
33 | object `lisa` "was formed by" object `cat` and has the same "form"—"cat."
34 |
35 | Let's get back to the object `cage`. The object is used as temporary storage of objects in memory.
36 | It should be remembered that `cage` does not dataize a stored object.
37 |
38 | Here is the typical example of how `cage` was used before:
39 |
40 | ```
41 | cage 0 > cg
42 |
43 | seq > @
44 | cg.write lisa
45 | ```
46 |
47 | Here we copy object `cage` and store the object `0` (which is "formed by" object `int`) in it, and
48 | then we write an object `lisa` to it.
49 |
50 | Such behavior is prohibited now and will lead to an exception being thrown.
51 | Object `cage` can store inside only objects of the same "form."
52 |
53 | The next code will work since object `cat` and `lisa` have the same "form"–"cat":
54 |
55 | ```
56 | cage cat > cg
57 |
58 | seq > @
59 | cg.write lisa
60 | ```
61 |
62 | You may wonder why we did it.
63 | Here it's time to talk a bit about our plans for EO.
64 |
65 | We believe that EO can be used as intermediate representation for performing optimizations for many
66 | object-oriented programming languages.
67 | To achieve that, we have to make EO stronger and stricter.
68 | This is how we're about to do it:
69 | - Prohibit writing objects formed differently into `cage` (done)
70 | - Prohibit writing objects formed differently into `memory`
71 | - Prohibit weak atoms typing (`[] > atom /?`)
72 |
73 | Be in touch and see you soon.
74 |
--------------------------------------------------------------------------------
/_posts/2023/09/2023-09-04-memory-as-container-for-real-data.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-09-04
4 | title: "MEMORY as a container for a real data"
5 | author: maxonfjvipon
6 | ---
7 |
8 | In the recently released version [0.31.0](https://github.com/objectionary/eo/releases/tag/0.31.0),
9 | we've changed the behavior of the `memory` object. Until now, when we stored an object in `memory`,
10 | it attempted to dataize the object into data and started behaving accordingly. However, we are now
11 | reevaluating the concept of data within our language, and the `memory` is an entry point.
12 |
13 |
14 | Let's delve into the topic of data for a moment. In every programming language, we are accustomed to
15 | representing data using various primitive types, or in our case, objects such as `int`, `float`,
16 | `bytes`, `string`, and `bool`. But upon closer examination, you may observe that four of them can
17 | be reduced to `bytes`, making it unnecessary to single them out.
18 |
19 | Henceforth, there are only two fundamental entities in our language: objects and data, with data
20 | being merely a sequence of bytes, nothing more.
21 |
22 | Now, let's revisit how we used `memory` previously. Consider the following code, which illustrates a
23 | typical usage of `memory`:
24 |
25 | ```
26 | memory 0 > mem
27 |
28 | while. > @
29 | mem.lt 10
30 | [i]
31 | mem.write > @
32 | mem.plus 1
33 | ```
34 | Here, after storing an `int` in `memory`, it behaves as if it were an `int`, allowing access to all
35 | internal objects of the `int`. In this case, `int` acts as data.
36 | However, from now on, an `int` is just a regular object, and `bytes` is the sole representation of data.
37 | `memory` adheres to these rules. The following code demonstrates how the behavior of `memory` has been altered:
38 |
39 | ```
40 | memory 0 > mem
41 |
42 | while. > @
43 | mem.as-int.lt 10
44 | [i]
45 | mem.write > @
46 | mem.as-int.plus 1
47 | ```
48 |
49 | Here, after storing an `int` in `memory`, it behaves like `bytes` – genuine data.
50 |
51 | Additionally, it's important to remember that `memory` is not unlimited. Therefore, we have
52 | introduced a new restriction: when `memory` accepts and converts an object into data for the first
53 | time, it records the object's length in bytes. Subsequently, it is not permissible to write an
54 | object whose length in bytes exceeds that of the original object.
55 |
56 | As a result, the following code will fail:
57 |
58 | ```
59 | memory TRUE > mem # <-- 1 byte is written here
60 |
61 | mem.write 10 > @ # <-- 8 bytes are written here
62 | ```
63 |
64 | However, it's crucial to note that `memory` only retains the length of the first stored object.
65 | Consequently, the following code will NOT fail:
66 |
67 | ```
68 | memory 8 > mem # <-- 8 bytes are written here
69 |
70 | seq > @
71 | mem.write TRUE # <-- 1 byte is written here
72 | mem.write 10 # <-- 8 bytes are written here again
73 | ```
74 |
75 | That's all for today, be in touch!
76 |
--------------------------------------------------------------------------------
/_posts/2023/10/2023-10-04-application-to-application.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-10-04
4 | title: "Application to application"
5 | author: maxonfjvipon
6 | ---
7 |
8 | In the process of working on the recent release
9 | [0.32.0](https://github.com/objectionary/eo/releases/tag/0.32.0), we've faced an interesting case
10 | related to one of the fundamental concepts of EO in particular and phi-calculus in general -
11 | application.
12 |
13 | This blog post will attempt to explain what application is under the hood, how it works in our
14 | compiler, and why this code `(arr.at 0) "Hello"` does not work in the way you expect.
15 |
16 |
17 |
18 | ### Application
19 | Application is the process of copying an abstract object while specifying some of its free
20 | attributes.
21 |
22 | Consider the example. Here, `dog` is an abstract object with one free attribute: `name`.
23 |
24 | ```
25 | [name] > dog
26 | stdout > bark
27 | sprintf
28 | "I'm %s! Woof!"
29 | name
30 | ```
31 |
32 | Abstract objects are like templates or factories for concrete objects. So, getting a specific
33 | instance of a `dog` occurs in two stages: copying and setting free attribute. The copying process
34 | takes place behind the scenes. Thus, we obtain a new specified object, `dog`, with its `name` as
35 | "Bary".
36 |
37 | ```
38 | dog "Bary" > bary
39 | ```
40 |
41 | At the Java level (into which EO is being translated), application looks something like this:
42 |
43 | ```java
44 | Phi dog = Phi.Ф.attr("org.eolang.dog").get(); // finding an abstract object "dog"
45 | Phi copy = dog.copy(); // copying/cloning an abstract object
46 | copy.attr("name").put("Bary"); // setting the free attribute
47 | ```
48 |
49 | As you can see, no object execution occurs. It's vital to note and remember that everything that
50 | happens during the application involves getting a new object by copying and setting its internal
51 | state. Nothing more.
52 |
53 | ### Application to application
54 |
55 | However, despite knowing what application is, we encountered an interesting problem for which we
56 | couldn't find a solution for a long time.
57 |
58 | Consider the following code:
59 |
60 | ```
61 | 1. [name] > dog
62 | 2. "I'm %s! Woof!" > bark
63 | 3. * dog > arr
64 | 4. (arr.at 0) "Bary" > bary
65 | ```
66 |
67 | - As before, `dog` is an abstract object with one free attribute, `name`.
68 | - In the third line, an abstract object `dog` is stored in an array.
69 | - In the fourth line, we attempt to retrieve an abstract object `dog` from the array by applying
70 | object `0` to `arr.at` (in simpler words, we're trying to access the first element of the array)
71 | and then set the object `"Bary"` as the free attribute `name` of the `dog`.
72 |
73 | We can try to clarify the code like this:
74 |
75 | ```
76 | 1. [name] > dog
77 | 2. "I'm %s! Woof!" > bark
78 | 3. * dog > arr
79 | 4. arr.at 0 > first
80 | 5. first "Bary" > bary
81 | ```
82 |
83 | It appears that everything is fine, and the code should work, but it doesn't, and moreover, it must
84 | not.
85 |
86 | ### What's wrong
87 |
88 | It all comes down to the application discussed earlier. No object execution occurs during the
89 | application. So if you take a closer look at the fourth line:
90 |
91 | ```
92 | 4. arr.at 0 > first
93 | ```
94 |
95 | there is no information about what's inside the array. It simply sets the object `0` as the free
96 | attribute of the object `arr.at`, and that's it.
97 |
98 | And what happens next in the fifth line:
99 |
100 | ```
101 | 5. first "Bary" > bary
102 | ```
103 |
104 | We're taking an object `first` (which is just a reference to the object `arr.at` with an already
105 | specified free attribute) and then trying to specify its free attribute again.
106 |
107 | And obviously (perhaps not so obvious), this leads to an error because we're trying to set the same
108 | free attribute twice.
109 |
110 | ### So, what's the solution?
111 |
112 | Firstly, code where application is placed at the "head" of another application is now prohibited at
113 | the grammar level:
114 |
115 | ```
116 | (arr.at 0) "Bary"
117 | ```
118 |
119 | Secondly, we found out that such cases can be easily resolved with code like this:
120 |
121 | ```
122 | (arr.at 0).@ "Bary" > bary
123 | ```
124 |
125 | Here, we first specify the free attribute of the object `arr.at`, and then we access its `@`
126 | attribute and apply the object `"Bary"` to it.
127 |
128 | The information about the abstract object `dog` stored inside the array is revealed when we access
129 | the `@` attribute of the object `arr.at`.
130 |
131 | In this particular case, `arr.at.@` is a so-called lambda object that performs calculations and
132 | returns the object from the array by providing an index. It's worth noting that if the free
133 | attribute of `arr.at` is not specified, the following code:
134 |
135 | ```
136 | arr.at.@
137 | ```
138 |
139 | will fail with an error.
140 |
141 | I hope you've learned a little more about EO today. Stay tuned for updates and be in touch!
142 |
--------------------------------------------------------------------------------
/_posts/2023/10/2023-11-02-comparison-of-floating-zeros.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-11-02
4 | title: "Comparison of 0.0 and -0.0"
5 | author: c71n93
6 | ---
7 |
8 | Due to the peculiarities of working with data in EO, an interesting quirk had been arising when comparing `0.0` and
9 | `-0.0.` The fact is that in EO, these two values were not considered equal until we made changes.
10 |
11 | Until recently, the comparison of `0.0` and `-0.0` in EO didn't work like in other languages, but we changed that. This
12 | short blog post provides a simplified explanation of number encodings, how such comparison takes place in popular
13 | programming languages, and how we changed this comparison in EO to meet the standard.
14 |
15 |
16 |
17 | ### Why do we have two zeros?
18 |
19 | Without delving into the intricacies of number encoding and standards, let's briefly understand why this happens.
20 |
21 | The familiar `signed int` works based on the [two's complement](https://en.wikipedia.org/wiki/Two%27s_complement)
22 | principle, in which zero has a unique representation (all bits are `0`).
23 |
24 | On the other hand, `float` operates differently, using the [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754) standard
25 | for encoding and arithmetic operations. In this standard, numbers have a sign bit. If the sign bit is `1`, the number is
26 | negative; if it's `0`, the number is positive. As a result, we have two different binary representations of float
27 | zero: `0.0` has all zeros in its binary representation, while `-0.0` has all zeros except for the sign bit.
28 |
29 | ### Comparison of 0.0 and -0.0 in EO before the changes
30 |
31 | EO comparison used to work as follows:
32 |
33 | ```
34 | 0.0.eq -0.0 # FALSE
35 | 0.0.gt -0.0 # FALSE
36 | 0.0.lt -0.0 # FALSE
37 | 0.0.gte -0.0 # FALSE
38 | 0.0.lte -0.0 # FALSE
39 | ```
40 |
41 | This happened because the `eq` attribute compared data within objects bitwise. In simpler terms, regardless of the data
42 | being compared, it was first interpreted as a set of bits and then compared.
43 |
44 | Thus, due to the fact that numbers `0.0` and `-0.0`, as previously determined, have different bitwise representations,
45 | when compared in EO using `eq`, they turned out to be not equal.
46 |
47 | ### Comparison of 0.0 and -0.0 in other languages
48 |
49 | In most mainstream programming languages `0.0` is considered equal to `-0.0` in basic equality comparisons. For
50 | example, in Java, C++, JavaScript, and Python, the comparison of these values works as follows:
51 |
52 | ```java
53 | 0.0 == -0.0 // true
54 | 0.0 < -0.0 // false
55 | 0.0 > -0.0 // false
56 | 0.0 <= -0.0 // true
57 | 0.0 >= -0.0 // true
58 | ```
59 |
60 | Why do these languages consider `0.0` and `-0.0` as equal, even though they have different bitwise representations? The
61 | same IEEE 754 standard states that *"negative zero and positive zero should compare as equal with the usual (numerical)
62 | comparison operators"* (referencing the standard in the blog post isn't possible as it's a paid document, but you can
63 | find this information [here](https://en.wikipedia.org/wiki/Signed_zero)).
64 |
65 | Thus, this behavior for float numbers is built into most CPUs and works at the assembler level. Comparison operators,
66 | such as `==`, in the languages discussed above, correspond to how it is implemented in the hardware. This is indeed the
67 | case in most languages.
68 |
69 | ### Comparison of 0.0 and -0.0 in EO now
70 |
71 | In order for the floating-point comparison in EO to comply with the standard, we have changed the behavior of the `eq`
72 | attribute for `float`. After these changes the comparison of `0.0` and `-0.0` behaves as follows:
73 |
74 | ```
75 | 0.0.eq -0.0 # TRUE
76 | 0.0.gt -0.0 # FALSE
77 | 0.0.lt -0.0 # FALSE
78 | 0.0.gte -0.0 # TRUE
79 | 0.0.lte -0.0 # TRUE
80 | ```
81 |
82 | Now it works like in all popular programming languages. It's worth noting that we didn't add extra atoms (you can read
83 | more about atoms in [this](https://news.eolang.org/2022-12-02-java-atoms.html) blog post). The `eq` attribute still
84 | compares floats bitwise; we simply added a special condition for zeros.
85 |
86 | ### Conclusion
87 |
88 | We changed `eq` attribute of `float` to meet the IEEE 754 standard. Significant reasons are needed to deviate from the
89 | standard, so we decided that it would be more correct to do as in other programming languages.
90 |
--------------------------------------------------------------------------------
/_posts/2023/11/2023-11-15-this.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-11-15
4 | title: "$ Object"
5 | author: graur
6 | ---
7 |
8 | In the world of EO programming, the `$` object acting as a syntax sugar that refers to the current abstract object it is used in.
9 | This seemingly simple yet powerful feature provides programmers with an elegant way to manipulate and access objects within their code,
10 | ultimately enhancing readability and ease of use.
11 | In this blog post, we will dive deep into the concept of the `$` object and shed light on its practical applications through illustrative examples.
12 |
13 |
14 |
15 | ### Understanding the $ Object
16 | Upon encountering the `$` symbol in EO code, it is important to recognize its true significance.
17 | The `$` object essentially serves as a reference to the abstract object within which it is utilized.
18 | By leveraging this syntax sugar, developers can harness the power of the current object without explicitly referring to it by name.
19 | This concise and intuitive approach enhances code clarity and conciseness, leading to more efficient and maintainable codebases.
20 |
21 | ### An Example
22 | Let's examine a code snippet to better understand how the `$` object functions within the EO programming language:
23 |
24 | ```
25 | [] > foo
26 | assert-that > @
27 | 2.plus 2
28 | $.equal-to 4
29 | ```
30 |
31 | In this example, we define an abstract object named `foo`. Within the `assert-that` scope, we pass as the parameter to it `2.plus 2` object
32 | and the second object's matcher, then verify whether it is equal to `4`, using the `$` object as a reference.
33 | Upon initial inspection, the code may seem a bit puzzling. However, we can break it down to reveal its true meaning:
34 |
35 | 1. Firstly, `$` refers to nearest abstract object `foo`:
36 | ```
37 | [] > foo
38 | assert-that > @
39 | 2.plus 2
40 | foo.equal-to 4
41 | ```
42 | But `foo` object does not have `equal-to` object. So, EO compiler needs to find an object that has `equal-to` object.
43 |
44 |
45 | 2. Secondly, EO compiler tries to get `foo.@` and take `equal-to` from there:
46 | ```
47 | [] > foo
48 | assert-that > @
49 | 2.plus 2
50 | foo.@.equal-to 4
51 | ```
52 |
53 |
54 | 3. Finally, the compiler finds `equal-to` object in `assert-that` object and takes it from there:
55 | ```
56 | [] > foo
57 | assert-that > @
58 | 2.plus 2
59 | assert-that.equal-to 4
60 | ```
61 | By using `$` as a reference, we can directly access the `assert-that` object while within the `foo` scope.
62 | Here is the example of the `assert-that` object for better understanding:
63 |
64 | ```
65 | [actual matcher] > assert-that
66 | ...
67 | [expected] > equal-to
68 | actual.eq expected > @
69 | ```
70 |
71 | ### Practical Applications of the $ Object
72 | Undoubtedly, the `$` object's syntax sugar provides programmers with a clean and expressive way to work with objects.
73 | The following scenarios highlight its practical applications:
74 | 1. Chaining Methods:
75 | By utilizing the `$` object, we can succinctly chain methods together, simplifying complex operations.
76 | This leads to more readable and concise code, enhancing collaboration among team members and reducing the chances of introducing bugs.
77 | 2. Context Independence:
78 | The `$` object allows developers to maintain the context of their code while reducing the need for lengthy and repetitive object references.
79 | It facilitates writing clean and modular code that is easier to understand and maintain.
80 |
81 | ### Conclusion
82 | In conclusion, the `$` object serves as a vital syntax sugar in the EO programming language, offering developers an elegant way to refer to the current
83 | abstract object within their code.
84 | By leveraging this feature, programmers can enhance the readability and conciseness of their code, ultimately improving collaboration and productivity.
85 | Understanding the true meaning behind the `$` object allows developers to unlock its full potential and leverage it in various scenarios,
86 | from method chaining to context independence.
87 |
88 | So, embrace the `$` object and embrace the power of EO programming!
89 |
--------------------------------------------------------------------------------
/_posts/2023/12/2023-12-08-phi-and-unphi-mojos.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-12-08
4 | title: "Convert EO to φ-calculus Expression and Back"
5 | author: maxonfjvipon
6 | ---
7 |
8 | In the recently released version [0.34.0](https://github.com/objectionary/eo/releases/tag/0.34.0),
9 | we have implemented several changes to EO. Today, we will discuss the conversion of EO
10 | to φ-calculus expression and vice versa.
11 |
12 |
13 |
14 | As you may know, φ-calculus is a formal model that we are attempting to use as a base for
15 | object-oriented programming languages, including EO.
16 |
17 | From now on, it is possible to convert a program written in EO to a φ-calculus expression.
18 | Here's how you can accomplish this in your personal project.
19 |
20 | First you need to add `eo-maven-plugin` dependency:
21 | ```xml
22 |
23 | org.eolang
24 | eo-maven-plugin
25 | 0.34.0
26 |
27 | ```
28 |
29 | Conversion occurs in four stages: registration, parsing, optimization, and actual conversion.
30 | Therefore, include the corresponding goals in your build pipeline:
31 |
32 | ```xml
33 |
34 |
35 |
36 | org.eolang
37 | eo-maven-plugin
38 |
39 |
40 |
41 | convert
42 |
43 | register
44 | parse
45 | optimize
46 | xmir-to-phi
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | ```
58 |
59 | Now, you are ready to convert an EO program to a φ-calculus expression. Place the `.eo` file in the source
60 | directory and run your Maven project. When it's done, files with the `.phi` extension are placed in
61 | the `phiOutputDir` directory.
62 |
63 | You may also convert a φ-calculus expression back to EO.
64 | For this, your build pipeline should look like:
65 |
66 | ```xml
67 |
68 |
69 |
70 | org.eolang
71 | eo-maven-plugin
72 |
73 |
74 |
75 | convert
76 |
77 | phi-to-xmir
78 | optimize
79 | print
80 |
81 |
82 |
83 |
84 | ${project.basedir}/target/eo/2-optimize
85 |
86 |
87 |
88 |
89 |
90 |
91 | ```
92 |
93 | When it's done result `.eo` files are placed in output `printOutputDir` directory.
94 |
95 | Here's an example of how the EO Fibonacci program looks in φ-calculus (you can find more examples
96 | [here](https://github.com/objectionary/eo/tree/master/eo-maven-plugin/src/test/resources/org/eolang/maven/phi)):
97 | ```eo
98 | +package eo.example
99 |
100 | [n] > fibonacci
101 | if. > @
102 | lt.
103 | n
104 | 2
105 | n
106 | plus.
107 | fibonacci
108 | n.minus 1
109 | fibonacci
110 | n.minus 2
111 | ```
112 |
113 | Its [XMIR](https://news.eolang.org/2022-11-25-xmir-guide.html) representation (default location is
114 | `target/eo/2-optimize`):
115 | ```xml
116 |
117 |
124 |
125 | +package eo.example
126 |
127 | [n] > fibonacci
128 | if. > @
129 | lt.
130 | n
131 | 2
132 | n
133 | plus.
134 | fibonacci
135 | n.minus 1
136 | fibonacci
137 | n.minus 2
138 |
139 |
140 | Missing home
145 | Missing version meta
150 |
151 |
152 | not-empty-atoms
153 | duplicate-names
154 | many-free-attributes
155 | broken-aliases
156 | duplicate-aliases
157 | global-nonames
158 | same-line-names
159 | self-naming
160 | cti-adds-errors
161 | add-refs
162 | wrap-method-calls
163 | expand-qqs
164 | add-probes
165 | vars-float-up
166 | add-refs
167 | sparse-decoration
168 | unsorted-metas
169 | incorrect-architect
170 | incorrect-home
171 | incorrect-version
172 | expand-aliases
173 | resolve-aliases
174 | add-refs
175 | add-default-package
176 | broken-refs
177 | unknown-names
178 | noname-attributes
179 | duplicate-names
180 | duplicate-metas
181 | mandatory-package-meta
182 | mandatory-home-meta
183 | mandatory-version-meta
184 | correct-package-meta
185 | prohibited-package
186 | external-weak-typed-atoms
187 | unused-aliases
188 | unit-test-without-phi
189 | explicit-data
190 | set-locators
191 |
192 |
193 |
194 |
195 | package
196 | eo.example
197 | eo.example
198 |
199 |
200 | probe
201 | n.lt.if
202 | n.lt.if
203 |
204 |
205 |
206 |
211 |
212 |
217 |
218 |
223 |
227 | 00 00 00 00 00 00 00 02
230 |
231 |
232 |
237 |
238 |
243 |
247 |
252 |
256 | 00 00 00 00 00 00 00 01
259 |
260 |
261 |
262 |
267 |
271 |
276 |
280 | 00 00 00 00 00 00 00 02
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 | ```
292 |
293 | And its φ-calculus representation:
294 |
295 | ```phi
296 | {
297 | eo ↦ ⟦
298 | example ↦ ⟦
299 | fibonacci ↦ ⟦
300 | n ↦ ∅,
301 | φ ↦ ξ.n.lt(
302 | α0 ↦ Φ.org.eolang.int(
303 | α0 ↦ Φ.org.eolang.bytes(Δ ⤍ 00-00-00-00-00-00-00-02)
304 | )
305 | ).if(
306 | α0 ↦ ξ.n,
307 | α1 ↦ ξ.ρ.fibonacci(
308 | α0 ↦ ξ.n.minus(
309 | α0 ↦ Φ.org.eolang.int(
310 | α0 ↦ Φ.org.eolang.bytes(Δ ⤍ 00-00-00-00-00-00-00-01)
311 | )
312 | )
313 | ).plus(
314 | α0 ↦ ξ.ρ.fibonacci(
315 | α0 ↦ ξ.n.minus(
316 | α0 ↦ Φ.org.eolang.int(
317 | α0 ↦ Φ.org.eolang.bytes(Δ ⤍ 00-00-00-00-00-00-00-02)
318 | )
319 | )
320 | )
321 | )
322 | )
323 | ⟧,
324 | λ ⤍ Package
325 | ⟧,
326 | λ ⤍ Package
327 | ⟧
328 | }
329 | ```
330 |
331 | That's it for now, be in touch.
332 |
--------------------------------------------------------------------------------
/_posts/2023/12/2023-12-19-tuple-varargs.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2023-12-19
4 | title: "Recursive Tuple and Varargs"
5 | author: maxonfjvipon
6 | ---
7 |
8 | We're continuing to observe new features of the latest release
9 | [0.34.1](https://github.com/objectionary/eo/releases/tag/0.34.1) of EO, and today we talk about new
10 | recursive implementation of `tuple` object and why we got rid of varargs in our language.
11 |
12 |
13 | ### Recursive tuple
14 | As it was mentioned in the [previous](https://news.eolang.org/2023-12-08-phi-and-unphi-mojos.html)
15 | blog post, EO is based on φ-calculus, which is a formal model that we are attempting to use as
16 | a base for object-oriented programming languages. There are only two fundamental entities in the
17 | calculus - objects and data. Object is a collection of uniquely named attributes and data is just a
18 | sequence of bytes.
19 |
20 | There's also a special attribute `Δ`(delta) which is attached to the data. In our vision of EO only
21 | one object should have such an attribute - `bytes`. But for a long time at least 6 objects had it:
22 | `bytes`, `int`, `float`, `string`, `bool` and (surprise) `tuple`. The `Δ` attribute of `tuple`
23 | stores array of java `Phi` objects, which was totally wrong.
24 |
25 | But the decision was made - only `bytes` should have a `Δ` attribute, so we need to remove it from
26 | other 5 objects including `tuple`. And it was a good chance to rewrite `tuple` in pure EO which
27 | allowed us to decrease amount of [atoms](https://news.eolang.org/2022-12-02-java-atoms.html).
28 |
29 | So, welcome new implementation of `tuple` written in pure EO:
30 | ```
31 | # Tuple.
32 | [head tail] > tuple
33 | # Empty tuple
34 | [] > empty
35 | [i] > at
36 | error "Can't get an object from the empty tuple" > @
37 | [x] > with
38 | tuple > @
39 | tuple.empty
40 | x
41 | 0 > length
42 |
43 | # Obtain the length of the tuple.
44 | [] > length
45 | ^.head.length.plus 1 > @
46 |
47 | # Take one element from the tuple, at the given position.
48 | [i] > at
49 | ^.length > len!
50 | if. > index!
51 | i.lt 0
52 | len.plus i
53 | i
54 | if. > @
55 | or.
56 | index.lt 0
57 | index.gte len
58 | error "Given index is out of tuple bounds"
59 | if.
60 | index.lt (len.plus -1)
61 | ^.head.at index
62 | ^.tail
63 |
64 | # Create a new tuple with this element added to the end of it.
65 | [x] > with
66 | tuple > @
67 | ^
68 | x
69 | ```
70 |
71 | As you may see `tuple` has two free attributes now: `head` and `tail`; where the `head` is always
72 | supposed to be a `tuple` as well and `tail` is the object we want to store.
73 |
74 | For example, if we want to create a tuple of one object it would look like this:
75 | ```
76 | tuple > my-tuple
77 | tuple.empty
78 | 1
79 | ```
80 |
81 | The `tuple.empty` is a special `tuple` that stores nothing and used as a top level `tuple` in whole
82 | recursion.
83 |
84 | If we want to create a tuple of three objects it would look like this:
85 | ```
86 | tuple > my-tuple
87 | tuple
88 | tuple
89 | tuple.empty
90 | 1
91 | 2
92 | 3
93 | ```
94 |
95 | I hope you get the idea. We also left the `*`(star) syntax sugar which allows you to write a `tuple`
96 | in one line:
97 |
98 | ```
99 | * 1 2 3 > my-tuple
100 | ```
101 |
102 | This example is equivalent to the previous one and will be transformed by compiler to it.
103 |
104 | ### Varargs
105 |
106 | Before the release [0.34.0](https://github.com/objectionary/eo/releases/tag/0.34.0) there were
107 | varargs in EO which allow you to have an object with uncertain amount of free attributes. For
108 | example `int.plus` object looked something like this:
109 |
110 | ```
111 | [] > int
112 | [x...] > plus
113 | # code here
114 |
115 | 5.plus 5 10 > twenty
116 | 20.plus 1 2 3 4 > thirty
117 | ```
118 |
119 | It was quite convenient mechanism, but it didn't match to φ-calculus where every attribute has to
120 | be attached to the concrete object. With varargs application `5.plus 5 10` looks something like
121 | this:
122 |
123 | ```
124 | Φ.org.eolang.int(Δ ⤍ 5).plus(
125 | α0 ↦ Φ.org.eolang.int(Δ ⤍ 5),
126 | α1 ↦ Φ.org.eolang.int(Δ ⤍ 10)
127 | )
128 | ```
129 |
130 | But there aren't two free attributes in formation of `int.plus`, only one `x`:
131 |
132 | ```
133 | Φ ↦ ⟦org ↦ ⟦eolang ↦ ⟦int ↦ ⟦plus ↦ ⟦x ↦ ∅, ...⟧, ...⟧, ...⟧, ...⟧, ...⟧
134 | ```
135 |
136 | So as not to complicate things we decided to get rid of varargs in EO at all. And now it's a perfect
137 | match between EO and φ-calculus. Of course readability suffered a little because of it, but it
138 | worth that.
139 |
140 | Next time we'll put an end to data primitives, be in touch.
141 |
--------------------------------------------------------------------------------
/_posts/2024/04/2024-04-16-release-0-36-0.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2024-04-16
4 | title: "Big changes in 0.36.0"
5 | author: maxonfjvipon
6 | ---
7 |
8 | It's been a while since our last blog post. All this time, we were working hard on fixing bugs,
9 | creating new objects, and improving EO in general. And here it is - release
10 | [0.36.0](https://github.com/objectionary/eo/releases/tag/0.36.0), which contains many new features.
11 | So, this blog post is a summary that highlights the most significant changes.
12 |
13 |
14 |
15 | ### Rho attribute
16 | The first significant change is related to the special `ρ` (rho) attribute. A few words about it:
17 | - In general, the `ρ` attribute refers to the "parent" (or context) of the object. In Java, an
18 | analog of `ρ` would be the `this` keyword.
19 | - Every object has a `ρ` attribute.
20 | - At the beginning, when an object is formed (just created for the first time), its `ρ` is void (referring to nothing).
21 | - `ρ` is immutable and may be set only once (the rules of setting will be described in a future blog post).
22 |
23 | ### Vertex attribute
24 | The second significant change is related to the `ν` (vertex) attribute. We got rid of it and made our language simpler.
25 |
26 | The purpose of the `ν` attribute was to uniquely identify an object in the universe. Before the
27 | release [0.36.0](https://github.com/objectionary/eo/releases/tag/0.36.0), every object had such a
28 | unique numeric identifier, and EO guaranteed that. However, we decided that giving such badges to
29 | objects is not really object-oriented. We don't want and don't need to interact with objects relying
30 | on whether they have some unique ID. All we want from the object is its behavior, the functionality
31 | it provides. So, it just does not matter if an object has some identifier or not; the way it behaves
32 | with us is what really matters.
33 |
34 | That's why objects in EO don't have the `ν` attribute anymore.
35 |
36 | ### Caching
37 | We've changed the logic of object caching in EO.
38 | ```
39 | some-object > cached!
40 | ```
41 | Until now, this `!` meant that if we take attributes from the object more than once, they will be
42 | calculated only the first time and cached. Sounds good, but it didn't work as we wanted.
43 |
44 | Now, `!` means that when a cached object is touched for the first time (for example, an attribute
45 | is taken), it's dataized, converted to `bytes`, and starts to behave as the `bytes`. All the next
46 | manipulations with the cached object are transferred to the given `bytes`.
47 |
48 | ### Objects
49 | We've done a lot of work to remove redundant objects, redesign some old ones, and introduce new ones.
50 |
51 | - The object `while` was removed from `bool` and became a
52 | [separated](https://github.com/objectionary/eo/blob/0.36.0/eo-runtime/src/main/eo/org/eolang/while.eo)
53 | object written in pure EO. Its logic is still
54 | [declarative](https://news.eo.org/2022-12-22-declarative-while.html) as it was before.
55 | - The object `if` also was removed from `bool` and became a
56 | [separated](https://github.com/objectionary/eo/blob/0.36.0/eo-runtime/src/main/eo/org/eolang/if.eo) object.
57 | - The object `goto` was
58 | [implemented](https://github.com/objectionary/eo/blob/0.36.0/eo-runtime/src/main/eo/org/eolang/go.eo) in pure EO.
59 | - The object `dataized` was
60 | [introduced](https://github.com/objectionary/eo/blob/0.36.0/eo-runtime/src/main/eo/org/eolang/dataized.eo).
61 | This object dataizes its argument, makes a new instance of the `bytes` object, and behaves as it.
62 | - The objects `ram` and `heap` were removed.
63 | - The object `malloc` was
64 | [introduced](https://github.com/objectionary/eo/blob/0.36.0/eo-runtime/src/main/eo/org/eolang/malloc.eo).
65 | It's a classic memory management object that can allocate a block in memory, write to it, read from it, and free it.
66 | - The object `memory` was redesigned and
67 | [implemented](https://github.com/objectionary/eo/blob/0.36.0/eo-runtime/src/main/eo/org/eolang/memory.eo) in pure EO.
68 | It uses the objects `dataized` and `malloc` inside.
69 | - The object `cage` was
70 | [redesigned](https://github.com/objectionary/eo/blob/0.36.0/eo-runtime/src/main/eo/org/eolang/cage.eo).
71 | But it's still a "bad" object, which does not belong to EO.
72 |
73 | ### Grammar
74 | We've made EO more strict by making changes in its [grammar rules](https://github.com/objectionary/eo#backus-naur-form):
75 | - Empty lines inside an abstract object body are prohibited. Only one line in front of an abstract object is allowed.
76 |
77 | ```
78 | # Wrong.
79 | [] > object
80 |
81 | 5 > five
82 |
83 | 10 > ten
84 |
85 | [] > inner
86 |
87 | # Right.
88 | [] > object
89 | 5 > five
90 | 10 > ten
91 |
92 | [] > inner
93 | ```
94 | - A comment in front of a named abstract object is mandatory. A comment in front of an anonymous
95 | (unnamed) abstract object is prohibited. The mandatory comment must start with a capital letter,
96 | end with a dot, have a length >= 64 characters, and include only printable characters (`0x20-0x7f`).
97 | Comments in front of other top-level objects are optional.
98 |
99 | ```
100 | # This is a good commentary in front of a named abstract object with a length >= 64 characters.
101 | [] > object
102 | # This comment is optional but has the same requirements as in front of an abstract object.
103 | while > @
104 | TRUE
105 | # This commentary is prohibited and will lead to a parsing exception being thrown.
106 | [i] (i > @)
107 | ```
108 | - The `ν` (vertex) attribute is removed from the grammar.
109 |
110 | ```
111 | # This code won't be parsed.
112 | TRUE.< > vtx
113 | ```
114 | - Explicit object copying via `'` is removed. Until now, the main purpose of explicit object copying
115 | was to create a new object with a new `ν` (vertex) attribute. But since we got rid of it, there's
116 | no more sense to have such an operation in EO.
117 |
118 | ```
119 | # This code won't be parsed.
120 | TRUE' > copy
121 | ```
122 | - Object caching via `!` is no longer a language feature but just syntax sugar for the `dataized` object.
123 |
124 | ```
125 | some-object > cached!
126 | # The same as
127 | (dataized some-object).as-bytes > cached
128 | ```
129 | That's it. This is what we were working on for the last 4 months. We'll try not to make such huge
130 | breaks between blog posts in the future. So keep following us!
131 |
--------------------------------------------------------------------------------
/_posts/2024/04/2024-04-26-bye-bye-bool.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2024-04-26
4 | title: "Bye-bye, bool!"
5 | author: maxonfjvipon
6 |
7 | ---
8 | After the [previous](https://news.eolang.org/2024-04-16-release-0-36-0.html) blog post, one of the
9 | followers brought an interesting suggestion in our Telegram [chat](https://t.me/eolang_org) (join it btw).
10 | He proposed getting rid of the object `bool` and making `if` an object not an atom.
11 | And it was quite interesting. So we made a new [release](https://github.com/objectionary/eo/releases/tag/0.37.0)
12 | where we followed our follower's proposal.
13 |
14 |
15 |
16 | The idea is simple: instead of one object `bool`, we introduced two new objects, `true` and `false`,
17 | which decorate specific `bytes`, `01-` and `00-`, respectively.
18 |
19 | ```
20 | [] > true
21 | 01- > @
22 |
23 | [] > false
24 | 00- > @
25 | ```
26 |
27 | Such implementation has the next benefits:
28 | - There's no way to create a boolean object with an unexpected amount of bytes.
29 | - We got rid of the atom `if` and defined it right inside `true` and `false`:
30 |
31 | ```
32 | [] > true
33 | 01- > @
34 |
35 | [left right] > if
36 | left > @
37 |
38 | [] > false
39 | 00- > @
40 |
41 | [left right] > if
42 | right > @
43 | ```
44 |
45 | The decision on which `if` branch we should jump to is transferred to the moment of creation of the
46 | objects `true` or `false`.
47 |
48 | - We got rid of two literals `TRUE` and `FALSE` in EO
49 | [grammar](https://github.com/objectionary/eo?tab=readme-ov-file#backus-naur-form).
50 | - The implementation of other `bool` objects like `and`, `or`, `not` became simpler.
51 |
52 | So, the result `true` and `false` objects now look like:
53 |
54 | ```
55 | [] > true
56 | 01- > @
57 | false > not
58 |
59 | [left right] > if
60 | left > @
61 |
62 | [x] > and
63 | 01-.eq x > @
64 |
65 | [x] > or
66 | ^ > @
67 |
68 | [] > false
69 | 00- > @
70 | true > @
71 |
72 | [left right] > if
73 | right > @
74 |
75 | [x] > and
76 | ^ > @
77 |
78 | [x] > or
79 | 01-.eq x > @
80 | ```
81 |
82 | That's it for today. There are more interesting features we introduced in the last release.
83 | We're planning to write blog posts about all of them because they're worth it. So keep following us!
84 |
--------------------------------------------------------------------------------
/_posts/2024/05/2024-05-02-phi-bound-only.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2024-05-02
4 | title: "New Syntax for Nameless @-Bound-Only Objects"
5 | author: maxonfjvipon
6 |
7 | ---
8 | We're continuing to observe the features of the latest
9 | [release](https://github.com/objectionary/eo/releases/tag/0.37.0) of EO, and today we're talking
10 | about new syntax for nameless @-bound-only objects.
11 |
12 |
13 |
14 | The `@` attribute is a special attribute that indicates the current object decorates another object.
15 | For example, in the snippet below, objects `cat` and `dog` decorate an object `animal`:
16 |
17 | ```
18 | [voice] > animal
19 |
20 | [] > cat
21 | animal "Meow" > @
22 |
23 | [] > dog
24 | animal "Woof" > @
25 | ```
26 |
27 | The attribute `@` is also often used in nameless abstract objects. A common example is the second
28 | argument of the object `try`:
29 |
30 | ```
31 | try
32 | 1.div 0
33 | [e]
34 | QQ.io.stdout > @
35 | e
36 | true
37 | ```
38 |
39 | We noticed quite some time ago that there are so many small objects with only the `@` attribute
40 | bound. So, to simplify the code and reduce the number of indentations, we introduced new syntax for
41 | such objects:
42 |
43 | ```
44 | QQ.io.stdout e > [e]
45 |
46 | # Which is the same as
47 |
48 | [e]
49 | QQ.io.stdout e > @
50 |
51 | # OR
52 |
53 | [e]
54 | QQ.io.stdout > @
55 | e
56 | ```
57 |
58 | It's worth noting that only objects in horizontal notation can be used with such syntax:
59 |
60 | ```
61 | QQ.io.stdout e > [e] # horizontal application, the same as:
62 | # [e]
63 | # QQ.io.stdout e > @
64 | #
65 | if. true first second > [] # reversed horizontal application, the same as:
66 | # []
67 | # if. > @
68 | # true
69 | # first
70 | # second
71 | # OR
72 | # []
73 | # if. true first second > @
74 | #
75 | QQ.io.stdout > [] # horizontal method/dispatch, the same as:
76 | # []
77 | # QQ.io.stdout > @
78 | #
79 | x > [] # object reference, the same as:
80 | # []
81 | # x > @
82 | # OR
83 | # [] (x > @)
84 | #
85 | [x] (5.plus x > sum) > [i] # horizontal anonymous abstract object
86 | # the same as:
87 | # [i]
88 | # [x] > @
89 | # 5.plus x > sum
90 | ```
91 |
92 | All objects in vertical notation can NOT be used with such syntax and their usage leads to a parsing
93 | exception:
94 | ```
95 | QQ.io.stdout > [e] # vertical application - wrong
96 | e #
97 | #
98 | QQ # vertical method/dispatch - wrong
99 | .io #
100 | .stdout > [e] #
101 | #
102 | if. > @ # reversed vertical method with application - wrong
103 | true #
104 | first #
105 | second #
106 | #
107 | [x] > [i] # vertical anonymous abstract object - wrong
108 | 5.plus x > sum #
109 | ```
110 |
111 | Returning to the example with object `try`, it can now be written in a shorter and more convenient way:
112 | ```
113 | try
114 | 1.div 0
115 | QQ.io.stdout e > [e]
116 | true
117 | ```
118 |
119 | That's all for today. We'll be right back in a week with a new fresh blog post. Stay in touch.
120 |
--------------------------------------------------------------------------------
/_posts/2024/05/2024-05-02-rho-sigma-delta-lambda.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2024-05-14
4 | title: "Rho, Sigma and Other Fantastic Beasts of EO"
5 | author: maxonfjvipon
6 |
7 | ---
8 |
9 | Since the last blog post, we [released](https://github.com/objectionary/eo/releases/tag/0.38.0) a
10 | new version of EO where we got rid of the `σ` (Sigma) attribute. So, this blog post will try to
11 | explain all special attributes and assets such as `Δ` (Delta), `φ` (Phi), `σ` (Sigma), `λ` (Lambda),
12 | and `ρ` (Rho) as promised in one of the previous blog posts.
13 |
14 |
15 |
16 | ### Where I Was Born
17 |
18 | The first special attribute we're observing (and which was removed) is `σ` (Sigma). The `σ`
19 | attribute of the object `X` was the attribute that referred to the object `Y` inside which the
20 | scope object `X` was born (formed or created for the first time).
21 |
22 | The `σ` attribute in EO:
23 | - was indicated by the `&` sign.
24 | - was initialized right after the object is formed.
25 | - every object except the global parent object `Φ` had it.
26 |
27 | For example, `int.& -> eolang`, `float.div.& -> float`. Consider the next code snippet:
28 |
29 | ```
30 | [] > loop
31 | "Hello, world" > str
32 |
33 | while > @
34 | true
35 | [i]
36 | stdout > @
37 | &.str
38 | ```
39 |
40 | Here we have an endless while loop. The second argument of the object `while` is an anonymous
41 | abstract object, let's call him `X`. The `X` object is not used in the scope of the object `loop`;
42 | it's just created here. The object `X` will be used inside the scope of the object `while` when
43 | dataization is started. But as you may see `X` has access to the scope of the object `loop` via
44 | `&` and may reach the attributes of `loop` like `str`.
45 |
46 | And we decided that it was a bad idea to give the object such an opportunity to have access to the
47 | place where it was born. It kind of breaks the idea of object orientation because `&` is actually
48 | a static attribute like a static method in Java. We don't tolerate static methods and attributes,
49 | [here's](https://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html) why.
50 |
51 | ### Who Uses Me
52 |
53 | The second special attribute we're observing is `ρ` (Rho). The `ρ` attribute of the object `X` is
54 | the attribute that refers to the object `Y` that uses the object `X`. In EO, the attribute `ρ` is
55 | indicated by the `^` sign. Drawing the analogy with Java, the closest thing to `ρ` is the `this`
56 | keyword which refers to the current object:
57 |
58 | ```
59 | class Animal {
60 | String type;
61 | Animal(String tpe) {
62 | this.type = tpe;
63 | }
64 | void voice() {
65 | System.out.print("I'm a %s", this.type)
66 | }
67 | }
68 |
69 | Animal cat = new Animal("Cat");
70 | cat.voice(); // I'm a Cat
71 |
72 | Animal dog = new Animal("Dog");
73 | dog.voice(); // I'm a Dog
74 | ```
75 |
76 | Here when we create two instances of `Animal` - `cat` and `dog`. The `this` keyword inside their
77 | functions `voice` refers to different objects - `cat` and `dog` accordingly.
78 |
79 | The same functionality can be achieved in EO:
80 | ```
81 | [type] > animal
82 | [] > voice
83 | stdout > @
84 | sprintf
85 | "I'm a %s"
86 | ^.type
87 |
88 | animal "Cat" > cat
89 | cat.voice > moew # I'm a Cat
90 |
91 | animal "Dog" > dog
92 | dog.voice > woof # I'm a Dog
93 |
94 | ```
95 | The main difference between `this` in Java and `ρ` in EO is the moment when these "links" actually
96 | become referred to the objects. In Java - right after the object is created, in EO - on attribute
97 | dispatch. Let's look a bit closer. The dynamic dispatch in EO is a mechanism of retrieving an
98 | attribute from the object. Syntactically it's implemented via "dot-notation".
99 |
100 | So this is dispatch:
101 |
102 | ```
103 | cat.voice
104 | ```
105 |
106 | We're trying to retrieve an attribute `voice` from the concrete object `cat`. At the moment we've
107 | found the attribute `voice` inside the object `cat` and ready to return it - the `voice` attribute
108 | is copied and its `ρ` attribute is initialized with a link to the object `cat`. Until we touch
109 | `cat.voice` object its `ρ` attribute refers to `Ø` (nothing).
110 |
111 | A few more examples:
112 |
113 | ```
114 | cat.voice > voice1 # voice1.^ -> cat
115 | cat.voice > voice2 # voice2.^ -> cat
116 | dog.voice > voice3 # voice3.^ -> dog
117 |
118 | cat.voice > voice4 # voice4.& -> animal - deprecated
119 | dog.voice > voice5 # voice5.& -> animal - deprecated
120 | ```
121 |
122 | ### What I Decorate
123 |
124 | The third special attribute we're observing is `φ` (Phi). We've already described the attribute in
125 | one of the previous blog posts, but let's dive a bit deeper. In EO, the attribute is indicated
126 | by `@` sign. The attribute is not mandatory and may be absent. The `φ` attribute of the object `X`
127 | is the attribute that refers to the object `Y` which object `X` decorates. The main purpose of
128 | decoration - reuse of the attributes. For example:
129 |
130 | ```
131 | [type] > animal
132 | [] > voice
133 | stdout > @
134 | sprintf
135 | "I'm a %s"
136 | ^.type
137 |
138 | [] > cat
139 | animal "Cat" > @
140 | ```
141 |
142 | Here we have an object `cat` which decorates an object `animal` with `type` attribute set to
143 | `"Cat"`. That means that all the attributes which are allowed to be taken from the object `animal`,
144 | like `voice`, are allowed to be taken from the object `cat`:
145 |
146 | ```
147 | cat.voice > meow # I'm a Cat
148 | ```
149 |
150 | The decoration may have several layers and all the attributes on the deepest level are available
151 | on the top level:
152 |
153 | ```
154 | [type] > animal
155 | [] > voice
156 | stdout > @
157 | sprintf
158 | "I'm a %s"
159 | ^.type
160 |
161 | [color] > cat
162 | animal > @
163 | sprintf
164 | "%s cat"
165 | color
166 |
167 | [] > black-cat
168 | cat "black" > @
169 | ```
170 |
171 | Here the object `black-cat` decorates the object `cat` and the object `cat` decorates the object
172 | `animal`. This onion of decorators allows taking the attribute `voice` from the object `black-cat`:
173 |
174 | ```
175 | black-cat.voice > meow # I'm a black cat
176 | ```
177 |
178 | ### What Data I Have
179 |
180 | The fourth special thing we're observing is `Δ` (Delta) asset. A few words about this asset:
181 | - It's not an attribute but an asset because it refers not to the object but to the data which is
182 | a sequence of bytes.
183 | - There's no way to explicitly touch this asset in EO.
184 | - Only `org.eolang.bytes` object has this asset.
185 | - The only way to touch the data in the asset is dataization.
186 |
187 | ### What I Can Reach from Outside
188 |
189 | The last special thing we're observing is `λ` (Lambda) asset. Let's look at it a bit closely:
190 | - It's not an attribute but an asset because it refers not to the object but to some external
191 | function which returns an object.
192 | - Objects in EO that have the `λ` asset are called "atoms".
193 | - There's no way to explicitly touch this asset in EO.
194 | - Atoms can't have a `φ` attribute.
195 | - The `λ` asset, as well as the `φ` attribute, also allows reusing the attributes:
196 |
197 | ```
198 | [] > mars-temperature /float # measures the temperature on Mars and returns float
199 |
200 | mars-temperature.div 10 > divided
201 | ```
202 |
203 | Here, as you may see, `mars-temperature` is the atom that does not have an attribute `div` and
204 | returns `float`. However, we can still retrieve the attribute `div` from it. It will go to the
205 | `λ` asset, execute it, do some calculations, return us some `float`, and the `div` attribute will
206 | be taken from this `float`.
207 |
208 | That's all for today. We'll be right back in a week with a new fresh blog post. Stay in touch.
209 |
--------------------------------------------------------------------------------
/_posts/2025/02/2025-02-21-auto-named-abstract-objects.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | date: 2025-02-21
4 | title: "Auto named abstract objects or how to reach the ρ"
5 | author: maxonfjvipon
6 | ---
7 |
8 | It's been a difficult year... It's been a while since our
9 | [last](https://news.eolang.org/2024-05-14-rho-sigma-delta-lambda.html) blog post. Today, we're back
10 | and starting by answering a question from our Telegram [chat](https://t.me/eolang_org) reader:
11 | "What does the `>>` EO syntax stand for"?
12 |
13 |
14 |
15 | In one of the previous releases, we introduced this EO syntax for the automated naming of abstract
16 | objects. The only place where such auto-named abstract objects are allowed is as arguments of an
17 | application. They CAN'T be used as top-level abstract objects because that wouldn't make any
18 | sense — there would be no way to "touch" them from other objects.
19 |
20 | ```
21 | [x] >> # prohibited
22 |
23 | malloc.of
24 | 12
25 | [m] >> # allowed
26 | ```
27 |
28 | The idea is simple: generate a random unique name for an object if the user considers
29 | meaningful naming unnecessary. But why might they decide this? That's the most interesting part.
30 |
31 | To understand the real reason, we need to go back to the
32 | [previous](https://news.eolang.org/2024-05-14-rho-sigma-delta-lambda.html) blog post,
33 | particularly the section about the `ρ` (Rho) attribute. Let's recap some important points:
34 |
35 | 1. The `ρ` (Rho) attribute of the object `voice` refers to the object `animal` that uses `voice`.
36 | 2. In EO, the `ρ` (Rho) attribute is indicated by the `^` sign.
37 | 3. "The object `animal` uses the object `voice`" implies dynamic dispatch.
38 | 4. Dynamic dispatch in EO is a mechanism for retrieving an attribute from an object.
39 | Syntactically, it is implemented via dot notation: `animal.voice`.
40 | 5. The `ρ` (Rho) attribute is initially empty and is set right after dynamic dispatch occurs.
41 |
42 | ```
43 | [name] > animal
44 | [] > voice
45 |
46 | animal "kitty" > cat
47 | cat.voice > meow
48 | ```
49 |
50 | In the code snippet above, we copy the object `animal` and set its attribute `name` to `"kitty"`
51 | (which is a `string` object). Then, we take the `voice` attribute from the object `cat`.
52 | At the exact moment the object `voice` is retrieved, its `ρ` (Rho) attribute is set and starts
53 | referring to the object `cat`. Now, we can do `meow.^`.
54 |
55 | Considering the above, we can assume that for the object `meow` (which is a copied `voice` object)
56 | to use the `ρ` (Rho) attribute, `voice` must be "taken" (or dispatched) from somewhere
57 | (specifically, from the object `cat`). If it has to be "taken," that means the object `cat` must
58 | have an attribute named `voice`, because dynamic dispatch is only possible via an attribute name.
59 | This is the key point: an object must have an attribute with a name. Only the presence of a name
60 | allows the object to have the `ρ` (Rho) attribute.
61 |
62 | Now, let's return to the example with abstract objects.
63 |
64 | ```
65 | [] > foo
66 | "Hello" > greetings
67 | malloc.of > @
68 | 5
69 | [m]
70 | $.^.greetings > str
71 | m.write str > @
72 | ```
73 |
74 | Here, we have an object `foo` with two attributes: `greetings` and `@`. The attribute `@` is bound
75 | to the object `malloc.of`, which is copied with two arguments: the object `5` and a nameless
76 | abstract object (let's call it "scope"). The "scope" has three attributes: `m`, `str`, and `@`.
77 | As you can see, `str` is bound to a chain of dynamic dispatches: `$.^.greetings`.
78 |
79 | Here, `$` means "this" (i.e., the abstract object itself, "scope");
80 | `.^` takes the `ρ` (Rho) attribute of the abstract object;
81 | and `.greetings` retrieves the `greetings` attribute.
82 |
83 | Clearly, "scope" is trying to access the `greetings` attribute of `foo` via its `ρ` (Rho) attribute.
84 | For this to work, "scope" must have the `ρ` attribute referring to `foo`, meaning that "scope" must
85 | be dispatched (or "taken") from `foo`. However, "scope" lacks a name. No name means no dynamic
86 | dispatch, and without dynamic dispatch, there is no `ρ` (Rho) attribute.
87 |
88 | The solution is simple: give a name to "scope".
89 |
90 | ```
91 | [] > foo
92 | "Hello" > greetings
93 | malloc.of > @
94 | 5
95 | [m] > scope
96 | $.^.greetings > str
97 | m.write str > @
98 | ```
99 |
100 | This is a sugared version where the name `scope` is placed at a certain nesting level.
101 | To better understand it, let's rewrite it in its canonical form, which is semantically the
102 | same (and which our compiler actually builds under the hood).
103 |
104 | ```
105 | [] > foo
106 | "Hello" > greetings
107 | [m] > scope
108 | $.^.greetings > str
109 | m.write str > @
110 | malloc.of > @
111 | 5
112 | $.scope
113 | ```
114 |
115 | Now, you can see that `foo` has one more attribute, `scope`, and the second argument of
116 | `malloc.of` now appears slightly different: `$.scope`. Take a closer look at it.
117 | What do you see? Right! This is dynamic dispatch we have here! The `$` means "this"
118 | (i.e., the current abstract object, `foo`), and `.scope` retrieves the `scope` attribute
119 | from `foo`. This means that right after the dispatch is done, the `scope` object has
120 | its `ρ` attribute set, referring to `foo`, and `$.^.greetings` starts working correctly.
121 |
122 | This solves the main problem. However, the canonical form is somewhat verbose, while the
123 | sugared form relies on attribute naming when it's unnecessary.
124 |
125 | For cases where an abstract object’s name is unimportant but must be present to enable dynamic
126 | dispatch, we introduced the `>>` syntax.
127 |
128 | ```
129 | [] > foo
130 | "Hello" > greetings
131 | malloc.of > @
132 | 5
133 | [m] >>
134 | $.^.greetings > str
135 | m.write str > @
136 | ```
137 |
138 | Under the hood, the compiler rewrites it into something like this:
139 |
140 | ```
141 | [] > foo
142 | "Hello" > greetings
143 | [m] > random-unique-name
144 | $.^.greetings > str
145 | m.write str > @
146 | malloc.of > @
147 | 5
148 | $.random-unique-name
149 | ```
150 |
151 | It continues to work according to the same rules but looks cleaner for the user.
152 |
153 | That's all for today. Hopefully, you now have a better understanding of the `ρ` attribute and
154 | dynamic dispatch in EO.
155 |
--------------------------------------------------------------------------------
/css/main.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 | /**
4 | * SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
5 | * SPDX-License-Identifier: MIT
6 | */
7 |
8 | @charset 'utf-8';
9 |
10 | body {
11 | background-color: #f2f2f2;
12 | }
13 |
14 | header,
15 | footer,
16 | .pagination {
17 | text-align: center;
18 | }
19 |
20 | section {
21 | width: 40em;
22 | }
23 |
24 | footer {
25 | color: gray;
26 | }
27 |
28 | .disqus {
29 | padding-top: 4em;
30 | }
31 |
32 | header {
33 | padding-bottom: 1em;
34 | }
35 |
36 | hr {
37 | width: 50%;
38 | margin-left: auto;
39 | margin-right: auto;
40 | }
41 |
42 | .fork-me {
43 | position: absolute;
44 | top: 0;
45 | right: 0;
46 | width: 8em;
47 | }
48 |
49 | article {
50 | border: 0;
51 | padding: 2em;
52 | padding-bottom: 1em;
53 | margin-bottom: 2em;
54 |
55 | h1 {
56 | margin-top: 0;
57 | }
58 |
59 | .subline {
60 | font-size: 90%;
61 | }
62 | }
63 |
64 | .logo {
65 | width: 5em;
66 | height: 5em;
67 | }
68 |
69 | .subline {
70 | margin-left: 0;
71 | li {
72 | margin-right: 1em;
73 | display: inline;
74 | list-style: none;
75 | }
76 | }
77 |
78 | pre code {
79 | line-height: 1.4em;
80 | }
81 |
--------------------------------------------------------------------------------
/images/fork-me.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
12 |
16 |
20 |
25 |
32 |
37 |
41 |
45 |
50 |
54 |
58 |
64 |
68 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | # SPDX-FileCopyrightText: Copyright (c) 2022-2025 Objectionary.com
3 | # SPDX-License-Identifier: MIT
4 |
5 | layout: default
6 | title: "News About EO Programming Language"
7 | description: |
8 | Here we post most recent news about
9 | EO programming language and 𝜑-calculus
10 | keywords:
11 | - oop
12 | - eolang
13 | ---
14 |
15 | {% for post in paginator.posts %}
16 |
17 |
47 |
48 | {% endfor %}
49 |
50 |
67 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:base"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/robots.txt:
--------------------------------------------------------------------------------
1 | sitemap: https://news.eolang.org/sitemap.xml
2 |
--------------------------------------------------------------------------------
/static/404.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: static
3 | title: Page Not Found
4 | date: 2017-03-02
5 | permalink: /404.html
6 | description: |
7 | The page is not found.
8 | keywords:
9 | - page not found
10 | - artipie
11 | ---
12 |
13 | The page you are looking for is not here. Try to start with the [root](/) one.
14 |
15 | Don't hesitate to email us if you are lost:
16 | team@eolang.org .
17 |
--------------------------------------------------------------------------------
/static/contents.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: static
3 | title: "Contents"
4 | date: 2017-03-02
5 | permalink: /contents.html
6 | description: |
7 | All articles published on the blog, in chronological
8 | order, starting from the most recent
9 | keywords:
10 | - artipie
11 | ---
12 |
13 | Total: {{ site.posts.size }}.
14 |
15 | {% for post in site.posts %}
16 |
17 |
22 |
23 |
24 |
25 | @{{ post.author }}
26 |
27 |
28 |
29 |
30 | {{ post.date | date_to_string }}
31 |
32 |
33 |
34 | comments
35 |
36 |
37 |
38 | {% endfor %}
39 |
--------------------------------------------------------------------------------
/static/papers.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: static
3 | title: Papers About EO and 𝜑-calculus
4 | date: 2022-06-09
5 | permalink: /papers.html
6 | ---
7 |
8 | Here is a full list of papers about 𝜑-calculus,
9 | [EO](https://www.eolang.org) programming language,
10 | [Polystat](https://www.polystat.org),
11 | and other related projects (in reverse chronological order):
12 |
13 | * Yegor Bugayenko and Mikhail Lipanin (2023),
14 | [An Algorithm for Partial Elimination of Jumps in an Object-Oriented Dataflow Language](https://dl.acm.org/doi/10.1145/3638584.3638679),
15 | Proceedings of the 7th International Conference on Computer Science and Artificial Intelligence (CSAI).
16 |
17 | * Alena Vasileva and Yegor Bugayenko (2023),
18 | [Object Specialization to Partially Reduce Polymorphism of Attributes](https://dl.acm.org/doi/10.1145/3638584.3638674),
19 | Proceedings of the 7th International Conference on Computer Science and Artificial Intelligence (CSAI).
20 |
21 | * Vadim Piven and Sergey Zykov (2022),
22 | [Assessment of static type checking compliance of EOLANG](https://www.sciencedirect.com/science/article/pii/S1877050922013795),
23 | Proceedings of the 26th International Conference on Knowledge-Based and Intelligent Information & Engineering Systems (KES).
24 |
25 | * Joseph Afriyie Attakorah, Vitaliy Korzun, Eugene Popov, Hadi Saleh (2022),
26 | [EOLANG Book](https://www.objectionary.com/eo-book/book.pdf)
27 |
28 | * A. I. Legalov, Y. G. Bugayenko, N. K. Chuykin, M. V. Shipitsin, Y. I. Riabtsev, A. N. Kamenskiy (2023),
29 | [Transformation of C Programming Language Memory Model into Object-Oriented Representation of EO Language](https://dl.acm.org/doi/10.3103/S0146411623070088),
30 | Automatic Control and Computer Sciences, Volume 57, Issue 7, Dec 2023
31 |
32 | * Vitaliy Korbashov, Nikolai Kudasov, Mikhail Olokin, and Violetta Sim (2022),
33 | [Detecting unjustified assumptions in subclasses via EO representation](https://arxiv.org/abs/2209.01825),
34 | arXiv
35 |
36 | * Nikolai Kudasov, Mikhail Olokin, Oleksii Potyomkin, Nikolay Shilov, and Maxim Stepanov (2022),
37 | [Detecting unanticipated mutual recursion using Elegant Objects representation of object-oriented programs](https://arxiv.org/abs/2209.01803),
38 | arXiv
39 |
40 | * Yegor Bugayenko (2022),
41 | [On the Origins of Objects by Means of Careful Selection](https://arxiv.org/abs/2206.02585),
42 | arXiv
43 |
44 | * Nikolai Kudasov and Violetta Sim (2022),
45 | [Formalizing 𝜑-calculus-Calculus: A Purely Object-Oriented Calculus of Decorated Objects](https://dl.acm.org/doi/10.1145/3611096.3611103), ([Copy on arXiv](https://arxiv.org/abs/2204.07454))
46 | Proceedings of the 24th ACM International Workshop on Formal Techniques for Java-like Programs
47 |
48 | * Yegor Bugayenko (2021),
49 | [Reducing Programs to Objects](https://arxiv.org/abs/2112.11988),
50 | arXiv
51 |
52 | * Yegor Bugayenko (2021),
53 | [EOLANG and 𝜑-calculus](https://arxiv.org/abs/2111.13384),
54 | arXiv
55 |
56 | * Hadi Saleh, Joseph Afriyie Attakorah, Sergey Zykov, Alexander Legalov (2021),
57 | [Exploring the EOLANG-Java Integration and Interoperability](https://www.sciencedirect.com/science/article/pii/S1877050921019736),
58 | Procedia Computer Science, Volume 192, pp. 4560-4569
59 |
60 | * Hadi Saleh, Sergey Zykov, Alexander Legalov (2021),
61 | [EOLANG: Toward a new java-based object-oriented programming language](https://link.springer.com/chapter/10.1007/978-981-16-2765-1_30),
62 | Proceedings of the 13th KES-IDT 2021 Conference, pp. 355–363
63 |
64 | You may also want to watch
65 | [this YouTube playlist](https://www.youtube.com/playlist?list=PLaIsQH4uc08wnU7X5ZKdDHjJ8zOb1sUIl).
66 |
67 | If you publish something, please [let us know](mailto:team@eolang.org).
68 |
--------------------------------------------------------------------------------