huynguyen-and-friend-projects / smoldb

Simple database in C(++)
1 stars 3 forks source link

Use C++ for anything related to string handling or data structure, and C for anything else #15

Closed nguyenhuy0905 closed 2 months ago

nguyenhuy0905 commented 4 months ago

If you've used some C, you know how sus the C strings are. And, data structure, C++ has classes (and structs). But the best thing of all, C++ has RAII. So, I can declare unique_ptr or shared_ptr and let the program allocate memory for me.

However, C++ will make the syntax look "less clear" also. If you're not too familiar with C in the first place, it may be best to stick with C. A lot of what C++ does, only makes sense when you know enough C. For example, unique_ptr and/or shared_ptr makes sense when you have suffered the pain of having to recursively traverse a binary tree to free every-single-node.

Leave comments down below to discuss through this.

nguyenhuy0905 commented 2 months ago

So I did use C++ after all huh.