Skip to content

Version 0.1.0 is a first version, for trial. See what is not proven →

bogolang
FR

Version 0.1.0 on Python 3.15

A programming language for network and telecommunications engineers.

Bogolang is a language of its own, built on top of Python 3. It has its own literals, statements, rules and tools. It is class based, as Java is: all code stands inside a class, and a program starts in main. Addresses, subnets, interfaces and units are real types. Reaching hosts, reading devices, testing an access list or planning a radio link are built-in commands. A change to a device is refused when it has no rollback. Every Python package keeps working.

  • Class based
  • Windows and Linux
  • No administrator right
  • MIT licence
reach_hosts.bogo Open the example
edition 2027
"""Is everything up? Ping a list of hosts at once, trace the path to one, scan a small network."""


class ReachHosts:
    """A morning reach check: a table of ping results, one trace and one scan."""

    hosts: list[IP] = [192.0.2.1, 192.0.2.10, 198.51.100.7, 203.0.113.20]
    far: IP = 203.0.113.20
    lan: Net = 192.0.2.0/29
    slow: Duration = 50ms

    @staticmethod
    def verdict(r: PingResult, slow: Duration) -> str:
        """One word for a ping result: DOWN, LOSS, SLOW or ok."""
        if not r.ok:
            return "DOWN"
        if r.received < r.sent:
            return "LOSS"
        if r.avg is not None and r.avg > slow:
            return "SLOW"
        return "ok"

    @staticmethod
    def main(args: list[str]) -> None:
        results: list[PingResult] = ping_all(ReachHosts.hosts, count=3, timeout=1s)
        rows: list[dict[str, object]] = []
        for r in results:
            rows.append(
                {
                    "host": r.host,
                    "received": f"{r.received}/{r.sent}",
                    "loss": r.loss,
                    "avg": r.avg,
                    "jitter": r.jitter,
                    "state": ReachHosts.verdict(r, ReachHosts.slow),
                }
            )
        table(rows)

        print(f"\nPath to {ReachHosts.far}:")
        for hop in trace(ReachHosts.far, max_hops=10, probes=2):
            print(f"  {hop}")

        up: list[IP] = scan(ReachHosts.lan)
        print(
            f"\n{len(up)} addresses answer in {ReachHosts.lan}: {', '.join(str(ip) for ip in up)}"
        )

$ bogo run --replay saved reach_hosts.bogo

host          received  loss     avg       jitter  state
------------  --------  -------  --------  ------  -----
192.0.2.1     3/3       0pct     1.233ms   0.25ms  ok
192.0.2.10    2/3       33.3pct  2.35ms    0.5ms   LOSS
198.51.100.7  0/3       100pct                     DOWN
203.0.113.20  3/3       0pct     61.767ms  4.1ms   SLOW

Path to 203.0.113.20:
  1  192.0.2.1  1ms  0% loss
  2  198.51.100.1  8.65ms  0% loss
  3  *  *  100% loss
  4  198.51.100.65  40.95ms  0% loss
  5  203.0.113.20  61.05ms  0% loss

3 addresses answer in 192.0.2.0/29: 192.0.2.1, 192.0.2.2, 192.0.2.5

The shape of a program

Class based, as in Java

Every Bogolang program has the same shape, so any engineer can open a colleague's file and know where to look.

All code stands inside a class
The top of a file holds only the edition line, imports and classes. A function, an assignment or a loose line at the top is refused before the program runs.
A program starts in main
The start is the static method main of the class named after the file: link_check.bogo starts in class LinkCheck. The words typed after the file name arrive in args.
Tests are classes too
A test is a method whose name starts with test_, in a class whose name starts with Test. A program may carry its own tests, and bogo test runs them.
Everything Python offers for classes stays
Inheritance, decorators, @dataclass, Enum, Protocol, properties and class methods work as in Python.

How a file is laid out

link_check.bogo
edition 2027
"""Says which routers answer."""


class LinkCheck:
    """Pings each router twice."""

    routers: list[IP] = [192.0.2.1, 192.0.2.2]

    @staticmethod
    def main(args: list[str]) -> None:
        for r in LinkCheck.routers:
            print(r, ping(r, count=2))


class TestLinkCheck:
    def test_there_are_two_routers(self) -> None:
        assert len(LinkCheck.routers) == 2
A line outside a class is refused
top.bogo:3:1: error: code must be inside a class
    x = 1
    ^
    Only imports and classes stand at the top of a file. Put this line in a method of a class.

Built in

The daily work of a network engineer, as commands of the language

No library to find, no wrapper to write. Each card opens the page that explains it.

Safe by rule

Careful with the network, because a mistake there is costly

Read-only by default
Device sessions are read-only unless a change block says otherwise.
No change without a rollback
A change block with no rollback is refused before the program runs.
No login in a file
Logins are kept in the protected store of the system, never in a file.
Try it with no device
--dry prints each change and sends nothing. --replay answers from saved outputs.

Read about the change block

From the example change_vlan
change on d:
    apply:
        vlan {vid}
         name {name}
        interface {trunk}
         switchport trunk allowed vlan add {vid}
    rollback:
        interface {trunk}
         switchport trunk allowed vlan remove {vid}
        no vlan {vid}
    verify:
        name in show("vlan brief")
        str(vid) in show(f"interfaces {trunk} trunk")

$ bogo run --dry --replay saved change_vlan.bogo

DRY RUN: change on core-sw1. Nothing is sent.
  apply:
    vlan 30
     name CAMERAS
    interface GigabitEthernet1/0/2
     switchport trunk allowed vlan add 30
  rollback:
    interface GigabitEthernet1/0/2
     switchport trunk allowed vlan remove 30
    no vlan 30
core-sw1: VLAN 30 would be added, nothing was sent
access-sw3: VLAN 30 is already there, nothing to do

The language

Python underneath, stricter on top

If you read Python, you read Bogolang. The rules it adds catch mistakes before a packet leaves the PC.

The language page

  1. 01

    Values with a type

    192.0.2.1, 10.40.0.0/16, 50ms and 18GHz are values with a type. Comparing a duration with a rate is a mistake.

  2. 02

    Checked before it runs

    A mistake in a type stops the program before it starts, with the line, the column and what to write.

  3. 03

    Editions keep old programs working

    An edition fixes the meaning of the language. A newer Bogolang runs every older edition with the meaning it had.

  4. 04

    Every Python package keeps working

    The Python 3.15 engine stays inside. Python packages are imported as they are.

kinds of work built in
10
documentation pages
20
example programs
13
systems: Windows and Linux
2

Examples

Programs that run on any PC

Each example comes with saved answers, so it runs with no device and no network.

All 13 examples

From an empty folder to a program that runs

Install Bogolang, then follow the first-program page. Its last step runs on saved answers and contacts no host.