Hacker News new | ask | show | jobs
by v8dev123 1870 days ago
Also,

"Lack of Object-Orientation was a concern"

Whenever you port a big program to another language it is important to be conservative, in my view. You don't want to make so many structural changes in the way things work in the original codebase while porting things over. You risk things becoming very confusing and the port could fail. In future iterations you could definitely make things more idiomatic in the target language.

As far as Rust is concerned, it does not have traditional OO features. But by using the Deref/DerefMut trait specifically and traits in general I was able to recover and mimic a lot of OO behaviors present in rr in rd.

The rd code may not always be beautiful.

FYI,

Rust had a GC also Classes in it's initial versions but they were removed for some reason!!!

2 comments

Note that implementing Deref/DerefMut to mimic OOP is considered a bad practice. They were originally meant solely for smart pointer types, although some have opinions™ about that. Either way, you may need to reshape the way you think about program design coming from OOP languages - I know you've probably heard that before, but its true :) There are usually better options. Learning from FP pattern helps, as Rust leans more towards FP than OO in my opinion, although it has elements of both. Separating data and implementation (behavior) at the syntax level is one instance of that design decision showing through, no inheritance is another.
Are you talking to me or the author?

These sentences direct copy paste from Author post, but I agree that Rust leans more towards to FP. The creator labeled Rust as Linear FP language.

Ah, sorry, I didn't realize they were quotes from the post. (You generally put quotes in quotation marks or blockquotes "> ..." to distinguish). I guess the advice applies to anyone struggling with rust coming from an OOP background :)
"Whenever you port a big program to another language it is important to be conservative, in my view."

Either be very conservative or just tear things up. I think the middle ground is the worst, where you can't decide whether it's a rewrite or a port.