Closed ChineseRansomware closed 1 year ago
To be fair, that entire function should be less C and more C++ but that's something to think about in the future
str::string::find can be a workable replacement for C's strchr
.
Speaking of "less C, more C++" - what's your consideration on treating entities as objects instead of having them proceduarly processed? For example:
Instead of
countrySetPolitics(blr, "neutrality", 25, 25, 25, 25)
have
blr.setPolitics("neutrality", 25, 25, 25, 25)
Generally speaking, I don't really want OOP programming as of now due to a few reasons.
br.setPolitics
do? What's blr
? In the functional programming example, such questions don't exist as it's pretty clear that it sets the politics of a country and blr
is clearly something country related.Now it isn't to say I won't implement OOP in HCL, but I don't expect it to happen anytime soon. What would be an optimal solution is if someone were to fork HCL and create a version with OOP support in it and renamed libpdx.hcl
functions (kinda like C and C++ in a way), but I reaaally doubt someone would want to do all of that work, which I can't blame honestly.
Functional programming is more clear than OOP programming in most cases. For an example, what does the br.setPolitics do? What's blr? In the functional programming example, such questions don't exist as it's pretty clear that it sets the politics of a country and blr is clearly something country related.
blr
was taken from the examples provided in the repository itself. I cannot agree that these questions do not exist in OOP as logically speaking setPolitics would be a function exclusive to country objects. Meanwhile having it as a function that accepts a country makes it confusing and someone can pass a non-country variable to the function and be scratching their head for a reasonably long amount of time.
You can't just input a a non-country variable as the 1st argument as the language will output an error if it's attempted to. Also when I meant with "What's blr?" is that at first glance it doesn't tell you much and now you need context to figure out what type blr is.
Also I forgot to mention but what would even be the major benefit of making HCL more OOP-oriented? As far as I am concerned, it doesn't add enough benefits to varant pain and sweat to implement OOP into the language (in fact it might just make the interpreting process much slower but that's just guessing, nothing concrete).
Clang does not see the
cstring
library in the helper file - This causes compilation to fail on linux:Adding
cstring
as a library to the file solves this.