Page 1 of 1

learning c++

PostPosted: Wed Feb 20, 2013 03:29
by Neuromancer
So I'm learning c++. I wrote a couple small projects in it 20 plus years ago but reading the Minetest code has been difficult to say the least. Anyway, one of the interesting things I discovered in that the new C++ standard, there is a thing called smart pointers (shared pointers and unique pointers) and these things are in the standard library. They basically are classes that wrap pointers so that you don't have to worry about deleting them when they go out of scope. It removes a lot of the administrative code you have to do when cleaning long lived objects off of the heap/free storage. I'm guessing this is too new for Minetest to use but it seems really cool. Does anyone know if minetest uses C++11 and smart pointers?

PostPosted: Tue Mar 12, 2013 07:54
by Jordach
Celeron55 should have took Python since day 1. Oh and yes, compared to C/++ it is nice, clean and frickin readable.

PostPosted: Tue Mar 12, 2013 09:17
by 0gb.us
Jordach wrote:Celeron55 should have took Python since day 1. Oh and yes, compared to C/++ it is nice, clean and frickin readable.


Python (as a language) has issues too though. I won't argue with you though, as I don't know C++, so I can't compare the two.

But isn't C++ lower level, and therefore faster running? Also, Python doesn't compile into a nice executable, but into byte code to be run in an interpreter, further slowing it down. Surly the speed boost offered by C++ is worth it?

PostPosted: Tue Mar 12, 2013 11:14
by rarkenin
0gb.us wrote:
Jordach wrote:Celeron55 should have took Python since day 1. Oh and yes, compared to C/++ it is nice, clean and frickin readable.


Python (as a language) has issues too though. I won't argue with you though, as I don't know C++, so I can't compare the two.

But isn't C++ lower level, and therefore faster running? Also, Python doesn't compile into a nice executable, but into byte code to be run in an interpreter, further slowing it down. Surly the speed boost offered by C++ is worth it?


There used to be a mid-way point, via HipHop, but the HipHop->C++->Native has been discontinued.

PostPosted: Tue Mar 12, 2013 15:44
by celeron55
Neuromancer wrote:I'm guessing this is too new for Minetest to use but it seems really cool. Does anyone know if minetest uses C++11 and smart pointers?


Minetest uses smart pointers for a small amount of things, but not those found in C++11. It has it's own implementation. Most of the time they aren't worth using though; memory management in constructors and destructors is easy. Also, Irrlicht uses reference counting for it's stuff.

Jordach wrote:Celeron55 should have took Python since day 1. Oh and yes, compared to C/++ it is nice, clean and frickin readable.Celeron55 should have took Python since day 1. Oh and yes, compared to C/++ it is nice, clean and frickin readable.


Python is a nice language, but sucks way more than Lua for embedding. Also, it should be obvious that Python or Lua or anything like that is way too slow for the core things in Minetest. You simply can't do things like mesh or map generation or voxel lighting in realtime in it.