« first day (526 days earlier)      last day (4412 days later) » 

4:00 AM
but then, I just don't have Object, at all, and never want to have it, and never will have it, so
 
@DeadMG Yeah, but I mean, reflection is incredibly useful in .NET. I like being able to query the type of an object at runtime.
Could have been some utility function or something, though.
 
sure, but there's nothing wrong with, say, class X : public Reflectable
 
Indeed.
 
in fact, I was planning on doing exactly that in Wide
 
Would allow you to specify which type to generate the metadata for.
 
4:01 AM
and skip types that don't need metadata generated
 
And then, if you try to query non-reflectable objects, bam, compiler error.
 
of course, I have a big advantage in Wide, because I can make your type inherit on request, rather than having to do it initially
 
Could have a compiler flag to make standard library types reflectable.
 
nah
event-based metaprogramming
 
Hmm.
Explain.
 
4:04 AM
type t = type {}; t.OnConversionRequested = [&](type other) { if (other == Standard.Reflectable) { t.BaseClasses.Add(other); } else throw BadConversionError(); }; return t;
 
I'm going to work on my "game" now I guess...
 
actually, that's really not quite what I had in mind... it's the wrong way around
should be the same functionality but listed on the Reflectable type
so you don't have to list it on every type t that comes along
anyway, the point is
 
how does curses function on a *nix computer? does it create a new window or run in the console?
 
when the compiler requests a conversion from any type t to Reflectable, and it fails, then it calls this user-defined function, which in this case, mutates t to now inherit from Reflectable, and then the compiler makes the conversion in the normal way
 
So, anytime you want to query metadata for a type, the compiler generates the metadata for that type if required?
 
4:07 AM
yes
 
Awesome.
 
I use it in many other ways to replace SFINAE, as well
 
...
 
for example, when you create a Vector(T), then if T is POD, you can resort to your implementation's memcpy equivalent
 
@ScottW Oh hey, I got a ping! Whazzup?
 
4:08 AM
but if T mutates to become non-POD, then an event fires so you can change your method implementation to fall back to the copy constructor
 
@Mysticial he wants to talk nano time units lol
 
I actually don't even have POD, I just went for trivial construction/copy construction/move/destruction traits, I'm pretty sure
but the point is the same
 
Oh oh, there will be blood.
 
@ScottW You're assuming I care about performance. :-P
I'm gonna need a lot more context than that.
 
@EtiennedeMartel you aren't going to murder anyone soon are you?
 
4:11 AM
the point is that event-based metaprogramming rocks
and I'm going to use it to create a whole world of mutating types for funsies and efficient compile-time metaprogramming
 
"java vs. c++" well... one sucks and the other doesn't. :-P
 
@Hoxieboy Nah, only my C++ runtime if it keeps sending R6025s in my face.
 
Anything specific?
 
@Mysticial Actually, both suck, but one way more than the other.
 
@ScottW (by nanoseconds I meant that point being, there isn't really a noticeable difference of two languages (doesnt matter which) unless you are creating a program to compare the windspeed of a fighter jet, every nano-second...)
@EtiennedeMartel that was my point entirely!
 
4:13 AM
@DeadMG I'm impressed. Do you think you could make Wide easy to embed? I bet it would rock as a "scripting" language.
 
The STL is not very usable without exceptions (allocations can fail without an easy way to detect them), what is the friendliest way around this? Intrusive containers?
 
Are you trying to measure nanoseconds?
 
@user1290696 Make your code exception safe.
 
@EtiennedeMartel Ironically, that was it's original function.
 
@Mysticial god no, I used nano-seconds and a time unit a computer is capable of tracking, I could have used seconds but why?
 
4:14 AM
@EtiennedeMartel That is impossible in my execution environment; we do not get to use exceptions.
 
but when I realized that I was describing a language that was vastly more powerful and easy-to-use, and faster, than C++, I realized it would be a better fit as a compiled language
 
@user1290696 Oh. Legacy code, eh?
 
@user1290696 Unfortunately, virtually all C++ libraries are not designed to function correctly without exceptions.
you would basically have to write almost all of your own containers and such from scratch
 
@EtiennedeMartel No, kernel mode programming environments do not have something akin to the entire Itanium C++ ABI implemented (which is what does the work of the stack unwinding, etc.)
 
@EtiennedeMartel But I do still have plans to use LLVM's JIT to execute Wide code, which could be interpreted from source.
 
4:15 AM
omh I have 2 more minutes left of the dwarf fortress theme to learn on my guitar 0-0
(2 out of 8 D:)
 
@user1290696 I don't think you should use the STL in the kernel.
 
@EtiennedeMartel The NT and xnu kernels allow, and xnu requires, C++ but both do not have a fully implemented runtime for kernel mode.
 
But I'm not a systems programmer, so...
 
in any case
I have many, many more things to specify and implement before any of this becomes reality
 
@EtiennedeMartel I do not want to use the STL because of the STL having an inappropriate interface, hence this question. I was wondering what is the "best" way to deal with this.
 
4:18 AM
@user1290696 You will have to write your own from scratch, effectively.
 
@ScottW Rather quick escalation!
 
tracing our though process, we went from being fat, to calculating walking distances, then calories burned, then obesity, then what causes obesity, then genetics, after, wards how stupid java is, then to a whole page and a half of arguing, and now finally, STL XD
 
@user1290696 But, actually, it's a very good question. Could you put that on SO?
@Hoxieboy "The room of a thousand topics"
 
@DeadMG No question, what I was curious is what is the best kind of API to expose...
 
@EtiennedeMartel it couldn't be more acurate :)
@ScottW speak nothing of these sins
 
4:20 AM
@ScottW That's actually a pretty accurate statement... lol For now at least...
 
@user1290696 Exceptions are ugly, but non-exception-based error handling is disgusting and always will be.
 
@EtiennedeMartel I will go ahead and do so in a bit.
 
there is pretty much no good API to expose at all
 
Don't forget to explain the whole problem and why you need that, otherwise you might get a bunch of bone headed comments.
 
@DeadMG Yes, lots of gotos.
 
4:22 AM
@ScottW What bugs me in the current republican race is that the only sane man is a libertarian.
 
@ScottW kinda like emerging out of creating bat files into a real programming language and finally figuring out what an array is?
 
@EtiennedeMartel What bothers me about politicians is all of them.
 
He's the sanest of them all.
 
That's still insane.
 
Yeah. But anyway I dislike libertarianism.
 
4:26 AM
STL to politics :D
 
@EtiennedeMartel And I hate disintegration.
 
Yeah, that must hurt.
 
Every fuckin time.
"And I hate disintegration." is a line in this song :p
So my game state changes in a worker thread and I want to somehow notify the GUI thread that it must redraw itself. What's your take on this?
 
one of the pet peeves of most languages I have experienced: {} or () to block multiple lines of code, its like... WHAYYYYYYYYYYY
 
@Hoxieboy "block multiple lines"?
Hey a line, let's block it!
 
4:31 AM
like in java:
try
                {
                        //get the radius from console
                        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                        radius = Integer.parseInt(br.readLine());
                }
                //if invalid value was entered
                catch(NumberFormatException ne)
                {
                        System.out.println("Invalid radius value" + ne);
                        System.exit(0);
                }
 
@StackedCrooked Worker and GUI thread is a bad abstraction for games, IMO
 
That's one of your pet peeves?
 
why not just python
try:
	something
except:
	something else
else:
	continue
 
@DeadMG Suggested alternative?
 
worker and GUI run synchronously with respect to each other
 
4:32 AM
its annoying to enter an entire new line for a single } character
 
worker internally runs asynchronously
 
1
Q: C++ STL Containers are unusable without exceptions, what can we do about this?

user1290696The supposed ethos of C++ is "what you use, you pay for". However, this can be quite debilitating due to exceptions and their pervasive use in the STL. Before anybody says "just turn exceptions on", life is not so generous with the programming environments we must live in. Mine is kernel program...

I hope I was descriptive enough.
 
and GUI runs internally asynchronously, if you're using a technology stack that allows that
 
No problem. Message loop works like that, right?
 
what, running the worker synchronously or the gui asynchronously?
 
4:34 AM
@user1290696 It's great. Unfortunately I don't have the skills to answer that, but perhaps someone on SO does.
 
@EtiennedeMartel I am fairly new to SO and wanted to be sure I was on-target etiquette wise
 
@DeadMG I'm not sure what you mean with running the GUI asynchronously. Is there any other way than to just run it on the main thread using a message loop?
 
(one of my favorite reasons however of using java is I can make programs that run on mah phone :D)
 
@StackedCrooked If you're rendering controls in hardware using D3D11 or D2D, they can accept rendering commands asynchronously.
I don't know of any other asynchronous renderers though
 
@DeadMG That's like PostMessage then?
 
4:36 AM
@ScottW blackberry curve
old one too lol
 
uh, not really
 
In the sense that the call is not blocking.
 
yes
 
...
 
well, all hardware renderers use non-blocking renderer calls, because the actual execution takes place on the GPU
the difference between D3D11 and normal renderers is that normal renderer drivers cannot accept commands to go to the GPU from multiple threads
 
4:37 AM
Ugh, just as I feared, I was misunderstood... sigh
 
derp moments -.- anyways @ScottW I think I'm going to research and see if there is a python compiler built for a j2me interface XD
 
whereas in D3D11, you can create command lists that can batch commands to go to the GPU all at once
and those can be created and recorded asynchronously, and then dispatched very quickly synchronously
also, there's a lot of rendering work like computing layouts and stuff which is basically a giant tree, and you can do all the child objects concurrently
in my 3D simulation, I can check for collisions for every object's next movement concurrently, compute all their world matrices concurrently, etc
 
So if the game state changes you simply call an asynchronous rendering command from within the same thread.
 
no
the game loop looks totally synchronous
while(dont_end) { process_user_input(); update_game_state(); render_game_state(); }
the difference is that update_game_state is concurrent in it's internal execution
 
So you update view regardless of whether there are game state changes.
 
4:42 AM
yes
that is how normal games work
remember that in the majority of games, the state is always changing
objects are moving, other players are interacting, animations are playing
computer players are changing the state
 
Currently do it like this as well. But it does mean a constant CPU usage even when nothing is happening.
 
The rendering is done at somewhat regular intervals (n times per second), but everything else happens all the time.
 
the general solution to that is to use a blocking timer
D3D9 has the vsync functionality which will block on Present()
but, of course, if you use user input polling, then you pretty much have to be constantly executing anyway, because else, you won't be polling for input and won't know when to wake up
 
I've gone back and forth between polling and notify/obverve.
 
the Windows message loop only supports polling, so that's what I've gone with
 
4:46 AM
Polling is less error-prone in any case.
 
the problem with notify/observe is that it really tends to break once you're trying to observe multiple input sources and that kind of thing
polling is more reliable, IMO
 
I'm currently working on a game engine, both for fun and learning, and for now it's all running in one thread. What would be the best way to make a multithreaded game engine?
 
@EtiennedeMartel 1. Keep current engine. 2. Insert some judiciously-placed parallel_for calls in place of existing for loop. 3. Done.
 
Oh. Seems easy enough.
 
depends where your bottlenecks are and how it's architected, of course
it's harder to do some kinds of games than others
for me, it's easy because my physics is very simple
 
4:48 AM
@DeadMG Additional problems arise if you want to notify in the worker thread and want to event to arrive in the GUI thread.
 
@StackedCrooked Yeah. It's not worth it over just polling, IMO.
worker/GUI works fine for work which is going to be multiple seconds, like, loading projects in Visual Stdio
but it's not worth it when you realistically have to work at what would be a good frame rate anyway
 
Using polling would solve a few of my problems.
 
personally, I architected my engine with concurrency in mind, and it has simple physics and I use few libraries, so it's easy for me
for example, I have a ComputeWorldMatrices function that loops through all the objects and computes all their matrices- but it's easy to see that each object could be done in parallel
so if I have N objects, I can run N threads
whereas when you have GUI/Worker, it only scales to 2 cores
I can assure you that Supreme Commander used Worker/GUI, and it had real problems with only going to 2 cores
it also means you don't have to mess with e.g. double buffering your game state and that kind of thing
 
If only we had infinite memory, then we could double buffer everything.
 
lol
more like infinite patience
 
4:52 AM
What is double buffering the game state?
 
double buffering is just annoying
 
A copy for reading?
 
@StackedCrooked It's basically the same principle as double buffering the frame buffer.
you have two copies of the game state.
one, your GUI thread reads and renders
the other, your worker thread mutates in the next worker tick
 
We're using it in our SC AI. Influence maps are double buffered because they need to be available for worker threads.
 
when they're both ready, you flip which is which
 
4:53 AM
Actually, it's more like n-buffered, with copy-on-write when the main thread comes and updates the maps.
 
so you can both mutate and read at the same time
 
@DeadMG The flip must be protected with a lock I assume?
 
it can be done atomically
 
How?
I asked on SO a while ago and the answer seemed to be that it was not possible.
 
well, you can't flip when they're in the middle of using them, so you naturally have to sync both threads before you can flip them
else you'll be rendering half one state and half another
but you could use InterlockedExchangePointer to safely flip them
 
4:54 AM
@DeadMG Fun fact: InterlockedExchangePointer does not swap pointers.
 
With flip you mean swap of the game state pointers?
4
Q: Atomic swap function using gcc atomic builtins

StackedCrookedIs this a correct implementation for a generic atomic swap function? I'm looking for a C++03-compatible solution on GCC. template<typename T> void atomic_swap(T & a, T & b) { static_assert(sizeof(T) <= sizeof(void*), "Maximum size type exceeded."); T * ptr = &a; ...

 
@StackedCrooked Right.
@EtiennedeMartel You're right. That's the wrong function.
but you can use InterlockedXor for the same effect
 
@DeadMG Yeah, I had to atomically swap boost::shared_ptrs. Turns out you need a critical section.
 
@DeadMG Does C++ atomic operations provide an equivalent?
 
@StackedCrooked Dunno.
@EtiennedeMartel Depends on how they're accessed.
you can atomically flip any T in a single instruction if you can control it's allocation and access
you know, now I come to think of it, that's probably not at all safe
I mean, you could still be reading out the old value
I would only achieve swapping the pointers pointing to them, as it were
anyway
 
4:59 AM
@DeadMG One thread periodically comes and updates what the pointer points to. Because I don't want to update stuff while some other thread is using it, I clone the data if it's being used elsewhere, update the clone, and then resets the pointer with the clone. But I don't want a worker thread to come by and get the pointer while it is being reset, so I have to use a critical section.
 
double buffering -> best avoided
 
Hurray for thread safe influence maps.
 
@EtiennedeMartel If both pointers are valid values after the reset, you can do it atomically.
 
If you got a better way, I'm listening.
 
@DeadMG Well, I'm using STM so it won't be needed.
 
5:00 AM
how aboutsomething like this
 
trick of x86: load instructions are atomic on word-sized values
so you can just do a normal read of the volatile value and get an atomic access
 
Yeah, we're pretty much guaranteed to use x86
 
I would also verify that your compiler actually outputs the intended assembly
I used volatile so it should be fine, but who knows
 
@DeadMG That's clever.
 
5:03 AM
@StackedCrooked This is double buffering, bitch! :P
the problem is that there's nothing preventing you calling GetSecond() and then the other thread flip()ing
 
I might return by value though.
 
so you can be certain that it won't crash, but you can't be certain that it's still the second you think it is
 
Perhaps a spinlock is safer.
 
which is why I said that both values should be valid values after the flip is called
 
I wonder how fast it would be to swap a boost::shared_ptr.
 
5:05 AM
else when you come to read the result of GetSecond, you get nasties
@EtiennedeMartel In this scheme, that one atomic operation. But, as I've said, it has dependencies to operate correctly.
if you were to flip() and then start writing to GetFirst(), for example, you could screw anyone who called GetSecond() and started reading
of course, my preferred method is the lockless concurrent queue
 
Lockless concurrent queue? Sounds interesting.. I created a worker class that stores tasks in a queue. It turned out to be a very error prone bit of code.
 
have a look at this
@StackedCrooked TBB and PPL both ship one.
I presume you can also find one in other places.
the Windows API has a forward list, which would be fine for this, as a built-in, I think
 
I'm just using boost::thread atm lol.
 
ah
that is a very big mistake, IMO
I mean, boost::thread is a step up from assembly, but not far
 
Does using utf8/16 turn most string operations into O(n) instead of O(1)
I'd think it would
 
5:12 AM
stuff like TBB is leagues ahead
many, many leagues
concurrent containers, concurrent algorithms, a concurrent memory allocator, sometimes even custom thread schedulers, agent-based systems
a metric shitload of stuff pre-provided with a perfectly good STL interface
 
Seems I've been missing out.
 
Unfortunately, we can't use TBB because we have to statically link everything.
 
with TBB, if you want to run in parallel, you change std::for_each to tbb::parallel_for_each
that's it
 
It's a requirement if we want to participate in the SC AI competition.
 
viola, one instant parallelised loop
you can see that it's leagues ahead of manually doing it yourself
@EtiennedeMartel That sucks. They don't provide a static lib?
if you can use VS2010, then the PPL is part of the CRT and you can link it statically
 
5:16 AM
Nope. Something to do with their scheduler being a singleton and stuff.
 
@DeadMG Ah, I ended up building Worker and WorkerPool classes to achieve something similar.
 
And we also can't use VS2010 because one of our dependencies requires VC++9.
 
And they are probably crappy.
 
@StackedCrooked the Vista API comes with a thread pool class (insofar as the WinAPI is ever a class), as well as SR/W locks and some other threading goodies.
including the flist I referred to, I think
 
I do like to write code that can run on Linux, Mac and Windows. That's kind of an old habit.
But TBB seems to be cross-platform.
 
5:18 AM
indeed it is
in fact, I'd be damn near an Intel tools fanboy if they didn't charge for their Windows version of their compiler :(
 
Is TBB only a 30 day evaluation thing?
 
I think it's free for non-commercial use
 
It's open source, IIRC.
Or maybe there's a dual-license thing.
 
@EtiennedeMartel I was about to say
I just downloaded the source code
 
On the webpage I need to fill in a form for a 30 day trial.
 
5:19 AM
why not just build a static lib of it yourself?
@StackedCrooked They did something really funky with it.
 
@DeadMG Felt like a pain, from what I've heard.
 
like, threadbuildingblocks.com is commercial, and threadbuildingblocks.org is the FOSS version
or something ridiculous like that
threadingbuildingblocks.org/download.php gives out the source for free
 
Cool. Apparently I was looking at the commercial page.
 
they use GPL v2 with Runtime Exception
so a pretty generous FOSS licence for non-commercial
 
If I use utf8cpp to work with UTF-8, will I have to reimplement all the algorithms like substring, find, etc.
 
5:24 AM
What does the Runtime Exception mean?
 
basically, it's a specific exception to the GPL which means that you can link GPL v2 libraries (with Runtime Exception) and use the contents of their headers, e.g. macros and templates, and not be GPL-ified yourself
so you could choose to release under the MIT licence or some other non-commercial licence yourself
whereas IIRC, the original GPL or without Runtime Exception means that if you use any GPL library, anywhere, then you must now be GPL software
 
@SethCarnegie C++11 supports UFT-8, but you probably knew that.
 
No, I didn't know that, how do you use it
u8string?
I think I will just use ICU
 
@DeadMG But if I release my code as MIT and my code uses on a GPLv2 library (with Runtime Exception) then my code still can't be used commercially I assume? Or it would be a simple way to hack GPL.
 
I wasn't aware ICU did regular expressions too
 
5:30 AM
Intensive care unit does regular expressions?
 
some do
 
Their job is a form of expression and they do it regularly.
 
we hope they do it regularly
 
Can anyone explain this typedef to me?
typedef int (*FnP)(void);
 
@soandos It's a typedef named FnP to a function pointer.
 
5:32 AM
@soandos Typedef to a function pointer of signature int() named FnP.
 
Got it, thanks
 
@StackedCrooked I'm pretty sure you can.
 
How did you get that though?
 
@soandos ?
 
5:33 AM
in fact, the terms of the GPL v2 licence with Runtime Exception fairly clearly indicate that it's the express purpose of the Runtime Exception to not put any restrictions on the licence of the user's code
 
@soandos that's just the syntax for it
 
@soandos here it is
 
@soandos the same way we know what int x; does
 
ah, got it
thanks
 
of course, with TBB, specifically, you would fall under the terms of their other licence
 
5:33 AM
@DeadMG Aarg, legalese. I no understand.
 
but that's a TBB thing, not a GPL v2 Runtime thing
@StackedCrooked It means you can release commercial closed-source software that uses GPL v2 Runtime Exception code.
 
@DeadMG Then why would anyone ever buy the commercial version of TBB?
For support?
 
because Intel's dual licencing means that for them, specifically, if you want to sell it, you have to buy commercial
I think
 
@StackedCrooked for their conscience's sake
 
but under the terms of the non-Runtime GPL, you would have to be open-source and free
whereas under GPL Runtime v2, even for Intel, you could be closed-source and free
or it might just be a "Pay for support" dealie
I think, after reading some more, that their legalese means that it is exclusively a "Pay for support" deal
 
5:37 AM
But if I write a dummy library with MIT license and make it depend on TBB and use that from within my code the I don't have to pay the license. That sounds too easy to be true.
 
and the OSS version is usable in commercial software
@StackedCrooked You can't get Intel to support you unless you pay them. There's no way around that.
which supports my (revised) theorem
 
I go to SO for support.
:D
 
lol
me too
but you know, some managers, they might be like "Must get support direct from manufacturer!"
also, their FAQ fairly well states that if you bought other Intel products, then you might prefer the commercial licence so it's all under the same roof, as it were
 
DeadMG seems a lot nicer lately
 
At the job we're shipping code + server hardware as a single product. Servers are not Intel though, but Supermicro.
Not that it much since we're not using TBB but posix... Heh.
 
5:49 AM
hopefully, this time next ... century ... I'll be shippin a gaem
 
Shipping a game as an individual game developer? Sounds like a big job.
 
depends on the size of the game and the quality of my tools :P
 
Today seems to be the age of the indie developer.
Esp for mobile development.
 
of course it is
triple A is tired and over-done; their dev budgets are through the roof
indie devs offer innovative, fun, and cheap games for low budget
 
I don't have much marketing skills or business sense. I just like to code. So this probable isn't much for me.
 
5:55 AM
Innovative? I don't know, most indie games seem to be either physics puzzle games or edgy adventure games featuring a child losing his innocence.
 
@StackedCrooked What isn't much for you?
 
@DeadMG Being an indie game dev :)
 
@EtiennedeMartel Depends on the segment. I generally found that to be true of phones, less true of PC.
@StackedCrooked heh. I don't have much of those either. That's what Steam is for.
that's why indie gaming is taking off
 
That's true.
Hey, maybe it is my thing! Yeah!
 
cheap, risk-free distribution of any game that can compile and execute with a reasonable level of bugs
 
5:58 AM
I have a friend who released an iPhone app called "ski maps". It appears to be pretty successful.
 
Steam is the best
 

« first day (526 days earlier)      last day (4412 days later) »