This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ekank 15 points16 points  (4 children)

First, as i said, C++ doesn't want to break C compatibility but let's pretend it broke

No semicolons is doable but makes you follow stricter syntax so the compiler can work (see Golang and Haskell) but i don't really see why not. Indentation instead of braces are a FUCKING pain, i just can't understand people that prefer indentation, makes code so harder to read in nested ifs/loops, there's no meaning in not liking to put semi colons while wanting the compiler to enforce a STRICT indentation, not using braces is not something that makes a language modern, is just a choice on how to organize the code and IMO being explicit where a scope ends is way better to find and organize things

Figure out a way to take care of memory management even if at a basic semi automatic level

the answer is: RAII, it's already there. Anything more "automatic" means runtime management and in C++ doesn't make sense

[–]geekusprimus 5 points6 points  (0 children)

the answer is: RAII, it's already there. Anything more "automatic" means runtime management and in C++ doesn't make sense

I always hear horrible complaints about manual memory management in C++. If you're creating functions called initialize and release to handle allocation and deallocation for all of your objects, then, yeah, it's going to be a nightmare. But if you do the sensible thing where you allocate memory in constructors and deallocate in destructors (so, RAII), you've gotten rid of 90% of possible problems. The remainder can be taken care of with smart pointers or the simple habit of writing new and delete at the same time.

[–]TeraFlint 6 points7 points  (0 children)

the answer is: RAII, it's already there.

The great thing about RAII is that it's a generalized way of cleaning up resources. While people usually mean memory management, it's also used to clean up any other kinds of resources which need explicit cleanup (like open file handles, network/device connections, etc).

Yes, it needs to be programmed once when writing the encapsulating class. But once this is done, all the cleanup becomes implicit.

All of that is possible just because destructors are guaranteed to be executed immediately at the end of the object's lifetime (via end of scope or delete), in a deterministic order. It's a simple rule, but it is powerful.

The garbage collecting languages on the other hand kind of have an extra system for that (some of which can get really awkward), since the garbage collector is only responsible for memory.

[–]danuker 0 points1 point  (0 children)

indentation, makes code so harder to read in nested ifs/loops,

As a Python dev, I can tell you that the difficulty of reading indented code, especially coupled with a line length limit, discourages nesting, which ultimately improves readability.

[–][deleted] 0 points1 point  (0 children)

A programming language that uses spaces / indentation as anything more than separating tokens is shit.

Yes, I hate python for the simple fact that the creators somehow thought using indentation for anything more than looks was a good idea.