Programming thread

c++ doesn't have a simple, standard way to do anything because there is always the c way, the stl way, the other stl way added in 2023, the 4 different boost ways, and the qt way

c++ is a huge piece of shit, but it's a very carefully designed piece of shit made by very smart language designers to make a c variant that is as abstract as possible without needing tons of runtime support
is it a powerful language that can be used for lots of things? yes. is it well-thought-out? mostly. is it elegant? fuck no
When I see C++ code I mostly don't know what the fuck is going on. When I tried CSFML which is from a C++ libary SFML but for C it seriously lacked documentation at the point people had no choice but to read the header files themselves. What exactly is it that makes people like C++ over C, I often feel like it's just because of the fucking OOP support.
 
What exactly is it that makes people like C++ over C, I often feel like it's just because of the fucking OOP support.
RAII, dynamic container classes, smart pointers, exceptions, the occasional template, and other certain features are amazing if you want to do certain things that are painful in C. To have code that approximates these things in C, you end up needing a bunch of ugly hacks and inserting calls to the reference count decrementers and incrementers every 5 lines.

C++ does these things, and then average C++ programmers end up abusing it for extremely retarded shit that makes no sense
 
RAII, dynamic container classes, smart pointers, exceptions, the occasional template, and other certain features are amazing if you want to do certain things that are painful in C. To have code that approximates these things in C, you end up needing a bunch of ugly hacks and inserting calls to the reference count decrementers and incrementers every 5 lines.

C++ does these things, and then average C++ programmers end up abusing it for extremely retarded shit that makes no sense
Jus mor featurs. From what I heard it is also safer by default.
 
I could overload the & operator on the enums in CustomTypes.h, but there's like twenty of them and if I write an overload for each one it might be prone to errors. So my possibly dumb question is this: Is it possible to write an overloaded & operator that applies to all the enums in Utilities::CustomTypes, but only those ones? I don't want my overload to apply to all enums just in case. Is there a safe way to do this?
If you have C++20 you can use concepts to create template with allowed list of types.
C++:
#include <iostream>
enum class Mask { A = 0x0, B = 0x1, C = 0x2, D = 0x4 };
enum class Mask2 { A = 0x0, B = 0x1, C = 0x2, D = 0x4 };
enum class Mask3 { A = 0x0, B = 0x1, C = 0x2, D = 0x4 };

template <typename T, typename... List>
concept AnyOf = (std::is_same_v<T, List> or ...);

template <typename T>
concept OverloadedMasks = AnyOf<T, Mask, Mask2>;

template <typename LHS, OverloadedMasks RHS> bool operator&(LHS lhs, RHS rhs) {
  return lhs & (LHS)rhs;
}

int main() {
  bool flag_1 = 2 & Mask::B;
  bool flag_2 = 2 & Mask2::C;
  bool flag_3 = 4 & Mask3::D; // <- Won't compile
  std::cout << flag_1 << std::endl;
  std::cout << flag_2 << std::endl;
  std::cout << flag_3 << std::endl;
}
 
it's funny how the language, for all its strengths, doesn't have a simple, standard way to implement bitmasks (that I can see).
Code:
struct foo {
    unsigned int e : 1;
    unsigned int n : 1;
    unsigned int d : 1;
};

struct bar {
    unsigned int m : 1;
    unsigned int e : 1;
    unsigned int n : 1;
    unsigned int o : 1;
    unsigned int w : 1;
};
 
Jus mor featurs. From what I heard it is also safer by default.
essentially yes
c++ provides lots of conveniences, but it provides lots more ways to make the compiler take hours to run
C:
struct foo {
    unsigned int e : 1;
    unsigned int n : 1;
    unsigned int d : 1;
};

struct bar {
    unsigned int m : 1;
    unsigned int e : 1;
    unsigned int n : 1;
    unsigned int o : 1;
    unsigned int w : 1;
};
this makes my undefined behavior 6th sense trigger for some reason
 
I like to think I'm pretty knowledgeable with tech things, but I haven't had a chance to sit down and actually learn a programming language. Not a pajeet, promise :)

What would you say is the ideal language for getting the hang of how things generally work, programming wise?
 
I like to think I'm pretty knowledgeable with tech things, but I haven't had a chance to sit down and actually learn a programming language. Not a pajeet, promise :)

What would you say is the ideal language for getting the hang of how things generally work, programming wise?
BASIC
then Fortran, then Pascal and finally C.

Sorry, I may be still stuck in the 1980s.
 
I like to think I'm pretty knowledgeable with tech things, but I haven't had a chance to sit down and actually learn a programming language. Not a pajeet, promise :)

What would you say is the ideal language for getting the hang of how things generally work, programming wise?
I hate Python, but Python is probably a solid option considering availability of tutorials and libraries and projects to fuck around with.
 
I hate Python, but Python is probably a solid option considering availability of tutorials and libraries and projects to fuck around with.
Got it, but why do you hate Python? Have heard it's one of the easiest languages to learn as there are tutorials/libs/projects like you said.
 
Got it, but why do you hate Python? Have heard it's one of the easiest languages to learn as there are tutorials/libs/projects like you said.
In my opinon: whitespace shouldn't have meaning. It's one of the few common languages* where that applies and likely causes negative transfer of learning. It is an easy language but I think it's less good as a stepping stone if you start with it. If all you're doing is Python then it's fine.

Admittedly my first Python-like language was PERL, so take that for whatever it's worth.

* Makefiles are not a language
 
Last edited:
It's one of the few common languages*

* Makefiles are not a language
And you do not put that shit on Makefiles. Makefiles have an elegant and easily parsed syntax wherein a \t delineates the rule from its execution. The reason for \t is because it is on a keyboard and it is not usually used in shell invocation. Python goes levels deep, and many characters match "whitespace".
 
Got it, but why do you hate Python? Have heard it's one of the easiest languages to learn as there are tutorials/libs/projects like you said.
Like @DavidS877 said, syntactically significant whitespace.

It's a shit design.

Also there's some annoying boilerplate habits that Python programmers get up to a lot as a consequence of the language design. Like I'm thinking of how they often manually handle optional keyword arguments. No clue why there isn't a good syntax for that yet. (Or I looked into this at some point and I figured out what was going on. But I wasn't impressed by the justification.)

Otherwise it's a fairly mundane language interpretation model. Some parts of the standard library are surprisingly well thought out.

Javascript is shit in its own way. If you cherry picked parts of Python like its object model and standard library and used a more Javascript like syntax, you'd have a lot better of a language.
 
I like to recommend Lua, because it's so basic and simple (no syntactic sugar), but you need to have it embedded in something else to be useful, like the LOVE game engine or Roblox. On its own, it's not even useful as a scripting language, really :(
great opportunity to learn c and make something to embed lua into as you make things in lua, but this is more of an advanced project than a hello world

you could try learning scheme first if you like simple languages with no sugar, but it's fairly unorthodox compared to "industry" languages so you might have a learning curve getting into things like javascript
programming languages don't matter. here's the optimal method to pick a good first language:
  1. look at something you would find interesting to do
  2. see what people are using for it
  3. use that
 
Back