• TIME TO 2024 UK RANKINGS

  • C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

C++ vs Rust

In cause some people missed this quote

This is a symptom of a larger immaturity in the crypto space. Crypto is replete with recent students who chase after buzzwords and new fads but can't see the forest from the trees. They don't understand the pitfalls of experimenting with a new technology vs. a tried and proven workhorse.

All reputable crypto firms that a I'm familiar with are using C++ for their trading systems and Python for research. No Rust, and not Java as many banks mistakenly chose when Java has its moment.
 
What is interesting/concerning is how many of the blockchains are built using Rust (Polkadot, Solana, Elrond, NEAR Protocol, and Oasis I know off the top of my head), while I can only name two that use C++ (EOSIO and NEO).

I wonder what's making those folks choose Rust.
Indeed; that's the 64 million dollar question!
 
Indeed; that's the 64 million dollar question!
Most things like this boil down to a simple explanation. In this case, it’s probably just a generational decision and nothing more.

People building blockchain protocols are mostly younger, which means they came up at a time when Rust was the cool language.

Some will try to convince you that they had some epic vision. But that is usually fluff used to create a storyline and aura that makes them sound like a visionary rather than someone who simply worked hard and had some luck along the way.
 
Last edited:
“When I was a boy of 14, my father was so ignorant I could hardly stand to have the old man around. But when I got to be 21, I was astonished at how much the old man had learned in seven years.”

Mark Twain

A little learning is a dangerous thing ;
Drink deep, or taste not the Pierian spring :
There shallow draughts intoxicate the brain,
And drinking largely sobers us again.
Fired at first sight with what the Muse imparts,
In fearless youth we tempt the heights of Arts ;
While from the bounded level of our mind
Short views we take, nor see the lengths behind,
But, more advanced, behold with strange surprise
New distant scenes of endless science rise !
So pleased at first the towering Alps we try,
Mount o’er the vales, and seem to tread the sky ;
The eternal snows appear already past,
And the first clouds and mountains seem the last ;
But those attained, we tremble to survey
The growing labours of the lengthened way ;
The increasing prospect tires our wandering eyes,
Hills peep o’er hills, and Alps on Alps arise !

Alexander Pope
 
Funny thing is the Rust guys are looking for C++ guys mostly since Rust is so new.
A safe pair of hands.

C++:
 // unsafe code 101
   unsafe fn dangerous() {}
 
   unsafe
   {
    dangerous();
   }

   // unsafe code, raw ptr and dereferencing
   let mut num = 5;
   let r1 = &num as *const i32;
   let r2 = &mut num as *mut i32;

   //println!("r1 is: {}", *r1);

   unsafe
   {
        println!("r1 is: {}", *r1);
        println!("r2 is: {}", *r2);
   }
 
Last edited:
Some generic classes and traits
(using parametric polymorphism).


C++:
struct Point<X, Y> {
    x: X,
    y: Y,
}

// Method definitions
impl<X,Y> Point<X,Y>
{
    fn x(&self) -> &X
    {
        &self.x
    }
}

impl<X,Y> Point<X,Y>
{
    fn y(&self) -> &Y
    {
        &self.y
    }
}


// Traits .. aka interfaces
pub trait IPrint
{
    // Empty tuple (unit)
    fn print(&self) ->();
}

pub struct Pair
{
    pub f: f64,
    pub s: f64,
}

impl IPrint for Pair
{
    fn print(&self) ->()
    {
        println!("f= {}", self.f);
        println!("s= {}", self.s);
    }
}

fn main()
{
    println!("Hello, prof!");

    let p1 = Point{x: 5, y: 1};
    let p2 = Point{x: 5, y: 1.1};
    let p3 = Point{x: 5.2, y: 1};
    let p4 = Point{x: 5.2, y: 1.1};

    println!("x= {}", p1.x());
    println!("y= {}", p1.y());
    println!("x= {}", p2.x());
    println!("y= {}", p2.y());
    println!("x= {}", p3.x());
    println!("y= {}", p3.y());
    println!("x= {}", p4.x());
    println!("y= {}", p4.y());

    let pa = Pair{f:2.0,s:4.0};
    println!("pair = {} : {}", pa.f, pa.s);
    pa.print();
 
Last edited:
Professor you've mastered rust in 24 hours!

How are you liking the memory management and ownership stuff?
Thank you.
Memory stuff is the next target.

charles-bronson-toshiro-mifune-440nw-5876933c.jpg
 
Back
Top