Skip to main content

Oktopios - un langage de programmation moderne, expressif et bio-inspire

Project description

Oktopios

Oktopios est un langage de programmation expérimental, moderne et expressif, interprété en Python. Il combine une syntaxe lisible, un modèle orienté objet, des fonctions avancées, des modules natifs et une architecture bio-inspirée appelée architecture pieuvrique.

L'objectif du projet est de construire un langage capable d'orchestrer des unités d'exécution locales comme des tentacules autour d'un cerveau central. Oktopios n'est donc pas seulement un langage de script : c'est une base pour explorer l'exécution distribuée interne, les matrices, l'adaptation IA et les systèmes modulaires.

Vision

Oktopios s'inspire de l'organisation d'une pieuvre :

  • un cerveau central pour la gouvernance et l'orchestration ;
  • plusieurs coeurs spécialisés pour l'exécution, la circulation des données et l'adaptation ;
  • des tentacules capables d'exécuter localement des tâches ;
  • un mécanisme d'intention pour diffuser des ordres ;
  • une distribution aléatoire ou dynamique des tâches avec tentRandom ;
  • une ouverture vers des modules IA adaptatifs comme Ollama, DeepSeek ou StarCoder.

Cette vision se traduit progressivement dans le langage avec les mots-clés :

tent
heart
core
ten
intention
tentRandom

Installation

Depuis PyPI

pip install oktopios

Après installation :

okp --version
okp 'print("Bonjour Oktopios")'

Depuis les sources

git clone https://github.com/ALISOULEMOUANWIYA/oktopios.git
cd oktopios
pip install -e .

Windows

pip install oktopios
okp-setup
okp --version

Si la commande okp n'est pas reconnue, ouvrez un nouveau terminal ou ajoutez le dossier Scripts de Python au PATH.

Linux et macOS

pip install oktopios
okp --version

Depuis le dépôt :

bash installers/linux/install.sh
# ou
bash installers/macos/install.sh

Android avec Termux

Installez Termux depuis F-Droid, puis :

pkg install python git -y
pip install oktopios
okp --version

iPhone ou iPad avec iSH

apk update
apk add python3 py3-pip
pip install oktopios
okp --version

Utilisation rapide

# Exécuter un fichier
okp programme.okp

# Exécuter du code inline
okp 'print("Bonjour")'

# Lancer le REPL
okp --repl

# Afficher l'aide
okp --help

Premier programme

val nom: string = "Oktopios"
print("Bonjour " + nom)

Syntaxe de base

Variables

val x: int = 10          // constante
var compteur: int = 0    // variable mutable
var message = "Salut"    // type inféré

Fonctions

fun add(a: int, b: int): int {
    return a + b
}

print(add(2, 3))

Surcharge

fun calcule(a: int, b: int): int {
    return a + b
}

fun calcule(a: int, b: int, c: int): int {
    return (a + b) * c
}

Lambdas

val doubler = lambda(x: int) => x * 2
print(doubler(5))

Conditions

if (compteur > 10) {
    print("grand")
} elif (compteur == 10) {
    print("égal")
} else {
    print("petit")
}

Boucles

for (var i: int = 0; i < 5; i += 1) {
    print(i)
}

var noms: string[] = ["Awa", "Mouanwiya", "Ali"]
for (nom in noms) {
    print(nom)
}

Classes et objets

class Animal {
    var nom: string

    fun __construct(n: string) {
        this.nom = n
    }

    fun parler(): string {
        return this.nom + " dit bonjour"
    }
}

var chat = new Animal("Mimi")
print(chat.parler())

Oktopios prend aussi en charge progressivement :

  • interfaces ;
  • classes abstraites ;
  • héritage ;
  • override ;
  • super ;
  • énumérations ;
  • méthodes statiques ;
  • visibilité public, private, protected, global.

Pattern matching avec __matches__

__matches__ permet de comparer une valeur contre plusieurs formes. Il peut retourner plusieurs résultats si plusieurs cas sont vrais.

val x = 20
val y = 20
var list: string[] = ["@Nabile", "@Soultan", "@Abdallah"]

val r = __matches__ x => {
    1                 => "one"
    2, 3              => "two or three"
    4|10              => "dans le range [4:10]"
    in list           => "dans la liste"
    like y            => f"x{x} = y{y}"
    between 18 and 30 => f"{x} appartient à [18:30]"
    is int            => "integer"
    else              => "other"
}

print(r)

Patterns supportés :

  • valeurs simples : 1, "hello" ;
  • plusieurs valeurs : 2, 3 ;
  • intervalle : 4|10 ;
  • appartenance : in list ;
  • ressemblance ou contenance : like value ;
  • intervalle explicite : between 18 and 30 ;
  • regex : matches "[a-z]+" ;
  • type : is int, is string, is float, is bool ;
  • fallback : else.

Architecture pieuvrique

Oktopios introduit une architecture bio-inspirée pour organiser l'exécution.

tent class Brain {
    heart {
        var mode: string = "defense"
    }

    core {
        print("System Ready")
    }
}

ten class Arm1 {
    fun alert(msg: string) {
        print("Arm1 received " + msg)
    }
}

ten class Arm2 {
    fun alert(msg: string) {
        print("Arm2 received " + msg)
    }
}

intention alert("Danger")
tentRandom alert("Ping")

Dans ce modèle :

  • tent class déclare le cerveau central ;
  • heart contient la configuration centrale ;
  • core contient le noyau exécuté au démarrage ;
  • ten class déclare une tentacule locale ;
  • intention diffuse un appel à toutes les tentacules compatibles ;
  • tentRandom envoie un appel à une tentacule compatible choisie au hasard.

Cette partie est en évolution. Le but est d'aller vers un vrai moteur interne de routage, d'adaptation et d'exécution distribuée.

Matrices

Oktopios possède un module matrix pour manipuler des structures denses ou clairsemées.

Matrice clairsemée

Utile pour les graphes, réseaux, liens entre cellules ou parcours BFS/DFS.

inject matrix

var m = matrix.new([3, 3])
matrix.set(m, [0, 0], 42)
matrix.link(m, [0, 0], m, [1, 1])
var chemin = matrix.traverse(m, [0, 0], "bfs")

Matrice dense

Utile pour les calculs mathématiques, l'IA et les opérations numériques.

inject matrix

var A = matrix.new([2, 2], true)
var B = matrix.new([2, 2], true)
matrix.set(A, [0, 0], 1)

var C = matrix.add(A, B)
var T = matrix.tensor(A, B)
var R = matrix.contract(A, B, 0, 1)

Modules natifs

Oktopios utilise inject pour charger des modules natifs.

inject Math
inject String
inject matrix

print(Math.sqrt(16))
print(String.upper("oktopios"))

Modules et familles de fonctionnalités disponibles ou en évolution :

  • Math ;
  • String ;
  • collections ;
  • matrices ;
  • temps et entrées/sorties ;
  • fonctions avancées ;
  • coeur heart ;
  • modules adaptatifs.

Gestion des erreurs

try {
    throw "erreur volontaire"
} catch(e) {
    print("Attrapé : " + e)
} finally {
    print("Fin")
}

Commandes CLI

Commande Description
okp fichier.okp Exécute un fichier Oktopios
okp 'code' Exécute du code inline
okp --repl Lance le REPL
okp --check fichier.okp Vérifie la syntaxe
okp --version Affiche la version
okp --keywords Liste les mots-clés
okp --native Liste les fonctions natives
okp --doc Affiche la documentation intégrée
okp --init NomProjet Crée un projet Oktopios

Structure du projet

vm/
  lexer.py                # tokenisation
  parser.py               # parsing vers AST
  ast_nodes.py            # modèle AST
  interpreter.py          # exécution
  environment.py          # environnements et portées
  runtime_instance.py     # instances objets
  native_funcs.py         # fonctions natives
  native_collections.py   # collections natives
  matrix.py               # matrices
  heart/                  # modules coeur
  modules/                # modules .okp
installers/               # scripts d'installation
tests/                    # tests et exemples
docs/                     # documentation

État du projet

Oktopios est encore expérimental. Certaines fonctionnalités sont stables, d'autres sont en cours de conception ou d'intégration. Le langage évolue rapidement autour de trois axes :

  • lisibilité de la syntaxe ;
  • puissance du runtime objet et fonctionnel ;
  • architecture pieuvrique pour l'orchestration, les matrices et l'adaptation IA.

Licence

MIT © Mouanwiya Ali Soule

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oktopios-0.0.21.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oktopios-0.0.21-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file oktopios-0.0.21.tar.gz.

File metadata

  • Download URL: oktopios-0.0.21.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for oktopios-0.0.21.tar.gz
Algorithm Hash digest
SHA256 378afc781e47561800dd5e447f2c9efba8c7dd2d7ae26167526eba07b4da13d5
MD5 20736a1c114747b9503c9f30b5cad1b7
BLAKE2b-256 1f52ca968c5f02b9dd79be9165d94e1e28f7a51dcbb57a31ffb82ca235e04bcd

See more details on using hashes here.

File details

Details for the file oktopios-0.0.21-py3-none-any.whl.

File metadata

  • Download URL: oktopios-0.0.21-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for oktopios-0.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 2dc6e7e5727c40f5b59e176b7d7622b1c6ab059ea61ab49dde7da9085f832045
MD5 d0f6c78330b3be8f84d3256f3adabc4b
BLAKE2b-256 b6889921ae6245f374b5cd5b2d761ede290ce52ac86efaae932fc7014b90725e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page