• 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

Ixian

Member
Off-hand, doesn't getline take some parameters? And is it possible that your file uses different line-endings than what getline supports?
 

dabig2

Member
Off-hand, doesn't getline take some parameters? And is it possible that your file uses different line-endings than what getline supports?

Yeah, getline needs at least 2 parameters I believe.

Should be something like this:

Code:
std::getline(infile, line);
 

usea

Member
It would be helpful if you described the problem you're having. Does the code compile? Do you get a runtime error? Or is the behavior just not what you expect? If you get an error, it would be helpful if you posted it.

At a glance, it looks like getline() is supposed to take some arguments and you're not giving it any. The first step would be to google ifstream.getline().

http://www.cplusplus.com/reference/iostream/ifstream/
http://www.cplusplus.com/doc/tutorial/files/

You could also try googling "C++ read numbers from file"
http://www.bgsu.edu/departments/compsci/docs/read.html
http://www.java2s.com/Tutorial/Cpp/0240__File-Stream/Readingnumbersfromafile.htm
They seem to use >> instead of getline(). I don't know c++ very well so I'm not much help there.

Let's look at your program's structure. Your program has a for-loop inside of a while loop. It's saying "As long as there are more lines in the file, loop 100 times. During each loop, read an entire line of text as a number and put it in an array of numbers." After it reads 100 lines, if there are any more lines in the file it loops 100 more times. Surely this is not what you intended.

What does your polygon.txt file look like? Does it only have numbers in it? Is each number on its own line? Does it always have the same number of numbers in it?
 
ok thanks for the help, I finally got it to compile and display the data in the text file.

Code:
void readFile()
{
	string line;
	short loop = 0;
	
	char buffer[256];		//data from text file
	int numLines;
	ifstream infile;
    infile.open("polygon.txt");

    // Exit if file opening failed
    if (!infile.is_open()){
        cerr<<"Failed to open file" <<endl;
        exit(1);
    }

    // Start reading data
    while (!infile.eof()){
		infile.getline (buffer,100);
		cout << buffer << endl;
		}
	
	infile.close(); 
	system("PAUSE");
 }

Now I am trying to store each line in an array but I can't seem to access the "buffer".
Trust me I've been searching for the past 4 hours I feel like an absolute idiot...
 

wolfmat

Confirmed Asshole
Damn I really need help, i've been searching for hours. I'm using C++ and I am trying to read a text file, and store only certain values from that text file into an array so that I can later use them as data values for a polygon.


here's what I have. Something isn't working with the getline() function.
SNIP

You need to pass a char[] of some size. The size determines how many characters of the line will be read.
http://www.cplusplus.com/reference/iostream/istream/getline/
Like so:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>

using namespace std;

void readFile()
{
        int number_of_lines = 100;
        int linebuffer_maximum = 100;
        char buffer[number_of_lines][linebuffer_maximum];

        ifstream infile;
    infile.open("polygon.txt");

    // Exit if file opening failed
    if (!infile.is_open()){
        cerr<<"Failed to open file" <<endl;
        exit(1);
    }

    int i=0;
    // Start reading data
    while (i<number_of_lines && !infile.eof()){
        infile.getline(buffer[i++],linebuffer_maximum);
    }

    number_of_lines = i-1;
    for(i=0; i<number_of_lines; i++){
        cout<<buffer[i]<<endl;
    }

    infile.close();
}
int main(){
        readFile();
}

Edit: Late, but this answers your other question, I guess.

Edit: Made a mistake with the iterator. Sorry for that.
 

wolfmat

Confirmed Asshole
Also note that you'll probably want to include more cool data in the file, so you might as well either implement a format, or use a library. Generally speaking, this is a solved problem. If you don't recognize that, you'll run into problems like having to make generic data structures because your array isn't big enough and things like that.

Not saying you shouldn't get your prototype going like this, of course. But don't forget to always try to see where the point is at which the learning phase is over and you just want to get asset data in, but not bother with shit nobody really cares about, like Unicode support for named particle type references or whatever.
 
Was playing around with parsing input from files, and came up with a slightly inelegant solution...

Code:
	fstream accountdetails;
	accountdetails.open("Account Info.dat", ios::in | ios::out);//opens account file to read and set balance
	if (accountdetails.fail())
	{
		cout << "Error could not open file" <<endl;//failure message
		
	}
        for(int i = 0; i < 4; i++)
	    accountdetails >> input[i];
		
	balance = input[0];
	amountD = input[1];
	amountP = input[2];
	amountW = input[3];

Just for fun. I then loop it back to the beginning of the file and once you go to exit the program, it rewrites the file with the new values.

input[] is a float array.
 

Stylo

Member
In C, does scanf() always leave a trailing newline? I used getchar() at the end of my program to pause it before it terminates, but I think scanf is giving me problems. FYI, I run my programs on the console but I still want the programs to pause before they terminate if run on an IDE or as an .exe file. Here's a small program I made.

Code:
#include <stdio.h>
#define CONSTANT 5

int add_const(int intvar, int constant);

int main(void)
{
	int sum, intvar;
	printf("Enter a decimal integer:");
	scanf("%d", &intvar);
	
	sum = add_const(intvar, CONSTANT);
	printf("%d + %d is %d.\n", intvar, CONSTANT, sum);
	
	if(sum < 20)
		printf("The number is small.\n");
		
	getchar();
	return 0;
}

int add_const(int intvar, int constant)
{
	return (intvar + constant);
}
 
Hello guys

I'm trying to apply as a developer in my current job, but I need to know how to develop video games in C++, is there any good tutorial/course/whatever for that language? I know programming, but I have never developed a videogame.

Thanks!
 

Bollocks

Member
Hello guys

I'm trying to apply as a developer in my current job, but I need to know how to develop video games in C++, is there any good tutorial/course/whatever for that language? I know programming, but I have never developed a videogame.

Thanks!

Let me just say that this is a stupid idea. You can't learn video game development by reading some online tutorial over the weekend, it takes ages to learn especially if this should be part of your job. Any recruiter who is even half serious about this will see right through you.
There's just too much stuff you'd have to learn apart from the API(which there are plenty!), maths!, framebuffer, graphics pipeline, rasterizer, vertex format, shaders,...
 

Kikarian

Member
Hello guys

I'm trying to apply as a developer in my current job, but I need to know how to develop video games in C++, is there any good tutorial/course/whatever for that language? I know programming, but I have never developed a videogame.

Thanks!
You do realise this will take months if not years to learn?
 
I disliked programming until I discovered Haskell.

yea functional programing is cool and totally expand your mind, big fan.

I'm trying to apply as a developer in my current job, but I need to know how to develop video games in C++, is there any good tutorial/course/whatever for that language? I know programming, but I have never developed a videogame.

can't do it overnight, you'll probably have to fake it during the interview.
 
You do realise this will take months if not years to learn?

Let me just say that this is a stupid idea. You can't learn video game development by reading some online tutorial over the weekend, it takes ages to learn especially if this should be part of your job. Any recruiter who is even half serious about this will see right through you.
There's just too much stuff you'd have to learn apart from the API(which there are plenty!), maths!, framebuffer, graphics pipeline, rasterizer, vertex format, shaders,...


It's not a weekend plan, I have like a year to learn some basics... so isn't there something that you can help me with?....

Thanks....
 

Bollocks

Member
It's not a weekend plan, I have like a year to learn some basics... so isn't there something that you can help me with?....

Thanks....

Well there is no standard way to develop video games in C++, there are multitude of engines out there and each have different implementation/usage.
What they all have in common however is that they are built on either DirectX or OpenGL which is very low level. It's crucial to have a good knowledge about C++(pointers, memory allocation).
I personally would go with OpenGL as it is cross platform and not bound to any architecture.
If you have it working on a PC you can easily port your code to Android with minimal effort.
But be warned though OpenGL ist not a 3D Engine ready to use, it just provides functionality to talk to the graphics processor and thus it is very low level and therefore very technical so I would suggest a book instead.

If you just want some free C/C++ frameworks:
OgreEngine, irrLicht (3D Engine)
Allegro, SDL (2D Engine)
Source Engine, CryEngine
 

Haly

One day I realized that sadness is just another word for not enough coffee.
DirectX 10, 11: http://rastertek.com/tutindex.html
Math:
41kwLPWN8EL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20_OU01_.jpg
 

Kikarian

Member
It's not a weekend plan, I have like a year to learn some basics... so isn't there something that you can help me with?....

Thanks....

Well there is no standard way to develop video games in C++, there are multitude of engines out there and each have different implementation/usage.
What they all have in common however is that they are built on either DirectX or OpenGL which is very low level. It's crucial to have a good knowledge about C++(pointers, memory allocation).
I personally would go with OpenGL as it is cross platform and not bound to any architecture.
If you have it working on a PC you can easily port your code to Android with minimal effort.
But be warned though OpenGL ist not a 3D Engine ready to use, it just provides functionality to talk to the graphics processor and thus it is very low level and therefore very technical so I would suggest a book instead.

If you just want some free C/C++ frameworks:
OgreEngine, irrLicht (3D Engine)
Allegro, SDL (2D Engine)
Source Engine, CryEngine
This.
 

gblues

Banned
In C, does scanf() always leave a trailing newline? I used getchar() at the end of my program to pause it before it terminates, but I think scanf is giving me problems. FYI, I run my programs on the console but I still want the programs to pause before they terminate if run on an IDE or as an .exe file. Here's a small program I made.

Using scanf() is an extraordinarily bad idea. It's basically a security hole waiting to happen.
 

Shikoro

Member
Well there is no standard way to develop video games in C++, there are multitude of engines out there and each have different implementation/usage.
What they all have in common however is that they are built on either DirectX or OpenGL which is very low level. It's crucial to have a good knowledge about C++(pointers, memory allocation).
I personally would go with OpenGL as it is cross platform and not bound to any architecture.
If you have it working on a PC you can easily port your code to Android with minimal effort.
But be warned though OpenGL ist not a 3D Engine ready to use, it just provides functionality to talk to the graphics processor and thus it is very low level and therefore very technical so I would suggest a book instead.

If you just want some free C/C++ frameworks:
OgreEngine, irrLicht (3D Engine)
Allegro, SDL (2D Engine)
Source Engine, CryEngine

I would suggest going with SFML instead of SDL, since it is written in C++ and is heavily dependent on object-oriented programming which you will need if you want to make games. After you get used to it, you can up the level and start learning OpenGL. :)
 
Well there is no standard way to develop video games in C++, there are multitude of engines out there and each have different implementation/usage.
What they all have in common however is that they are built on either DirectX or OpenGL which is very low level. It's crucial to have a good knowledge about C++(pointers, memory allocation).
I personally would go with OpenGL as it is cross platform and not bound to any architecture.
If you have it working on a PC you can easily port your code to Android with minimal effort.
But be warned though OpenGL ist not a 3D Engine ready to use, it just provides functionality to talk to the graphics processor and thus it is very low level and therefore very technical so I would suggest a book instead.

If you just want some free C/C++ frameworks:
OgreEngine, irrLicht (3D Engine)
Allegro, SDL (2D Engine)
Source Engine, CryEngine

Thank you so much, I'm off to start reading and learning.
 

xJavonta

Banned
Posted this in the Indie Game Development thread too.
----

So GAF, I have a problem.

When I was younger, I made games in Gamer Maker. Usually simple platformers and occasionally a racing game or fighting game. Once I started getting into the 3D stuff, I made an engine and for some reason just dropped Game Maker. I don't know why, but I didn't go back to it. That was around 5 or 6 years ago.

I've always been coding in HTML though, since before I even started Game Maker I made websites in HTML. I still do it to this day, I took a Web Site Design class during my senior year of High School and was considered the star pupil of the class; helping out everyone else with their HTML and CSS issues until everyone switched to Dreamweaver (ugh).

Then about a few months ago, I decided I should get a head start on C++ (I'll be taking Comp Sci in college). I enjoyed it at first, but like Game Maker, I just dropped it. I don't know why, but I did. I ended up picking it up again a few weeks ago to discover I had forgotten everything I learned.

Now, I want to start again, but this time I want to keep at it. I really enjoy programming and watching things change as I go along, but I don't know why I keep dropping it right when I'm getting used to it. It's an annoying problem that I'm totally self aware of. Maybe I'm not keeping it up because there's no one doing it with me, so I can't really "share" my progress with someone and watch theirs as well. I think that's why I had such a tremendous amount of growth in my Web Site Design class.

So I'm starting from scratch, again. What are some good resources? I'd prefer an e-book so I can read it on my iPad when I'm away from my desk or at school. Should I start with C++ again or attempt something else like Java? I'm used to looking at a wall of code, since I never ever used Dreamweaver in WSD, I always hard coded my websites in Notepad++.

Can't wait to see what Gaf recommends! Thanks in advance.
 

Red UFO

Member
I used a book called "Sam's teach yourself C++ in an hour a day."

Maybe the structure that a book like that provides will help solve your problem.
 

Godslay

Banned
Posted this in the Indie Game Development thread too.
----

So GAF, I have a problem.

So I'm starting from scratch, again. What are some good resources? I'd prefer an e-book so I can read it on my iPad when I'm away from my desk or at school. Should I start with C++ again or attempt something else like Java? I'm used to looking at a wall of code, since I never ever used Dreamweaver in WSD, I always hard coded my websites in Notepad++.

Can't wait to see what Gaf recommends! Thanks in advance.

I always recommend finding out what languages you will be using in your classes, and then either look into internet resources or books.

If you want to start off in the C++ world, I would recommend taking a look over the books recommended on this stack overflow posting:

http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

They offer some very good recommendations for C++ on a variety of levels. While the Sam's recommendation was noble, they are hit or miss in terms of quality from what I understand.

As far as a Java pathway to learn from books, I would recommend starting off with this:

http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208

Or even this:

http://www.amazon.com/Murachs-Java-Programming-Joel-Murach/dp/1890774650/ref=sr_1_1?s=books&ie=UTF8&qid=1343009413&sr=1-1&keywords=murach%27s+java+programming

Then maybe moving on to something like this:

http://www.amazon.com/Java-Complete-Reference-Herbert-Schildt/dp/0071606300/ref=sr_1_1?s=books&ie=UTF8&qid=1343009457&sr=1-1&keywords=java+complete+reference+8th

Additionally if you are more of a visual learner, I love plural sight. It's $29.99 a month and mostly tailored toward Microsoft technologies (.Net, C#, ASP), but it has a ton of great videos. It will also help you further down the road as it covers data structures, algorithms, design patterns, and the like. You get a free 10 hour trial if I recall correctly.

http://www.pluralsight-training.net/microsoft

Good luck!
 

Stylo

Member
Using scanf() is an extraordinarily bad idea. It's basically a security hole waiting to happen.

Ahh. I'm still at the beginning half of my book. It seems that a lot of books use scanf just for basic input in the beginning. (Is it still an issue for games?)
 

Lkr

Member
i am a comp sci major, and have only taken an intro to c++ class. let's just say that i am not the best at programming. i understand what different lines of code do and what not, but when given a task like make a program that counts characters in a line, i sorta freeze up until someone calmly tells me its so simple all you gotta do is read the file in, there is a library for reading characters in, etc. this upcoming semester i have an object oriented class, and i'm wondering if this will make things easier for me, or even harder. is there anything i should read over during the next month to get myself back in the programming spirit?
 

wolfmat

Confirmed Asshole
i am a comp sci major, and have only taken an intro to c++ class. let's just say that i am not the best at programming. i understand what different lines of code do and what not, but when given a task like make a program that counts characters in a line, i sorta freeze up until someone calmly tells me its so simple all you gotta do is read the file in, there is a library for reading characters in, etc. this upcoming semester i have an object oriented class, and i'm wondering if this will make things easier for me, or even harder. is there anything i should read over during the next month to get myself back in the programming spirit?

It's hard to say if it'll make things easier or harder. Most of the time, the complexity increases, the number of lines of code increases, but novice programmers have an easier time being productive.

No idea on the reading question. What exactly do you want to explore? OOP in C++? OOP in general? C++ basics?

Also, programming yourself makes for more efficient learning.
 

FillerB

Member
i am a comp sci major, and have only taken an intro to c++ class. let's just say that i am not the best at programming. i understand what different lines of code do and what not, but when given a task like make a program that counts characters in a line, i sorta freeze up until someone calmly tells me its so simple all you gotta do is read the file in, there is a library for reading characters in, etc. this upcoming semester i have an object oriented class, and i'm wondering if this will make things easier for me, or even harder. is there anything i should read over during the next month to get myself back in the programming spirit?

If you sorta freeze up when facing a task like counting the characters in a line.... OOP is going to be fun for you. If you're sadomasochistic.

Then again it sounds to me that your "problem" isn't so much that you don't know how to program, it's more that you don't know how to get started on a problem. I know that there has been a lot of research on this but I can't for the life of me think of a good article to recommend.

However I'm a firm believer in the old and corny "practice makes perfect" line so why not instead of reading about programming, you start thinking of (increasingly) programs you would want or could use and then try to make them? Keep the standard C++ Library reference open in a tab and see if there is anything in it that you might be able to use.

Two ideas for what you could try to make:
- Make a function that displays the number of days/hours/minutes/seconds between two given days.
- Remake the "Word Count"-function of Microsoft Word for TXT-files.
 

wolfmat

Confirmed Asshole
Some easy, fun projects if you want to do OOP:
— Cash dispenser
— Family tree
— Theater ticket reservation

A general approach to understanding how to solve a problem with programming:
— Dissect the problem so that you have all necessary operations in a list
— Implement the data structures
— Implement the operations
— Gather the data
— Execute
— Refine

Here's an example with the cash dispenser:
— A person has an account
— An account has a PIN for identification purposes
— An account has money on it
— The dispenser has an amount of cash stored
— Dispensing money reduces money on an account
— Dispensing money reduces money in the cash storage
— A person cannot dispense more money than is on his account
— A person cannot dispense more money than is left in the dispenser's cash storage
— A person might have multiple accounts because why not
— A person can put money into an account
— Putting money into an account also increases the dispenser's amount of stored cash
— A person can change the PIN for an account (provide old PIN, provide new PIN, confirm new PIN)

And so forth. As you see, splitting it up into atoms makes it just a bunch of very easy programming tasks. That's why experienced programmers say that design is a bigger deal than implementation.
 

Kikarian

Member
Some easy, fun projects if you want to do OOP:
&#8212; Cash dispenser
&#8212; Family tree
&#8212; Theater ticket reservation

A general approach to understanding how to solve a problem with programming:
&#8212; Dissect the problem so that you have all necessary operations in a list
&#8212; Implement the data structures
&#8212; Implement the operations
&#8212; Gather the data
&#8212; Execute
&#8212; Refine

Here's an example with the cash dispenser:
&#8212; A person has an account
&#8212; An account has a PIN for identification purposes
&#8212; An account has money on it
&#8212; The dispenser has an amount of cash stored
&#8212; Dispensing money reduces money on an account
&#8212; Dispensing money reduces money in the cash storage
&#8212; A person cannot dispense more money than is on his account
&#8212; A person cannot dispense more money than is left in the dispenser's cash storage
&#8212; A person might have multiple accounts because why not
&#8212; A person can put money into an account
&#8212; Putting money into an account also increases the dispenser's amount of stored cash
&#8212; A person can change the PIN for an account (provide old PIN, provide new PIN, confirm new PIN)

And so forth. As you see, splitting it up into atoms makes it just a bunch of very easy programming tasks. That's why experienced programmers say that design is a bigger deal than implementation.
I'll have a go at a family Tree, but yes you are right, design is a really big part of Programming.
 

Lkr

Member
It's hard to say if it'll make things easier or harder. Most of the time, the complexity increases, the number of lines of code increases, but novice programmers have an easier time being productive.

No idea on the reading question. What exactly do you want to explore? OOP in C++? OOP in general? C++ basics?

Also, programming yourself makes for more efficient learning.

probably basics. i want to find something that gives projects to make and then you can see if you do it properly.
i'm at a very beginner level fwiw
 

Tomat

Wanna hear a good joke? Waste your time helping me! LOL!
Some easy, fun projects if you want to do OOP:
— Cash dispenser
— Family tree
— Theater ticket reservation

A general approach to understanding how to solve a problem with programming:
— Dissect the problem so that you have all necessary operations in a list
— Implement the data structures
— Implement the operations
— Gather the data
— Execute
— Refine

Here's an example with the cash dispenser:
— A person has an account
— An account has a PIN for identification purposes
— An account has money on it
— The dispenser has an amount of cash stored
— Dispensing money reduces money on an account
— Dispensing money reduces money in the cash storage
— A person cannot dispense more money than is on his account
— A person cannot dispense more money than is left in the dispenser's cash storage
— A person might have multiple accounts because why not
— A person can put money into an account
— Putting money into an account also increases the dispenser's amount of stored cash
— A person can change the PIN for an account (provide old PIN, provide new PIN, confirm new PIN)

And so forth. As you see, splitting it up into atoms makes it just a bunch of very easy programming tasks. That's why experienced programmers say that design is a bigger deal than implementation.

I might try the cash dispenser, it sounds like fun. The only thing like if that I've made so far are a few lists (linked lists and binary trees). I know I'm incredibly inpatient but I really wish I could make something that was actually useful to someone.
 

KorrZ

Member
probably basics. i want to find something that gives projects to make and then you can see if you do it properly.
i'm at a very beginner level fwiw

516QMpbGRzL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA278_PIkin4,BottomRight,-49,22_AA300_SH20_OU02_.jpg


Buy this book. I've learned everything I know so far from it, and I started from absolutely no programming experience. Tons of great examples, and very thorough explanations so you're never left to question why something happens like it does. It's also full of review questions and practical exercises to try on your own.
 
Recently, I've started working on a Java game for Android and desktop. I've coded in Java for a while, but never released anything. This time, I'm finally completing a project, and I've decided to do something very ambitious: create a way to store and receive user created levels online. This would involve PHP coding, something I haven't done in a couple years.

My biggest worry about this is web security. I know about SQL injections, but there are also things I didn't know about, like cross-site record forgery (CSRF).

As a result, I decided to use some sort of PHP framework with the hope that it'll help minimize my work and research and maximize security. Turns out most PHP frameworks are MVC only, requiring you to split code across multiple files, and I'm not really willing to write PHP code straying outside of one file per action (like upload, display, etc) since I'm a novice.

I ended up using WordPress. It already has a web site design (no design work for me), is popular (heavily documented API), is reportedly fast, and allows me to write code in any lazy way I want. Outside of a few quirks, it's been very good to me.


On the Java side, today I finally coded something that will allow me to POST data to my PHP scripts, essentially allowing for level uploads. It was pretty gratifying, running my project and receiving a web page that everything went OK. To get to this point, it took me 3 days of research and testing... Research on PHP, MySQL, the WordPress API, the HTTP protocol, HTTP headers, the formation of POST data, Java's connection API HTTPConnect, JSON, and more.

I'm still far from complete, though. However, getting to that point made me very happy.

A note: I hate PHP. It's basically Java, but without declaring variables to be of a type, which just makes things annoying. For example, look at PHP's "find substring in string" function, which can return 0 to say it's at position 0, or false to say it isn't in the string at all. This will cause headaches when testing for equality.
Though it also doesn't have types, I do like Python. It's different with Python, for some reason. Somehow, it's just easier...

Also, I decided to use a PHP IDE (well, an Eclipse plugin). It made everything suck a little less. :p
 

tuffy

Member
A note: I hate PHP. It's basically Java, but without declaring variables to be of a type, which just makes things annoying. For example, look at PHP's "find substring in string" function, which can return 0 to say it's at position 0, or false to say it isn't in the string at all. This will cause headaches when testing for equality.
Though it also doesn't have types, I do like Python. It's different with Python, for some reason. Somehow, it's just easier...
Everyone who has to deal with PHP should read through the Fractal of Bad Design rant to fully understand what a minefield of hassles it can be.
 
I would say C is better than PHP for cgi programming on the whole. That "Fractal of Bad Design" rant is correct. C may be lower level, but it's consistent. Still, JSP via Java, Python, Perl, ASP.NET via C#, and a slew of other languages are better.
 
Everyone who has to deal with PHP should read through the Fractal of Bad Design rant to fully understand what a minefield of hassles it can be.

That was an awesome article, thanks for that. :p However, I wish I read it after completing my project, because it sort of turned me off of PHP. lol.

If I decide to do a future web project, I'll make sure to get a server that supports CGI, or better yet, JSP. I imagine they'd have better performance than PHP, too.
 
Sorry to double post, but this is the perfect example of why PHP sucks:

document for PHP function intval() said:
intval($var, $base)
Get the integer value of a variable

Returns:
int The integer value of var on success, or 0 on failure. Empty arrays and objects return 0, non-empty arrays and objects return 1.

That's just... crazy.

The funny thing is, PHP allows functions to return more than one type. So it could have easily done something like:

the perfect world said:
Returns:
int|boolean The integer value of var on success, or false on failure. Empty arrays and objects return false, non-empty arrays and objects return true.

but instead they made it so it's impossible to tell if you're legitimately getting 0 or you're getting an error.

Another funny thing is that functions like strpos DO output int|boolean, yet this one doesn't. (I mentioned that in my previous post.) The rant/article tuffy posted is spot-on about the fact that PHP is inconsistent.
 
This is more of a question for DBA GAF than Programmer GAF, but perhaps some of you may be able to steer me in the right direction.

Recently we purchased a new server for our development/development database.

Specs:
2x 2.4GHz Intel Xeon E5-2609
32GB RAM
3x 146GB 15K RPM SAS Drives configured in RAID 5
OS: Windows Server 2008R2 Service Pack 1 64-bit

The old server is as following:
1x 2.8 GHz Intel Xeon (5+ year old processor, and I think despite the clock speed it's slower than the new)
4GB RAM
4x HDD 7200 RPM IDE drives in RAID 1, I think ~300GB capacity with the mirroring
OS: Windows Server 2003 32-bit (does this even come in 64-bit?)

Anyway, we have SQL Server 2008 on the old system and SQL Server 2008R2 on the new system.

We have a process that does about 50000 row updates per minute, and has been tested at up to 150,000 row updates per minute. On our old server configuration we have absolutely no problem running the process, neither at the 50k load or the 150k load. On our new machine, which has massively better specs, the process runs so slowly that we get a queue overflow and eventually a failure within about 30 minutes of running the process at best.

I simply can't figure it out. It's properly indexed, we've checked the query execution plans and they're the same on both systems, etc. For some reason the new hardware is simply processing updates at probably around a quarter of the speed of the old server. I've chalked it up to a configuration issue at this point, because it doesn't make sense that it could be a hardware issue. The only hardware issue I could think of is that the new server is configured in RAID 5, which could have a write penalty, but the drives are twice as fast as the old 7200RPM drives, and there's so much more memory that it should be able to minimize the amount of writes it actually needs to make, plus it's got a hardware RAID controller which should help alleviate some of the impact from the RAID 5. I've checked, SQL Server is using around 29GB of the available 32GB, so it's not as if some other process is hogging the memory.

So basically, configuration. Anyone have any tips as to what I may be doing wrong in the configuration to make my new server perform so poorly compared to the 5+ year old machine?
 
516QMpbGRzL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA278_PIkin4,BottomRight,-49,22_AA300_SH20_OU02_.jpg


Buy this book. I've learned everything I know so far from it, and I started from absolutely no programming experience. Tons of great examples, and very thorough explanations so you're never left to question why something happens like it does. It's also full of review questions and practical exercises to try on your own.

would this or Accelerated C++ be better to learn from a beginner's stand point? I like that I can get this one on Kindle but I don't mind ordering the actual book for Accelerated if it is better.
 

r1chard

Member
Though it also doesn't have types, I do like Python.
Just a nit here: Python does have types - every object from the lowliest integer to a custom class instance knows its type; what it doesn't have is static (ie. in-code) type declarations for variables. It also rarely allows you to play loose and fast with odd combinations of types like some other languages ;-)
 

ferr

Member
So basically, configuration. Anyone have any tips as to what I may be doing wrong in the configuration to make my new server perform so poorly compared to the 5+ year old machine?

Definitely sounds like a configuration error and my guess is it's in the big change in RAM. I'd say play around with the config with respect to the max memory usage, maybe pull it down to 24GB.

Also, you can use the query execution plan to analyze how the query is being executed -- it might have changed in reaction to the differing hardware. If it's possible to do a cross-analysis of plans between the old server and new server, you could see the differences and possibly find the issue. http://www.sql-server-performance.com/2006/query-execution-plan-analysis/
 

usea

Member
Definitely sounds like a configuration error and my guess is it's in the big change in RAM. I'd say play around with the config with respect to the max memory usage, maybe pull it down to 24GB.

Also, you can use the query execution plan to analyze how the query is being executed -- it might have changed in reaction to the differing hardware. If it's possible to do a cross-analysis of plans between the old server and new server, you could see the differences and possibly find the issue. http://www.sql-server-performance.com/2006/query-execution-plan-analysis/
They said the execution plans are the same.
 

KorrZ

Member
would this or Accelerated C++ be better to learn from a beginner's stand point? I like that I can get this one on Kindle but I don't mind ordering the actual book for Accelerated if it is better.

I can't speak for Accelerated C++ because I haven't read it myself but, I started off about 6 months ago as a complete beginner using C++ Primer and it was fantastic. I think it's a great starting point and I'd fully recommend it.
 

Pirabear

Banned
In C, how exactly do you assign a word to a string in a struct? My professor taught how to let the user do it, but not how to hard code it.

Code:
example.name[10]="John";

Something like this is what I assumed to be correct, but apparently not.
 

xptoxyz

Member
In C, how exactly do you assign a word to a string in a struct? My professor taught how to let the user do it, but not how to hard code it.

Code:
example.name[10]="John";

Something like this is what I assumed to be correct, but apparently not.

Ok, I'm rusty as hell but you should I think you should use simply define "name" as a pointer. if you've done so. you should change the value simply with example.name="John";
 
Top Bottom