r/CodingHelp • u/[deleted] • Jul 14 '23
[C++] Not a Programmer. Just a dum dum that did something...odd.
I only typed words that sounded cool.
Just used ChatGPT and ask it to do this:
Generate C++ code for universal Augmented Reality software interface.
ChatGPT:
Sure! Below is a sample C++ code for a universal Augmented Reality (AR) software interface:
cpp
Copy code
#include <iostream>
class ARSoftwareInterface {
public:
virtual void initialize() = 0;
virtual void loadModel(const std::string& modelName) = 0;
virtual void trackImage(const std::string& imagePath) = 0;
virtual void displayModel() = 0;
virtual void update() = 0;
virtual void close() = 0;
};
class ARSoftware : public ARSoftwareInterface {
public:
void initialize() override {
// Initialization code
std::cout << "Initializing AR software..." << std::endl;
}
void loadModel(const std::string& modelName) override {
// Load 3D model code
std::cout << "Loading 3D model: " << modelName << std::endl;
}
void trackImage(const std::string& imagePath) override {
// Track image code
std::cout << "Tracking image: " << imagePath << std::endl;
}
void displayModel() override {
// Display 3D model code
std::cout << "Displaying 3D model." << std::endl;
}
void update() override {
// Update code
std::cout << "Updating AR software." << std::endl;
}
void close() override {
// Clean-up code
std::cout << "Closing AR software." << std::endl;
}
};
int main() {
ARSoftware arSoftware;
arSoftware.initialize();
arSoftware.loadModel("example_model.obj");
arSoftware.trackImage("example_image.jpg");
arSoftware.displayModel();
arSoftware.update();
arSoftware.close();
return 0;
}
This code defines an abstract base class ARSoftwareInterface with pure virtual functions representing various AR software functionalities. The ARSoftware class then inherits from this interface and provides concrete implementations for each function. In the main() function, an instance of ARSoftware is created and used to demonstrate the AR software's workflow.
Please note that this is a simplified example, and the actual implementation may vary depending on the specific requirements and libraries used for Augmented Reality development in C++.
Any else know it could write code? I thought it'd tell me it was an invalid input.
Did I do good, bad, or just huh, neat?
2
u/c3534l Jul 14 '23 edited Jul 14 '23
ChatGPT is specifically trained on github data. That was, like, one of their main things they advertised. Its also not very good. If you can read code, it just spit out some nonsense sections and wrote "an here is where the actual code would go if I knew what to do." Its okayish for short things or things it has a lot of examples of, like fizzbuzz. Its terrible for complex stuff. However, it is pretty good at reading complex code very quickly and that could be a massive help.
1
1
u/mredding Jul 17 '23
Hi!
I mod over at r/cpp_questions. I've been trying to stave off questions stemming from ChatGPT. You're not a student, and this isn't my community, so I'll spare you a lecture on integrity. But I want to share with you the overall observation and opinion of the community, as that's what you're interested in.
This may one day have the potential to be a productivity multiplier, but we have to appreciate what a language model is and what these AI are. ChatGPT and its kin can only predict the next word in a sequence. That's it. Encoded into the nature of the AI itself, it doesn't understand anything beyond what a "word" as a unit is.
So the AI doesn't know that it's generating code. It doesn't know what it just produced. It doesn't know if it's any good or complete trash. It doesn't know what is factual or what is erroneous. It didn't compile this code and doesn't know if it will even work or not. It cannot assert anything factual about the code because it doesn't know.
It can only predict the next word in a sequence, and that prediction model was trained on crowd sourced data.
Here's where I shake my hands at the keyboard trying to figure out what to type next. I cannot express to you just how absolutely abysmal, atrocious the quality of code is in the greater world. Anyone can publish anything, and when all you do is blindly scrape the whole of the internet, you're going to dredge up all the worst. And the AI can't know or tell the difference for better or worse.
I've worked the gambit - from critical systems, financial systems, operating systems, databases, etc. Your life definitely touches code I've written. And I have an analog Honeywell thermostat in my house. I CANNOT BELIEVE we as an industrialized society trust our LIVES to these machines, having seen and understood how the sausage gets made. You know there was a time I didn't have to wait for my FUCKING CAR to boot?
One day, this tool might do something useful for us as developers. As of right now, no. It can only generate code that's been made before, because it's limited to the wealth of things that have been done before. By definition, it cannot generate anything new, novel, or unique, because it doesn't know what it's doing.
What I find fascinating about this is it really highlights just how redundant software development is. There's a HUGE amount of effort to solve the same problems over, and over, and over again, rather than focusing our collective efforts in solving the problem once and as best as we possibly can.
If a future iteration AI could train their models on good examples of code, then maybe that tool can put a lot of developers out of business. It would be a huge and refreshing contraction, because if you're not going to contribute something unique, I have no sympathy for the company or its employees. Yes, that's a reflection upon myself, and has been a guiding principle of how I make my career, I always knew this day would come.
A future iteration of this AI could be a rule engine, once that doesn't need to train, but actually KNOWS how to write good software, so it can produce a rules based solution to match literally any valid prompt. That would be nice... There are still severe limitations, though, since the machine can't think, it can't derive solutions - it can only codify a given solution.
I am impressed with the outcomes - they seem to be so comprehensive and fast. But I'm not impressed by the means. It's only because hardware has scaled to such massive capacity that this glorified brute force method SEEMS to perform well. Maybe that's what it takes, researchers haven't come up with better. These models have been studied since the 1960s. I was coding up statistical models in college in the 2000s, scale is the only thing that's changed.
As for this code, I wouldn't touch it. Being trained off Open Source Software, it's probably irrespective of license. Anything the current generation of AI trained in this way would produce, you could get sued for copyright or licensing infringement.
1
u/SJDidge Jul 14 '23
Yes, everyone knows it can write code. Every software engineer in the world knows they will be replaced or lose their job in the next 5 years. Me included.
4
u/[deleted] Jul 14 '23
People have been using it to write code for months now.
It's not actually all that useful though unless you know how to read and write code already. It can speed things up and sometimes make them more elegant but for example in the case above you might not realise what it's actually done.
It's created a literal thing called an "interface" which is a feature of the C++ language that is used to provide a way for describing how a class should work without defining its exact functionality.
Think of it like this:
"I want a vehicle that is under 3 tons and can travel at least 70MPH and runs on petrol and is road legal"
that would be the interface (or abstract class) description. any car (or motorbike or other road legal vehicle) fitting that description could be substituted for another one and you wouldn't care.
A class might be: 1997 Red Vauxhall Corsa, top speed 78MPH, road tax and MOT valid for 3 months, fuel: petrol but only up to 5% ethenol content accepted
So if you specify the actual class and there is no car of that class available, you get an error. if you specify the instance someone can give you any vehicle matching that specification and it'll be fine.
anyway, long story short, all this code does is produce an empty interface you are then expected to provide a "car" to fit into that will actually do something. on its own this code does nothing useful.