GaalVM: The best embedable VM. Wish it weren’t GPL-licensed.

// cpart.c
#include <polyglot.h>

#include <stdlib.h>
#include <stdio.h>

struct Point {
    double x;
    double y;


void *allocNativePoint() {
    struct Point *ret = malloc(sizeof(*ret));
    return polyglot_from_Point(ret);

void *allocNativePointArray(int length) {
    struct Point *ret = calloc(length, sizeof(*ret));
    return polyglot_from_Point_array(ret, length);

void freeNativePoint(struct Point *p) {

void printPoint(struct Point *p) {
    printf("Point<%f,%f>\n", p->x, p->y);

Compile this with:

$ clang -g -O1 -c -emit-llvm -I$GRAALVM_HOME/jre/languages/llvm cpart.c

You can access your C/C++ code from other languages like JavaScript:

// jspart.js

// Load and parse the LLVM bitcode into GraalVM
var cpart = Polyglot.evalFile("llvm" ,"cpart.bc");

// Allocate a light-weight C struct
var point = cpart.allocNativePoint();

// Access it as if it were a JS object
point.x = 5;
point.y = 7;

// Pass it back to a native function

// We can also allocate an array of structs
var pointArray = cpart.allocNativePointArray(15);

// We can access this array like it was a JS array
for (var i = 0; i < pointArray.length; i++) {
    var p = pointArray[i];
    p.x = i;
    p.y = 2*i;


// We can also pass a JS object to a native function
cpart.printPoint({x: 17, y: 42});

// Don't forget to free the unmanaged data objects

Run this JavaScript file with:

$ js --polyglot jspart.js

Modern TV display technologies explained: Photo-Enhanced Quantum-Dot (QD); OLED; Photo-Emissive QD; Electro-Emissive QD; Micro-LED TV With QD.

  • Photo-Enhanced Quantum-Dot TV


  • Photo-Emissive QD TV

  • Electro-Emissive QD TV

  • Micro-LED TV With QDs