• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Updating using delta time is usually not necessary in Flash applications because framerate is fixed.

In Flash you can set the frame rate to whatever you want. 12fps, 24fps, 30fps, 60fps or whatever.

The problem is that even though you can fix the frame rate to those rates, if it's a browser game/application, then it's going to fighting for resources with all the other flash ads and complex JS/ajax on the web page. So even though you fixed the frame rate to 30fps, depending on what's going on in the web page and the speed of the user's computer, your Flash game/app might only achieve 12-20 fps and have all the object movement in the game appear to go in slow motion.

Speaking as someone who's created several dozen Flash and web games over the last 7-8 years, you want to use time-based (delta) movement for most of your game objects. This way objects move at a consistent speed for the most part regardless of how fast or slow the user's computer is. If the user has a fast computer, then it simply makes the movements more smooth, but they'll go the same speed as the slower computer.

You still will want to add some caps though. For example, if the frame rate temporarily stutters for a second or two, you don't a spaceship "popping" clear across the screen. So you'll want to add a movement cap, so the spaceship can never move more than 100 pixels (or whatever distance) in a single frame update regardless if there is a pause and the game doesn't update the frame for a second or two.

Using fixed frames is only recommended if the hardware is fixed (like a console or closed mobile device). Otherwise it's recommended to use time-based updates and adding some caps to control sudden fluctuations.
 

bubnbob

Banned
Can we discuss web languages here? I have a JavaScript/jQuery question that I'm hoping someone can answer or shed light on.
 

Hari Seldon

Member
I started reading some tutorials on Ruby on Rails. Should that be the starting point into getting into web apps? I really love how easy it makes creating a data model integrated with a database almost transparent to the programmer. How far does just learning Ruby on Rails take you? Do you still need to learn javascript and ajax or whatever?
 

Zoe

Member
I started reading some tutorials on Ruby on Rails. Should that be the starting point into getting into web apps? I really love how easy it makes creating a data model integrated with a database almost transparent to the programmer. How far does just learning Ruby on Rails take you? Do you still need to learn javascript and ajax or whatever?

Unless you want to constantly make postbacks to the server, you should look into JS and AJAX so you can implement some things client-side.
 

Sqorgar

Banned
I'm also curious about the people suggesting functional languages before C++. If a novice programmer's career goals are to work in the game industry, wouldn't it be in their best interest to start out with C++ or a C++ like language?
I'd say that to be an excellent programmer, you need to have spent some quality time with a functional programmer. But if you have extensive experience with imperative languages, there's a lot of stuff you must unlearn before functional stuff makes sense. If you start with functional languages, the learning curve is smoother and you can transition into imperative languages later with ease and be better at them. Also, in the multi-core future, functional languages will become the norm as they are better suited to concurrency (like Clojure or Scala). Might as well make the jump sooner than later.

That being said, new programmers who want to do something specific, like make games, will be better off with a language in which that is easily possible and has lots of community resources (JavaScript with Canvas, C# with XNA, Java, Objective-C for OS X/iOS, and C/C++ with Direct X/OpenGL)

What do you mean? I can understand disliking C++. As someone who has used it extensively for the past few years, I have my own personal grudges against it. But, I don't see how it would make someone a worse programmer.
C++ is a language which allows you to write BAD code. Thanks to operator overloading, you can end up with non-idiomatic code (like the way input streams are handled - VAR >> cout?). Templates are almost impossible to use without making your code look like someone barfed on it. And if you end up doing anything large scale, you need to do some very non-obvious things or you'll end up recompiling the entire project every change. And the STL library is complete crap.

The C++ code that I worked with in the game industry was an abomination. It had the worst implementation of smart pointers I've ever seen, and used things like constructors and destructors to perform critical behaviors, such that declaring a variable would be enough to modify the game state. It used templates of templates of templates to the point where the compiler would crash if you tried to declare one using the wrong types of variables - not to mention that it was an unreadable mess. And the entire game had to be recompiled ever time, taking about 15 minutes each time. And a lot of these things were taken from books like Effective C++ wholesale, without understanding what they meant or how they were intended to be used.

Most languages make it possible to write bad code. C++ is the only language I've ever seen where it is easier to write bad code than good.
 

Misguided

Banned
Only the document class gets direct access to the stage supervariable I believe.

But I'm doing this code in the document class file. I'm also getting this error for things like addEventListener and my parameters to make functions with (onEnterFrameHandler, onMouseUpHandler, etc.).
 

Haly

One day I realized that sadness is just another word for not enough coffee.
The only thing I can think of is that you're somehow calling those functions/lines of code before your document class is actually added to the stage.
 
Woohoo, just wanted to celebrate finally getting an Oath process to work for my mobile app. That was a pain in the ass!

My goal is to make a FantasySports app that'll be able to get information about your yahoo fantasy team. Really, it's just a good way to get further into mobile development now that I'm out of school and preparing to start my job.
 

Spoo

Member
C++ is a language which allows you to write BAD code. Thanks to operator overloading, you can end up with non-idiomatic code (like the way input streams are handled - VAR >> cout?). Templates are almost impossible to use without making your code look like someone barfed on it. And if you end up doing anything large scale, you need to do some very non-obvious things or you'll end up recompiling the entire project every change. And the STL library is complete crap.

The C++ code that I worked with in the game industry was an abomination. It had the worst implementation of smart pointers I've ever seen, and used things like constructors and destructors to perform critical behaviors, such that declaring a variable would be enough to modify the game state. It used templates of templates of templates to the point where the compiler would crash if you tried to declare one using the wrong types of variables - not to mention that it was an unreadable mess. And the entire game had to be recompiled ever time, taking about 15 minutes each time. And a lot of these things were taken from books like Effective C++ wholesale, without understanding what they meant or how they were intended to be used.

Most languages make it possible to write bad code. C++ is the only language I've ever seen where it is easier to write bad code than good.

I don't think anyone would deny that C++ is a language where you can write poor code. Frankly, I've been able to write poor code in a lot of languages that would suggest it otherwise impossible -- but it's pretty much always my fault, and I learn from it, and proceed to write better code "next time."

Would it invariably turn every new programmer exposed to it into a BAD programmer? No, at least, not when there's a sense of direction for the learner, and they can be made aware of potential pitfalls. You can certainly argue that that's a real staple of the "C" in any context, and I wouldn't bother trying to disagree.

I can only draw off of my experiences and the experiences of others I know, and while we can tell plenty of horror stories from the land of C that we may not be able to share from other languages, we started out with C, and we grew from our mistakes, and would diligently work to circumvent problems like you describe. I might posit that mathematics is terrible because it's so easy to write a non-nonsensical equivalence (8 = 2), but any mathematician may stop you and say "Oh no, you can't do that, and if you are you need to go back and read the rule-book!"

Bad programmers have their own inherent problems which the language of choice holds no real sway over. They don't investigate the meaning of their code; they copy and paste, play "white-box" programmer all day. If a book they're studying from has a "difficult" section, they skip it. And yes, they will end up writing bad code, and maybe C++ can show association, but by no means does it show causation.

On the other hand; I subscribe to the notion that if you haven't run into the problems that a language like C or C++ can provide for you via "bad programming", you're missing an invaluable opportunity to learn. I haven't forgotten my first segmentation fault, that nearly untraceable null-pointer exception, that unassigned value with garbage data I thought was legitimate, that 99% of the time it works and 1% of the time it doesn't conundrum. All things that might've been circumvented completely if a compiler had caught them, or if the language wouldn't have let me do it in the first place.

But that's not a fight worth leveraging at a language that claims openly these things can happen, or for the new programmer "will" happen. If you don't want them to happen, don't use C or C++. If you're going to use them, make sure you're aware of the lurking problems that can or will occur. If you solve them, you'll be a much better programmer than many I know who have never seen them before, and probably never will.
 

Fersis

It is illegal to Tag Fish in Tag Fishing Sanctuaries by law 38.36 of the GAF Wildlife Act
C++ is like a gun: You can defend your country from the King of France or blow your brains out its your choice.
 

Chris R

Member
C++ is like a gun: You can defend your country from the King of France or blow your brains out its your choice.

One of my professors said something very similar :p He likened it to a shotgun though, and pointed out it is possible to blow your toes off if you aren't careful.
 

LuffyZoro

Member
I've tried to teach myself to program in the past, and recently took a course in Java. However since that's over, my main obstacle in continuing is an inability to think up projects. Is there anywhere that has a selection of projects I could do in (preferably) Python or Java?
 
I've tried to teach myself to program in the past, and recently took a course in Java. However since that's over, my main obstacle in continuing is an inability to think up projects. Is there anywhere that has a selection of projects I could do in (preferably) Python or Java?

There is this for Python. I haven't gotten to it yet because I am still trying to get the fundamentals of programming down.

http://learnpythonthehardway.org/book/

I am currently doing these two sites to help me with the fundamentals... coursea.org and udacity.com
 

Godslay

Banned
Did you find this way more helpful when it came to learning java? I watched some videos earlier this year, but I wasn't able to remember anything from them.

I refresh my Java knowledge from time to time. I recently went through an SCJP book, which was a very good book. 6 is now 7, but I'm not sure if the book has updated yet. This is the book, it assumes you have read through something like HeadFirst Java:

http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060/ref=sr_1_1?s=books&ie=UTF8&qid=1338420701&sr=1-1


My personal favorite in order to learn the language a little more in-depth was the complete reference, which is surprisingly readable and technical at the same time. Additionally, it fills in Java 7 features which the previous book didn't cover:

http://www.amazon.com/Java-The-Complete-Reference-Edition/dp/0071606300/ref=sr_1_1?s=books&ie=UTF8&qid=1338420839&sr=1-1

If you want videos, this series from UC Berkeley is very good, and covers a ton of material. You start at the basics and work with common data structures and algorithms in Java:

http://www.youtube.com/playlist?list=PL4BBB74C7D2A1049C
 
How am I only finding this thread now? GAF holds new things for me every day.

I've got a fairly challenging problem ahead of me.. I need to solve the k-MST problem (find a minimum spanning tree with k vertices, NP-hard) using the Branch and Bound method, in Java. We are supposed to implement the algorithm recursively and I have trouble wrapping my head around how that's supposed to work.
 

Miutsu

Member
I refresh my Java knowledge from time to time. I recently went through an SCJP book, which was a very good book. 6 is now 7, but I'm not sure if the book has updated yet. This is the book, it assumes you have read through something like HeadFirst Java:

http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060/ref=sr_1_1?s=books&ie=UTF8&qid=1338420701&sr=1-1

This book is GOOD for those who want to prepare for a Java Developer Oracle Certification :) that and doing a lot of mockup tests should get you all setup for the exam.
 

Sqorgar

Banned
Would it invariably turn every new programmer exposed to it into a BAD programmer?
I'm going to stick by my statement that if you learn C++ first, you will learn terrible coding standards that you will ultimately need to obliterate from space if you want to be a decent program. Later, after you have some standards under your belt, then check out C++. Heck, even if you read books like Effective C++, which propose coding standards that are supposed to be good, you'll end up with some abomination barely worth talking about. C++ doesn't just let you shoot your foot off, it actively encourages you to.

I mean, I've seen some terrible code in Java - like embarrassingly terrible - at job doing java servlets about a decade ago. It was written by someone who obviously never programmed before... doing production work! On the other hand, I've worked on teams of experienced (10+ years) programmers working in C++ that made that amateurish Java code look amazing. If you've never done large scale team C++ development, you don't know what horrors C++ really is capable of.

Learn C++ third (or not at all). Never, ever, EVER start with C++. And if you have to write code in it, pretend it is C with objects and ignore STL, templates, operator overloading, and all that crap.
 

Slavik81

Member
C++ is a language which allows you to write BAD code. Thanks to operator overloading, you can end up with non-idiomatic code (like the way input streams are handled - VAR >> cout?). Templates are almost impossible to use without making your code look like someone barfed on it. And if you end up doing anything large scale, you need to do some very non-obvious things or you'll end up recompiling the entire project every change. And the STL library is complete crap.

The C++ code that I worked with in the game industry was an abomination. It had the worst implementation of smart pointers I've ever seen, and used things like constructors and destructors to perform critical behaviors, such that declaring a variable would be enough to modify the game state. It used templates of templates of templates to the point where the compiler would crash if you tried to declare one using the wrong types of variables - not to mention that it was an unreadable mess. And the entire game had to be recompiled ever time, taking about 15 minutes each time. And a lot of these things were taken from books like Effective C++ wholesale, without understanding what they meant or how they were intended to be used.

Most languages make it possible to write bad code. C++ is the only language I've ever seen where it is easier to write bad code than good.
I don't think working with bad code (or even writing bad code) makes people bad programmers. Working with bad code helps people appreciate good code when they work with it. I've worked with some truly terrible code and I wrote some pretty shoddy stuff myself when I started working. The pain of having to maintain that code has definitely influenced me positively.

However, one thing certainly might play into making people bad programmers: C++ provides very little help for behavioural testing. It's easy enough testing leaf methods, but it's a lot of work to actively build seams for tests and C++ demands that you do so if you want to write unit tests for every behaviour on every class.

C++ is like a gun: You can defend your country from the King of France or blow your brains out its your choice.
It's like a gun built from scavenged parts of various other weapons and held together by duct tape.

The defaults are never sensible thus demanding you explicitly undo them (#include guards, explicit, nocopy), there are strange restrictions (cannot forward-declare a typedef, enum or inner class). And, the compilation model in particular is terrible. Compilation is slow and requires lots of effort to keep it from becoming even slower.

C++ is a terrible language. It's unfortunate that it's so useful. I've always wanted to take a look at perhaps switching to python or D.

Learn C++ third (or not at all). Never, ever, EVER start with C++. And if you have to write code in it, pretend it is C with objects and ignore STL, templates, operator overloading, and all that crap.

I really disagree. To go without basic template classes like std::vector would be ridiculous.
 

Bollocks

Member
Also what is up with QT?
Last time(2y ago) you could simply download the sdk and be done.
Now it's bundled with tons of crap.
Why do I have to download 1.7GB to write a win gui application, I don't want the mobile libraries or any other crap that's in there.
Worse, there's an online installer but it's useless since you can't select which packages you want beforehand, so you end up downloading the same files as in the ordinary installer anyway.
Way to ruin your credit QT.
 

Slavik81

Member
Also what is up with QT?
Last time(2y ago) you could simply download the sdk and be done.
Now it's bundled with tons of crap.
Why do I have to download 1.7GB to write a win gui application, I don't want the mobile libraries or any other crap that's in there.
Worse, there's an online installer but it's useless since you can't select which packages you want beforehand, so you end up downloading the same files as in the ordinary installer anyway.
Way to ruin your credit QT.

You don't need to download that stuff. The libraries are just a little further down the page. http://qt.nokia.com/downloads/downloads#qt-lib

And the work they've done on Qt Creator in the past 2 years has been fantastic. I've heard people starting to recommend it even for normal C++ development.
 
Alright chumps here's my opinion about programming languages. I've programmed professionally in the gaming and medical industry.

If you're worried about FPS go with C++ because you don't want a garbage collector to slow you down.

If you're programming in a browser go with Javascript or Actionscript.

If your programming business applications go with C# or Java.

If you're crunching numbers go with Matlab.

If you're crazy enough to write your own language try using Scheme.

If you're learning in a classroom any language is fine, just get out there and do it.
 

Boss Man

Member
I like C++ dudes :(
I do too, but I don't disagree with any of the negative things said about it. I also don't think it should be taught as a first language.

The only thing I disagree with is the notion that you should stay away from it altogether and never learn it. On a personal level, I like the language, but even on an objective level I don't know that it's correct to have that attitude about any language. Even at the very least, you get to see some of those bad practices in action, and get a grasp for things that are possible and why some restrictions on them do exist in other languages.
 

Bollocks

Member
You don't need to download that stuff. The libraries are just a little further down the page. http://qt.nokia.com/downloads/downloads#qt-lib

And the work they've done on Qt Creator in the past 2 years has been fantastic. I've heard people starting to recommend it even for normal C++ development.

I know, I tried that but the installer says it's missing MinGW even though I installed it and the file in question is indeed there.
Also that package lacks Qt Creator, why on earth would they not bundle it if they have separate packages for VS08/10. What's the point?
Overall it's just much more complicated than it used to be.
 

The Technomancer

card-carrying scientician
I think C++ can be fine for a starter to learn as long as you don't immediately introduce them to things like operator overloading and other messy stuff. The way I learned it it was basically treated like C up until we got into using Classes but because C++ does require memory management when you learn it early on it becomes a relief not to have to worry about it in languages like Java, instead of having to try and learn it having gotten used to everything being handled.
 

Sqorgar

Banned
The only thing I disagree with is the notion that you should stay away from it altogether and never learn it. On a personal level, I like the language, but even on an objective level I don't know that it's correct to have that attitude about any language.
I'm not suggesting that people never learn C++ ... okay, I am, but even so, there are about twenty languages I would suggest someone learn BEFORE C++. For instance, you'll learn more about programming by learning FORTH than C++. I can't think of anything C++ can teach you that you wouldn't learn better from somewhere else.
 

usea

Member
I'm not suggesting that people never learn C++ ... okay, I am, but even so, there are about twenty languages I would suggest someone learn BEFORE C++. For instance, you'll learn more about programming by learning FORTH than C++. I can't think of anything C++ can teach you that you wouldn't learn better from somewhere else.
It's the best language for learning how to program in C++.
 

Slavik81

Member
Support for forward declaration of enums was added to C++11.

Unfortunately, that's only with enums of a defined type. And only if you redeclare the type in each forward declaration. And many enums are defined within class scope so you cannot forward declare them. As far as I'm concerned, that addition is useless.

There's no good reason you couldn't write a compiler that accepts the same forward declaration for any type (class, struct, union, enum). Maybe something like
Code:
typename [insert symbol here];
It's just a language deficiency.
 

amrihua

Member
Attending lecture on OpenACC presented by a scientist from Cray Inc. mind blown. What would require 30-70 CUDA lines can be written in ~10 lines. I wonder if it'll run on Intel MIC.

I'll check the site later:
http://www.openacc-standard.org/


Edit:
I see the C++ debate is still going on. There is never a reason and nothing to be gained from learning C++ except maybe how not to design a programming language. It always was and always will be a bad language. I second the previous poster and recommend FORTH. In addition to my previous recommendation of Functional and Logical programming languages such as Haskell, Prolog and Lisp.
 

Datwheezy

Unconfirmed Member
As someone who is looking to get into the game industry mostly focusing on level design in things like UDK/Source/etc, I want to have at least a rough knowledge of a language so that I don't feel completely inadequate and useless in that department. What language would you guys suggest learning? It looks like Unreal Engine 4 is going to be ditching Unrealscript for a mix of a better Kismet system and c++ so i thought that may be a good direction, but I'm seeing a lot of people saying it isn't a good first language to learn. Would learning something like objective-c be more useful (ability to program iOS apps) while getting the basics of object oriented programming down as well? Or something else entirely (lua, java, etc.)? Keep in mind this would be to supplement my level design skills.
 

The Lamp

Member
I'm curious why I have to learn C. As a mechanical engineer, will C overlap with any other engineering fields or be of any use to me? What about C++?
 

smuf

Member
But I'm doing this code in the document class file. I'm also getting this error for things like addEventListener and my parameters to make functions with (onEnterFrameHandler, onMouseUpHandler, etc.).

Sometimes it fucks up even on the document class, you can fix this by adding an event listener (Event.addedToStage) in your class constructor, then accessing this.stage in your addedToStage event handler.
 

IceCold

Member
I'm curious why I have to learn C. As a mechanical engineer, will C overlap with any other engineering fields or be of any use to me? What about C++?

You'll never use it. I know many Engineers who had to learn C++ on their 1st year. By the 4th they had forgotten everything.
 
Could anyone help me with PHP? Was trying to install an old forum system I found and everything works well unless you try to click a link to mark a message for a mod to see. I get a fatal error then. ...But nothing shows up in the error log.

I'd greatly appreciate it. Like, you have no idea how much. :p
 
Visual Studio 2012 RC is out and is looking pretty good. :)

Now's the perfect time to put together a little MVC, Kockout.js and SignalR app I think...
 

SamVimes

Member
Does anyone know a good resource to learn caml? It's mandatory for my programming course but i don't find anything useful online.
 

tokkun

Member
I'm curious why I have to learn C. As a mechanical engineer, will C overlap with any other engineering fields or be of any use to me? What about C++?

I couldn't say about on-the-job use for mechanical engineers, but C is the language to know for research in all engineering fields, since that is what almost all simulators are written in. It's actually a big problem in engineering schools these days that many undergrad programs only teach Java, but graduate programs only want you to use C/C++.
 

jvalioli

Member
You'll never use it. I know many Engineers who had to learn C++ on their 1st year. By the 4th they had forgotten everything.

College =/= work.

I was forced to learn a lot of functional languages in college but I'm not going to use any of them for work for a long time.
I also haven't had to use OOP in college since freshman year and now all my worklife is about that.
 

Spoo

Member
I think academics still treat functional languages poorly -- almost like they are novelties. I've had exposure to Prolog from a discrete mathematics course (something I'm actually not thrilled with, since I would've rather spent my time doing more math in that course), but by and large with the exception of Microsoft's brief "push" for F#, nobody takes them seriously, and without that kind of acceptance you're basically handing people a neat tool that most of them can't use.

You're taught to be a compiler in most programming courses. The "how" is equally important with the "what" or "why" there, and you're seated down with pencil and paper working with C or C++ and trying your best to solve the kind of problems machines are well-suited to, but that functional languages would give their left nut to abstract away from you so you can focus on just solving problems.

So, maybe if you haven't been forced in the position of "being the compiler" (you know they've said that to you at least once) you can engage yourself from the get-go with functional languages, and really develop that skill. On the other hand, I think most programmers who come from the school of thinking like "machines" first will naturally have problems with that level of abstraction. There's also a not-so-subtle reliance upon mathematics with functional languages, such as function composition, which -- if you never really approached programming with mathematics as a primer -- will be confusing.

Many professionals would like to be using functional languages. I remember Carmack in his last keynote saying he wishes ocaml or something could've been the basis for an industry-tough engine, but there were too many logistical problems there; lack of support, and frankly, a lack of people who can even do it.

I'd like to see academics step away from their reliance on C; but in my school at least, a lot of the professors are very old, and it's what they know, and they still see it as the foundational language. I'm stuck between BYU and University of Utah, two schools which are Java schools and go OOP from day-1. That's some change, but it's not enough. I haven't used Python, ever, but maybe it's the right choice, and that will catch on. Right now, I think it's relegated to programming language analysis courses, or electives.
 

usea

Member
At my university Java was used for the 2 intro courses. After that it's pretty much use whatever you want. For some classes like machine learning they will change the language each time the course is offered (last semester it was python). For other classes you can turn in assignments in Java, C++ or C# as long as the professor can compile it. Depends on the teacher and the subject.

There's also a survey of languages class where they do each assignment in a different language, which covers COBOL, lua, python, javascript, C++ and whatever else. Changes each semester, but it's always a wide variety.

Most of the time they're just trying to teach concepts, not languages.
 

Zoe

Member
Visual Studio 2012 RC is out and is looking pretty good. :)

Now's the perfect time to put together a little MVC, Kockout.js and SignalR app I think...

Hmmm...it's tempting to upgrade though I know that's not the brightest idea at the beginning...

Does it come with MVC 3 or 4?
 

Quixzlizx

Member
On learnpythonthehardway, the author basically says in the intro to use Python 2 or not to bother. Is there an absolutely compelling reason for someone starting out to use 2 over 3, or is it mostly what people are used to and the broader module support? It seems more logical to use the newer one when learning from scratch, rather than having to relearn things when the newer version eventually becomes the standard.
 

Tiktaalik

Member
...And if you have to write code in it, pretend it is C with objects and ignore STL, templates, operator overloading, and all that crap.

I'm going to chime in here and agree with Sqorgar that C++ can be very dangerous and can be used to write some absolutely idiotic code. From my experience in the games industry I've largely seen the quoted advice above followed. C with a peppering of useful C++ features, but lots of stuff ignored and use of certain elements of the language strongly discouraged. I think lots of games companies ignore the STL and instead roll their own String and Map, Vector and List classes.
 
Top Bottom