• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Kyall

Is C++ too complex?

122 posts in this topic

[quote name='Hodgman' timestamp='1354288648' post='5005710']
No, exceptions in C++ are a fundamentally different construct than exceptions in Java, they just happen to share terminology.
[/quote]
No, I kid you not. The Java exception runtime in gcj [i]is[/i] the C++ exception runtime in g++. They do not just share terminology. They are the same runtime library. Java and C++ exceptions are conceptually and fundamentally identical.
0

Share this post


Link to post
Share on other sites
[quote name='Bacterius' timestamp='1354279223' post='5005669']
...
[/quote]


Oh lord, another 'goto' topic.

Most production code really isn't very nice to look at. Just look at the source code for Doom 3 ([url="https://github.com/TTimo/doom3.gpl"]https://github.com/TTimo/doom3.gpl[/url]) It's not exactly the most beautiful code out there, but it gets the job done, and in the end that is what matters most. And as a side note, the Doom 3 source code is littered with 'goto', so you can certainly use it. But as with any loaded weapons... handle with care.
0

Share this post


Link to post
Share on other sites
Most individual things in C++ are useful (to someone, sometimes) and the language would be worse off if they weren't there, because they address a real problem with the rest of the language. The real issue is that there are so many of those problems, and a zillion features are needed to fix them, and the language as a whole is so complex and ugly. I figure it's just what you get when you add features piece by piece over decades, insist on near-total backwards compatibility for everything, and your starting point is the C language. So no, you can't avoid the bad stuff by not using certain features; the bad stuff is everywhere, even in C++ code that is valid C.

The very worst thing about the language is how it makes undefined behavior nearly impossible to avoid (Sicrane noted one instance, but there are a lot). Even if that kind of lack of safety was necessary for C++'s goals of best possible optimization and wide platform support, basic operations should be safe by default, and the coder should explicitly ask for the unsafe version in the <0.1% of situations when that is actually beneficial. Likewise, most things in the language should be const by default, and explicitly marked as mutating/mutable when necessary. That ties into how metaprogramming should be a matter of simply writing a bunch of code that has a const result, easy enough for most programmers to do, instead of the template metaprogramming hell of C++. Behavior of value/reference/move semantics should be visible and obvious. Name lookup should be fixed to be way simpler, and to work the same in different situations.

I haven't used D, but based on what I have read about it, it gets most of the things right which C++ gets wrong.
0

Share this post


Link to post
Share on other sites
So for a future of clean c++ code, there doesn't necessarily need to be a complete revision of the language, but a definition of a sub set of the language that is the best practice usage. Is there a good wiki describing this available, or should I learn Dlang and then figure out the c++ equivalents and preference that equivalent subset in my coding?
0

Share this post


Link to post
Share on other sites
[quote name='Kyall' timestamp='1354330948' post='5005926']
So for a future of clean c++ code, there doesn't necessarily need to be a complete revision of the language, but a definition of a sub set of the language that is the best practice usage. Is there a good wiki describing this available, or should I learn Dlang and then figure out the c++ equivalents and preference that equivalent subset in my coding?
[/quote]

I would argue that the variety of styles and idioms used for the variety of C++ libraries, as well as the disjointed tacking on of syntax makes clean C++ code not just a simple subset of best practices for non-trivial code. I mean sure, you can make it more clean, but not *clean*.

As for D... I wouldn't bother. If it was going to take off, it would've done it by now.
0

Share this post


Link to post
Share on other sites
I've been learning D today, and I would like to put forward a request that someone make a D board on these forums. Just because the forums on dlang have so many boards, and so few replies. D for dead as a dodo I guess. I reckon using D for game programming where the D is built on top of c/c++ would be a move worth trialing just because it'll reduce bugs and it suits game programming a little better. I'm trying to say this without insulting myself and other game programmers, but yeah... deadlines vs code quality; getting paid vs writing good code. It has a few interesting features, but the main part will be getting the benefits of all it's scope features & the gc. Normally I would be hating on a gc, eating up cycles when and grrr/rage. But it has the feature that you can use malloc to get around the gcc, and make a custom allocator which also gets around the gc as well as lets you use static memory for short-life objects (or everything if you're not scared of code that should crash, not crashing). Actually come to think of it I wouldn't mind turning off the gc altogether. Could that can't work without GC, shouldn't work, ever.

Anyone have any experience with getting C++ and D to work nicely together? Edited by Kyall
0

Share this post


Link to post
Share on other sites
There's no point in making a D forum here. Traffic would be abysmal.

D is an interesting but failed experiment in trying to make C++ suck less. Its lack of adoption and toolchain maturity is a serious problem, but not nearly as serious as the fact that moving to D from C++ is a painful process. If you're going to undergo the misery of converting massive legacy codebases to a new language, you may as well pick one that's better than D.
2

Share this post


Link to post
Share on other sites
You are going to laugh me right off the site but yes C++ is way too complex.

I thought I would explore the world of C++ programming. I managed to find the NeHE site where they have tutorials written in VC++ then translated into every know flavor.
Since I want my project to be cross platform I decided to take the first tutorial and compare VC++, Linux, and Mac. losw and behold there are like 3 different Linux translations that appear throughout the 48 tutorials, another discussion. So I copied the code into a spreadsheet and low and be hold not a single line of the 3 sources line up. I do not want to consider how the differrence between Intel and ATT syntax will further my confusion.
Now granted I come from a construction and accounting background, but I got to tell you every wall in the in the world since the invention of sheet rock is built with wall studs 16" on center. Every one states that C++ is a tool box well your tool box is cluttered.
On the otherhand I axcept that what you as programmers do is art and for that I am amazed. Andas such, as artists you all have your own style. Monet's little dabs and Picasso's odd balance. But, they all used the same brushes, the same base colors.
So I am more confused as ever after this mornings work. How can Qt and Code::Blocks, whom I thought would be the best tools for my project, can they claim to...code once, code less, deploy everywhere...with such differences in coding rules and styles? So I am starting to believe my 2 programer friends when they said I am in over my head. And, after posting on 5 forums and being "viewed" by over 200 people to have only one respond has given me the insight that I am not welcomed in this particular sandbox.
But I will figure this out and my 3 year old will get his learning game.
0

Share this post


Link to post
Share on other sites
It's not really hostility if you don't get more replies. We have this unfortunate thing of not posting replies when we're not completely confident we know this answer. So yeah... the best way to get help from programmers is asking directly....
1

Share this post


Link to post
Share on other sites
[quote name='NightCreature83' timestamp='1354278416' post='5005667']
[quote name='Karsten_' timestamp='1354273814' post='5005651']
The parts of C++ that should generally be avoided (unless necessary) is misusing C stuff rather than the C++ alternative.
For example fopen, malloc and goto could be replaced with ifstream, new (with smart pointer) and exception respectively.

Whilst the ability to use classic C stuff seems to make the language complex, I actually prefer the way C++ extends rather than reinventing the whole language again from scratch (such as C#).

Kindof like OpenGL is seemingly quite hard to learn for new developers because it still has all the old stuff rather than dropping it all and starting with a brand new graphics API.
[/quote]
how would you replace the goto in this bit with an exception
[code]
for (int bar =0; bar < 100; ++bar)
{
for(int foo = 0; foo < 100; ++foo)
{
if (foo * bar == 100)
{
goto loopBreak;
}
}
}

loopBreak:
printf("%d", 100);
[/code]

The code I am presenting is not doing something usefull at all to be honest but imagine a difficult calculation going on over a grid in which if a certain condition is met you need to break out of both loops and continue the rest of the algorithm with the results already calucalted?
[/quote]

[code]
for (int bar =0; bar < 100; ++bar)
{
for(int foo = 0; foo < 100; ++foo)
{
if (foo * bar == 100)
{
foo = 100;
bar = 100;
continue;
}
}
}
printf("%d", 100);
[/code]
-3

Share this post


Link to post
Share on other sites
I'm getting more and more into this D thing. An experienced programmer can write an interface and a unit test using the tools already embedded in the language, then get a junior to build the interface to pass that unit test. As only a mid level programmer myself I'm not the authority on this; but this gets rid of thick skulled juniors (like I was) doing things wrong right?
0

Share this post


Link to post
Share on other sites
I'm thinking you need a programming application test instead.... A really simple one. That contains a loop requirement...
-1

Share this post


Link to post
Share on other sites
C++ [i]is[/i] too complex. Anyone who doesn't (or isn't willing to) admit that probably hasn't worked with the language enough to realize that or is delusional. Try writing your own parser for the language... But that doesn't mean one can't use it in a manageable way. Of course, I'm speaking mostly from a language implementer's point of view, but many language complexity issues come to light to every day programmers through things like syntax and language semantics.

I recently graduated with a BS in computer science and I have a few friends who are lower classmen and they're now looking to get jobs and I have often looked over their resumes to at least do a bullshit check on it. My school teaches Java as the first language (gross...), but eventually forces people to learn C or C++ through data structures classes and a dash of functional programming in a compilers and languages class. Almost everyone [u]LOVES[/u] Java and hates C, C++, and OCaml. Anyways, some people become what I would call "Syntactically proficient" in C++, where I would trust them to implement very small pieces of code or features. Nothing more. It amazes me the audacity people have when they claim their proficiencies in particular languages, even though they have absolutely [u]ZERO[/u] credibility in making them. My favorite, of course, is the listing of languages they know and they write something like:

[quote]Languages Known:[list]
[*]C++ (Expert)
[*]Java (Expert)
[*]Python (Intermediate)
[/list]
[/quote]

I know of only a [i]handful[/i] of names in the world (We're talking like, 5-10 people) which could be on such a resume that could claim [b]EXPERT[/b] in a language as complex as C++... Anyways, this turned out to be more of a rant. The reason why we (game developers) stick with such a complex and nasty language is for many different reasons. For me, one of the biggest reasons is simply [i][b]it's the best we've got for the job we have[/b].[/i] When you need to write high performance code, C++ surely can let you do that. If you need very precise control of hardware, C++ can let you do that. But be wary, if you need both of those, you will likely need to know what you're doing, and C++ does not spare those who don't know what they're doing.

My advice for people who want to know C++ more intimately:[list=1]
[*]Write more C++ code and [u]READ[/u] other people's C++ code. Figure out what you do and what they do. Why are you the same or different?
[*][b]IMPLEMENT YOUR OWN COMPILER![/b]
[*][b]LEARN ABOUT LANGUAGE DESIGN![/b]
[*]Learn other languages.
[*]Read the C++ language standard.
[/list]

I put 1 up first since I think it's most easily done by the vast majority of people. 2 and 3 though I think really lets you understand some of the fundamental issues that drive the decisions the C++ language committee has to make. You also begin to understand why entire features are designed the way they are in terms of semantics and syntax. It also helps you put into perspective other programming languages (sure helped me). The last point, isn't really going to be helpful if you aren't already pretty proficient in C++ and programming language design issues. In fact, it may be of very little help to anyone unless you're interested in implementing a C++ compiler.

*Edit*
I should clarify my suggestion #2: Implement your own compiler for a simple, object oriented language. [url="http://theory.stanford.edu/~aiken/software/cool/cool.html"]COOL[/url] perhaps. Implementing your own C++ compiler would be a herculean task. It takes teams of experts to implement one. Edited by snowmanZOMG
1

Share this post


Link to post
Share on other sites
[quote name='snowmanZOMG' timestamp='1354529055' post='5006558']
*Edit*
I should clarify my suggestion #2: Implement your own compiler for a simple, object oriented language. COOL perhaps. Implementing your own C++ compiler would be a herculean task. It takes teams of experts to implement one.
[/quote]
Thank god for that clarification, I was starting to wonder if implementing your own C++ compiler was par for the course [img]http://public.gamedev.net//public/style_emoticons/default/blink.png[/img]
0

Share this post


Link to post
Share on other sites
The way I see it is that it (C++) is only as complex as you make it. C++ has a lot to offer, but then there is no requirement to use it all. If anything, I see far too many coders who just go crazy with using as many c++ features as they possibly can. I many cases I would guess it is (again) simply because 'they can'. If they 'should' is a whole different story. I mostly code C and use C++ features where it makes my life a little easier. But for the most part it's C, unless there is a good reason not to.

I would suggest you not to waste time on D. It's been around for some 6+ years now, and I am doubtful you'll find much work in that area, if ever.

@whtemple1959: Just start easy with some very simple programs. Try to stick to the simple things in the beginning, using as few keywords as possible. Using your analogy, draw stick figures to familiarize yourself with the tools. But keep coding, even if it is the most simple things. Like doodling. In time (depending how much time you spend) you'll pick up the basics soon enough. As far as the tools go, don't worry about them. Install QT.. or MingW. But the only thing you need from them is to make them compile a program. If you get that working, you're good to go. All you need to focus on right now is making small programs. Here are some links for you:

[url="http://www.cplusplus.com/doc/tutorial/"]http://www.cplusplus.com/doc/tutorial/[/url]
[url="http://www.cppgameprogramming.com"]http://www.cppgameprogramming.com[/url]

I haven't look at them closely but I am sure you can find others later.
Learning to walk before running is important.

Also, If you want to be inspired, have a look here on what others have done:

[url="http://www.pouet.net"]http://www.pouet.net[/url]


Hope it helps.
0

Share this post


Link to post
Share on other sites
You really need to design and plan your code with C++, and preferably document it, it's all too easy to fall into the trap of "write only code" that no-one understands, or can read.

C++ is complex, probably too much so, as someone said (I think about C++11), it's like a commitee designing an octopus by nailing 4 legs on to a dog. Backwards compatibility is the killer though (but obviously that is one of its main strong points).
0

Share this post


Link to post
Share on other sites
I would not worry about C++11 too much. It'll be years before that version have become widely adopted.
0

Share this post


Link to post
Share on other sites
But it sorts out a lot of the performance problems that the old C++ had, at the expense of adding extra layers of things to remember all at once. There's far too many gotchas and undefined behaviour already, without adding more stuff ;)

If only they could get rid of some of the mistakes they made earlier on and make a cleaner lighter language. Not going to happen though.
1

Share this post


Link to post
Share on other sites
[quote name='LorenzoGatti' timestamp='1354530975' post='5006564']
[quote name='snowmanZOMG' timestamp='1354529055' post='5006558']
C++ [i]is[/i] too complex. Anyone who doesn't (or isn't willing to) admit that probably hasn't worked with the language enough to realize that or is delusional. Try writing your own parser for the language... [/quote]
Your car is too complex. Try disassembling and reassembling it.
[/quote]

Modern cars [i]are[/i] too complex. My mom's car has a big chunk of black-box electronics on top of the goddamn battery.

THE BATTERY. [img]http://public.gamedev.net//public/style_emoticons/default/dry.png[/img]

A 'proper' (read that as 'Khat is a smug, opinionated git') car can be taken apart and re-assembled by a decent mechanic. The new ones try to do way too much and end up not being able to go to from point A to point B because the satellite radio reception isn't good enough to power the flux capacitor or whatever.

C++ is (eeeeeehhhh...) sort of starting to look a little the same. There's a solid core language under it all, but all the stuff that's put on top of that can be a little bizzarre at times.

Even so, if you think about it in relative terms C++ is still good at the jobs that it's good at, so I wouldn't say that it's a huge problem. On the other hand, if a new language comes out right now that does the same job with less BS then I'd say there may be a fight on. Edited by Khatharr
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0