Onionfarms.online: The Geopolitical and Current Events Forum

All are welcome.

If you have a technical issue with Xenforo: Please post your request in the Town Square or the Talk to Staff (If you want more privacy) and one of us will check it out to address your concerns.Thank you for all your forum contributions (Owner - Onion Null).


Community Featured Submissions:

Programming Thread

Each step I take to learn COBOL I feel the Monster energy zero ultra, far greater than any televangelist could provide, coursing through my veins. I am Invincible. I am BoomerPrime. You will learn COBOL the true language spoken by the gods and will like it. You will wear corduroy. You will compliment my Minions memes. You will... Huh? My bad. Last thing I remember was learning COBOL then I don't know what took over me.
 
Stop writing C++ programs that don't handle invalid input or I will strangle you in your fucking sleep.
C++:
unsigned idx = 0;
//about 30 lines of code for writing to standard output

//save std::cin's current exception mask because this code is part of a library
const std::ios_base::iostate cin_orig_mask(std::cin.exceptions());
//throw an exception if std::cin's badbit is set, since it signifies an irrecoverable stream error
std::cin.exceptions(std::ios_base::badbit);

while(true){
    std::cout << "Enter the number corresponding to your choice: ";

    try{
        std::cin >> idx;
    } catch(...){
        //restore the original exception mask
        std::cin.exceptions(cin_orig_mask);
        //unset badbit
        std::cin.clear();
        throw;
    }

    //check if failbit was set
    if(std::cin.fail()){
        std::cerr << "Invalid input\n";
        //discard the contents of the input buffer
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        std::cin.clear();
    } else if(idx <= dataset_list.GetArray().Size()){
        break;
    } else{
        std::cerr << idx << " does not correspond to any of the datasets listed\n";
    }

}
 
Stop writing C++ programs that don't handle invalid input or I will strangle you in your fucking sleep.
C++:
unsigned idx = 0;
//about 30 lines of code for writing to standard output

//save std::cin's current exception mask because this code is part of a library
const std::ios_base::iostate cin_orig_mask(std::cin.exceptions());
//throw an exception if std::cin's badbit is set, since it signifies an irrecoverable stream error
std::cin.exceptions(std::ios_base::badbit);

while(true){
    std::cout << "Enter the number corresponding to your choice: ";

    try{
        std::cin >> idx;
    } catch(...){
        //restore the original exception mask
        std::cin.exceptions(cin_orig_mask);
        //unset badbit
        std::cin.clear();
        throw;
    }

    //check if failbit was set
    if(std::cin.fail()){
        std::cerr << "Invalid input\n";
        //discard the contents of the input buffer
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        std::cin.clear();
    } else if(idx <= dataset_list.GetArray().Size()){
        break;
    } else{
        std::cerr << idx << " does not correspond to any of the datasets listed\n";
    }

}
If people feed my programs garbage, then they should expect garbage output.
:tantrum:
 
Stop writing C++ programs that don't handle invalid input or I will strangle you in your fucking sleep.
C++:
unsigned idx = 0;
//about 30 lines of code for writing to standard output

//save std::cin's current exception mask because this code is part of a library
const std::ios_base::iostate cin_orig_mask(std::cin.exceptions());
//throw an exception if std::cin's badbit is set, since it signifies an irrecoverable stream error
std::cin.exceptions(std::ios_base::badbit);

while(true){
    std::cout << "Enter the number corresponding to your choice: ";

    try{
        std::cin >> idx;
    } catch(...){
        //restore the original exception mask
        std::cin.exceptions(cin_orig_mask);
        //unset badbit
        std::cin.clear();
        throw;
    }

    //check if failbit was set
    if(std::cin.fail()){
        std::cerr << "Invalid input\n";
        //discard the contents of the input buffer
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        std::cin.clear();
    } else if(idx <= dataset_list.GetArray().Size()){
        break;
    } else{
        std::cerr << idx << " does not correspond to any of the datasets listed\n";
    }

}
If people feed my programs garbage, then they should expect garbage output.
:tantrum:
lol calm down
 
1611733366557.png
 
Each step I take to learn JavaScript I feel the Estrogen, far greater than any HRT pill could provide, coursing through my veins. I am Invincible. I am TrannyPrime. You will learn JavaScript the true language spoken by the gods and will like it. You will wear programming socks. You will compliment my feminine penis. You will... Huh? My bad. Last thing I remember was learning JavaScript then I don't know what took over me.
web programming is cancer that ruins your brain's logical functions
 
Programming is more fun than I thought it would be but it still makes me want to kill myself every once in awhile. Then again I only use MATLAB which is mostly just a glorified calculator lol.
 
3. You will learn to approach things logically with formal methods.
Indeed, and that's a good thing, because the alternative is Josh.
lolcoder.png


Not converting input to lower case letter and then do a switch/if on all states (the entire lists of states isn't even that long.)
In Sig's defense, he was really bored that day.

Programming is more fun than I thought it would be but it still makes me want to kill myself every once in awhile. Then again I only use MATLAB which is mostly just a glorified calculator lol.
MATLAB is pretty good for matrix and differential equation/signal processing stuff. But yeah, it's obvious where their language designers spent their time. It does have some GUI stuff and basic OOP stuff in there too, but I've never met a non-insane person who ever used them. Unless you want MATLAB for its (fast!) matrix/FFT/etc stuff, then Python is usually the better choice for more general-purpose scientific computing anyway.
 
MATLAB is pretty good for matrix and differential equation/signal processing stuff. But yeah, it's obvious where their language designers spent their time. It does have some GUI stuff and basic OOP stuff in there too, but I've never met a non-insane person who ever used them. Unless you want MATLAB for its (fast!) matrix/FFT/etc stuff, then Python is usually the better choice for more general-purpose scientific computing anyway.

Yeah it is a really good diff eq solver and handles matrices and vectorization insanely well. But when using it to create applications or having it interface with physical components its really unoptimized for doing that efficiently and effectively.
 
>friend regularly asks me for help with his C++ homework
>last week, he had to write a program that stores each month's rainfall in an array
>told him to make an std::array<const char*, 12> for the month names and an std::array<double, 12> for the actual rainfall data
>fast forward to last night
>"hey I have to modify the program I wrote last week so that it sorts the rainfall from least to most"
>tell him to replace the two arrays with a single array of std::pairs, write a comparison function (he doesn't know about lamda functions), then call std::sort
>"why would I do that"
>"I'm just adding two more for loops"
>fast forward to right now
>he still hasn't gotten it to work and the assignment is now overdue
Why do people ask for help and then ignore what you tell them?
 
I write in malbolge, anything wrong with that?
The only thing I know about Malbolge is that there was an episode of Elementary (y'know that infamous Sherlock Holmes reboot with Lucy Liu as Watson) where Sherlock kept name-dropping Malbolge as a 'leet hacker/coding language' and it was a plot point for something. I thought that was exceptionally gay, and so Malbolge is therefore gay.
 
I want to learn C and C++ just to see how much I can do with stuff related to Quake Engine Games, and torturing my Windows XP Virtual Machine with ridiculous programs.
 
Back
Top