Saturday, August 29, 2026

A strong case for C++ and Julia combination - my exploration continues - developing a PID controller using this approach using jluna...

 For a simple simulation or educational demonstration, we can do all of these in Julia. But in real-world applications, it's better to keep the hardware interfacing part written in C++ and the visualization part in Julia. This is a pretty common pattern (Python frontend + C++ backend, MATLAB + generated C, etc.), just with Julia instead of Python/MATLAB.

Below are some of the rational points when this tango of C++ and Julia is a good choice.

  • Real controller needs C++ strengths: If the “main controller” runs in a hard/soft real-time loop, on embedded hardware, interfaces with drivers/sensors/actuators (serial, CAN, ROS, etc.), or must meet strict latency/determinism guarantees, C++ (or C) is the conventional and safer choice. Julia’s GC, JIT compilation, and runtime make hard real-time harder (though there is recent work deploying Julia controllers on platforms like Raspberry Pi + PX4 or even microcontrollers).
  • Julia for the interactive layer: Julia excels at numerical work, control-theory tooling (ControlSystems.jl, DiscretePIDs.jl, ModelingToolkit, Dyad/JuliaSim control packages with PID autotuning), and modern interactive visualization (Makie/GLMakie with sliders, Observables, live plots of step responses, Bode/Nyquist, time series, etc.). Building a nice desktop or web-ish dashboard with live parameter sliders and plots is straightforward and productive in Julia.
  • Clean separation of concerns: Frontend (visualization + interactive tuning of
    K_p, K_i, K_d, etc.) stays in a high-level language good at maths and plotting; the performance-/hardware-critical loop stays in C++. Communication can be via sockets, shared memory, ZeroMQ, files, or (better) a thin C API + ccall / CxxWrap.jl / jluna-style interop

  • Finally, it may look like the following...



    Stage 0 : Verifying the basic configuration...




                        
                     

    Friday, August 28, 2026

    When My Son Inspired Me to explore a Bridge Between C++ and Julia...

    Here's the video of a very simple program in which the Julia runtime is embedded inside C++.




    Some programming projects begin with a problem.

    Some begin with curiosity.

    And some begin with a conversation between a father and his son.

    This one began with my son.

    My son has been exploring programming, graphics, simulation and the fascinating world of computers. As I watched him move from one technology to another—C++, Python, Java, graphics and simulation—I found myself revisiting areas of computer science that I had not touched seriously for years.

    And somehow, that journey brought me back to C++.

    But not just C++.

    It led me to Julia.

    And then came an interesting question:

    What if C++ and Julia could work together inside the same application?

    That question eventually led me to jluna.

    Why C++ and Julia?

    C++ and Julia come from rather different programming traditions.

    C++ is the language I naturally associate with systems programming, performance, memory control, large-scale simulation and real-time applications.

    Julia, on the other hand, feels almost purpose-built for scientific computing.

    It combines a high-level mathematical syntax with impressive numerical performance.

    For someone interested in physics simulation, control systems, computational science and graphics, the combination is rather attractive.

    Imagine having the core simulation or controller in C++, while using Julia for:

    • numerical experimentation

    • visualization

    • plotting

    • interactive parameter tuning

    • rapid prototyping

    • scientific analysis

    That immediately opens up some interesting possibilities.

    The idea of a bridge

    Calling C++ from Julia is already possible through several mechanisms.

    But I was particularly interested in the opposite direction:

    Embedding Julia inside a C++ application.

    The architecture I had in mind was something like this:

                     C++ Application
                           │
                  ┌────────┴────────┐
                  │                 │
            Simulation /        Julia Runtime
            Controller              │
                  │          ┌───────┴───────┐
                  │          │ Visualization │
                  │          │ Experimentation│
                  │          │ Data Analysis │
                  │          └───────────────┘
                  │
                  └────────── jluna ──────────┘
    

    This is where jluna became interesting.

    Rather than treating Julia as a completely separate program, jluna provides a C++ interface for interacting with an embedded Julia runtime.

    And suddenly, the idea of a C++ program calling Julia code didn't feel so exotic.

    My first jluna experiment

    I decided not to start with a complicated application.

    No physics engine.

    No PID controller.

    No graphics.

    Just a tiny experiment:

    Can a C++ program start Julia and execute Julia code?

    That simple question became the first milestone.

    I created a small C++/CMake project and started working through the mechanics of embedding Julia.

    There were several pieces to understand:

    • locating the Julia installation

    • configuring CMake

    • linking the C++ application

    • initializing the Julia runtime

    • evaluating Julia expressions

    • passing values between C++ and Julia

    The interesting part wasn't simply getting the first program to run.

    It was understanding where the boundary between the two languages actually lies.

    Crossing the language boundary

    Once you start thinking about C++ and Julia as two parts of the same application, a more interesting question appears:

    What should belong to C++, and what should belong to Julia?

    For example, consider a PID controller.

    The controller itself could live in C++:

    Sensor
       ↓
    C++ PID Controller
       ↓
    Actuator
    

    But during development, I might want Julia to provide:

                 Julia
                   │
           ┌───────┼────────┐
           ↓       ↓        ↓
         Plot     Slider   Analysis
           │       │        │
           └───────┼────────┘
                   ↓
                 C++
              PID Controller
    

    Julia could change Kp, Ki and Kd interactively.

    The C++ controller could continue doing the real work.

    Julia could plot the response in real time.

    Now the bridge becomes much more than a programming curiosity.

    It becomes an architecture for experimentation.

    The father-son effect

    There is something amusing about this journey.

    I started exploring C++ and Julia because my son was exploring programming and simulation.

    Instead of simply teaching him something, I found myself learning something new as well.

    That is one of the unexpected pleasures of being a parent.

    Sometimes we imagine that we are introducing our children to technology.

    But they quietly introduce us to new technology too.

    A question from a young programmer can send a father down a rabbit hole involving CMake, compilers, ABI compatibility, Julia's runtime, C++ templates and foreign-function interfaces.

    And suddenly it is midnight and you're reading documentation about jluna.

    Why this exploration matters to me

    I'm not approaching jluna because I need another language binding for a production application.

    I'm exploring it because it sits at an interesting intersection of several things I enjoy:

    C++ + numerical computing + simulation + visualization + experimentation.

    C++ gives me control and performance.

    Julia gives me an expressive scientific environment.

    And jluna provides the bridge.

    The more I explore this combination, the more interesting the possibilities become.

    Perhaps the final project will be a PID controller.

    Perhaps a physics simulation.

    Perhaps something involving graphics.

    Or perhaps it will simply remain another enjoyable rabbit hole in my never-ending journey through computer science.

    But that is perfectly fine.

    Because sometimes the best projects aren't the ones that solve a business problem.

    They are the ones that make you curious again.

    And this particular curiosity started with my son.

    **He was exploring programming.

    I followed him down the rabbit hole.

    And somewhere along the way, we discovered a bridge between C++ and Julia.**



    Monday, August 3, 2026

    From Eclipse CDT to Zed + clangd — The Exploratory Engineer in Me Is Still Alive...



    I recently started moving from Eclipse CDT to Zed + clangd for my C++ development.

    On the surface, it is just an IDE change.

    For me, it is something more.

    Eclipse CDT has been a trusted companion for years. Projects, indexing, debugging, builds, refactoring—everything became familiar. And that familiarity is comfortable.

    But there is a danger in becoming too comfortable with the tools. Development becomes routine. We loose the power of curiosity.

    And then...

    Things that had become invisible are interesting again.

    Look at the image, which is clangd's compile_commands.json.

    clangd needs to know this information.

    Which compiler?

    Which C++ standard?

    Which include directories?

    Which preprocessor definitions?

    Which compilation flags?

    Once I started looking at it this way, clangd stopped feeling like some mysterious IDE feature.

    It became what it really is:

    a tool that needs an accurate model of how the compiler sees the source code.

    That shift in perspective makes troubleshooting much easier.

    How does clangd understand my project?
    What exactly does CMake generate?
    How does the debugger interact with my program?
    How much of an IDE do I actually need?

    These are not merely editor questions. They are engineering questions.

    And perhaps that is what I enjoy most.


    As engineers gain experience, there is a risk of becoming operators of familiar systems rather than explorers of new ones.

    I don't want that.

    The move from Eclipse to Zed is therefore not really about:

    Eclipse → Zed + clangd




    It is about:

    Routine → Exploration

    Familiarity → Curiosity

    "This is how I always do it" → "What happens if I try this?"

    Why This Experiment Is Interesting to Me

    I have always enjoyed understanding what happens underneath the abstraction.

    That is probably why I keep moving between areas such as:

    • C++
    • Java
    • Python
    • Linux
    • OpenGL
    • CUDA
    • OpenFOAM
    • ParaView
    • Julia
    • Blender
    • numerical simulation
    • computer graphics
    • design patterns

    There is a common thread running through all of them.

    I don't just want to use the software.

    I want to understand how the machinery works.

    Moving from Eclipse CDT to Zed + clangd is another small expression of the same instinct.

    The editor itself becomes less important.

    The interesting part is understanding the ecosystem around it.



    The tools will keep changing—C++, compilers, build systems, editors, AI, GPUs, simulation frameworks.

    The important thing is to keep experimenting.

    Because after years of programming, discovering a new tool is nice.

    But discovering that the explorative engineer inside me is still alive—and thriving is much better.