Dpdl (Dynamic Packet Definition Language)

Dpdl is a rapid development Programming Language and constrained Device platform with built-in Database and Agents technology.

Dpdl comes as a very compact and portable execution engine (DpdlEngine), compatible with JVM, with an extensible API interface, that enables to execute Dpdl programming language code (dpdl-lang), as well as code in different programming languages, or any other custom code syntax, directly embedded within the dpdl code, simultaneously, of multiple types and at it’s native Speed.

Dpdl enables Polyglot programming.

The Dpdl language constructs and syntax are simple and intuitive, yet powerful, with an object oriented paradigm (OOP) interoperable with JVM platform APIs and Native shared libraries. It enables also dynamic code generation and execution of heterogeneous embedded code sections, featuring Meta-programming techniques.

Dpdl provides access to JVM platform API’s, Native shared libraries, WASM modules and GPU compute.

In addition Dpdl enables also the embedding and execution of multiple programming languages like C, C++, Python & MicroPython, Julia, JavaScript, Lua, Ruby, Java, PHP, Perl, Groovy, V, Scheme, Clojure, Wat/Wasm, Wgsl, OpenCL, Modelica and others will follow…, directly embedded within dpdl code.

Everything comes already included out of the box along with the DpdlEngine, No additional installations needed.

The core DpdlEngine has the capability to run also on constrained devices and platforms via a dedicated compact code kilobyte virtual machine.

Compact, Self-contained, Portable and Customizable

Dpdl = dpdl-lang + ( C + ‘C++’ + Python + JavaScript + Julia + Java + Lua + Ruby + PHP + Perl + Groovy + V + Scheme + Clojure + Wat/Wasm + Wgsl + OpenCL + Modelica) + DB + AI = Powerful and Versatile

Dpdl itself is a general-purpose programming language, self-contained, interpreted and in part dynamically JVM bytecode compiled, statically as well as dynamically typed, with a very compact footprint and portable to most platforms. There is an on-going development to enable Dpdl to be compiled also to native code.

Dpdl introduces the concept of ‘embedded code sections’ that allows different programming languages, or any custom code syntax, to be executed within dpdl code by means of dedicated ‘Dpdl language plug-ins’, distributed along with the ‘DpdlEngine’ release, or developed ad-hoc and shipped separately.

MultipleDpdl language plug-ins’ are currently available for various programming languages. For example also the ‘Modelica’ language for cyber-physical simulations is available as ‘Dpdl language plug-in’. Further integrations are currently in active development, for example to enable also Quantum Computing directly inside Dpdl.

A dedicated Dpdl language plug-in for AI generative code (DpdlAINerd), enables to automatically generate programming language code and content or data by means of natural language descriptions inside dpdl code, embed it automatically into the dpdl code and execute the code right away, or to be executed in a subsequent steps.

Dpdl allows to create custom data containers with built-in database technology defined as ‘DpdlPacket’. It provides a convenient way to package, handle and query data very efficiently on memory scarce devices.

The included Dpdl language plug-inDpdlAgent’ provides an agent middle-ware based on open source for developing distributed and mobile multi-agent systems. It fully adheres to IEEE FIPA (Foundation for Intelligent Physical Agents) specifications, ensuring standardized, interoperable agent communication and coordination.

Dpdl is designed to:

DpdlEngine stack overview

Compact, Robust, Extensible and Portable

simple dpdl-lang example: Fibonacci series

func  fib(int n) int
	if(n <= 1)
		return n
	fi
	return fib(n - 1) + fib(n - 2)
end

int N = 20

int i
for(i < N)
	println("fib($i) = " + fib(i))
	i=i+1
endfor

println("done")

Common IoT protocol stacks such as Bluetooth™ and CoAP (Constrained Application Protocol) are supported and third party libraries and protocols can be added as extensions.

Dpdl provides a simple access to JVM API’s, Native shared libraries, Wasm modules and GPU compute.

The included Dpdl language plug-in ‘DpdlAINerd’ (DAN) enables to make use of AI generative code to automatically generate and embed executable code and content or data by means of natural language descriptions contained inside dpdl code.

The custom ‘DpdlPacket’ data container with built-in database technology provides a convenient way to package, handle and query data efficiently on memory scarce devices.

Dpdl enables the integration of different technologies to leverage fast prototyping and foster research and development.

Dpdl can be used as:

Features

For more Info visit the Official Dpdl-io GitHub repository:
DpdlEngine

Dpdl JVM access

Dpdl allows also to load and access java objects and methods of the underlying JVM platform and of any other external java libraries. This allows to use a broad set of API’s within Dpdl.

Dpdl Example using external Java libraries

Sample Dpdl application implementing a 3D model visualization of chemical molecules using the JavaFX library. The model can be rotated freely with mouse events, and controlled with key events.

graphics/dpdl3DJavaFX_molecule.h

VIDEO of Dpdl sample 3D application

Dpdl ‘embedded code sections’ (Dpdl language plug-ins)

Multiple programming languages can be embedded and executed within the same dpdl source code via configurable Dpdl language plug-ins by using the dedicated keyword >>.

Further programming languages and syntax interpreters can be developed and integrated via a dedicated plug-in interface and simple configuration if form of Dpdl language plug-ins.

This enables basically every sort of programming language or syntax interpreter to be embedded directly in dpdl code.

This features is very useful for rapid development and rapid prototyping and is also a key feature for generative code.

Currently the following programming languages can be embedded directly within Dpdl:

and also for some less known, but yet very powerful programming languages:

available Add-on ‘Dpdl language plug-ins’:

See this doc for more details: Dpdl_language_plugins.md

In development ‘Dpdl language plug-ins’ (available soon in coming releases):

Dpdl Example with ‘embedded code sections

Sample Dpdl code with embedded code sections in ‘C’ code and ‘JavaScript’:

struct  A  {
	string id = "A"
	int  x = 10
	float f = 0.3
	double d = 0.4d
	object stro = new("String",  "This is a java.lang.String object")

	func print()
		println("------------------")
		println("id: "  + id)
	end
}

println("With Dpdl you can make use of any java library and embed different programming languages...")

struct A mya
mya.print()

println("creating a hashmap to store key/value pairs...")

object mymap = new("HashMap")
mymap.put(1,  "Dpdl")
mymap.put(2,  "is")
mymap.put(3,  "Simple")
mymap.put(4,  "Compact")
mymap.put(5,  "Portable")

object keys = mymap.keySet()
object iter = keys.iterator()
object key, value
for(iter.hasNext())
	key = iter.next()
	value = mymap.get(key)
	println("key: "  + key +  " value: "  + value)
endfor

bool bcon = mymap.containsValue("Dpdl")
println("mymap contains 'Dpdl': "  + bcon)
println("")

println("Embed different programming languages directly..")
println("")

int n = 6
double x = 10.0d
string a = "test"
println("embedding C...")

dpdl_stack_push(n, x, a)

>>c(dpdlbuf_var1)
	#include <stdio.h>
	#include <dpdl.h>

	int dpdl_main(int argc,  char  **argv){
		printf("Hello C from Dpdl!\n");
		printf("\n");
		printf("num  params: %d\n", argc);
		int cnt;
		for (cnt =  0; cnt < argc; cnt++){
			printf(" param %d: %s\n", cnt, argv[cnt]);
		}
		char *buf = "My result";
		dpdl_stack_buf_put(buf);
		return  0;
	}
<<
int exit_code = dpdl_exit_code()
println("embedded C exit code: "  + exit_code)

string buf = dpdl_stack_buf_get("dpdlbuf_var1")

println("response buffer: "  + buf)
println("")

println("embedding javascript...")
int val = 23
arr[] = [1, 2, 3, 4]

dpdl_stack_push(val, arr)

>>js
	console.log('Dpdl sends a message with js');
	var sa;
	var arr;
	var v;
	if(scriptArgs.length > 1){
		v = scriptArgs[0];
		sa = scriptArgs[1];
		arr = sa.split(",");
		std.printf("val=%d\n", v);
		console.log(arr);
	}else{
		sa = "";
	}

	for(let i = 0; i < arr.length; i++)  {
		std.printf("arr[%d]=%d\n", i, arr[i]);
	}
<<
int js_exit_code = dpdl_exit_code()
println("embedded javascript exit code: "  + js_exit_code);

Supported Platforms

Dpdl runs on a wide range of platforms and includes also a small code footprint kilobyte range java virtual machine that can be compiled for almost every platform as soon as an ANSI C compiler is available for the target platform.

‘DpdlEngine’ is compatible with:

So far DpdlEngine V1.0 has been tested on:

Roadmap

The following integrations are in development:

Documentation

The DpdlEngine and Dpdl documentation are available via the following links:

Dpdl language quick Tour

Dpdl lang Documentation

Dpdl API Documentation

Dpdl ‘embedded code sections’ (Dpdl language plug-ins)

Dpdl compiler documentation

Dpdl Native Interface

Dpdl GPU Compute

Dpdl Wasm runtime

Dpdl Meta-programming

Dpdl Agents

DpdlVM

DpdlAI

DpdlPacket

DpdlClient

Dpdl profiles

More…

Dpdl Examples

Dpdl HowTo’s

Dpdl Tutorials

Visit also the official Dpdl-io GitHub repository for more details and updates: DpdlEngine

dpdl-lang examples

Dpdl Example that makes use of JRE classes

println("example that uses a java java.util.HashMap")

object map =  new("HashMap")

map.put(1,  "data1")
map.put(2,  "data2")
map.put(3,  "data3")

println("my map: "  + map)

println("iterating over the map using a key/value iterator")

object keys = map.keySet()
object iter = keys.iterator()

object key, value
while(iter.hasNext())
	key = iter.next()
	value = map.get(key)
	println(""  + key +  "="  + value)
endwhile

Dpdl Example that calls native shared library functions of the ‘libc’ library

import('native')

println("testing dpdl Native access to 'libc'...")

object libc = native.loadLib("c")

int uid = libc.getuid()

println("uid: "  + uid)

int gid = libc.getgid()

println("gid: "  + gid)

string env_java = libc.getenv("JAVA_HOME")

println("env java: "  + env_java)

int page_size = libc.getpagesize()

println("page_size: "  + page_size)

println("setting an environment variable...")

string new_env =  "MY_ENV"

int stat = libc.setenv(new_env,  "this is env MEGA",  1)

println("status: "  + stat)

println("getting env variable 'MY_env'...")

string new_env_val = libc.getenv("MY_ENV")

println("env value: "  + new_env_val)

println("now let's write some data to a file...")

object fcntl = getObj("Fcntl")

int fh = libc.open("./Test/TestWrite.txt", fcntl.O_RDWR)

raise(fh,  "Error in opening file")

string mydata_str =  "this is the content to write to my file"

object ptrstr = libc.malloc(1024L)
ptrstr.setString(0L, mydata_str,  "utf-8")

object size =  new("size_t")
size.setValue(strlen(mydata_str))

println("data size: "  + size)

size = libc.write(fh, ptrstr, size)

println("data size written: "  + size)

libc.close(fh)

Dpdl Example that downloads and decodes data in JSON format via http

import('http')
import('json')

struct Story {
	int id
	string title
	string url
}

string stories_url = "https://hacker-news.firebaseio.com/v0/topstories.json"
string item_base_url = "https://hacker-news.firebaseio.com/v0/item/"

println("downloading and displaying the top 10 news stories from hacker-news, decoded from json format...")

string resp = http.getraw(stories_url)

raise(resp, "Error in downloading data")

object jsonobj = json.parse(resp, 0)

ids[] = array(jsonobj)

struct Story storyobj

string story_url
int c = 0
for(c < 10)
	println("---------------------------------------------------------------------")
	story_url = item_base_url + ids[c] + ".json"
	
	resp = http.getraw(story_url)
	
	raise(resp, "Error in downloading story")

	storyobj = json.decode(resp, storyobj)

	println("id: " + storyobj.id)
	println("title: " + storyobj.title)
	println("url: " + storyobj.url)

	c=c+1
endfor

println("finished!")

Dpdl Example with ‘embedded code setion’ in C++ code that makes use of the ROOT framework libraries

C++ code can be embedded within Dpdl via the keyord ‘>>cpp

The following dpdl example makes use of an embedded code section in C++ that makes use of libraries from the the powerful ROOT Data Analysis Framework developed by CERN (https://root.cern/) .

Example Dpdl code embedding C++ code that make use of ‘ROOT’ libs:
Dpdl ROOT example

println("test embedded C++ code that make use of ROOT libs...")

>>cpp
	auto canvas = new TCanvas("c","Graph2D example",0,0,700,600);

	double x, y, z, P = 6.;
	int np = 200;
	auto dt = new TGraph2D();
	auto r = new TRandom();
	for (int N=0; N<np; N++) {
		x = 2*P*(r->Rndm(N))-P;
		y = 2*P*(r->Rndm(N))-P;
		z = (sin(x)/x)*(sin(y)/y)+0.2;
		dt->SetPoint(N,x,y,z);
	}
	dt->Draw("tri1 p0");
	canvas->Modified(); canvas->Update();
<<

int exit_code = dpdl_exit_code()
println("embedded ROOT exit code: " + exit_code)

Dpdl Example that shows the use of type ‘class’ Inheritance

This is the use of the simple dpdl class ‘Car’ implementation below:

println("testing my 'Car' class implementation...")

class Car mycar("Jeep", "Mercedes")

class Car yourcar("Suv")

yourcar.setType("Porsche")

println("The type of my car is: " + mycar.getType() + " and the brand is: " + mycar.getBrand())

println("The type of your car is: " + yourcar.getType() + " and the brand is: " + yourcar.getBrand())

Simple implementation of dpdl class: ‘Vehicle’ as a super class of ‘Car’


class Vehicle {
	string type
	object properties = new("HashMap")

	func Vehicle(string type_)
		this.type = type_
	end

	func getType() string
		return type
	end

	func setType(string type_)
		type = type_
	end

	func getBrand()
		return "unknown"
	end

	func setProp(object prop_map)
		properties = prop_map
	end
}

class Car : Vehicle {
	string brand

	func Car(string type)
		super(type)
		this.brand = "unknown"
	end

	func Car(string type, string brand)
		super(type)
		this.brand = brand
	end

	func getBrand()
		return brand
	end
}

Bluetooth device discovery

Example dpdl code that performs Bluetooth device discovery using high level Dpdl BT API :

int status = DPDLAPI_searchClientsOnServer()
int status_discovery = dpdlFalse
int service_discovery = dpdlFalse
int counter = 0
if(status == dpdlTrue)
	while (status_discovery != dpdlTrue) && (service_discovery != dpdlTrue)
		status_discovery = DPDLAPI_discoveryServerFinished()
		service_discovery = DPDLAPI_serviceDiscoveryServerFinished()
		print(".")
		counter = counter+1	
		sleep(3000)
	endwhile
	
	string dev = "n"
	int dev_found = 0
	while(dev != "null")
		dev = DPDLAPI_getServerVisibleBTAddr()
		if(dev != "null")
			println("bluetooth device visible: " + dev)
			saveData(dev)
			dev_found = dev_found + 1
		fi
	endwhile
else
	println("No working Bluetooth stack found")
fi

Note: The Bluetooth™ API JSR-82 can also be accessed directly for more specific implementations

Embedding of Python code

Python code can be embedded within Dpdl script by using the keyword ‘>>python’.

Example Dpdl script with embedded ‘Python’ code:

println("testing embedding python code wihin Dpdl")
println("")

>>python
	languages = ['Dpdl', 'C', 'Python', 'OCaml']
	for language in languages:
		print(language)
<<
# again Dpdl
println("")
int exit_code = dpdl_exit_code()
println("ebedded python exit code: " + exit_code);

Embedding C code

Dpdl allows the embedding and on-the-fly compilation and execution of C code directly within Dpdl code.

The C code can be embedded and executed with 2 distinct Modes, either interpreted OR compiled and executed in memory at runtime.

The two modes have distinct properties: The interpreted C code execution is for example more convenient for testing, small footprint and portability, while the compiled C code execution is more convenient for faster execution and for linking with external libraries.

The execution of C code is driven by a native Dpdl library that has a small footprint. For the interpreted mode it includes a basid set of essential C libraries (stdlib) and language constructs (ISO standard C90, POSIX compliant), no external library dependencies needed. Custom libraries and functions can be integrated and linked via a straight forward implementation configuration approach.

Dpdl example with embedded C code (interpreted):

println("testing embedded C code in Dpdl")
int n = 6
double x = 10.0
string a = "test"
dpdl_stack_push(n, x, a)
>>c
	#include <stdio.h>

	int dpdl_main(int argc, char **argv){
		printf("Hello C from Dpdl!\n");
		printf("\n");
		printf("num params: %d\n", argc);
		int cnt;
		for (cnt = 0; cnt < argc; cnt++){
			printf(" param %d: %s\n", cnt, argv[cnt]);
		}
		return 0;
	}
<<
# again Dpdl...
int exit_code = dpdl_exit_code()
println("embedded C exit code: " + exit_code);

object str = new("String", "Dpdl embedded C")
bool b = str.contains("C")
println("Dpdl contains C: " + b)

This is a more articulated example of the usage of embedded C code (interpreted) within dpdl:

dpdlEmbeddedC.h

Embedding of ‘Julia’

Julia is a powerful and performant computational programming language (https://julialang.org)

Julia code can be embedded within Dpdl via the keyord ‘>>julia

Example Dpdl script embedding ‘Julia’ that generates a Plot and saves it as PDF file:

Dpdl ROOT example

println("Testing Plot data with Julia programming language...")

>>julia
	using Plots

	x = range(0, 10, length=100)
	y1 = sin.(x)
	y2 = cos.(x)
	p = plot(x, [y1 y2])

	savefig(p, "./Test/myplot.pdf")

	dispose_status = @ccall dpdl_julia_dispose()::Int32
	return 1
<<

int exit_code = dpdl_exit_code()
println("finished with exit code: " + exit_code)

Other programming languages

Other programming languages or custom code interpreters can be easily integrated in Dpdl via a dedicated plug-in interface and configuration in form of ‘Dpdl language plug-ins’.

More Examples

Dpdl_Examples.md

Small prototype applications

Small prototype applications developed with Dpdl are published on this GitHub repository:

Dpdl-sample-Apps

Request free trial ‘DpdlEngine lite’

The ‘DpdlEngine lite’ release can be requested as Trial Shareware (with some limitation/restrictions) at the following request form:

Download Request Form

The ‘DpdlEngine pro’ instead is available with custom licensing models only.

How to buy a ‘full’ DpdlEngine license?

To buy a full featured ‘DpdlEngine lite’ license please submit your request via the following request form:

Order Request Form

For custom requirements or a bulk reseller license write an e-mail to the contact address.

Contact

e-mail: info@dpdl.io