Aah… I am at the crossroads - tried-and-true marriage (C++/Python) or solo act (Julia).
For the past few months, I delved into many tools that act as a glue between C++ and Python, like nanobind, pybind11, SWIG, Boost.Python, etc. All of these looked good. This is the industry-wise power couple for performance and ease of use.
Yesterday, while trying to understand why so many top-level AI scientists are leaving bigtech, I got a clue about scientific AI and Julia, the programming language especially made for this field.
Yes, I am not talking about LLM - because I am sure AI ≠ the next word suggestion. There is a vast field in AI to cover vis-à-vis Scientific AI and simulation. In fields like climate modeling, drug discovery, or fluid dynamics, we aren't just predicting tokens; we are constrained by the laws of physics.
This is where Julia has carved out a unique, dominant niche through a movement called SciML.
While Python and C++ can do this, Julia has structural advantages that make it the "lab equipment" of choice for this decade.
To train an AI, you need gradients (derivatives). In Python, you can only differentiate through code written in specific frameworks like PyTorch or JAX. In Julia, the entire language is essentially differentiable. You can take the derivative of a complex simulation, a CAD model, or a custom physics engine without rewriting it in a "tensor" format.
Remember, scientific models are often written by scientists, not software engineers.
The Old Way: A scientist writes a model in Python; it’s too slow for the Supercomputer, so a software engineer rewrites it in C++.
The Julia Way: The scientist writes high-level code that is automatically compiled to LLVM (machine code). The prototype is the production code.
Some important use cases for Julia…
Climate Modeling: The CliMA project (MIT/Caltech) is rebuilding global climate models in Julia to better integrate satellite data with fluid dynamics.
Pharmaceuticals: Pumas is a Julia-based tool used for "quantitative pharmacology" to predict how drugs move through the body.
Aerospace: Organizations like NASA use Julia for trajectory optimization because it handles the massive matrix math of orbital mechanics at C++ speeds
Julia isn't a "Python killer" for building a website or a simple chatbot. But for Scientific AI—where you need to solve a partial differential equation while training a transformer—it is currently the only language that doesn't make you choose between your sanity (Python) and your performance (C++).
So… here we go… my exploration of Julia has begun today. The way I learn new software languages is by doing the same thing for Julia - using Julia to implement some of the GoF Design Patterns, here the Strategy Pattern.
Here is the source code of the Strategy Pattern developed using Julia.
abstract type JourneyToTheAirport end
struct Bus <: JourneyToTheAirport end
struct Metro <: JourneyToTheAirport end
struct Auto <: JourneyToTheAirport end
gotoairport(::Bus) = println("🚌 Journey by bus... hope there's no traffic!")
gotoairport(::Metro) = println("🚇 Journey by metro... fast and efficient.")
gotoairport(::Auto) = println("🛺 Journey by auto... hold on tight!")
# 1. Create a mapping of strings to Type Constructors
choices = Dict(
"bus" => Bus(),
"metro" => Metro(),
"auto" => Auto()
)
function run_app()
println("How do you want to get to the airport? (bus, metro, auto):")
# 2. Get user input and clean it up (lowercase and strip whitespace)
user_input = lowercase(strip(readline()))
# 3. Look up the strategy in our dictionary
if haskey(choices, user_input)
strategy = choices[user_input]
gotoairport(strategy)
else
println("❌ Sorry, '$user_input' is not a valid transport option.")
end
end
run_app()
Enjoy…

No comments:
Post a Comment