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
Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

MeruFM posted:

that's amazing and reminds me of something similar

in python
code:
lastNum = 5
...
...
lastNum = "lastNum"
...
...
lastNum = lastNum + "= 5"
...
...
in production code.

My brain exploded.
What could this possibly have been trying to accomplish?

Adbot
ADBOT LOVES YOU

that awful man
Feb 18, 2007

YOSPOS, bitch

Gazpacho posted:

What could this possibly have been trying to accomplish?

The codebase is trying to become self-aware. It's just not doing a very good job of it.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

MeruFM posted:

that's amazing and reminds me of something similar

in python
code:
lastNum = 5
...
...
lastNum = "lastNum"
...
...
lastNum = lastNum + "= 5"
...
...
in production code.

My brain exploded.

I love this. I think all my code is now going to contain this.

In fact, I think I'll push out updates to code I've got out there now that just adds this.

Vanadium
Jan 8, 2005

http://www.codeofhonor.com/blog/tough-times-on-the-road-to-starcraft

code:
class CUnit ... {
    #include "header_1.h"
    #include "header_2.h"
    #include "header_3.h"
    #include "header_4.h"
};

quote:

the programming team continually worked towards shipping in only two months for the next fourteen months!

It's a nice read :shobon:

raminasi
Jan 25, 2005

a last drink with no ice

Vanadium posted:

http://www.codeofhonor.com/blog/tough-times-on-the-road-to-starcraft

code:
class CUnit ... {
    #include "header_1.h"
    #include "header_2.h"
    #include "header_3.h"
    #include "header_4.h"
};
It's a nice read :shobon:

This is great. I don't know why you left out that inheritance hierarchy:

quote:

History tells us that programmers feel compelled to try every feature of their new language during the first project, and so it was with class inheritance in StarCraft. Experienced programmers will shudder when seeing the inheritance chain that was designed for the game’s units:

CUnit < CDoodad < CFlingy < CThingy

CThingy objects were sprites that could appear anywhere on the game map, but didn’t move or have behaviors, while CFlingys were used for creating particles; when an explosion occurred several of them would spin off in random directions. CDoodad — after 14 years I think this is the class name — was an uninstantiated class that nevertheless had important behaviors required for proper functioning of derived classes. And CUnit was layered on top of that. The behavior of units was scattered all throughout these various modules, and it required an understanding of each class to be able to accomplish anything.

That Turkey Story
Mar 30, 2003

At a place I worked they did something similar regarding linked lists. I can relate to a lot of that stuff. The game industry really needs some fixing.

w00tz0r
Aug 10, 2006

I'm just so god damn happy.

That Turkey Story posted:

At a place I worked they did something similar regarding linked lists. I can relate to a lot of that stuff. The game industry really needs some fixing.

Unfortunately, the place I just left is evidence that this problem isn't only in the games industry. The inheritance hierarchy in particular really hit home.

akadajet
Sep 14, 2003

GrumpyDoctor posted:

This is great. I don't know why you left out that inheritance hierarchy:

Makes about as much sense as most inheritance hierarchies I've encountered at work.

That Turkey Story
Mar 30, 2003

Some day, people will more widely embrace generic programming and we won't have to deal with retarded, inflexible hierarchies of poo poo.

Hughlander
May 11, 2005

That Turkey Story posted:

At a place I worked they did something similar regarding linked lists. I can relate to a lot of that stuff. The game industry really needs some fixing.

I've been involved in MMO codebases that did similar for quick network replication. Just memcpy the class into the packet and send it on it's way.

tef
May 30, 2004

-> some l-system crap ->

That Turkey Story posted:

Some day, people will more widely embrace generic programming and we won't have to deal with retarded, inflexible hierarchies of poo poo.

or embrace composition

http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

It can even be done easily in Java using the handy @Delegate function that you showed me tef :)

Pilsner
Nov 23, 2002

The talk about inheritance hierarchies in games reminds me of something: EverQuest. Anyone else play that way back? There were so many quirky bugs, particularly with NPCs (monsters). You could trade with them, /tell to them (no error message = monster is alive somewhere in the dungeon), they could /say stuff, they could cast the same spells as players, they had mana and health like players, you could weigh them down by trading heavy items to them (like players), and much more. I'll bet my rear end it was because they had an inheritance hierarchy where both players and monsters inherited a lot of the same functionality.

MrMoo posted:

Which is pretty much why Boost exists.

Just curious, if I ever were to code some C++ again, is Boost like a good wrapper for all the horrible tedious stuff in basic C++, like having to write 10 lines of code to read a file and such? What about networking, image handling, databases, etc?

Aionic Duck
Apr 21, 2010
Speaking of EverQuest, all character data was, and I'm pretty sure still is, stored completely in a flat file system. Their excuse for not adding bags with more than 10 slots for a good part of like 5 years was that they didn't want to completely blow up the spaghetti code nightmare that was Verant code. It was seriously a time bomb and devs would flat out refuse to touch portions of legacy code because of how fragile it was.

Hughlander
May 11, 2005

Pilsner posted:

The talk about inheritance hierarchies in games reminds me of something: EverQuest. Anyone else play that way back? There were so many quirky bugs, particularly with NPCs (monsters). You could trade with them, /tell to them (no error message = monster is alive somewhere in the dungeon), they could /say stuff, they could cast the same spells as players, they had mana and health like players, you could weigh them down by trading heavy items to them (like players), and much more. I'll bet my rear end it was because they had an inheritance hierarchy where both players and monsters inherited a lot of the same functionality.


Just curious, if I ever were to code some C++ again, is Boost like a good wrapper for all the horrible tedious stuff in basic C++, like having to write 10 lines of code to read a file and such? What about networking, image handling, databases, etc?

There were a lot more behind the scenes fuckery, something about the nav node evaluation was hosed for years, and #define const was a thing there. (Or maybe it was #define private public, I can't remember, but one of the two...)

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

Aionic Duck posted:

Speaking of EverQuest, all character data was, and I'm pretty sure still is, stored completely in a flat file system. Their excuse for not adding bags with more than 10 slots for a good part of like 5 years was that they didn't want to completely blow up the spaghetti code nightmare that was Verant code. It was seriously a time bomb and devs would flat out refuse to touch portions of legacy code because of how fragile it was.

I remember wanting so badly to see how Anarchy Online's inventory database worked. As I recall, it was entirely server-side, so when you moved something in your bag there was a slight lag while it updated with the server, item locations would shift randomly...

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal

Pilsner posted:

Just curious, if I ever were to code some C++ again, is Boost like a good wrapper for all the horrible tedious stuff in basic C++, like having to write 10 lines of code to read a file and such? What about networking, image handling, databases, etc?

Ha! I'm stuck writing C++ and boost doesn't help with that poo poo at all sadly.

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.
What's so hard about reading a file?

ToxicFrog
Apr 26, 2008


Mustach posted:

What's so hard about reading a file?

Clojure:
code:
(let [buf (-> "items.dat" as-file to-byte-array)] ...)
Python:
code:
with open("items.dat", "rb") as fd:
    buf = f.read()
C++:
code:
#include <iostream>
#include <fstream>

ifstream fd ("items.dat", ios::in|ios::binary|ios::ate);
ifstream::pos_type size = fd.tellg();
uint8_t * buf = new uint8_t[size];
fd.seekg (0, ios::beg);
fd.read (buf, size);
fd.close();
Don't forget to delete[] (not delete) buf when you're done with it!

Slash
Apr 7, 2011

SavageMessiah posted:

Ha! I'm stuck writing C++ and boost doesn't help with that poo poo at all sadly.

I'm quite fond of the Qt libraries for simplifying a lot of the tedium of c++. The multi-threading and network libraries I have found particularly useful. Also the Qt GUI stuff is pretty good for knocking up quick, attractive HMI's.

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.

ToxicFrog posted:

Don't forget to delete[] (not delete) buf when you're done with it!
Who reads in whole files at once, but okay
code:
#include <fstream>
#include <string>
#include <sstream>

std::string read_whole_file(const std::string& path){
	std::ostringstream buf;
	std::ifstream in (path, ios::binary); // or path.c_str() if you're in the dark ages of '98
	buf << in.rdbuf();
	return buf.str();
}

Pollyzoid
Nov 2, 2010

GRUUAGH you say?

ToxicFrog posted:

C++:
code:
#include <iostream>
#include <fstream>

ifstream fd ("items.dat", ios::in|ios::binary|ios::ate);
ifstream::pos_type size = fd.tellg();
uint8_t * buf = new uint8_t[size];
fd.seekg (0, ios::beg);
fd.read (buf, size);
fd.close();

Let's make it two lines then.

code:
#include <fstream>
#include <vector>
#include <iterator>

std::ifstream ifs("items.dat", std::ios::in | std::ios::binary);

std::vector<char> stuff(std::istreambuf_iterator<char>(ifs),
                        std::istreambuf_iterator<char>());

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal

StorrowS posted:

I'm quite fond of the Qt libraries for simplifying a lot of the tedium of c++. The multi-threading and network libraries I have found particularly useful. Also the Qt GUI stuff is pretty good for knocking up quick, attractive HMI's.

Sadly I'm working on a project that's run by a bunch of morons and the thought of using useful libraries or *gasp* a language that's actually appropriate for the job is completely lost on them. I'd post more about this project in this thread but that would require articulating then endless problems and that would leave me seething whereas right now I simply ignore the problems and leave them plenty of rope to hang themselves with. I will note that it was hilarious to report all the critical failings of this project to the president of the company during a strategic brief. He was horrified - and it seems that someone in the chain has been covering things up. :toot:

I've used Qt for some non gui stuff before and found it pretty nice.

That Turkey Story
Mar 30, 2003

Pilsner posted:

Just curious, if I ever were to code some C++ again, is Boost like a good wrapper for all the horrible tedious stuff in basic C++, like having to write 10 lines of code to read a file and such? What about networking, image handling, databases, etc?

Reading files was already mentioned, but as for networking there's Boost.Asio, for image handling there's Boost.GIL.

E:

ToxicFrog posted:

Don't forget to delete[] (not delete) buf when you're done with it!

If you're manually using new and delete for dynamic memory allocation in modern C++, you're probably missing a better alternative in the standard library and/or boost.

That Turkey Story fucked around with this message at 19:35 on Sep 10, 2012

hepatizon
Oct 27, 2010

That Turkey Story posted:

If you're manually using new and delete for dynamic memory allocation in modern C++, you're probably missing a better alternative in the standard library and/or boost.

The use of "probably" kinda sums up the whole problem.

That Turkey Story
Mar 30, 2003

I'm only saying "probably" to be a pedant. unique_ptr is good for most cases where you'd use dynamic memory allocation, even when building higher-level data-structures, and shared_ptr and weak_ptr are good enough in those situations where one wants shared ownership. It's pretty difficult to come up with situations where you'd manually use new and delete for dynamic memory allocation in place of tools like these.

raminasi
Jan 25, 2005

a last drink with no ice

Pilsner posted:

The talk about inheritance hierarchies in games reminds me of something: EverQuest. Anyone else play that way back? There were so many quirky bugs, particularly with NPCs (monsters). You could trade with them, /tell to them (no error message = monster is alive somewhere in the dungeon), they could /say stuff, they could cast the same spells as players, they had mana and health like players, you could weigh them down by trading heavy items to them (like players), and much more. I'll bet my rear end it was because they had an inheritance hierarchy where both players and monsters inherited a lot of the same functionality.


Just curious, if I ever were to code some C++ again, is Boost like a good wrapper for all the horrible tedious stuff in basic C++, like having to write 10 lines of code to read a file and such? What about networking, image handling, databases, etc?

Boost can be nice but you absolutely won't forget that you're using C++.

Vanadium
Jan 8, 2005

Boost is more like the C++ standard library turned all the way up to eleven. If you want something that looks less like C++, try using some libraries that ship with Qt, I hear they're fairly convenient.

shrughes
Oct 11, 2008

(call/cc call/cc)
Boost is more like what happens when you take a bunch of sperglords who feel the need to make poo poo complicated in order to feel smart about themselves.

That Turkey Story
Mar 30, 2003

shrughes posted:

Boost is more like what happens when you take a bunch of sperglords who feel the need to make poo poo complicated in order to feel smart about themselves.

This is what programming plebes actually believe.

KaneTW
Dec 2, 2011

shrughes posted:

Boost is more like what happens when you take a bunch of sperglords who feel the need to make poo poo complicated in order to feel smart about themselves.

Boost is complicated? :confused:

hobbesmaster
Jan 28, 2008

KaneTW posted:

Boost is complicated? :confused:

Some people are allergic to templates or something.

Xae
Jan 19, 2005

Can I tell a horror story of being the only programming/technical resource on a 10 man team in IT?


BA 1: Hey Xae, Can you create a "Database-thingie"* to support this testing?
Xae: Sure, we have a database out there I can create some tables in. Just let me know what you need and when you need it by.
BA 2: We can't do that.
Xae + BA3-6: Huh?
BA 2: Xae is STEALING that software. He doesn't have a license for it! He said he has the studio installed on his own Laptop!
Xae: It (SQL Server Management Studio) is free software. They charge for the server, not the client. I have an MSDN Subscription anyway, so I can access most Microsoft tools...
BA 2: No, YOU ARE STEALING IT! I heard you say so Last week! That is a FELONY!!!!!! I won't be a part of it.
Xae: Huh?
BA 2: You said you had figured out some trick with the database!!!**
Xae: I don't like being accused of crimes in a team meeting. The company has a license, we have a license and the software is free anyway...
BA 2: STOP LYING!!!!!
BA 3: Well, we will just table this discussion...


* Direct Quote
**The trick was to write an array to a file and use BulkLoader to solve performance in a different app, which I found after poking around the studio finding bulk loader and finding the C# class associated with it. BA2 knows just enough to confuse the poo poo out of things and be dangerously ignorant.

KaneTW
Dec 2, 2011

Ouch. Were there any consequences for BA2 guy?

Markovnikov
Nov 6, 2010

Xae posted:

Can I tell a horror story of being the only programming/technical resource on a 10 man team in IT?


BA 1: Hey Xae, Can you create a "Database-thingie"* to support this testing?
Xae: Sure, we have a database out there I can create some tables in. Just let me know what you need and when you need it by.
BA 2: We can't do that.
Xae + BA3-6: Huh?
BA 2: Xae is STEALING that software. He doesn't have a license for it! He said he has the studio installed on his own Laptop!
Xae: It (SQL Server Management Studio) is free software. They charge for the server, not the client. I have an MSDN Subscription anyway, so I can access most Microsoft tools...
BA 2: No, YOU ARE STEALING IT! I heard you say so Last week! That is a FELONY!!!!!! I won't be a part of it.
Xae: Huh?
BA 2: You said you had figured out some trick with the database!!!**
Xae: I don't like being accused of crimes in a team meeting. The company has a license, we have a license and the software is free anyway...
BA 2: STOP LYING!!!!!
BA 3: Well, we will just table this discussion...


* Direct Quote
**The trick was to write an array to a file and use BulkLoader to solve performance in a different app, which I found after poking around the studio finding bulk loader and finding the C# class associated with it. BA2 knows just enough to confuse the poo poo out of things and be dangerously ignorant.

What are the other 9 people there for? "Relationship Managers"?

Xae
Jan 19, 2005

KaneTW posted:

Ouch. Were there any consequences for BA2 guy?

Nope!
The boss wasn't there, and she has bullied a lot of people on the team into submission, so that plus her being on the team for 3 years versus my 6 months means that I'm certain nothing will happen.

quote:

What are the other 9 people there for? "Relationship Managers"?
1 Manager
8 Business Analysts
1 "Business Analyst" (Really a developer/Architect)

Considering I'm doing a "full BA workload" in less than 10 hours a week, covering for one on paternity leave and still doing 20+ hours of development a week I have no clue what the rest of my team does. I manage more than half of our deliverable load in less than 20 hours a week.

MrMoo
Sep 14, 2000

SavageMessiah posted:

Ha! I'm stuck writing C++ and boost doesn't help with that poo poo at all sadly.

I'm using Boost + Chromium + 0mq.

I tend to rip apart the Chromium code and replace their weird C++11 compat code with either pure C++11 or Boost equivalents.

shrughes
Oct 11, 2008

(call/cc call/cc)

hobbesmaster posted:

Some people are allergic to templates or something.

Um, no.

That Turkey Story
Mar 30, 2003

Boost isn't perfect, but it's generally as complicated as it needs to be and no more. Libraries go through peer review before being accepted. If you think something specific can be simplified without sacrificing functionality then post to the mailing list and someone will either listen to you and make changes or they will kindly explain existing rationale. If you have patches, you'll be all the more welcome.

Adbot
ADBOT LOVES YOU

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.
At this point it's hard to say much about Boost in general, because Boost consists of a lot of libraries. Some of these are very simple to use and don't take much effort to understand. For example, anything that was absorbed into C++11. On the other hand, some of the libraries are insanely powerful, yet painful to use because there are so many prerequisite concepts involved. For example, GIL and Graph.

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