Search found 718 matches

by Sc4Freak
Mon May 21, 2012 9:19 pm UTC
Forum: Coding
Topic: Was I too harsh?
Replies: 167
Views: 42824

Re: Was I too harsh?

Zamfir wrote:
freakish777 wrote:Is it a Senior Software Engineer position for Lochheed Martin where you're writing programs that UAVs rely on (ie, people die if the code is wrong)?

The U really helps though, when it comes to safety

Not when you're dropping bombs from the things...
by Sc4Freak
Mon May 21, 2012 5:16 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

Tell me when I would be referencing memory that has been deleted. The two biggest memory errors are leaks and dangling pointers. Unique ptr solves leaks... I want to solve dangling as well. Shared and weak has issues with leaks due to reference leaks. Hmm. A weak unique that takes a lambda that tak...
by Sc4Freak
Fri May 18, 2012 4:10 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

Tell me when I would be referencing memory that has been deleted. The two biggest memory errors are leaks and dangling pointers. Unique ptr solves leaks... I want to solve dangling as well. Shared and weak has issues with leaks due to reference leaks. Hmm. A weak unique that takes a lambda that tak...
by Sc4Freak
Fri May 18, 2012 3:26 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

What would a "unique_weak_ptr" actually accomplish though?
by Sc4Freak
Thu May 17, 2012 1:03 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

As their names imply, unique_ptr is for unique ownership and shared_ptr is for shared ownership. Under the hood, unique_ptr automatically deletes the pointed-to-object when the unique_ptr goes out of scope. shared_ptr works differently - it only deletes the pointed-to-object if the last shared_ptr p...
by Sc4Freak
Wed May 16, 2012 11:15 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

Basically a general rule of thumb is to never say "new" without immediately putting the result into a smart pointer. { Foo* x = new Foo(); // bad /* ... */ delete x; // have to call delete manually otherwise you'll leak } { unique_ptr<Foo> x(new Foo()); // good /* ... */ } // x magically g...
by Sc4Freak
Tue May 15, 2012 2:07 am UTC
Forum: Coding
Topic: Are GUIs always frustrating/tedious?
Replies: 6
Views: 3510

Re: Are GUIs always frustrating/tedious?

Yes, there are other ways to do it. Try writing an application for WPF (or Silverlight, or Metro in Win8, or anything else that uses XAML). WPF, Silverlight, and Metro for Win8 all use the same general layout engine and while it can be hard to grasp at first, but it's probably one of the most elegan...
by Sc4Freak
Sun May 13, 2012 7:23 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

If you really want to do that then allocate it on the heap, not the stack. vector<int*> ptrs; { int* x = new int(5); ptrs.push_back(x); } assert(ptrs[0] == 5); But it sounds like you have a problem with your design anyway. Why have a giant switch statement in the first place? Why is the entity respo...
by Sc4Freak
Mon May 07, 2012 1:20 am UTC
Forum: Computer Science
Topic: How does a computer monitor work, OS-side?
Replies: 19
Views: 7929

Re: How does a computer monitor work, OS-side?

If all you want is a command prompt, you can somehow put the system in a text mode (there might be a couple of these, I'm not sure), and then you write to the monitor by just changing bytes at a specific location. When I was writing an OS for class, there were two bytes per pixel, one for the chara...
by Sc4Freak
Mon May 07, 2012 12:57 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

Also, DVCSs tend to be awfully slow at handling huge amounts of large binary files. Which is extremely common in some domains like game development.
by Sc4Freak
Sun May 06, 2012 6:56 am UTC
Forum: Coding
Topic: Programming paradigm advice
Replies: 7
Views: 1718

Re: Programming paradigm advice

What your friend describes is a state machine. The problem in general you're trying to solve is "game state management". And, yes, what your friend describes is a common approach to the problem. int* is a pointer-to-int. int& is a reference-to-int. They accomplish similar goals (indire...
by Sc4Freak
Thu May 03, 2012 1:00 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

As far as I'm aware the way covariance and contravariance is implemented in .NET is always type-safe (array covariance doesn't count, that's a holdover from Java). I don't think Thesh's code will compile. You should be able to do this, though: IEnumerable<IOrder> Orders = Dal.GetOrders(o => o.OrderD...
by Sc4Freak
Wed May 02, 2012 5:47 pm UTC
Forum: Coding
Topic: Getting into coding with a PhD in math
Replies: 20
Views: 9849

Re: Getting into coding with a PhD in math

Just be aware that a career in game development generally isn't going to be very pleasant for most people. Game developers are underpaid, severely overworked, and there is a constant stream of young graduates aspiring to be game developers.
by Sc4Freak
Mon Apr 30, 2012 4:08 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

But that's not why concepts were removed. Concepts were shown to make C++ slightly slower to compile but not fatally so. My understanding is that the real problem with concepts was semantic: there was disagreement about what a concept should be and how it should be implemented in the standard librar...
by Sc4Freak
Sun Apr 29, 2012 5:13 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

Yes, there wouldn't be any way to convert a lambda to a std::function. But that in itself doesn't seem like it would be a problem. In a sense, lambdas are analogous to functions (or functors) as std::function is to function pointers (if you understand my meaning). You can't take the address of a fun...
by Sc4Freak
Sun Apr 29, 2012 12:33 am UTC
Forum: Coding
Topic: Getting into coding with a PhD in math
Replies: 20
Views: 9849

Re: Getting into coding with a PhD in math

I have to ask first: with those qualifications, why not go into research? If you're interested in the Seattle area, then Microsoft Research is one of the largest and most well respected computer science research institutes around. There are MSR campuses all around the world, including the main Micro...
by Sc4Freak
Sat Apr 28, 2012 8:42 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

I don't remember where I heard this, but I think one of the reasons this didn't make it into the standard is because it raised some additional questions: if you can make a lambda have templated parameters by just specifying "auto" as the type (or "template" or whatever keyword yo...
by Sc4Freak
Sat Apr 28, 2012 8:03 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

Yes, the way this would be implemented would be to create a templated operator(). Normally a lambda can be expressed as a simple functor: struct MyLambda1 { void operator()(map<string, SomeHugeComplexType>>& x) { /* ... */ } } In a polymorphic lambda, the type(s) are merely replaced my template ...
by Sc4Freak
Sat Apr 28, 2012 5:19 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

For varying definitions of "help". :P
by Sc4Freak
Sat Apr 28, 2012 1:07 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

What I would like before a variadic lambda is just a simple polymorphic lambda - that is, a template lambda with an automatically deduced type. vector<map<string, SomeHugeComplexType>> vec; /*...*/ transform(begin(vec), end(vec), [](auto& x){ /* do stuff */ }); // alas this will not compile The ...
by Sc4Freak
Mon Apr 23, 2012 8:05 pm UTC
Forum: Coding
Topic: Smart Pointers
Replies: 26
Views: 5988

Re: Smart Pointers

LINQ?
by Sc4Freak
Mon Apr 23, 2012 1:22 am UTC
Forum: Coding
Topic: Differences between MSVC++ and G++
Replies: 11
Views: 3796

Re: Differences between MSVC++ and G++

The only other one I can think of that hasn't already been mentioned is that MSVC can be a bit lax on requiring the "template" keyword. This will compile in MSVC10: template<typename T, typename TBar> struct Foo : TBar { typedef Foo<T, typename TBar::Baz<T>> SpecificFoo; }; struct MyBar { ...
by Sc4Freak
Thu Apr 19, 2012 4:56 am UTC
Forum: Coding
Topic: Writing a Game Engine
Replies: 21
Views: 11325

Re: Writing a Game Engine

The two concepts are orthogonal. Using OOP patterns for your renderer or sound engine or whatever doesn't mandate a particular design for your entity system. For example, you might have some components that handle various aspects of rendering and transformation. If, for example, you use a traditiona...
by Sc4Freak
Thu Apr 19, 2012 3:10 am UTC
Forum: Coding
Topic: "Don't use comments"
Replies: 39
Views: 7571

Re: "Don't use comments"

That doesn't sound right... if a class holds onto some resources (unmanaged or otherwise) that need deterministic destruction, it should always implement IDisposable. It sounds like an oversight.
by Sc4Freak
Tue Apr 17, 2012 5:09 pm UTC
Forum: Coding
Topic: Writing a Game Engine
Replies: 21
Views: 11325

Re: Writing a Game Engine

Oh, and I forgot one thing that I was going to say earlier: Making a game engine on its own is actually not such a good idea. Game engines exist for only one purpose: to make games work. Constructing a game engine in a vacuum just plain doesn't work. You end up with a giant mess of very abstract, ge...
by Sc4Freak
Tue Apr 17, 2012 5:02 pm UTC
Forum: Coding
Topic: Writing a Game Engine
Replies: 21
Views: 11325

Re: Writing a Game Engine

Although unless it needs to be a singleton, don't make it a singleton. The only time you'd use a singleton is if it would be logically incorrect to have more than once instance. That doesn't apply to a renderer, so there's no benefit to making it a singleton. I like reinventing the wheel. It helps m...
by Sc4Freak
Tue Apr 10, 2012 6:27 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

I think most things in C are like that... What in the world does "atoi" do? ASCII-to-integer. Though, I've never understood exactly what the "T" in TCHAR/LPTSTR/etc stands for... Well yes, the point is that "atoi" is just as cryptic as "long pointer to constant ge...
by Sc4Freak
Tue Apr 10, 2012 2:37 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

I think most things in C are like that...

What in the world does "atoi" do?
by Sc4Freak
Mon Apr 09, 2012 5:38 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1975268

Re: Coding: Fleeting Thoughts

Didn't the old OpenGL API do the exact same thing? It's been a long time since I've used OpenGL but I seem to recall all its functions were postfixed with the type of the arguments it took.
by Sc4Freak
Thu Apr 05, 2012 5:18 pm UTC
Forum: Coding
Topic: Smart Pointers
Replies: 26
Views: 5988

Re: Smart Pointers

An example to help illustrate what I mean: void Frobnicate(const shared_ptr<Foo>& foo) { foo->Bar(); // Do other stuff to foo (observe, mutate, etc) } This uses shared_ptr to enforce reference counting. That's great, but what has it bought you? Frobnicate doesn't change the ownership of foo. It ...
by Sc4Freak
Thu Apr 05, 2012 5:03 pm UTC
Forum: Coding
Topic: Smart Pointers
Replies: 26
Views: 5988

Re: Smart Pointers

I disagree. In a single threaded application ,what Sc4Freak is saying is reasonable. But in a multithreaded one, that is not required to be so. If we have a structure A owns B, B keeps a raw ptr to A, if you use the raw pointer while A is being destroyed , the pointer is invalid. If you used a smar...
by Sc4Freak
Thu Apr 05, 2012 3:13 am UTC
Forum: Coding
Topic: Smart Pointers
Replies: 26
Views: 5988

Re: Smart Pointers

I disagree with some of these answers. Use a smart pointer when you need to express ownership semantics . That is, if you have a pointer which owns the pointed-to object, then you should use a smart pointer. Non-owning pointers should use raw pointers (but prefer references when applicable). In C++1...
by Sc4Freak
Tue Mar 20, 2012 10:24 pm UTC
Forum: Coding
Topic: Segfault on variable, that is used identically to another.
Replies: 4
Views: 1950

Re: Segfault on variable, that is used identically to anothe

I think you messed up your call to MPI_Scatter. I've never used this library before, but it looks like some documentation is here: http://mpi.deino.net/mpi_functions/MPI_Scatter.html An alternative description is that the root sends a message with MPI_Send(sendbuf, sendcount * n, sendtype, ...). So ...
by Sc4Freak
Thu Mar 15, 2012 11:30 pm UTC
Forum: Coding
Topic: On the Implementation of Entity-Component Systems
Replies: 32
Views: 20882

Re: On the Implementation of Entity-Component Systems

Yes, that's the idea. Like I said before, Components should basically be PODs. Use common sense, obviously, but that's the general idea of it. One of the main goals of Component systems in games is pure unadultered performance which is a requirement typically unique to game development. Components m...
by Sc4Freak
Thu Mar 15, 2012 11:27 pm UTC
Forum: Coding
Topic: Visual Studio Find and Replace Macro
Replies: 8
Views: 2749

Re: Visual Studio Find and Replace Macro

It's not a macro, it's just a regex that you use in the Find and Replace window.
by Sc4Freak
Thu Mar 15, 2012 3:40 pm UTC
Forum: Coding
Topic: On the Implementation of Entity-Component Systems
Replies: 32
Views: 20882

Re: On the Implementation of Entity-Component Systems

There's not really any compelling reason to use member functions. All fields are public, meaning a member function has no special access. And the only thing that will be able to call that function will be the component manager. So you may as well just put it in the component manager (so you can pote...
by Sc4Freak
Thu Mar 15, 2012 5:44 am UTC
Forum: Coding
Topic: Visual Studio Find and Replace Macro
Replies: 8
Views: 2749

Re: Visual Studio Find and Replace Macro

Find:

Code: Select all

//\[source1\]{(.|\n)*}//\[/source1\]{(.|\n)*}//\[destination1\](.|\n)*//\[/destination1\]

Replace with:

Code: Select all

//[source1]\n//[/source1]\2//[destination1]\1//[/destination1]

Unreadable, but seems to work just fine.
by Sc4Freak
Thu Mar 15, 2012 5:23 am UTC
Forum: Coding
Topic: On the Implementation of Entity-Component Systems
Replies: 32
Views: 20882

Re: On the Implementation of Entity-Component Systems

That explanation works just as well to explain why we don't actually need member access protection at all. Why does abandoning the private and protected keywords suddenly become safer in an entity-component system than in regular old OO programming? Also, I think the point of murphy is that, given ...
by Sc4Freak
Wed Mar 14, 2012 3:17 am UTC
Forum: Coding
Topic: Visual Studio Find and Replace Macro
Replies: 8
Views: 2749

Re: Visual Studio Find and Replace Macro

Could you give an example of what you actually want to achieve? This sounds like something that can be done simply with a regex.
by Sc4Freak
Wed Mar 14, 2012 2:27 am UTC
Forum: Coding
Topic: On the Implementation of Entity-Component Systems
Replies: 32
Views: 20882

Re: On the Implementation of Entity-Component Systems

The answer to that is "don't do that". You're trying to protect against murphy, not machiavelli. That is, your coding practices should aim to prevent mistakes, not to protect against sabotage. For example, it's a widely accepted idiom in C++ to pass large objects by const reference into a ...

Go to advanced search