Appearance
ABCode Programming Language
Minimizing the Tower of Babel of Software.
Language Specification - Version 1.
© 2021-2025, César Andrés Arcila Buitrago. All rights reserved.
Table of Contents
- Introduction.
- What is ABCode?
- Essential example.
- ABCode programming language vs. natural language.
- Essential language tips.
- Basic data types.
- Variables.
- Functions.
- Language operators.
- Conditional if / when (else).
- For loop.
- Exceptions.
- Statements and Operations (run, echo...).
- Comments.
- Data structures.
- Importing program libraries.
- Classes.
- Web server and its internal mechanism.
- A look at the database query pattern.
- Summary of reserved words.
- Reserved words versus other languages.
- Differences with Python.
- About YAML.
- Current status.
Introduction
In this text, aimed at software professionals and software enthusiasts who are already initiated in it, I present my programming language that has been inspired by the origins and simplicity of database code transferred to our days, where the code is located in what we call “middleware” in an application, micro-services architecture, “serverless”, and others. Adding that in the face of so many languages and derived technologies, it is possible to achieve a unifying path to minimize the Tower of Babel of Software to a great degree.
Imagine also that, in times where AI (Artificial Intelligence) is here to stay, there is a technology that understands existing technologies providing a higher and simpler level of understanding of the generated code.
Before I talk about a new specification and programming language ABCode, let me tell you a little experience...
Noting certain abilities to interact with different programming languages (as if I were a computer polyglot) it occurred to me to look for a way to achieve an abstract language for the component that takes care of what happens on the server (backend), accompanying a database manager (OnMind-XDB) that I also made along with my own platform OnMind. So I decided to create a language specification that would convert the code to another language of interest. Finally, the programming language ABCode was born.
Indeed I found similar ideas but it required something different and as I have emphasized: "abstract". Then it occurred to me to combine YAML (a markup language for data) and something from [Python](/code/en/Python. md) (with a restricted syntax), where each line starts with an attribute (distinguished by ending with a colon :
) that indents every two spaces (according to YAML), the rest of the line could be code (like Javascript). I validated the idea of this programming language with a great friend and colleague, who found it interesting and enthusiastic.
As a curious fact, before thinking about YAML, the idea was originally conceived in 2020 using as code editor a spreadsheet and its layout by columns (as an indentation), applying color to the cells with sentences.
About the Author
Systems Engineer with a passion for Software Architecture and Development, with knowledge in Project Management and studies in Philosophy. Certifications in AWS and Scrum Master, I have been PMP certified until expiration a few years ago.
Experience for over 20 years participating in software projects (ERP, CRM, Workflow, API, Microservices, Integration) with various technologies in major companies in different sectors, as well as cloud projects (AWS).
Leader, expert and creative, with a singular and holistic point of view. I could say a computing polyglot. I have become an author of my own technology and blog, as well as the book: The OnMind Method (available on Amazon).
Portfolio: https://github.com/kaesar
What is ABCode?
A language for many environments and a specification as a bridge.
It is a specification and interpreted programming language (created by Cesar Andrés Arcila Buitrago) that combines the style of a markup language like YAML with some Python and Javascript, under the premise of being abstract and with an initial focus on server-side code, in order to generate (transpile) mainly Javascript, perhaps some other experimental language as a dialect, variant or flavor, e.g. Kotlin, Java, Python.
It can be thought of as a Typescript with a peculiar style. It transpiles to Javascript with a look that mixes aspects of Python and YAML, oriented to business logic (use cases or core logic).
The initial strategy of ABCode is oriented where Javascript and WebAssembly operates (although originally considered to be Python), thinking mainly in the Backend, that is, in the portability or readability of business logic (use cases). It can also be seen as a replacement for the layer of code that promoted relational databases with stored procedures (in languages such as: PL/SQL or PL/pgSQL), and that we currently find some similarity in new technologies (e.g. AWS Lambda Cloudflare Workers, etc.).
And is that in my origins as a software professional I worked my first decade with Oracle technologies and what I miss from then was the simplicity when you developed code for Backend (or the database at that time), without requiring so many technologies or diverse knowledge.
In other words and in principle, you can associate ABCode with....
more internal logic (domain or core logic)
whose functions compose a Backend
embedded and portable mode (also script mode)
being invoked by another language or environment, or by itself
Each line of code starts with a reserved word or defined statement that would correspond to an attribute or key in YAML with indentation, the rest of the line could be seen as code close to Python, actually transpiles Javascript.
ABCode supposes an additional layer to interact with different programming languages looking for a unifying or conciliatory sense, perhaps in the future with some dialects (up to 5 additional ones, adding up to 6) that share the same root, for example, think of Kotlin, Java, Python and maybe Go (we'll see).
INDICATION: In the world of web application development using the Internet, the word Backend is used for what is behind the network (on a server), and with the word Frontend we refer to the visual aspect that the user sees, this can be seen in the browser or on a mobile device (example: native mobile development). ABCode starts with emphasis on the server and proposes a conciliatory path for the browser (dominated by the Javascript language).
Language considerations
Multi-paradigm, multi-environment, multi-platform, multi-language translation.
- ABCode is synonymous with the portability of your code.
- ABCode focuses in principle on server-side code (backend) combining YAML with some aspect of Python, actually transpiles Javascript using a restricted syntax of this language.
- ABCode is intended to be easy to learn by being close to an algorithm. You can also make an agile transition when coming from a language like Python. On the other hand, YAML is an expressive and human-readable markup language, so ABCode is too. It may be advisable to check the YAML reference before starting but it is also not required.
- ABCode is synonymous with the portability of your code.
- The ABCode language supports the OnMind Method and the OnMind-XDB database of the same author.
- ABCode is projected to become alternatively work as a specification in which another language is transpiled (in addition to Javascript). This would seek to keep readability even if the implementation is specific to one language in this case. Furthermore, customization is achieved when a technology requires the potential of a particular programming language.
- It can be thought of in the future as a translator or bridge between programming languages, environments and platforms, or multi-language, multi-environment and multi-platform, perhaps multi-purpose or multi-paradigm.
- Modernization and innovation often involve technology migration, projects that can take years. With the use of ABCode the impact may be less, having the potential to facilitate the change between technologies (in principle, on the server side).
- A great potential of this language can be found in projects with mixed technologies, allowing to add an abstract layer with a unifying sense. An application case is what is known as smart cities (Smart Cities), as well as for the operation with servers in the cloud (DevOps), or when thinking of incorporating machine learning (Machine Learning) with management software using a uniform semantics, or failing that, with a similar style for reading the work team. Perhaps we have the basis to explore in the future the case of the visual aspect (frontend).
- Other languages would be in mind and may be introduced gradually on an experimental basis, but the goal is to keep mainly 2 or 3 official targets (e.g. NodeJS, Deno and WebAssembly) and up to 5 additional dialects (adding up to 6 languages: Javascript, Typescript, Kotlin, Java, Python and maybe Go, we'll see).
What other language for?
Thinking about business logic code portability
I think the reason has been stated between the previous lines, but we can emphasize that it is sought to mitigate something... because of: "the Tower of Babel of Software ".
It is also understood that the idea has originated from requiring a level of abstraction or layer for a technology that also used components with generic orientation (the OnMind database and platform), in addition to supporting the OnMind Method. Surely others can identify a similar need as well as interest in something multiplatform, or perhaps observe the fatigue of the commercial and community battle over the best language or technology.
Unifying, embedding, porting code, integrating systems, maintaining a certain simplicity, contributing to agility, persisting business logic or use cases over time, reducing complexity by opening up to non-expert programmers, breaking certain current paradigms and IT doctrines by going back to basics, generating the corresponding impact wherever it is welcomed, are the reasons why ABCode was conceived.
Personally, I would have to tell another part of the story. The platform I author was initially built with Javascript and Kotlin. I then identified that if I were to involve Machine Learning, even DevOps, it would be great to learn Python. So I thought it might be useful to learn other languages and improve my skills in them by applying ABCode, while was coded in OnMind could be left in Javascript and Kotlin respectively, being the part of the business logic introduced with ABCode progressively (to the point of replacing that aspect in the Backend).
This could one day go back to the origins when code was developed in a database, i.e. implement and maintain business developments using specific and simple technologies, even if the result potentially spills over into more technologies to orient itself as a cross-platform technology.
It is true that this requires a new effort and not just any minor effort, however as long as progress is made with the compiler we would be adding efforts of technologies to which the code is converted, and in that aspect we would also be working on what is built. Not to mention that it would be more efficient with AI (Artificial Intelligence) to use ABCode as a bridge to get to have maintainable code on multiple platforms. I consider that a more readable code in syntax avoids distancing between the human understanding and the AI mechanism in terms of coding.
How do you pronounce it?
The first two letters ("ab") are spelled with their English pronunciation, when you get to the "c" you say the word "code". And by the way, it is encouraged to write it with the first three letters capitalized.
ABCode Installation
Just download and uncompress according to your system and run something like...
bash
./abcodec -s abc/hello.abc
abcodec
is the compiler andabc/hello.abc
represent your source code with ABCode.
The partially released sources can be found in my repository on GitHub: https://github.com/kaesar/abcode
Essential example
yml
echo: "Hello World!"
This program in ABCode prints a greeting on the screen using
echo:
.
Keep in mind that, in principle, each logic instruction in ABCode would correspond to one line of code.
A more complete variation would be for example:
yml
fun: hello()
echo: "Hello World!"
run: hello()
Note that in this case
echo:
is derived from or belongs tofun:
(which we will see moving forward) and this is why two spaces are left as indentation.
ABCode programming language vs. natural language
In a general and spontaneous sense, a natural language can be seen as an agreement that comes to be accepted to communicate, express or indicate something. ABCode usually uses English words of 3 or 4 letters. Knowing its meaning can give us an understanding of this language, i.e. what a computer would be told to do.
root:
rootfun:
something funset:
set (noun) or set (verb)var:
abbreviation for variableval:
abbreviation for value (immutable)run:
runpass:
passif:
if... (expresses a condition)when:
when... (expresses another condition or when not fulfilled)else:
| if... (expresses another condition or when not fulfilled)else:
if... (otherwise)for:
for... (for each)do:
dotry:
tryfail:
failuse:
usetype:
typeecho:
echogoal:
targetlike:
similar to...
Essential language tips
For those who have skills, programming expertise and/or require agility in technical concepts, the following essential language tips can be summarized:
- Basic data types:
int
,float
,boolean
,string
,array
,object
,any
. Variables are defined by starting with thevar:
attribute, the variable name, a colon again (:
), the data type and a value can be assigned. The indication of the data type can be omitted when it is a basic or generic one. - The functions are defined or start with the
fun:
attribute to the function name, then the parameters are enclosed in parentheses(...)
, continuing with the parameter name, the:
character separating the data type afterwards (and separating the parameters with comma,
). The data type to return is also followed by:
. In addition,pass:
is used to return a value. The main function of a program is calledmain
(fun: main()
). - For the block of the function or control flow, the YAML indentation is used and each line of a block corresponds to a statement with an attribute, i.e. the lines start with a YAML attribute corresponding to the language specification. Neither the brackets of other languages nor the semicolon are applied, so the indentation of the code becomes more important for readability and impact.
- The control flow varies with respect to languages such as C, Java, Javascript, Kotlin, but you find an equivalent form for the use of
if
andfor
, even for exception handling (try
), whose keywords must be followed by the:
character. - The constructor of a class is expressed with the
fun:
attribute and thenew
value (fun: new()
) and the class is defined with thetype:
attribute. - The data structures are defined with the
set:
attribute followed by the name and applying YAML on the associated attributes. However, when using YAML and Python, the use of JSON is practically native, understanding that it is not a natural type or structure of the language.
The declaration of variables and functions presents a variation with respect to Python. ABCode handles generic data types to keep compatibility with other languages, so it is a typed language. However, you can omit the data type indication in the variable declaration when initializing a value with a basic or generic type.
Basic data types
Since programming is associated with information, data is typed to identify whether it is a text, number or other type. The following data types can be cited.
string
- Character string or textint
- Integer numberfloat
- Floating number (with decimals)boolean
- Boolean (True/False)array
- Array or vector, represented as square brackets []object
- Object, represented as curly brackets {}any
- For cases where multiple types may apply (dynamic)void
- Empty (for methods or functions)
Several of these data types are inspired by Typescript, except that
int
andfloat
are used for numbers and there is nonumber
.
Variables
Remembering that the variable is like data to be held (in memory), you can express a variable by assigning a value with the equals operator (=
). Each time the variable is mentioned or used later, it must appear with the same original name (respecting upper and lower case). However, the convention for declaring variables starts the line with var:
or val:
(the latter for constant or immutable values), the variable name, colon again (:
) the data type, then a value can be assigned (with =
). The indication of the data type can be omitted in the variable declaration when it is a basic or generic one.
Example:
yml
var: variable = "Ana"
var: i = 0
val: list = [10, 20, 30]
echo: variable
echo:
is a statement that comes in the language to display something on the screen (in this case it prints the value of the variable). In a language like Python you would useprinter()
.
In computer programming variables have a data type that indicates the nature of the content, for example, if a variable contains a text (string
) or if it is an integer (int
) or float (float
), even if it is a true or false value (boolean
) or a list (array
). Let's see the example indicating the data type.
yml
var: variable:string = "Ana"
var: i:int = 0
val: list:array = [10, 20, 30]
Functions
Functions perform something or define a series of instructions that fulfill a purpose, that is, they are logically related in well-defined blocks as they are organized. In the case of ABCode, fun:
is prefixed to the function name, then the parameters are enclosed in parentheses (...)
, followed by the parameter name, the :
character separating the data type afterwards (and separating the parameters with a comma ,
). The data type to return is also followed by :
. Here is an example.
yml
fun: hello()
echo: "Hello World!"
run: hello()
Who knows Python can observe that the reserved word
def
is omitted being unnecessary when usingfun:
. Also, in this case it does not require returning a data type (although:void
could be used at the end of the function declaration).
Therun:
is used to invoke operations, functions or statements. In most languages something likerun:
is not prepended to operations or statements, these being the common lines, but here an attribute is required to preserve the YAML style.
Let's look at another example.
yml
fun: sayMyName(name:string):string
pass: name
echo: sayMyName("Andrey")
In this case
pass
is used to return the value contained in the variable (which in other languages is usuallyreturn
).
If you are just starting out with computer programming, you may not want to distinguish certain aspects of functions. But if you already have some knowledge, it is good to clarify that the functions in ABCode are public in nature. To indicate that a function is private, in the context of a given class, the sign @
must be prefixed to the name, for example: @sayMyName
.
Language operators
Mainly, operators are those that allow us to perform operations, although there are also those that allow us to evaluate something (based on tautology or truth table). With operators, two expressions or numbers can be added together, as well as the other mathematical operations. This is also associated with the essential algebra that refers to functions and variables. On the other hand, in the operators that allow you to evaluate something, you can compare or determine if two values are different, or define complex conditions (and, or, or, not).
Let's look at the language operators below.
=
: equals (assignment)+
: addition-
: subtraction*
: multiplication/
: division%
: modulus of a division+=
: increment-=
: decrement==
: exact comparison (equal to)!=
: difference comparison (different from)>
: greater than<
: less than>=
: greater than or equal to<=
: less than or equal to&&
: and||
: or!
: not, negation@
: replacement forself
orthis
for use of class properties in other languages.
Remembering truth tables with operators
The operators of inclusion &&
and of option ||
have incidence in the evaluation of a condition in a program. We start from the following table, where p
is the first variable and the second is q
, and True
and False
are used to indicate whether it is true or false (respectively).
p | q | p and q | p or q |
---|---|---|---|
True | True | True | True |
True | False | False | True |
False | True | False | True |
False | False | False | False |
If a variable or expression is negated with
!
then its value is inverted: if it is true it is interpreted as false and if it is false it is interpreted as true.
Conditional if / when (else)
The conditions allow you to determine the validation points in the logic you propose. For example, imagine that you are going to buy a drink for someone who ordered it for you and you have some possible scenarios in case the originally ordered drink is not found.
You use if:
to establish a validation point with a condition and when: no
, or simply else:
, when something is not fulfilled. Let's look at an example.
yml
var: i = 1
if: i == 1
echo: "coffee"
when: no
echo: "tea"
When
when: no
orelse:
correspond to what would happen when a condition is not met and should always be left as the last condition, indicating what happens otherwise.
You use when:
with a condition (which would be like else if
in other languages) to evaluate other given conditions. Let's see the following example.
yml
var: i = 3
if: i == 1
echo: "coffee"
when: i == 2
echo: "tea"
else:
echo: "aha"
Note that double equals (
==
) is used as a comparison operator, distinguishing it from assignment which naturally uses an equals sign (=
). In that order of ideas, to evaluate different values (negative comparison) the exclamation point and an equals sign (!=
) would be used.
There may be scenarios in which no alternative is evaluated, i.e. a simple condition (if:
). For example:
yml
var: i = 2
if: i == 1
echo: "coffee"
For loop
Cycles refer to instructions that repeat or where some iterations take place. Keep in mind that the for:
line usually includes in
, see below.
yml
var: names = ["Ana", "Alex", "Janeth"]
for: x in names
echo: x
if: x == "Alex"
run: break
Note that the variable
names
is a list of text values (also known as arrays) whose convention uses square brackets[]
separating each value by a comma. When usingbreak
the loop is interrupted, since it is under a condition the names would be printed until the condition is met (therefore Janeth would not be printed).
You can use the range
function to traverse a range, even combine it with len
which gets the size of an array. Let's look at a couple of examples:
yml
for: i in range(10)
echo: i
var: n = [10, 20, 30, 40]
for: i in range(len(n))
echo: n[i]
In these cases the loop is terminated when the stop is reached (by subtracting 1).
range
can also be used two parameters indicating the first the start and the second the stop. Its third way of being called is with a third parameter that would indicate an increment (in case it is different from 1).
A third variation would be including a condition and avoiding the use of in
, that is, without in
it would be interpreted as while
in other languages. Let's look at the example:
yml
var: i = 0
for: i < 10
run: i += 1
echo: i
Note that
for:
receives in this case a condition and does not carryin
.
An additional variation would be to enter a loop and interrupt it (using: break
) when it meets a given condition. Let's look at the example:
yml
var: i = 0
for: True
run: i += 1
echo: i
if: i < 10
run: break
Who already has knowledge in programming can associate this with the
do...while
statement of other languages, being the way to emulate it.
Exceptions
Exceptions originate when the expected logic is interrupted due to an error in the middle of the program execution so that we could handle them, in other words, they are useful for handling errors generaly of a technical nature.
yml
try:
echo: n
fail:
echo: "error"
The
try:
indicates that a controlled block of code is started and that in case of an exception it is passed to the block corresponding tofail:
.
Statements and Operations (run, echo...)
run:
is used to invoke operations, functions or statements. In most languages it does not prepend something like run:
with operations or statements being the common lines, but here an attribute is required to preserve the YAML style. It is also used to invoke break
, continue
, increments. Let's see below a couple of clarifications on this point.
Operations vs Statements
In ABCode var:
is used to declare variables and they can be initialized right there. On the other hand, when it comes to subsequent operations run:
is used, so it is possible to find similar code in both cases, but in one it fulfills an initialization function and the other would correspond to the common flow (subsequent to the definition). Let's see the example:
yml
var: i = 0
echo: i
run: i = 1
echo: i
We have not mentioned
val:
, which is used for immutable variables or constants, since an assignment withrun:
on immutable variables should not be supported.
Complementary statements and macros
In theory, lines that do not correspond to attributes such as fun:
, pass:
, if:
, when:
, for:
, try:
, fail:
, type:
, would correspond to a statement that use run:
. However, variations may exist for specific cases that it is appropriate for the language to distinguish.
Such is the case of echo:
which is used to print something on the screen. Thinking of future implementation, there would also be file:
, read
, web:
, dbc:
, ask:
, sql:
, page:
, jsx:
, html:
, css:
, code:
as complementary statements to run:
, known as well as macros.
In fact, echo:
allows you to format the output as in the following examples:
yml
echo: "Hello, {name}! Tienes {age} years."
echo: "Name: {name:10} | Age: {age:3}" # Alignment with spaces
For decimals you could use:
echo: “The prices is {price:.2f}”
For file management you would use file:
, considering four basic methods which are: @open
, @write
, @read
, @close
. For example:
yml
file: @open = "file.txt"
file: @write = "file.txt", "Hello world!"
For database connection you would use dbc:
. For example:
yml
use: @mongodb
dbc: @link = "mongodb://localhost:27017/"
dbc: mydb := "test"
echo: "Database connected!"
dbc: @link =
internally sets a dbc
variable to handle the database connection. Note that an address is reported with database controller, domain (or server) and port: "mongodb://localhost:27017/"
Then dbc: mydb := "test"
points to the specific database name (test
) by assigning it to a variable (mydb
) with :=
.
Comments
Comments provide hints for readability and understanding of the code but have no effect on the execution of the program, i.e. they are directed to the code documentation or to the team.
yml
# This is a comment
If you have knowledge of YAML or Python, you should know that the use of the padding (
#
) for comments matches ABCode.
Unlike YAML, ABCode supports full-line comments, i.e., it is not interpreted at the end of a line except for special language comment exceptions (e.g.#in:
).
Directives and special tags
If you are just starting with computer programming, you might understand this topic better by advancing in program coding. ABCode introduces three types of special comments that are actually more than comments, since they provide guidance in the language. Let's see:
goal:
indicates the target mode or the language (any
,cli
,api
,fun
,dbs
or a language environment:deno
,wasm
,kotlin
,java
,python
).like:
indicates that a preceding statement, other thanlike:
(for example withrun:
,echo:
,use:
orpass:
), is expressed in another language, which is defined in#@in:
(for example#@in: java
). Thus, it is literally transpiled when the destination corresponds to that language. It does not apply (and has no effect) when the target defined ingoal:
is a specific language.#in:
comment used at the end of thelike:
statement, indicating literal language expressed for that line and replacing a previous line of code when transpiling to that target#[...]
used for language annotations such as Java (inspired by Rust)
#goal:
is not a comment but is a tag (or attribute) that does not operate as a statement. For example,goal: fun
is used for more internal functions or embedded scripts, andgoal: dbs
is likefun
for databases withsql
.
Example of the above directives:
yml
goal: any
val: name = "Andrey"
echo: "Hello, ${name}"
like: "Hello" + name #in: java
like: "Hello, $name" #in: kotlin
This example is illustrative only and
echo:
may not need to be accompanied bylike:
to allow for a more standard format:echo: “Hello, {name}”
.
Let's review the following:
goal:
determines the language that is expressed in the code and is omitted when using the strict ABCode syntax. Default: Javascript (core
)goal:
would currently support values such asany
andcli
(ABCode for flat programs), plus thedeno
,wasm
,kotlin
,java
,python
andnodejs/bun
languages or environment, i.e. a couple of environments and at least 5 languages or dialects. Additionally,api
to indicate web server library compatible targets. Perhaps in the futurepwa
will be introduced to indicate target compatible with the visual aspect (Javascript in the browser).goal: any
is used for flat programs (POJO) where no dependencies (libraries) are required, which is why we plan to prepare the use ofgoal: cli
andgoal: api
to support a library compatible with official targets.goal: fun
is used to indicate that the content corresponds to more internal functions or scripts (e.g.Lua
).goal: dbs
is likefun
for databases withsql
(i.e. code for repository and data persistence).goal:
can be used to report a target other thanany
,cli
,api
,fun
ordbs
(evenpwa
in the future), so it should be understood as a bridging mode for another language. In this way the expressive structure (YAML) is preserved and the code part is targeted for translation to a particular language. This is useful for implementing specific solutions in a given language or environment.like:
combined with the#in:
comment is useful when you want to translate a line of code with a particular language (e.g., due to differences in libraries), always referring to the previous line (other thanlike:
), i.e., applying a literal translation. The above suggests that ifgoal:
is used with a target other thanany
,cli
,api
,fun
ordbs
, it is not required to uselike:
, in which case they are mutually exclusive.- There may be restrictions on the use of
like:
with#in:
in some statements, for example,fun:
,if:
,for:
,do:
,try:
, andfail:
must follow the ABCode proposal (without translation).
To avoid ambiguity or to reduce possible conflict between goal:
and the compiler argument on the command line where -t
is used to indicate target languages or environments, the interpretation is as follows:
The
abcodec
compiler in principle translates certain dialects, being native the Javascript language (nodejs/bun
), and the target dialect is indicated with the-t
argument. The compiler will check if thegoal:
tag exists (in the first lines of the file or first occurrence) and in the case of indicating a value for a different language a warning will be reported and transpilation will be avoided. Of course, if the value does not correspond to languages or environments (e.g.any
,cli
,api
,fun
,dbs
) the argument applies to translate to the target code.
Data structures
Data structures represent a model or tuples, and can be defined under the set:
attribute as follows:
yml
set: Person
name: string
age: int
The same YAML layout is used indicating the data types of each attribute.
Importing program libraries
Libraries or program libraries allow you to organize and use code found in another file. The reserved word use:
is used to indicate the library that is being imported and where it is located (path), or alternatively one that is built into the system. This is similar to what is known as import
in other languages.
yml
use: @sys
As an example,
@sys
,@api
,@mongodb
would be directives to resolve some mode libraries dynamically.
At the time of this publication,use:
is pending the definition of additional details for its usage mode (while implementing built-in functions or essential libraries for the language).
Classes
Classes allow a paradigm that is known as object-oriented programming, seeking to represent everything as an object. If you know Python, when handling classes this must be reinterpreted according to ABCode, finding variations or differences in this aspect.
yml
type: Circle
var: @radious
fun: new(radious)
run: @radious = radious
fun: print()
echo: @radious
The
new
is the name of the function with which the class is initialized, that is, the constructor of the class is expressed as:fun: new()
. This differs from Python and is inspired by Rust.@
is used to reference a direct property of the class, as distinguished from a common variable. This differs from Python which usesself
or others which usethis
, and is inspired by Ruby, but must be declared usingvar:
.
Other aspects
To indicate that a function is private, in the context of a given class, the _
sign must be prefixed to the name, for example: _print()
.
In languages such as C# or Java (even PHP and Kotlin), classes are organized or grouped with either namespace
or package
(respectively). In ABCode you find the root:
reserved word for these cases and it is usually placed in the first lines of the program, before defining a class. For example:
yml
root: awesome
type: Circle
...
cast:
is reserved to other concept known as interfaces. For example:
yml
root: awesome
cast: Area
...
These criteria are defined as part of the language specification, although in early versions of the compiler they may not yet be available.
Web server and its internal mechanism
The web:
statement uses methods for the Web implementing code for each language (according to the library used internally). web:
has basic methods which are: @server
, @listen
, @handle
(even @fetch
). Let's see an example...
yml
use: @api
web: @server = app
do: get("/") = index
web: @handle = "Hi there!"
fun: main()
val: port:int = 8000
echo: port
web: @listen = port
run: main()
Note that web: @server =
sets server variable, then web: @handle =
assigns a request handler, which in this case returns a text, and web: @listen =
starts the service on the specified port.
On the other hand, instead of fun:
use do: get(...) = ...
to define the functions associated with a web request according to the path. Thus, it could be get
, post
, put
or delete
.
These criteria are defined as part of the language specification, although in early versions of the compiler they may not yet be available.
Database query pattern
As long as ask:
is implemented (reserved word for database management), a declarative query structure would be used to interact with a database and translated internally to SQL
(Structured Query Language) keeping the YAML style and a pattern, using the database OnMind-XDB. For example:
yml
ask:
what: find
some: persons
with: name = 'peter'
how: order age
With ask:
you would use what:
, some:
, with:
, puts:
, show:
or how:
attributes to set a pattern in the query. to:
for the collection or table, what:
for the action (find
, insert
, update
, delete
), with:
for the search criteria or filter, and how:
for supplementary indications (e.g. order
, limit
). show:
when you find something and puts:
could be included for insert or update operations. Lets see another examples:
yml
ask:
what: find
some: persons
with: name = 'peter'
show: name,age
For
find
usesshow:
separating with,
, andwith:
uses a mode close toSQL
.
Instead of usingLIKE
insidewith:
you would usebegins_with(field, value)
orcontains(field, value)
functions (reporting field and value).
yml
ask:
what: insert
some: persons
puts: {name:'peter',age:25}
For
insert
usesputs:
with{}
(JSON).
yml
ask:
what: update
some: persons
with: name = 'peter'
puts: {age:20}
In this case,
puts:
setage = 20
, andwith:
useSQL
way.
yml
ask:
what: delete
some: persons
with: name = 'peter'
Additionally, dbc:
to indicate the specific connection, keys:
to set named parameters corresponding to a key-value list ({}
), call:
to launch functions, user:
and auth:
to report user and session token. Also from:
when it refers to a repository oriented with the OnMind Method.
These criteria are defined as part of the language specification, although in early versions of the compiler they may not yet be available.
Summary of reserved words
Essentially we can cite the following reserved words or type of statement.
root:
package or program module (referred to by compatibility, for example withpackage
ornamespace
)fun:
sets a function or method (routine that fulfills a function)set:
set data structure (template)var:
variable declaration (includes initial assignment)val:
declaration to set immutables (includes assignment)run:
statement, operation or assignment (also for break, continue)pass:
return or terminate a function with a value (if applicable)if:
set condition or start of validationwhen:
additional condition (else if
).when: no
or simplyelse:
when something is not fulfilled.for:
conventional cycle (the respective code can includein
)do:
code block, to be derived as subroutine (or lambda function)try:
starts block for exceptionsfail:
indicates generated event for exception controluse:
imports library (functions from another program file,import
)type:
defines a class, as class constructor usefun: new()
.echo:
print something on the screen (with parameters use:{param}
)file:
manage local files (@open
,@write
,@read
,@close
)goal:
suggests targetlike:
replaces a previous line of code as indicated (combining#in:
and the target language)
At the time of this publication, the
read:
statement is not implemented and is reserved as a language specification to be incorporated in future versions.
Reserved words versus other languages
For those who have knowledge of other languages, a quick way to understand ABCode is to quote the following parallel or comparative list:
root:
~package
,namespace
fun:
~function
,func
,def
,proc
set:
~struct
,type
,data class
,data class
var:
~let
,var
,let mut
val:
~const
,val
,let
,let
pass:
~return
if:
~if
when:
~else if
,elif
,elsif
,else
,else
for:
~for
,while
,return
.do:
~do
try:
~try
,while
fail:
~catch
,exception
,rescue
,rescue
use:
~import
,include
,using
,require
type:
~class
echo:
~print
,echo
,puts
,console
#
~//
(line comments)
run:
is usually not parallelized and therefore not found in the above table. In most languages something likerun:
is not prepended to operations or statements, these being the common lines, but here an attribute is required to preserve the YAML style.
Differences with Python
Python has been mentioned as a language whose syntax was an inspiration for my own language. Although ABCode is closer to Javascript it keeps some aspects of Python. For who has knowledge in Python, and without speaking of the incidence of YAML, the main differences are indicated below:
- Functions in ABCode start with
fun:
(inspired by Kotlin) and thedef
reserved word of Python is omitted. - Functions can specify the type of data to return by adding a colon (
:
) at the end and the respective data type. - The
return
reserved word of the Python language is omitted when usingpass:
. - Variables can specify the data type when defining them by adding a colon (
:
) after the name and the respective data type, before assigning a value (before=
). - Some reserved words are simplified with respect to Python or other languages. Such is the case of
while
that does not exist andfor:
is used (inspired by Go), orswitch...case
that do not exist either andif:
andwhen:
must be used. In principle, it is also not thought to implementfinally
which would correspond totry:
, in order to keep simplicity and compatibility with certain languages. - Classes are named after starting with
type:
, replacing theclass
reserved word of Python, and the class constructor must be callednew
(inspired by Rust). - Classes use the
@
character (inspired by Ruby) instead of theself
reserved word of Python, which in other languages would bethis
. This will be reflected in statements such asrun:
when using a property, i.e., when handling classes this must be reinterpreted according to ABCode, which has variations on this theme with respect to Python. - Python incorporates
print()
while ABCode usesecho:
to display something on screen (inspired by PHP). - Instead of the
and
,or
andnot
logical operators of Python, ABCode promotes the use of&&
,||
and!
in favor of various languages.
About YAML
So far, no variations to YAML are mentioned, since in a practical sense its style is respected. It can be seen, for example, that the reserved word run:
is introduced because of the YAML style, since this concept does not exist in other languages in the case of statements or operations.
On the other hand, future versions may introduce the YAML notation for long texts using the >
character, for example, in the case of the echo:
or pass:
statement.
yml
echo: >
This text
is wrapped
as a paragraph
These criteria are defined as part of the language specification, although in early versions of the compiler they may not yet be available.
Current status
Specification ready (this book), work in progress, sponsors are welcome
The present text is already a specification of the ABCode programming language proposed and elaborated by César Andrés Arcila Buitrago in the year 2021, although it was conceived with a rustic prototype in 2020. In the beginning of 2022, inside the platform [OnMind](//onmind. co) platform has a transpiler (translator from source language to another source language) as a proof of concept that allows to execute simple programs that do not require dependencies, for some languages or environments (Deno, NodeJS).
Remember that the initial focus of this new language is business logic that is addressed from the Backend. Thus one does not see an urgent need for the compiler to convert multiple files and instead should process file by file, although this can certainly be considered further down the road.
To write with ABCode you don't need a new application, that is, you use an editor (like VSCode
, Sublime
or another that you can download from the Internet) associating the YAML format with .abc
extension files. Alternatively, the format can be associated with Lua (just avoid applying their comments). However, an editor has even been considered for better integration with the compiler/transpiler.
The partially released sources can be found in my repository on GitHub: https://github.com/kaesar/abcode
About the intention of support
If we talk about a technology that would have an Open Source version, we would already be thinking about some support but not imposing, precisely because of the type of license. I think that in order to distinguish target languages and their level of support, the most coherent thing to do is to talk about a level of support intention by target language or priority, where five (5) is a remote possibility. It is true that the word experimental is often used for non-priority features and may not be attended.
For now, destinations are oriented to the backend, although there are technologies that promote FullStack development from the backend. Below is the proposed intention of the support level, given the context, non-binding for any level (including level 1).
Main targets
Feature of Interest or Estrategy:
- NodeJS
-
Level 1-
Web Server and Microservices, AWS Lambda, CDK - Deno
-
Level 2-
Multiplataform, Typescript - AssemblyScript
-
Level 2-
WebAssembly based on Typescript (wasm)
Bun could be used as a substitute for NodeJS because of its compatibility.
Complementary destinations of high experimentation in the future
Feature of Interest or Estrategy:
- Kotlin
-
Level 3-
Multiplatform, Web Server and Microservices - Java
-
Level 3-
Databases, Web Server and Microservices (SpringBoot) - Python
-
Level 4-
Scripting and Data Science - Go
-
Level 5-
WebAssembly, Web Server and Microservices
4
could correspond to Kotlin (JVM), then Java, perhaps Python and Go (it will be seen later).
Sources that count as much as the targets
Given that another strategy of ABCode is to operate as a portable and embedded language in another language (e.g. using quickjs) or in an environment highlighted for Backend, it should be understood potentially that it could become to used from PHP, NodeJS, Java, C, Python, Ruby, Dart, Deno, Rust, Go, Swift, Kotlin, C#, Pascal, PostgreSQL and perhaps more through runtime environments.
It would not only be a matter of thinking about target but also about the possibilities of languages and environments that integrate
wasm
(WebAssembly) or quickjs, even Lua with the TypescriptToLua (TSTL) project.
Why not PHP or other languages?
As for other languages, the strategy is considered to have a more than sufficient and very broad scope, with top languages. In the case of PHP more difficulty is identified in translating the code, for example, by the use of the $
sign in variables and similar considerations that would be impediment to obtain a clear target. It can also be replaced using Python, or the py2php
project, as well as ts2php
. Although, one could think int the feature about a lightweight web layer in PHP (a Runtime) that invokes functions in wasm
, thanks to wasmer-php
.
Further details on the technical progress
As a technical detail, no package manager is required (as this is left to each target language) and no standard library or SDK is required (so far). However, some essential software has started to be reviewed with a very specific simple and lightweight library. Web applications are considered for some API of classic or flat mode (without requiring library), that is, a main controller (endpoint
) without url
routing (it would be done by POST
with parameter indicating the function to invoke and a token for security), so it can be implemented in standard way.
Remember that ABCode finally converts code to Javascript, in its priority approach, by taking the parts of the line that are the values in YAML. This is already available in the compiler subject to maintenance and rule enforcement to reduce potential errors in its use.
Final invitation
If you have come this far, I would like to thank you for your welcome and invite you to see my portfolio of projects, although some of them are frozen or private and my occupation may be at full capacity, I have published free software that you can find among my works and I am planning to prepare an appendix to this text that has raised the fundamentals...
Portfolio: https://github.com/kaesar
ABCode (Compiler): https://github.com/kaesar/abcode
https://onmind.co
Errata
The digital format of eBook may have variations with respect to the original design where style, colors, indentation and other aspects are respected.