Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Marsol0
Jun 6, 2004
No avatar. I just saved you some load time. You're welcome.

Glasgerion posted:

Resurrecting a question from before because I phrased it vaguely and still haven't gotten it right after messing around with it for hours. I'm trying to use the pdcurses library with mingw on windows vista. Can someone tell me how to set it up? I'm not real familiar with this sort of thing.

You need MSYS from the Mingw site. Use that to run the makefile in pdcurses. After that's finished just setup your environment to check the pdcurses directory for include files and the win32 directory in that for the library.

Adbot
ADBOT LOVES YOU

Contero
Mar 28, 2004

This is more of a data-structures/algorithm question than C++, but I'm probably going to be using the STL to implement this and I'm pretty new to using it.

I'm trying to implement some 2d collision detection, and I'm trying to figure out a way to efficiently examine only objects near the one I'm doing a collision calculation on. The way I want to implement this is by having each object in a bounding box and only consider the objects who's bounding box intersects the one I'm interested in. I just have no idea how to organize my objects so that I can grab only the objects I'm interested in. I have considered imposing a maximum length on objects or putting them into some sort of grid, but those don't seem like real solutions and I suspect there might be a better way.

code:
 +--+
 |  |  +-------------+
 |  |  |             |
 | *+--+---*         |
 | ||  |   |         |
 | ||  +---+---------+
 | ||      |
 | *+------*
 |  |
 +--+
+---------------------------+
|                           |
+---------------------------+
So if the object I'm considering is the box with stars, how do I organize my data in such a way that I can ignore the bottom one without having to even look at it? Ideally I'd like to logarithmically (by the number of objects in the world) grab only the ones I want.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
It's late and i'm half asleep but have you looked at geometric hashing?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Contero posted:

So if the object I'm considering is the box with stars, how do I organize my data in such a way that I can ignore the bottom one without having to even look at it? Ideally I'd like to logarithmically (by the number of objects in the world) grab only the ones I want.

Real-Time Collision Detection by Christer Ericson has 3 full chapters about collision culling methods. Broadly speaking, you can either 1) create a bounding box hierarchy (think binary-tree), or 2) you can partition the space itself (grid, quadtrees, BSP).

Contero
Mar 28, 2004

Avenging Dentist posted:

Real-Time Collision Detection by Christer Ericson has 3 full chapters about collision culling methods. Broadly speaking, you can either 1) create a bounding box hierarchy (think binary-tree), or 2) you can partition the space itself (grid, quadtrees, BSP).

I took a look around and it basically looks like it's going to be a bit more complicated that I had hoped even with simple axis-aligned bounded boxes. I might just try a simple grid or just do a detection against everything and hope it won't be too slow. I'm not going to have very many items in my scenes.

If someone can explain spatial volume hierarchies in layman's terms I'd greatly appreciate it. I understand that you split the scene somewhere in the middle and build a tree, I just don't understand how to select nodes to place in the tree and in what order they are sorted.

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!
Does throw x; always create a copy of x? I'm wondering because that seems weird but I guess that's how things go.

code:
#include <iostream>

struct foo
{
	foo() { }
	foo( const foo& ) { std::cout << "foo( const foo& )\n"; }
	~foo() { std::cout << "~foo()\n"; }
};

int main( void )
{
	foo f;
	try
	{
		std::cout << "blah\n";
		throw f;
	} catch( foo& t )
	{
		std::cout << "bleh\n";
	}
	std::cout << "blih\n";
}
This prints

code:
blah
foo( const foo& )
bleh
~foo()
blih
~foo()

ehnus
Apr 16, 2003

Now you're thinking with portals!
I do believe so -- the object has to be copied somewhere safe (ie: not the stack) where it lives while the stack is unwound.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Question about templated classes in C++. Why is it that, when I compile a templated class, no errors are generated by the compiler in a function I KNOW has errors unless I call that function somewhere else?

Take this sample to see what I'm talking about (noting that in reality main() is in it's own cpp file that includes the templated class in question):

code:
template <class T>
class Foo
{
  void bar();
  void raz(int num);
};

template <class T>
void Foo<T>::bar()
{
  raz("fakeout!"); // ERROR
}

template <class T>
void Foo<T>::raz(int num)
{
  // do nothing
}

void main()
{
  Foo<int> f;
  // f.bar();
}
Now, if I uncomment that line in main(), I get an error as expected. If I leave it commented, the project compiles completely. While it's nice that it doesn't worry about uncalled code (I guess), it makes bugfinding a pain in the rear end. Is there anything I can do to change this behavior? It sucks having to fanagle a way to call every single function in the class just to help me check for compiler errors.

That Turkey Story
Mar 30, 2003

Ledneh posted:

Now, if I uncomment that line in main(), I get an error as expected. If I leave it commented, the project compiles completely. While it's nice that it doesn't worry about uncalled code (I guess), it makes bugfinding a pain in the rear end. Is there anything I can do to change this behavior? It sucks having to fanagle a way to call every single function in the class just to help me check for compiler errors.

This is the fault of your compiler (I'm guessing Visual C++?). Templates are supposed to go through two phases of name lookup -- once when the template definition is encountered for everything in it that is not dependent on a template argument and then a second time when the template is instantiated to resolve anything that is dependent on a template argument. For compilers that do this correctly, you should get an error without having to call the function in the code you posted. For compilers which (incorrectly) put everything off to the second phase, you will only get the error when the template is instantiated via the function call. Visual C++ is one such compiler that pushes everything to phase two meaning you won't get the compiler error until you call the function.

Also, use int main(), not void main(), as by standard, main must return an int.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
You can workaround some of it by putting as much of the nondependent code as possible in a base class (or non-memeber functions):
code:
struct Foo_shared{
  void bar();
  void raz(int num);
};

void bar(){
  raz("d'oh"); // will surely error
}

void raz(int num){
}

template<class T>
class Foo : public Foo_shared{
  // blah blah
};

int main(){
  Foo<int> f;
}

Mustach fucked around with this message at 17:48 on Nov 26, 2008

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


That Turkey Story posted:

This is the fault of your compiler (I'm guessing Visual C++?). Templates are supposed to go through two phases of name lookup -- once when the template definition is encountered for everything in it that is not dependent on a template argument and then a second time when the template is instantiated to resolve anything that is dependent on a template argument. For compilers that do this correctly, you should get an error without having to call the function in the code you posted. For compilers which (incorrectly) put everything off to the second phase, you will only get the error when the template is instantiated via the function call. Visual C++ is one such compiler that pushes everything to phase two meaning you won't get the compiler error until you call the function.

Also, use int main(), not void main(), as by standard, main must return an int.

Whatever compiler is being used by Sun Studio 12, actually--I don't remember. Solaris machine, anyway, but I guess if it's a compiler problem and not an inherent C++ thing I should go check.

And yeah in the real code it's int main with proper parameters, I just blew that out from memory :shobon:

(edit) Here's a related question. Say I have another function that looks like this:
code:
template <class T>
void Foo<T>::doSomething(const T& data)
{
  // blah blah
}
Now that DOES have a template parameter as a, well, parameter, so that means ANY compiler would have to wait for the second lookup to catch it, right?


(edit 2) Wait, there's something that doesn't make sense about this. I know templates aren't, strictly speaking, compilable code, but the pattern to generate compilable code. Wouldn't this mean that, as soon as main() declared a specific version of the template, the compiler should know it will need to do up the whole thing like a normal class, instead of waiting until I called any given function in it?

Also, would putting the template declaration AND definition in the same header file (instead of dec in header and def in a .cpp as normal) help? I can't think of why it WOULD, but I'm willing to think about it until I can get back to my machine.

Ciaphas fucked around with this message at 18:29 on Nov 26, 2008

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Sorry for the double post, but the edit chain was getting a little convoluted. I got to my machine and tried a solution which frankly, makes no sense to me, but it definitely works. I was hoping someone could explain why.

If I put something like the following line pretty much ANYWHERE in my project (or at least anywhere that #includes the template's header file) in global scope, the compiler does up the whole thing without question (and gives me all the errors I need):
code:
template class Foo<FAKE_TYPE_OR_VOID_STAR_OR_INT_OR_SOMETHING>;
Besides being hopeful for an explanation as to why this gets the whole thing compiled where actually declaring an object does not, does anyone know if this will have any unintended compile-time or run-time side effects, or if it's not going to work on other compilers?

Ciaphas fucked around with this message at 19:07 on Nov 26, 2008

That Turkey Story
Mar 30, 2003

Ledneh posted:

Besides being hopeful for an explanation as to why this gets the whole thing compiled where actually declaring an object does not, does anyone know if this will have any unintended compile-time or run-time side effects, or if it's not going to work on other compilers?

That's an explicit instantiation. It just forces the template to be instantiated at that spot for those particular template arguments (including the member functions of that type). It should work on most other compilers unless they don't support explicit instantiation, though most of them nowadays do.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Ah, okay, now that I know the name of that little trick I can do more looking around on my own. Thanks muchly.
<line break, stupid forums>

I probably learned this back in Compilers in university, but I've long since forgotten. Is there any reason the whole template doesn't get instantiated (and therefore compiled) when, in the sample code above, I declare a specific type? (the Foo<int> f; in main() above). I would guess it's for optimization's sake, but I don't know.

Dren
Jan 5, 2001

Pillbug
I'm gonna try to shed some light on this from the last time I had to deal with the Sun Studio compiler's differences from the GNU compiler in handling templates.

I believe the GNU compiler has a more straightforward approach to compiling templatized code than the Sun compiler. As I recall, the GNU compiler emits code for each templatized functions in each translation unit. If you'd compiled with g++ you would have gotten your compiler error without having to explicitly instantiate your template types. Your code, however, may be larger than necessary because it could contain duplicate template instantiations. More info about GNU compiler template instantiation here.

You didn't get the error in your first example because the Sun compiler's default behavior is to emit code for object methods only when those methods are referenced by code that must be compiled. The Foo class's constructor was instantiated but the bar method was not. You could change this behavior to what you expect by compiling with the -template=wholeclass switch on. Or you could appreciate Sun's efficiency in saving you a tiny bit of size on your binary, not turn it on, and miss terrible errors. Either way, you will be bitter because now you know all this useless crap and Sun could've made it work like everyone expects instead of saving us a tiny bit of HD space. More info about Sun Studio 12 template instantiation here.

At my job we explicitly instantiate our templatized objects because we have to support old rear end versions of the sun compiler. Explicit instantiation plays nice with Sun and GNU c++ compilers.

btw, the sun c++ compiler is CC. You can man CC for some info on compiler switches and other sun shittiness.

Dren fucked around with this message at 00:03 on Nov 27, 2008

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

Dren posted:

You could change this behavior to what you expect by compiling with the -template=wholeclass switch on. Or you could appreciate Sun's efficiency in saving you a tiny bit of size on your binary, not turn it on, and miss terrible errors.

So, -template=wholeclass for debug builds, and skip it for release builds, then.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Dren posted:

I'm gonna try to shed some light on this from the last time I had to deal with the Sun Studio compiler's differences from the GNU compiler in handling templates.

I believe the GNU compiler has a more straightforward approach to compiling templatized code than the Sun compiler. As I recall, the GNU compiler emits code for each templatized functions in each translation unit. If you'd compiled with g++ you would have gotten your compiler error without having to explicitly instantiate your template types. Your code, however, may be larger than necessary because it could contain duplicate template instantiations. More info about GNU compiler template instantiation here.

You didn't get the error in your first example because the Sun compiler's default behavior is to emit code for object methods only when those methods are referenced by code that must be compiled. The Foo class's constructor was instantiated but the bar method was not. You could change this behavior to what you expect by compiling with the -template=wholeclass switch on. Or you could appreciate Sun's efficiency in saving you a tiny bit of size on your binary, not turn it on, and miss terrible errors. Either way, you will be bitter because now you know all this useless crap and Sun could've made it work like everyone expects instead of saving us a tiny bit of HD space. More info about Sun Studio 12 template instantiation here.

At my job we explicitly instantiate our templatized objects because we have to support old rear end versions of the sun compiler. Explicit instantiation plays nice with Sun and GNU c++ compilers.

btw, the sun c++ compiler is CC. You can man CC for some info on compiler switches and other sun shittiness.

Boy did you peg my newfound feelings on the matter perfectly. What an annoying thing. Now I know why I never knew about this, because it really WAS never a problem before. Optimizing in a compiler is fine, but by default? Give me a break. :(

Thanks for the great info, though :)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Dren posted:

btw, the sun c++ compiler is CC. You can man CC for some info on compiler switches and other sun shittiness.

Wow, I didn't know CC was even in use anymore.

litghost
May 26, 2004
Builder
I have a optimization question. I am working on a OpenGL emulator for an embedded platform, and I find myself writing many loops over things like verticies and pixels (ie large number of elements). The problem lies in the complexity of OpenGL resulting in this huge matrix of possible options on the inside of the loop. Bottom line, I originally put the selection logic inside the loop, even though all the selection inputs are invariants within the loops. This combined with function overhead is turned to be killing performance. Inlining the selection functions helped, but I found the greatest improvement was to invert the logic. Example:
code:
Logic in loop:

for(;;)
{
   common_logic
   switch(type)
   {
   case a:
       switch(format)
       {
       case 1:
            // code1
       case 2:
            // code2
       case 3:
            // etc
       }
   case b:
       switch(format)
       {
       case 1:
       case 2:
       case 3:
       }
   case c:
       switch(format)
       {
       case 1:
       case 2:
       case 3:
       }
   }
   more_common_logic
}

into

logic outside loop:

switch(type)
   {
   case a:
       switch(format)
       {
       case 1:
           for (;;)
           {
              common_logic
              code1
              more_common_logic
           }
       case 2:
           for (;;)
           {
              common_logic 
              code2
              more_common_logic
           }
       case 3:
           for (;;)
           {
              common_logic 
              code3
              more_common_logic
           }
       }
   case b:
       switch(format)
       {
       case 1:
       case 2:
       case 3:
       }
   case c:
       switch(format)
       {
       case 1:
       case 2:
       case 3:
       }
This introduces a new problem, the common logic is now repeated for each combination. So I moved the common logic into a macro. So now I have a 50-100 line macro with non-trivial logic with a substitution in the middle. Even worse, for some options the sides of the options matrix is 4x8x3, so manual code generation is completely impractical, so I used Boost pre-processor to generate nested if/if/if/for statements. Code maintenance is going to be a bear, and compile times are horrific (~4-5 on one file), and binary sizes are gone up +200 kB. 200 kB is a lot when the binary is sharing space with the stack and heap.

The question is, is there a better way without sacrificing performance? Is this really a corner case where you need to whip out the crazy techniques (ie less well used, hard to maintain), like recursive macros? I tried function pointers, which greatly reduces the macro mayhem, but they are around 2-times slower because the inability to inline added significant overhead.

To nip the premature optimization question in the bud, these changes yield 10 performance improvements in pixel conversion code and at least 3-4 times in the vertex processing, potentially more. These improvements are the difference between 20 fps and 60 fps.

litghost fucked around with this message at 14:55 on Nov 27, 2008

TSDK
Nov 24, 2003

I got a wooden uploading this one

litghost posted:

I have a optimization question.
Policy based design is going to be your best bet for getting a decent amount of bang for your programming buck:
http://www.gamasutra.com/view/feature/1790/a_2d_render_base_using_policy_.php?page=1

Elected by Dogs
Apr 20, 2006
What's the easiest way to start learning C? Console or GUI apps are both fine, I'm on windows and I have cygwin if I want to use gcc (though it's sort of crap on cygwin).

Any recommended sites to start reading, etc?

TSDK
Nov 24, 2003

I got a wooden uploading this one
Kelly & Pohl's A Book on C. Once you've read it cover to cover, sell it on and buy a copy of Kernighan & Ritchie's The C Programming Language.

As for compilers, Visual Studio Express is free and decent.

Elected by Dogs
Apr 20, 2006

TSDK posted:

Kelly & Pohl's A Book on C. Once you've read it cover to cover, sell it on and buy a copy of Kernighan & Ritchie's The C Programming Language.

As for compilers, Visual Studio Express is free and decent.
Any non book things? I don't even have $3 to my name right now. :(

TSDK
Nov 24, 2003

I got a wooden uploading this one
Bruce Eckel's Thinking in... series of books used to be okay, so you could try this one (haven't reviewed this one myself):
http://mindview.net/CDs/ThinkingInC/beta3

Do you not have any public libraries kicking around near you?

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.
Your compiler should be perfectly capable of hoisting the switch statements out of the loop by itself. If this is really making a difference, something else is going on. Are you sure you're don't have optimization turned off?

Why can't common_logic and more_common_logic be inlined functions?

EDIT: there's no way a switch statement takes that much time. This might be a cache coherancy issue: the first form of the code can't fit both the common logic and all the different type/function specific operations into cache, so on each iteration is has to do the common code, then swap in the specific code, then swap the common code back in. In the second form, it's able to fit the entire for loop into cache. That would make your structure the "correct" thing to do. Again - check your compile settings and see if it will do this transformation itself, and if that doesn't work try your hardest to use an inlined function instead of a macro.

Here's a macro idea: put the common code in common_logic.inc and more_common_logic.inc (not .h to reinforce that they're not standard header files), and then #include them at the appropriate points. Same effect as a macro - the code gets pasted in - but easier to maintain in this particular case.

EDIT 2: if it IS cache coherence, this might be the place to use self-modifying code to keep the binary size down: keep one copy of "common logic" and "more common logic", and before entering the loop find out which specific code to use and arrange to load that between the two.

Hey look, this is even a recommended use case.

JoeNotCharles fucked around with this message at 16:22 on Nov 27, 2008

Elected by Dogs
Apr 20, 2006

TSDK posted:

Bruce Eckel's Thinking in... series of books used to be okay, so you could try this one (haven't reviewed this one myself):
http://mindview.net/CDs/ThinkingInC/beta3

Do you not have any public libraries kicking around near you?

They tend to have extremely extremely old books like "Windows 95 for Dummies."

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

TSDK posted:

Policy based design is going to be your best bet for getting a decent amount of bang for your programming buck:
http://www.gamasutra.com/view/feature/1790/a_2d_render_base_using_policy_.php?page=1

That still has to compile each combination into the executable, though, so he still has to worry about code bloat. (I agree that's a better approach than my lame #include suggestion; I thought he was using straight C for some reason.)

fritz
Jul 26, 2003

Elected by Dogs posted:

They tend to have extremely extremely old books like "Windows 95 for Dummies."

"A Book on C" and "The C Programming Language" are also extremely old books. (I bought a well-used copy of "ABoC" in 1992 from a used book store)

Elected by Dogs
Apr 20, 2006

fritz posted:

"A Book on C" and "The C Programming Language" are also extremely old books. (I bought a well-used copy of "ABoC" in 1992 from a used book store)

Alright, going to library in a bit I guess.

The thing is, I wanted online partially so I didn't have to retype a ton of stuff and it's easier to just select and google things.

MarsMattel
May 25, 2001

God, I've heard about those cults Ted. People dressing up in black and saying Our Lord's going to come back and save us all.
Retype what exactly? You'll get more benefit from typing out the sample & exercise problems than you ever would from copying and pasting, and I can't think of anything else you'd be retyping beyond function and struct names, which being C are likely to be about 8 characters long at a time.

TSDK
Nov 24, 2003

I got a wooden uploading this one

JoeNotCharles posted:

That still has to compile each combination into the executable, though, so he still has to worry about code bloat.
It shouldn't be all that evil. If you're smart in the way the render pipline gets picked and assembled, then you can write a genric 'catch-all' case and drive the whole thing from tables of function pointers.

If you initially leave the pipelines pointing at the default case, then you can selectively pick different combinations for instantiating through templates - giving you a good way to balance speed against code size.

You can even then extend the system to work with code loaded in a library (or from the assets themselves) so that you only bring in and run the code that's needed.

EDIT: On the subject of code bloat, it shouldn't be assumed that inlining code will make it faster. Depending on the system, inlining (and loop unrolling) may actively hurt the performance of code. So, as with all things, the performance difference needs to be measured.

Mikey-San
Nov 3, 2005

I'm Edith Head!

Elected by Dogs posted:

Alright, going to library in a bit I guess.

The thing is, I wanted online partially so I didn't have to retype a ton of stuff and it's easier to just select and google things.

What did you people do before the Internet? Sit there, staring at a problem, drooling incoherently and waiting for it to solve itself? ;)

Elected by Dogs
Apr 20, 2006

Mikey-San posted:

What did you people do before the Internet? Sit there, staring at a problem, drooling incoherently and waiting for it to solve itself? ;)

No internet? :ohdear:

I was born wayyy after the internet was invented :(

Vanadium
Jan 8, 2005

Before the internet, I did not want to be a rockstar programmer, just a plain rockstar.

litghost
May 26, 2004
Builder

TSDK posted:

Policy based design is going to be your best bet for getting a decent amount of bang for your programming buck:
http://www.gamasutra.com/view/feature/1790/a_2d_render_base_using_policy_.php?page=1

This seems to be what I did, only I did it with macros instead of templates. I was even thinking to myself that doing this is C++ would make a lot of sense, but this is only a C library.

JoeNotCharles posted:

Your compiler should be perfectly capable of hoisting the switch statements out of the loop by itself. If this is really making a difference, something else is going on. Are you sure you're don't have optimization turned off?

Currently compiling with -Os.

quote:

Why can't common_logic and more_common_logic be inlined functions?

I tested inlined functions, there is an improvement, but not enough.

quote:

EDIT: there's no way a switch statement takes that much time.

I don't think it is the specific switch statements, but the switch statement leads to more functions calls and more switch statements. I did attempt to inline each level of function call, and it did improve performance, but only by a factor of 3-4.

JoeNotCharles posted:

That still has to compile each combination into the executable, though, so he still has to worry about code bloat. (I agree that's a better approach than my lame #include suggestion; I thought he was using straight C for some reason.)

It is in straight C, for maximum compatibility. This system does not have dynamic libraries, so C++ will leak it's dependencies outward.

TSDK posted:

You can even then extend the system to work with code loaded in a library (or from the assets themselves) so that you only bring in and run the code that's needed.

Again, this system has no dynamic library functionality, and I am not confident enough to write one.

TSDK posted:

On the subject of code bloat, it shouldn't be assumed that inlining code will make it faster. Depending on the system, inlining (and loop unrolling) may actively hurt the performance of code. So, as with all things, the performance difference needs to be measured.

This is actually true to some point. If I compile the entire code base with -O2 it actually slower than -Os. However, in the specific case of pixel transfer and render dispatch, I measure performance improvements. I have done my best to perform test-based optimization.

JoeNotCharles posted:

EDIT 2: if it IS cache coherence, this might be the place to use self-modifying code to keep the binary size down: keep one copy of "common logic" and "more common logic", and before entering the loop find out which specific code to use and arrange to load that between the two.

The system does not have a sophisticated profiling system, how can I detect cache coherence problems? I made a function level profiler, but that probably does not have the resolution to see such a problem.

litghost fucked around with this message at 21:38 on Nov 27, 2008

Nippashish
Nov 2, 2005

Let me see you dance!

Elected by Dogs posted:

What's the easiest way to start learning C? Console or GUI apps are both fine, I'm on windows and I have cygwin if I want to use gcc (though it's sort of crap on cygwin).

Any recommended sites to start reading, etc?

Are you sure you really want to learn C? Why not jump straight to C++? Learning C first is a great way to never actually learn C++, especially if you are a casual programmer.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Nippashish posted:

Are you sure you really want to learn C? Why not jump straight to C++? Learning C first is a great way to never actually learn C++, especially if you are a casual programmer.

Let's not have this argument again, it's the worst. Besides that, a hobbyist programmer is going to have a hell of a time ever learning all of C++, but C is pretty easy to gain a complete understanding of.

Nippashish
Nov 2, 2005

Let me see you dance!

Avenging Dentist posted:

Let's not have this argument again, it's the worst. Besides that, a hobbyist programmer is going to have a hell of a time ever learning all of C++, but C is pretty easy to gain a complete understanding of.

I think having access to classes + the STL would be a huge benefit to a novice; but yeah, we can drop it.

Elected by Dogs
Apr 20, 2006

Nippashish posted:

I think having access to classes + the STL would be a huge benefit to a novice; but yeah, we can drop it.
Actually, I don't mind. Whichever you think will benefit later on.
I just want to do something for fun, and possibly use it later on.

Adbot
ADBOT LOVES YOU

indigoe
Jul 29, 2003

gonna steal the show, you know it ain't no crime
My experience with C is limited to `hello world` running in DOS with Turbo c++ sometime in the 90s, so I would appreciate if someone could point me in the right direction.

I have a burger processor script written in php (procedural) that is constantly running in a loop. When it's busiest, it can process about 5 burgers per second (BPS), but with the overheads it puts quite a strain on the server. It's not very scalable, and, after running over a year in production I'm sure it's as optimised as it can be. I need the process to handle 50 BPS without breaking a sweat, so I figured rewriting it in a more efficient language would be a great solution.

The requirements:
* Runs on linux (RHEL, fedora)
* Talks to mysql
* Makes http request (and needs to know response header code)

Will I need any special/nonstandard libraries? Anything I need to worry about if I want to be able to run it under different distros? Where do I begin?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply