I've been taking C++ classes this past week and I have to say it's less complex than I thought it would be. Of course, still making basic programs, but from what people said about it I thought it would take like 500 lines.
The complexity is in memory management and probably some other things.
[QUOTE=Slithersoul;23720156]I've been taking C++ classes this past week and I have to say it's less complex than I thought it would be. Of course, still making basic programs, but from what people said about it I thought it would take like 500 lines.[/QUOTE]
my project is now ~700 lines and it's just the framework of displaying a blank screen and handling different stuff(I haven't even started getting my hands dirty). What you're doing now is nothing compared to the stuff you'll do when you "get into" the object orientated programming that is within c++.
I guess you're just making functions and stuff and calling then within main, which is good for a newborn programmer, which is exactly what those classes will teach you. The rest you will have to learn by yourself by wanting to make something, then making it.
The hell are you using that takes 700 lines to display a blank screen and handle "different stuff" ?
I haven't added content yet but I have an eventhandler, soundplayer and a maploader.
[QUOTE=efeX;23721656]The hell are you using that takes 700 lines to display a blank screen and handle "different stuff" ?[/QUOTE]
It's 670 lines of blank
[QUOTE=Slithersoul;23720156]I've been taking C++ classes this past week and I have to say it's less complex than I thought it would be. Of course, still making basic programs, but from what people said about it I thought it would take like 500 lines.[/QUOTE]
If you're still learning the language, why are you saying "oh hey people said this would be a lot of lines". :geno:
[QUOTE=Elspin;23723333]If you're still learning the language, why are you saying "oh hey people said this would be a lot of lines". :geno:[/QUOTE]
Because non-programmers over-dramatize the complexities of programming. Before I started programming, my friend told me it took "over one hundred lines to make a black box like command prompt" in reference to C++.
[editline]11:30[/editline]
No, people below me. He did not mean a shell nor did he mean a functional application.
He literally meant a black window with white text.
A Hello World would suffice.
[QUOTE=<ToD> Aaron;23725860]Because non-programmers over-dramatize the complexities of programming. Before I started programming, my friend told me it took "over one hundred lines to make a black box like command prompt" in reference to C++.[/QUOTE]
Actually, if he was referring to an actual working shell (Like sh or bash or csh or something) "over 100 lines" is an underestimation.
Of course it's over a hundred lines, but it's often much more than a hundred.
Also, occasionally some of my friends ask me if it's possible to do something in, say, C++, and often the response is "Yes, and it's fairly easy".
But sometimes they ask me to code something way over my skill level or just plain impossible (In practise, not necessarily in theory) and act like I should obviously be able to write something that does just that in a few minutes or so .__.
(Never been asked to trace IPs with a GUI made in Visual Basic, though)
[QUOTE=<ToD> Aaron;23725860]Because non-programmers over-dramatize the complexities of programming. Before I started programming, my friend told me it took "over one hundred lines to make a black box like command prompt" in reference to C++.[/QUOTE]
Well, the black box comes free with any console application, but to be fair, an application that does something useful is likely to be more than 100 lines long, even if it's a console app.
Anyway, OP, 500 lines isn't that much for a real app. I have a Linux daemon written in C that's 770 lines, and a raytracer in C++ that's a little over 5400 lines, and both were written in my own time by me and nobody else. Large-scale applications written over the course of years by teams of full-time developers are often millions or tens of millions of lines.
Different programming languages and coding styles vary in how "dense" they are -- how many lines it takes to express something, or conversely, how much functionality can be implemented in a certain number of lines. I've written thousands of lines of Java that are just trivial getters and setters; on the other hand, a few weekends ago I wrote another raytracer (though a much more rudimentary one) in just 250 lines of Haskell.
[QUOTE=Wyzard;23726204]Different programming languages and coding styles vary in how "dense" they are -- how many lines it takes to express something, or conversely, how much functionality can be implemented in a certain number of lines. I've written thousands of lines of Java that are just trivial getters and setters; on the other hand, a few weekends ago I wrote another raytracer (though a much more rudimentary one) in just 250 lines of Haskell.[/QUOTE]
Yeah... I reckon when people say "this took me 1000 lines of code in C/C++", 500 of those lines are in the headers :v:
[QUOTE=Shammah;23726534]Lines say shit anyway
[code]if (1 == 1)
{
bEnabled = true;
}
else
{
bEnabled = false;
}[/code]
9 lines
[code]
bEnabled = (1 == 1) ? true : false;
[/code]
1 line[/QUOTE]
That's bad practice though. You should use the method that emphasizes what's important.
You could use ? : for printing as in:
[code]
std::cout << "SomeString had " << (SomeString == "SomeValue") ? "an expected value" : "an unexpected value" << ".\n";
[/code]
That's a situation where you'd want to emphasize the fact that you're printing more than the fact that a comparison is being made. In most cases, it's more appropriate to use the longer if/else if/else structure.
[editline]07:40AM[/editline]
But yes, the number of lines you use is irrelevant to the quality of your code.
[editline]08:09AM[/editline]
[code]
if (SomeVariable == SomeOtherVariable) {
// do shit
} else {
// do some other shit
}
[/code]
Looks much nicer than when you put the { on a seperate line and cuts back a bit.
Also:
[code]
if (SomeVariable == SomeOtherVariable)
SomeBoolean = true;
else
SomeBoolean = false;
[/code]
It's better to do that if you're only using a single line after the comparison.
[QUOTE=TehDoomCat;23726484]Yeah... I reckon when people say "this took me 1000 lines of code in C/C++", 500 of those lines are in the headers :v:[/QUOTE]
I doubt that. Some things actually [B]do[/B] take a lot of lines of code, but often it's just bad coding habits that cause this.
[QUOTE=esalaka;23726814]I doubt that. Some things actually [B]do[/B] take a lot of lines of code, but often it's just bad coding habits that cause this.[/QUOTE]
Yeah, I was over-exaggerating.
But it seems the more abstracted your code gets (if you're developing modules for/within a complex API with its own types, objects, lots of namespaces, etc.), the more headers you get. It seems like a lot of the time, everything you declare in a header (variables and functions) get re-declared in the .c[pp] files anyway, in constructor functions and stuff. I don't see the point in having headers at that point, except for when you want overloaded functions...
Like, why should I do this:
[code]#include <variouslibraries>
std::vector<float> objectEngine(int, int, int);[/code]
When I'm going to be declaring the same function in more depth in the code anyway:
[code]#include <that>
std::vector<float> imageProcessor::objectEngine(int ballColor, int yellowGoalColor, int blueGoalColor)[/code]
Then again, I'm just starting out with the C languages. It seems such a long-winded way of programming though.
[QUOTE=TehDoomCat;23727316]Like, why should I do this:
[code]#include <variouslibraries>
std::vector<float> objectEngine(int, int, int);[/code]
When I'm going to be declaring the same function in more depth in the code anyway:
[code]#include <that>
std::vector<float> imageProcessor::objectEngine(int ballColor, int yellowGoalColor, int blueGoalColor)[/code]
Then again, I'm just starting out with the C languages. It seems such a long-winded way of programming though.[/QUOTE]
So that you could include <that> (Which should be "that", actually) in other files and use the function there, too.
The headers tell that the function exists. The source files tell how it behaves. Easy as that.
[QUOTE=TehDoomCat;23727316]Yeah, I was over-exaggerating.
But it seems the more abstracted your code gets (if you're developing modules for/within a complex API with its own types, objects, lots of namespaces, etc.), the more headers you get. It seems like a lot of the time, everything you declare in a header (variables and functions) get re-declared in the .c[pp] files anyway, in constructor functions and stuff. I don't see the point in having headers at that point, except for when you want overloaded functions...
Like, why should I do this:
[code]#include <variouslibraries>
std::vector<float> objectEngine(int, int, int);[/code]When I'm going to be declaring the same function in more depth in the code anyway:
[code]#include <that>
std::vector<float> imageProcessor::objectEngine(int ballColor, int yellowGoalColor, int blueGoalColor)[/code]Then again, I'm just starting out with the C languages. It seems such a long-winded way of programming though.[/QUOTE]
Because it's C/C++, and the 'module' system is pretty shitty.
Compare to C# or Java where each code file is independent and doesn't need to be attached to any header, nor does it need to include any... C++ quickly becomes tedious to work with for newer programmers.
But there's some advantages in the end..
I think my longest project has been 2000 lines, but stuff in python uses less lines than C++
[QUOTE=Slithersoul;23720156]I've been taking C++ classes this past week and I have to say it's less complex than I thought it would be. Of course, still making basic programs, but from what people said about it I thought it would take like 500 lines.[/QUOTE]
Have fun with pointers and references, and memory management, operator overloading, etc.
Those really mess you up as a beginner :v:
[editline]12:25AM[/editline]
[QUOTE=gparent;23761981]But there's some advantages in the end..[/QUOTE]
Of course it has advantages, with headers you can allow other people to use your libraries without ever exposing your methods and algorithms to them.
Almost all languages have that advantage. Join it with obfuscation and then you can't expose your methods and algorithms to them anyway.
[QUOTE=DeanWinchester;23767801]Of course it has advantages, with headers you can allow other people to use your libraries without ever exposing your methods and algorithms to them.[/QUOTE]
Looks like you haven't used C# yet.
In my mind C# is way better then any other language. I have learnt other languages too, so it is not completely biased.
[QUOTE=Programmdude;23769990]In my mind C# is way better then any other language. I have learnt other languages too, so it is not completely biased.[/QUOTE]
Don't worry, I agree and I AM totally biased.
Sorry, you need to Log In to post a reply to this thread.