NATION

PASSWORD

#include "NationStates.hpp" — General Programming Thread

For discussion and debate about anything. (Not a roleplay related forum; out-of-character commentary only.)

Who is king?

Poll ended at Wed Aug 30, 2023 8:05 am

Linus Torvalds
3
50%
Dennis Ritchie
2
33%
Bjarne Stroustrup
0
No votes
Graydon Hoare
0
No votes
Guido van Rossum
1
17%
Mark Shuttleworth
0
No votes
 
Total votes : 6

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

#include "NationStates.hpp" — General Programming Thread

Postby Stratonesia » Tue May 02, 2023 1:57 am

Image

What's up, NationStates!

This is a thread for discussion of programming in general. If you want to share your interesting projects in your favourite language, share some neat programming tricks, or sometimes delve into the never-ending war between Emacs and Vim, this is the place for you.

Has nothing to do with ChatGPT, though it may overlap.
I've just started learning [insert language here], what should I do?
The "Reference" section on the right has some cool resources for you. If you're a newbie, I recommend you visit the tutorial site for your language.
It's [insert language here] being updated? How do I keep up with the new versions?
Yes, it's being updated. With each new revision of the language, there would be quite a lot of changes to the language. New features may be added, some features may be deprecated or have its definition/behaviour changed, others may be removed for good. Keeping up with the newest changes will help you code better.
Always check the Wikipedia articles, and the articles on [insert language here]'s official website on newest revisions.
What's C++ used for?
For making tools and programs that are fast enough for people whose works require speed, agility, flexibility and a brain. Speed creates performance, performance creates efficiency; the more efficient the tools, the easier the labour.
A few of the softwares you have on your PC might be written in C++. And that's just for Windows PCs; Linux PCs often have a hundred times more.
Users in NationStates have written a few "scorinators" in C++, for use in sports roleplays.
Can I talk about Python, or Rust, or Java?
Yes. This is the "general thread", after all.
Can I go off-topic?
NO.
This is not TET.
If you want to show your Mandelbrot fractal renderer in C++, then you can.
But if you want to tell everybody that "Chainsaw Man sucks, Makima sucks," do it somewhere else.
GWAAAAAAAAAAA OInfosin 90234u90 jiowejt390th3jy09h42 j9wj ['3.y[4]5y.[]
I do not want to see any kind of trolling, flaming, baiting or spamming here.
Remember, the mods are watching.
Image
"BTW I use Arch."
— Shiver
Image
"Ay! Ay, ay!"
(I love C++! Why go back to C? C++ is not "C with extensions"; C is "C++ with handicaps"!)

— Big Man
Last edited by Stratonesia on Wed Aug 23, 2023 8:10 am, edited 11 times in total.
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Tue May 02, 2023 4:28 am

/bump
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Umeria
Senator
 
Posts: 4423
Founded: Mar 05, 2016
Left-wing Utopia

Postby Umeria » Tue May 02, 2023 5:09 am

That last line isn't going to print - cout only writes to stdout after a newline.

Also if you want you can put "using std::cout;" at the top so you don't have to write "std::" every time.
Ambassador Anthony Lockwood, at your service.
Author of GAR #389

"Umeria - We start with U"

User avatar
Dimetrodon Empire
Minister
 
Posts: 2910
Founded: Sep 21, 2022
Left-Leaning College State

Postby Dimetrodon Empire » Tue May 02, 2023 5:16 am

Cool thread, but unfortunately, I never learned C++.

I will look into installing the compiler + tutorials and check it out.
Last edited by Dimetrodon Empire on Tue May 02, 2023 5:20 am, edited 1 time in total.
Flag by someone named AdmiralRA on Reddit. (No, I don't have a Reddit account)
Proud Socialist. Bisexual.From the river to the sea
████████████
████████████

George Orwell wrote:Every line of serious work that I have written since 1936 has been written, directly or indirectly, against totalitarianism and for democratic socialism, as I understand it.

Citizen & Deputy Speaker of The Rejected Realms; Scout in the Rejected Realms Army

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Tue May 02, 2023 5:47 am

Dimetrodon Empire wrote:Cool thread, but unfortunately, I never learned C++.

I will look into installing the compiler + tutorials and check it out.

Learnt any language before?
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Tue May 02, 2023 5:51 am

Umeria wrote:That last line isn't going to print - cout only writes to stdout after a newline.

Also if you want you can put "using std::cout;" at the top so you don't have to write "std::" every time.

Thank you for pointing that out.
Remember, I have little experience with C++ though.
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Dimetrodon Empire
Minister
 
Posts: 2910
Founded: Sep 21, 2022
Left-Leaning College State

Postby Dimetrodon Empire » Tue May 02, 2023 6:12 am

Stratonesia wrote:
Dimetrodon Empire wrote:Cool thread, but unfortunately, I never learned C++.

I will look into installing the compiler + tutorials and check it out.

Learnt any language before?

Yeah, I know some .php but that is a server side language and its more for web applications. Well, more exclusively for web applications.
Last edited by Dimetrodon Empire on Tue May 02, 2023 6:20 am, edited 2 times in total.
Flag by someone named AdmiralRA on Reddit. (No, I don't have a Reddit account)
Proud Socialist. Bisexual.From the river to the sea
████████████
████████████

George Orwell wrote:Every line of serious work that I have written since 1936 has been written, directly or indirectly, against totalitarianism and for democratic socialism, as I understand it.

Citizen & Deputy Speaker of The Rejected Realms; Scout in the Rejected Realms Army

User avatar
Risottia
Khan of Spam
 
Posts: 55261
Founded: Sep 05, 2006
Democratic Socialists

Postby Risottia » Tue May 02, 2023 6:21 am

#include <stdio.h>

int load_data()
{
char stufftobetyped[]="I'm more of an ANSI C guy, maybe because I've never had to use objects.";
return 0;
}

int main()
{
int i;int k;
k=sizeof(stufftobetyped);
for(i=0;i++;i<k)
{
printf("%c",stufftobetyped[i]);
}
return 0;
}
Last edited by Risottia on Tue May 02, 2023 6:24 am, edited 2 times in total.
Statanist through and through.
Evilutionist Atheist Crusadjihadist. Egli/Lui.
"Darwinu Akhbar! Dawkins vult!"
Founder of the NSG Peace Prize Committee. Should I restart the bugger?
SUMMER, BLOODY SUMMER!

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Tue May 02, 2023 6:26 am

Risottia wrote:#include <stdio.h>

int load_data()
{
char stufftobetyped[]="I'm more of an ANSI C guy, maybe because I've never had to use objects.";
return 0;
}

int main()
{
int i;int k;
k=sizeof(stufftobetyped);
for(i=0;i++;i<k)
{
printf("%c",stufftobetyped[i]);
}
return 0;
}

Why don't you try out the [code] tag? That'd make things much easier...
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Dimetrodon Empire
Minister
 
Posts: 2910
Founded: Sep 21, 2022
Left-Leaning College State

Postby Dimetrodon Empire » Tue May 02, 2023 6:42 am

Stratonesia wrote:Why don't you try out the [code] tag? That'd make things much easier...

Probably because NSGers are not used to using the code tag here. I cannot remember the last time [code] was used in NSG.
Flag by someone named AdmiralRA on Reddit. (No, I don't have a Reddit account)
Proud Socialist. Bisexual.From the river to the sea
████████████
████████████

George Orwell wrote:Every line of serious work that I have written since 1936 has been written, directly or indirectly, against totalitarianism and for democratic socialism, as I understand it.

Citizen & Deputy Speaker of The Rejected Realms; Scout in the Rejected Realms Army

User avatar
Risottia
Khan of Spam
 
Posts: 55261
Founded: Sep 05, 2006
Democratic Socialists

Postby Risottia » Tue May 02, 2023 6:47 am

Stratonesia wrote:
Risottia wrote:#include <stdio.h>

int load_data()
{
char stufftobetyped[]="I'm more of an ANSI C guy, maybe because I've never had to use objects.";
return 0;
}

int main()
{
int i;int k;
k=sizeof(stufftobetyped);
for(i=0;i++;i<k)
{
printf("%c",stufftobetyped[i]);
}
return 0;
}

Why don't you try out the [code] tag? That'd make things much easier...


I'm too old for that fancy-schmancy shit. Now, geroff my tabs. :D
Statanist through and through.
Evilutionist Atheist Crusadjihadist. Egli/Lui.
"Darwinu Akhbar! Dawkins vult!"
Founder of the NSG Peace Prize Committee. Should I restart the bugger?
SUMMER, BLOODY SUMMER!

User avatar
The Blaatschapen
Technical Moderator
 
Posts: 63226
Founded: Antiquity
Anarchy

Postby The Blaatschapen » Tue May 02, 2023 7:48 am

I'm not sure if nsg is the best place for this. But it's hard to figure out where it should go instead


We might lock, move or merge this thread


That said, for development, some of the people who build applications on top of the NationStates API hang out in https://discord.gg/SgwWMTN

You might want to check it out.

(it is not formally endorsed by NS staff)
The Blaatschapen should resign

User avatar
Roavin
Admin
 
Posts: 1777
Founded: Apr 07, 2016
Democratic Socialists

Postby Roavin » Tue May 02, 2023 8:55 am

Hi. Been doing C++ professionally for over 15 years.

Stratonesia wrote:I've just started learning C++, what should I do?
The "Reference" section on the right has some cool resources for you. If you're a newbie, I recommend you visit the C++ tutorial site.
(NOTE: I'm a newbie too!)


The tutorial is not the worst I've seen, but has the typical tutorial issue in which there's too much focus on syntax and not enough on best practices, which a language like C++ desperately needs. Don't bother with raw arrays, use std::array instead.

Stratonesia wrote:What's C++ used for?
For making tools and programs that are fast enough for people whose works require speed, agility, flexibility and a brain. Speed creates performance, performance creates efficiency; the more efficient the tools, the easier the labour.


C++ being fast is a myth, because in 99% of cases, the relevant slowdown isn't the actual CPU cycle crunching, but rather algorithmic problems. Sloppy C++ will be slower than a comparable program in a compiled but managed language like Java, C#, or Go - and it's very, very, very hard not to write sloppy C++.

Stratonesia wrote:A few of the softwares you have on your PC might be written in C++. And that's just for Windows PCs; Linux PCs often have a hundred times more.


Both Linux and Windows platforms have tons of C++. Linux certainly doesn't have "hundred times more", and probably doesn't have more than Windows because most of the standard userspace tools in Windows are written in C++ whereas in Linux you're more likely to find C or a scripting language instead.




In 99% of cases, whatever you're doing with C++, is better done with another language. And I say this as somebody that has written hundreds of thousands of lines of C++. Between Rust, Go, Typescript, and C#, you can find an appropriate language and environment for nearly all use-cases you're likely to encounter.
Last edited by Roavin on Tue May 02, 2023 8:55 am, edited 1 time in total.
Helpful Resources: One Stop Rules Shop | API documentation | NS Coders Discord
About me: Longest serving Prime Minister in TSP | Former First Warden of TGW | aka Curious Observations

Feel free to TG me, but not about moderation matters.

User avatar
Dimetrodon Empire
Minister
 
Posts: 2910
Founded: Sep 21, 2022
Left-Leaning College State

Postby Dimetrodon Empire » Tue May 02, 2023 9:46 am

The Blaatschapen wrote:We might lock, move or merge this thread

Isn't NSG the place where anything (within reason and the site rules) of the real world can be discussed?

I know this is not a coding site but IMHO, it doesn't make sense why it would be unacceptable on this forum, unless another forum is made for things like this.
Flag by someone named AdmiralRA on Reddit. (No, I don't have a Reddit account)
Proud Socialist. Bisexual.From the river to the sea
████████████
████████████

George Orwell wrote:Every line of serious work that I have written since 1936 has been written, directly or indirectly, against totalitarianism and for democratic socialism, as I understand it.

Citizen & Deputy Speaker of The Rejected Realms; Scout in the Rejected Realms Army

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Tue May 02, 2023 9:47 am

Roavin wrote:The tutorial is not the worst I've seen, but has the typical tutorial issue in which there's too much focus on syntax and not enough on best practices, which a language like C++ desperately needs.

I am very sorry. As I said earlier, I am a newbie and I could not find a better manual at the time I wrote the introduction.
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Tue May 02, 2023 9:53 am

Dimetrodon Empire wrote:
The Blaatschapen wrote:We might lock, move or merge this thread

Isn't NSG the place where anything (within reason and the site rules) of the real world can be discussed?

I know this is not a coding site but IMHO, it doesn't make sense why it would be unacceptable on this forum, unless another forum is made for things like this.

Of course. I bet there are C++ coders on varying levels on this site. They certainly can share their creations or answer questions about the benefits of C++'s new features in latest revisions here.
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Farnhamia
Game Moderator
 
Posts: 112541
Founded: Jun 20, 2006
Left-Leaning College State

Postby Farnhamia » Tue May 02, 2023 11:28 am

Stratonesia wrote:/bump

:eyebrow: We don't do bumps here.
Make Earth Great Again: Stop Continental Drift!
And Jesus was a sailor when he walked upon the water ...
"Make yourself at home, Frank. Hit somebody." RIP Don Rickles
My country, right or wrong; if right, to be kept right; and if wrong, to be set right. ~ Carl Schurz
<Sigh> NSG...where even the atheists are Augustinians. ~ The Archregimancy
Now the foot is on the other hand ~ Kannap
RIP Dyakovo ... Ashmoria (Freedom ... or cake)
This is the eighth line. If your signature is longer, it's too long.

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Tue May 02, 2023 6:57 pm

Farnhamia wrote:
Stratonesia wrote:/bump

:eyebrow: We don't do bumps here.

Sorry
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Northern Socialist Council Republics
Senator
 
Posts: 3761
Founded: Dec 13, 2020
Ex-Nation

Postby Northern Socialist Council Republics » Wed May 03, 2023 12:27 am

The Blaatschapen wrote:-snip-

I do feel that this is perhaps a little to narrow. As far as I know we don't have an active Programming Discussion Thread, and I doubt that C/C++ alone will generate enough discussion to keep a thread active over the medium term.



Roavin wrote:Hi. Been doing C++ professionally for over 15 years.

I did both C and C++ for all of... ah, two years as part of my education. ;p

Based on my limited experience though I agree with the points raised here. Writing C++ projects in my undergraduate years was such a... challenging experience that I don't do it anymore. These days I do my work in Fortran 90 and my course assignments in Python 3.
Last edited by Northern Socialist Council Republics on Wed May 03, 2023 12:29 am, edited 1 time in total.
Call me "Russ" if you're referring to me the out-of-character poster or "NSRS" if you're referring to me the in-character nation.
Previously on Plzen. NationStates-er since 2014.

Social-democrat and hardline secularist.
Come roleplay with us. We have cookies.

User avatar
Huaren Gongsi state
Spokesperson
 
Posts: 194
Founded: Aug 23, 2022
Ex-Nation

Postby Huaren Gongsi state » Wed May 03, 2023 12:32 am

Didn't know you're also into C++ as well!

well for me, I haven't learned much (due to school) but I will learn on my sembreak.
I am also looking for an alternative to visual studio (I know) and is thinking about using notepad++ but yeah.
95.3 on the International Safety Index, 89.7 on the International Development Index, 78.6 on the International Corruption Index

User avatar
United Calanworie
Technical Moderator
 
Posts: 3751
Founded: Dec 12, 2018
Democratic Socialists

Postby United Calanworie » Wed May 03, 2023 12:33 am

Huaren Gongsi state wrote:Didn't know you're also into C++ as well!

well for me, I haven't learned much (due to school) but I will learn on my sembreak.
I am also looking for an alternative to visual studio (I know) and is thinking about using notepad++ but yeah.

Jetbrains offers student licenses, so you could get a copy of CLion for free!
Trans rights are human rights.
||||||||||||||||||||
Discord: Aav#7546 @queerlyfe
She/Her/Hers
My telegrams are not for Moderation enquiries, those belong in a GHR. Feel free to reach out if you want to just chat.

User avatar
Umeria
Senator
 
Posts: 4423
Founded: Mar 05, 2016
Left-wing Utopia

Postby Umeria » Wed May 03, 2023 3:11 am

United Calanworie wrote:
Huaren Gongsi state wrote:Didn't know you're also into C++ as well!

well for me, I haven't learned much (due to school) but I will learn on my sembreak.
I am also looking for an alternative to visual studio (I know) and is thinking about using notepad++ but yeah.

Jetbrains offers student licenses, so you could get a copy of CLion for free!

Emacs is way better.
Ambassador Anthony Lockwood, at your service.
Author of GAR #389

"Umeria - We start with U"

User avatar
Stratonesia
Ambassador
 
Posts: 1015
Founded: Sep 27, 2022
Psychotic Dictatorship

Postby Stratonesia » Wed May 03, 2023 8:01 am

Umeria wrote:
United Calanworie wrote:Jetbrains offers student licenses, so you could get a copy of CLion for free!

Emacs is way better.

Oh s██t, it's the Editor War all over again.
◁⁋ਧ‿◥▷
Welcome to the nation of STRATONESIA!
▌ᐳᐸ▜
Where milk and honey are plentiful!
 ╯w╰ 
Ay, ay! (May God of Ultra protect this nation!)

Hail Stratonesia! Praise Be to Ultra!
No, that's not news headlines.
So long as the audience thinks that "seeing is believing," there's no limit to the number of tricks I can pull off!

User avatar
Racoda
Technical Moderator
 
Posts: 579
Founded: Aug 12, 2014
Democratic Socialists

Postby Racoda » Wed May 03, 2023 10:32 am

Umeria wrote:That last line isn't going to print - cout only writes to stdout after a newline.

Also if you want you can put "using std::cout;" at the top so you don't have to write "std::" every time.

A program ending normally (vs segfaults etc.) will flush its output buffer.
I didn't want to go through the standard, so here's a secondary source: [...], or program termination forces a call to std::cout.flush().


Umeria wrote:
United Calanworie wrote:Jetbrains offers student licenses, so you could get a copy of CLion for free!

Emacs is way better.

As an extendable basis ("OS") for an IDE, it's awesome. You just need to change the stupid default editor keybinds. Modal editing FTW, and is also a win for your fingers.
Hell, I'd prefer using ed over raw Emacs.
Ed is the standard text editor.

Acting as a player unless accompagnied by mod action or reddish text
Any pronouns

User avatar
The Black Forrest
Khan of Spam
 
Posts: 59104
Founded: Antiquity
Inoffensive Centrist Democracy

Postby The Black Forrest » Wed May 03, 2023 10:34 am

Umeria wrote:
United Calanworie wrote:Jetbrains offers student licenses, so you could get a copy of CLion for free!

Emacs is way better.


Wow. Emacs is still around. I would use it if the other choice was VI.
*I am a master proofreader after I click Submit.
* There is actually a War on Christmas. But Christmas started it, with it's unparalleled aggression against the Thanksgiving Holiday, and now Christmas has seized much Lebensraum in November, and are pushing into October. The rest of us seek to repel these invaders, and push them back to the status quo ante bellum Black Friday border. -Trotskylvania
* Silence Is Golden But Duct Tape Is Silver.
* I felt like Ayn Rand cornered me at a party, and three minutes in I found my first objection to what she was saying, but she kept talking without interruption for ten more days. - Max Barry talking about Atlas Shrugged

Next

Advertisement

Remove ads

Return to General

Who is online

Users browsing this forum: Autumn Wind, Bienenhalde, Cyptopir, Deblar, Emotional Support Crocodile, Ferelith, Google [Bot], Hekp, Jerzylvania, Nippon-Nihon, Port Carverton, Socalist Republic Of Mercenaries, Stratonesia, Thermodolia, Uvolla

Advertisement

Remove ads