I'm about to start a new project from scratch. We are required to use C++ for everything, but I really don't like how chaotic is and would've really preferred Java, but the client is key but he claims he wants C++, because he said and I quote: "Minecraft Windows edition is sooo much faster than that Java crap, not having it". I'm responsible for code quality so I came up with a plan to still create usable source code:
- Any data structure except classes and enums are banned - Templates my only when absolutely necessary, to ensure quicker compile time - No classic pointers, new keyword is banned - Objects outside of 3rd party library may only be initialized using shared ptrs, weak ptrs, etc - No static variables, context must be carried through objects
This list is for from complete, but what do you think about the idea of neutralizing C++ idiocy by basicly forcing developer to use it more like Java?
Needs to run on Mac, no way in hell I'm opening that can of worms
Josiah Thomas
Maybe python that shit then :^) Shit nigger, I dunno. If it's something that specific maybe just go C++ or work on trying to convince the client otherwise since you're the technical counterpart
Problem most of use have limited C# experience. I have to choose between Java and C++ and Java is out. No I have to figure out a way to create readable code with the most chaotic language that is still in use. So I thought I just try to castrate C++ in order to neutralize some of the danger. I'm just not sure if theres a problem with this that I'm not seeing
Camden Roberts
>java grub >not using std structures >therefore not using std algorithms You're gonna reimplement fucking lists and sorts? How are those different than List chuj = new ArrayList(); ... List dupa = chuj.sorted(); ?
Aiden Morgan
What the fuck is java grub? And I mentioned that the rules on count for the internal structures, lists, vectors etc are fine. Main reason I wan't internal objects to only be used as pointers is to ensure that copies are always explicit and that references are the default.
William Morales
>Any data structure except classes and enums are banned Neither of those are "data structures" in the traditional sense, what exactly do you have in mind? >Templates my only when absolutely necessary, to ensure quicker compile time They usually will, but they will usually save you a shitton of code duplication by hand, so you decide. >No classic pointers, new keyword is banned This has already been pretty much standard practice in C++ for a while now, not sure why you bring up that point as an example of "C++ idiocy". >Objects outside of 3rd party library may only be initialized using shared ptrs, weak ptrs, etc For what reason? You are needlessly crippling yourself, nothing else. >No static variables, context must be carried through objects Fair point. This is the only guideline that makes sense.
How about you actually *learn* C++ instead of trying to come up with some twisted, arbitrary rules?
Christopher Brown
no structs, typedefs or other nonsense to avoid confusion. Basicly if starts with a lower case letter(int, std::string, int256, etc) its considered a primitve (even if thats not technically correct) and can be allocated and copied. If it starts with a capital, it must be a class and it may only be used using a shared ptr. Most c++ code is not very readable and most of our guys haven't used it that much. This seams like a recipe for disaster which I'm trying to prevent
Aiden Walker
Just to be more clear, I wan't the code to be readable in the sense that one doesn't have to look up 50 typedefs to understand how exactly it behaves. This is big advantage of Java since you that for instance the = operator makes copies for primitives and makes references for objects, wish I think is desirable. Also I still see the new keyword a lot in C++ projects, so it may be good practice, but it is far from standard.
Also I don't understand why c++ even has structs, since they are just inferior classes.
Colton White
Structs in C++ are exactly the same thing as classes except for the default access scope and inheritance mode, which is public instead of private. I don't see how they could cause "confusion". Maybe you're thinking about "pure data" classes? If so, how do they cause confusion? I agree with not using typedefs, though.
>Basicly if starts with a lower case letter(int, std::string, int256, etc) its considered a primitve (even if thats not technically correct) and can be allocated and copied. If it starts with a capital, it must be a class and it may only be used using a shared ptr. What? Are you unironically going to program around a naming convention? For what bizarre reason do you insist on using shared_ptr by default? It is often unnecessary, and introduces overhead, unlike unique_ptr. How about just avoiding any kind of pointer in general except when you actually need it? >Most c++ code is not very readable and most of our guys haven't used it that much. This seams like a recipe for disaster which I'm trying to prevent True. But trying to apply arbitrary rules to turn C++ into Java is a recipe for an even bigger disaster.
>This is big advantage of Java since you that for instance the = operator makes copies for primitives and makes references for objects, wish I think is desirable. Unless overridden or deleted, the = operator will copy in C++ via the copy constructor. If you want to avoid copies, use references, move semantics or unique_ptr.
>Also I don't understand why c++ even has structs, since they are just inferior classes. Compatibility with C.
Luis Gomez
>Structs in C++ are exactly the same thing as classes except for the default access scope and inheritance mode, which is public instead of private. I don't see how they could cause "confusion". then I see no reason to not just get rid of them. The possibility of later encapsulation or inheritance if necessary makes banning them worth it imo. >For what bizarre reason do you insist on using shared_ptr by default? It is often unnecessary, and introduces overhead, unlike unique_ptr. Mostly so objects behave smiliarly to java, which we do most of our shit in anyway. >Unless overridden or deleted, the = operator will copy in C++ via the copy constructor. If you want to avoid copies, use references, move semantics or unique_ptr. Copy a pointer and you have the same object. Copy an object and you have a clone.
Jeremiah Jenkins
Doesn't the windows version of minecraft also use java?
Cameron Harris
I think he meant bedrock
Logan Rogers
You're unbelievably stupid for thinking this is a good idea.
Parker Long
Yep.
Just use C++. Modern C++ is a great language.
Luis Cox
Is there a PEP8 style guildline for "Modern C++" that I can hand out or is this just a general term for C++ that isn't shit?
Charles Watson
Requirements seem pretty strict. Sounds more like a professor than "client." Do your own homework zoomer!
Levi Fisher
Just learn c++ like your professor commands you troglodyte bitch. Java is for Pajeet
>using polish curse words as impromptu variable names based
Logan Cook
that actually seams usefull, thanks
Jace Ortiz
no, it uses C++
Isaiah White
based pierogi
Lucas Hughes
Why not objective c?
Ryan Nguyen
What is this chaos you talk of? The STL and templates don't seem chaotic to me, nor does c++'s support for low level memory access. These are features of the language people use with varying skill. Like Linus said, c++ in itself isn't a terrible language, the problem is shitty programmers tend to (ab)use it.