Dpdl (Dynamic Packet Definition Language)

Dpdl is a rapid development programming language and constrained device framework with built-in database technology.

Dpdl provides access to java platform API’s, Native shared libraries, Wasm modules and GPU compute and enables the embedding and execution of multiple programming languages like C, C++, Python & MicroPython, Julia, JavaScript, Lua, Ruby, Java, PHP, Perl, Groovy, Clojure, Wgsl and OpenCL directly embedded within Dpdl code. Everything comes already included with the DpdlEngine, No additional installations required.

The Dpdl language constructs and syntax is simple yet powerful and follows an object oriented paradigm interoperable with the java platform APIs and external java and native shared libraries.

The core Dpdl engine has the capability to run even on memory scarce devices and platforms via the included dedicated kilobyte range virtual machine.

Dpdl is Self contained, Portable and Highly customizable via a dedicated extensible interface.

Dpdl = ( Java Api’s + C + ‘C++’ + Python + Julia + JavaScript + Java + Lua + Ruby + PHP + Perl + Groovy + Clojure + Wat/Wasm + Wgsl + OpenCL + AI) = Powerful and Versatile

Programming languages and natural language syntax interpreters can be implemented as extensions and embedded via a dedicated plug-in interface and configuration (Dpdl language plug-ins). For example the C++ ROOT Data Analysis framework from Cern is also available as Dpdl language plug-in.

These features make Dpdl a powerful development platform for rapid development and fast prototyping, in particular also due to the fact that software written with Dpdl will be enabled to access thousands of existing high-quality software libraries.

The included dedicated Dpdl language plug-in (DpdlAINerd) for AI generative code allows to automatically generate and embed executable code sections and content or data via embedded natural language descriptions defined inside Dpdl code.

Dpdl is designed to enable integration of different technologies seamlessly to leverage research and facilitate development.

Dpdl is designed to:

DpdlEngine stack overview

Dpdl is designed to be Compact, Robust, Extensible and Portable to almost every platform

Dpdl enables to combine the portability and vast API availability of Java and Python, the computational power of Julia, the expressiveness of Lua and Clojure, the simplicity of Ruby and Groovy, the web-enablement of JavaScript and WebAssembly (Wasm) and the power of C/C++ programming language within the same source code, and provides a simple access to java Api’s, Native shared libraries, Wasm modules and GPU compute. Therefore Dpdl is powerful and versatile development platform for industrial applications, education and research.

Embedded ANSI C code, OCaml, Groovy and Clojure are dynamically compiled in memory at runtime in order to achieve faster execution performance.

This makes Dpdl suitable for a wide range of use-cases and in particular also for Hardware programming.

Common IoT protocol stacks such as Bluetooth™ and CoAP (Constrained Application Protocol) are supported by default and further protocols and functions can be added as extensions.

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

Dpdl can be used as:

Dpdl can also be used to encode, store, control and query data efficiently on small memory footprint devices. Dpdl comes with a very compact (ca. 650 Kb for DpdlEngine core + ANSI C interpreter/compiler) and portable execution engine with an extensible API interface for the development of applications and embedded system software.

The Dpdl language constructs and syntax is kept simple and follows an Object Oriented paradigm (OOP) interoperable with the Java platform API and external java libraries.

Features

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

Prototype sample applications implemented with Dpdl can be found on this GitHub repository:
Dpdl-sample-Apps

Dpdl JRE access

Dpdl provides API functions to load and access java objects and methods of the underlying java JRE 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

This is a sample Dpdl app implementing a 3D model visualization of chemical molecules using the JavaFX library. The model can be rotated freely with mouse events.

graphics/dpdl3DJavaFX_molecule.h

VIDEO of Dpdl sample 3D application

Dpdl embeddable languages

Multiple programming languages can be embedded and executed within the same Dpdl code via the keyword >>.

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

This enables basically every sort of programming language or natural language syntax interpreter to be embedded and executed directly within 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 within Dpdl:

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

Dpdl Example with embedded ‘C’ and ‘JavaScript’ code

Sample Dpdl code with embedded ‘C’ code and javascript:

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

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

# main
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 = loadObj("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("dpdlbuf_var1",n, x, a)
>>c
#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)
>>qjs
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 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

Dpdl is currently developed by SEE Solutions and the following integrations has been defined:

Documentation

The Dpdl framework and API documentation are available via the following links:

Dpdl Documentation

Dpdl API Documentation

Dpdl language plug-ins

Dpdl embedded minimal C library Documentation

Dpdl compiler documentation

Dpdl Native Interface

Dpdl GPU Compute

Dpdl Wasm runtime

DpdlClient

DpdlPacket

DpdlAINerd

More…

Dpdl Examples

Dpdl HowTo’s

Dpdl Tutorials

Visit also the official Dpdl-io repository on GitHub for updates: DpdlEngine

Dpdl Examples

Dpdl-sample-Apps

Full featured applications developed with Dpdl are published on this GitHub repository:

Dpdl-sample-Apps

Dpdl example with embedded ‘C++’ code that make use of the ROOT framework libraries

ROOT is a powerful Data Analysis Framework developed by CERN (https://root.cern/) .

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

Example Dpdl code embedding C++ with libs ‘ROOT’:
Dpdl ROOT example

# main
println("test embedded ROOT C++...")

>>root
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 features type class inheritance and polymorphism

The following simple Dpdl example shows how the type ‘class’ can make use of Inheritance and Polymorphism. Some functions in this example make use of embedded code sections implemented in ‘Java’ and ‘C’

struct  property  {
	int  max_weight_gr
	float  max_height_m
	string desc  = null
}

class  Animal  {
	int  id
	string name
	struct property info =  {100000,  2.5,.}

	func Animal(int  id_)
		id = id_
		name =  "No name"
		
		println("new Animal() with id: "  + id +  " info: "  + info)
	end
	
	func Animal(int id_, string name_)
		id = id_
		name = name_
		
		println("new Animal with id: "  + id +  " and name: "  + name +  " - info: "  + info)
	end

	func print()
		println("This is an Animal")
	end
	
	func makeSound()
		println("kind of animal is not defined")
	end

	func getHashMap()
		object h_map = loadObj("HashMap")
		
		info_arr[]  = array(info)
		int i =  0
		for(i < info_arr.size())
			h_map.put(i, info_arr[i])
			i=i+1
		endfor
		
		return h_map
	end
}

class  Dog  :  Animal  {
	func Dog(int  id_, string name_)
		super(id_, name_)
		
		info.max_weight_gr =  8000
		info.max_height_m =  0.5
		info.desc =  "this breed is Shitzu"

		println("new Dog() with id: "  + id +  " and name: "  + name +  " - info: "  + info)
	end

	func print()
		println("This is a Dog with name: "  + name)
	end

	func makeSound()
		println("WOOF WOOF")
	end

	func makeSound(int times)  int
		int ret_val
		
		dpdl_stack_push(times)
		
		>>java
		int iter = arg0.intValue();
		
		for(int i =  0; i < iter; i++){
			System.out.println("WOOF");
		}
		return  1;
		<<
		ret_val = dpdl_exit_code()
		
		return ret_val
	end
}

class  Cat  :  Animal  {

	func Cat(int  id_, string name_)
		super(id_, name_)

		info.max_weight_gr =  1000
		info.max_height_m =  0.25
		info.desc =  "thie breed is Siamese"

		println("new Cat() with id: "  + id +  " and name: "  + name +  " - info: "  + info)
	end

	func print()
		println("This is a Cat with name: "  + name)
	end

	func makeSound()
		println("MIAUU MIAUU")
	end

	func makeSound(int beep)  int
		int ret_val

		dpdl_stack_obj_put("iter", beep)

		dpdl_stack_push("dpdl:applyvars")
		>>c
		#include  <stdio.h>
		#include  <unistd.h>

		// we output the character to ring 'bell' in the console
		for(int i =  0; i <  {{iter}}; i++){
			putchar('\a');
		}
		return  23;
		<<
		ret_val = dpdl_exit_code()

		return ret_val
	end
}

# main
println("testing class type Inheritance and Polymorphism...")
println("")

class Animal ani(1)

ani.print()
ani.makeSound()

println("")

class Dog mydog(2,  "Rosa")

mydog.print()
mydog.makeSound()
int sd = mydog.makeSound(100)

object map_dog = mydog.getHashMap()
println("map dog: "  + map_dog)

println("")

class Cat mycat(3,  "Minni")

mycat.print()
mycat.makeSound()
int sc = mycat.makeSound(3)

object map_cat = mycat.getHashMap()
println("map cat: "  + map_cat)

println("")
println("finished")

Compress and decompress data using the Java Platform API

Dpdl example that uses java.util.GZIP* classes to compress and de-compress data

# main
object str = loadObj("String", "my data to compress")
println("string to compress: " + str)

object byte_out = loadObj("ByteArrayOutputStream")
object zip_out = loadObj("GZIPOutputStream", byte_out)

println("compressing...")
zip_out.write(str.getBytes("UTF-8"))
zip_out.close()
println("data compressed successfully!")

object compressed_str = byte_out.toString()
println("compressed string: " + compressed_str)

println("decompressing...")
object byte_in = compressed_str.getBytes("UTF-8")
object byte_arr_in = loadObj("ByteArrayInputStream", byte_in)
object byte_arr_in_obj = cast(byte_arr_in)
object zip_in = loadObj("GZIPInputStream", byte_arr_in_obj)

object in_reader = loadObj("InputStreamReader", zip_in)
object buf_reader = loadObj("BufferedReader", in_reader)

string decompressed_str = ""
string line = ""
while(line != null)
	line = buf_reader.readLine()
	if(line != null)
		decompressed_str = decompressed_str + line
	fi
endwhile

println("decompressed: " + decompressed_str)

Bluetooth device discovery

Example Dpdl script (Bluetooth device discovery using high level Dpdl 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

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 scripts.

The C code can be embedded and executed with 2 distinct Modes, either interpreted only 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 and for the interpreted mode it includes all essential C libraries and language constructs (ISO standard C90), POSIX compliant) with no external library dependencies needed. Custom libraries and functions can be integrated and linked via a straight forward implementation configuration approach.

Example Dpdl script with embedded C code (interpreted):

# main
# starting with Dpdl, pushing parameters on the stack and embedding C code

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 = loadObj("String", "Dpdl embedded C")
bool b = str.contains("C")
println("Dpdl contains C: " + b)

This is a more complete example of the usage of embedded C code 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:

Dpdl ROOT example

#main
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 natural language interpreters can be easily integrated in Dpdl via a dedicated plug-in interface and configuration. Please feel free to suggest yours favorite language on the Discussion section on the DpdlEngine GitHub repository

More Examples

Dpdl_Examples.md

Request free trial ‘DpdlEngine lite’

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

Download Request Form

How to buy a ‘full’ DpdlEngine license?

To buy a full featured ‘DpdlEngine lite’ license with no limitations/restrictions, regular updates and support, 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