DEV Community

Robert Teminian
Robert Teminian

Posted on • Edited on

1

See old Object Pascal from new Rust

This is a post at Apr. 20th. 2024 from my old blog.
https://codenested.blogspot.com/2024/04/see-old-object-pascal-from-new-rust.html


Nowadays I'm working on a new application, and I thought it's a good chance to learn something new, I tried Rust.

As a newbie(or noob) in this area, I enjoy the time fighting against rust-analyzer that always-whining like Grouchy Smurf...... (lol) And today I found something interesting.

In Rust, the following is an error.

let mut raw: String;
handle.read_to_string(&mut raw);
Enter fullscreen mode Exit fullscreen mode

To fix, the first line should be changed like following.

let mut raw=String::new();
handle.read_to_string(&mut raw);
Enter fullscreen mode Exit fullscreen mode

Seeing the code reminds me of the good old days of Object Pascal (Delphi). If it's not an primitive type you've got to declare the variable in var clause and call constructor in implementation, or it'll emit runtime error. And Rust "inherited" the structure as it was, except for catching non-memory-assignment in compile time.

procedure function1();
var anObject: TAwesomeClass;
begin
anObject:= TAwesomeClass.Create(); // or the application will crash
end;
Enter fullscreen mode Exit fullscreen mode

The programming language Pascal is a minor one as it is, it influences to too many other languages, like Java, Python, Javascript, and now Rust....... They all adopted at least some part of Object Pascal.

As a good follower of the language, I feel dim as I saw this.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up