Search found 718 matches

by Sc4Freak
Tue Sep 11, 2012 2:43 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I've never liked the idea of making the distinction between points and vectors. There's a mathematical difference, but trying to enforce that through the type system just leads to annoyance and frustration in practice. I've used frameworks that do try to enforce it, and invariably I always run into...
by Sc4Freak
Mon Sep 10, 2012 11:22 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I've never liked the idea of making the distinction between points and vectors. There's a mathematical difference, but trying to enforce that through the type system just leads to annoyance and frustration in practice. I've used frameworks that do try to enforce it, and invariably I always run into ...
by Sc4Freak
Thu Aug 16, 2012 7:39 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

However, it did make me think a bit, and my current philosophy is that the usual convention of optimizing away assertions during release builds is in most cases going to be a premature optimization. Sure, every now and again you want to assert some property that actually takes some time to check --...
by Sc4Freak
Thu Aug 16, 2012 5:36 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

It feels as though I'm doing something terribly wrong and/or heinous, but I'm not sure what. :P Am I just scared of reflection from too many DWTFs, or is there some genuine reason why the above is a bad idea? I'm curious what the purpose of this is. Or at least, what does this do that you need that...
by Sc4Freak
Mon Aug 13, 2012 5:14 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Wow, you guys <i>like</i> the .NET libraries? I can't stand them: they're unpredictable and they violate basic rules of encapsulation by requiring the programmer to know the internal structure of the classes in order to use them. For example, I have to access rows in a System.Web.UI.WebControls.Tab...
by Sc4Freak
Sun Aug 12, 2012 5:30 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

You can do pointer arithmetic in C#, but you can't turn off the garbage collector. As for C# and .NET, I know next to nothing about them, so maybe I shouldn't say anything... but I don't expect to see particularly good language design coming out of Microsoft: things like elegance and simplicity tend...
by Sc4Freak
Sun Aug 05, 2012 6:08 pm UTC
Forum: Coding
Topic: Operator Overloading?
Replies: 36
Views: 8481

Re: Operator Overloading?

It's not so much that operator overloading increases the propensity for slow code when you don't expect it. It's that, without operator overloading, you can make stronger guarantees about what code does when looked at in isolation. If you see c[7] and you don't have operator overloading, you know ex...
by Sc4Freak
Tue Jul 24, 2012 7:05 pm UTC
Forum: Coding
Topic: Is the Right Tool a Matter of Preference?
Replies: 123
Views: 35262

Re: Is the Right Tool a Matter of Preference?

Of course memory management makes coding faster. Imagine C, exactly as it is, except now it's memory managed. All the time you've ever spent debugging memory leaks and segfaults just basically vanished. How is that not making you more productive? Because there's no such thing as a free lunch. C is ...
by Sc4Freak
Mon Jul 23, 2012 4:48 am UTC
Forum: Coding
Topic: Stupid Question
Replies: 15
Views: 3932

Re: Stupid Question

If you know in advance the number is a power of two, I'd usually just write a loop. But that's just because I tend not to like floats for integer operations.

If you really really need speed, consult the manual of bit twiddling hacks.
by Sc4Freak
Mon Jul 23, 2012 12:39 am UTC
Forum: Coding
Topic: Is the Right Tool a Matter of Preference?
Replies: 123
Views: 35262

Re: Is the Right Tool a Matter of Preference?

Yes, generally speaking memory is only a problem if you run out. There are some related issues which can impact performance - such as cache coherence - but strictly speaking that's not a direct consequence of high memory usage. EDIT: Kinda OT, but I'd actually be interested to see where C# lies on t...
by Sc4Freak
Sat Jul 21, 2012 7:57 pm UTC
Forum: Coding
Topic: Using Programming in Everyday Life
Replies: 24
Views: 13259

Re: Using Programming in Everyday Life

Ah, ever-changing requirements. The bane of every software engineer's existence.
by Sc4Freak
Wed Jul 18, 2012 11:39 pm UTC
Forum: Coding
Topic: Roller Coaster Tycoon in... Assembly?
Replies: 39
Views: 35858

Re: Roller Coaster Tycoon in... Assembly?

The performance of smart pointers in C++ depends on which one you use. unique_ptr is basically free. But because shared_ptr is reference-counted, there is some overhead in keeping track of the refcount. Each increment/decrement is the cost of an interlocked operation, which is a fairly expensive ope...
by Sc4Freak
Tue Jul 17, 2012 5:22 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

These decisions are hardly ever so black and white. You've essentially got the choice between making some small corner cases work, versus making all code run faster . I daresay say the C++ standards committee absolutely made the right decision here. If you really need a loop that cannot be optimized...
by Sc4Freak
Sun Jul 15, 2012 6:00 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I think you're exaggerating, at least - and that's a pretty big "except" you just glossed over. Pointers may be conceptually distinct from arrays in typical usage, but they *can* be used as arrays. Of course you can use a pointer as if it pointed to an array, because "using a pointer...
by Sc4Freak
Sat Jul 14, 2012 7:14 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

You wouldn't use -4 off of the allocated address, you allocate memory, then use +4 (or whatever) as the address of your actual array. You just have to make sure to allocate the extra bytes when you allocate the array (and of course make sure to pass the original allocated memory address when you fr...
by Sc4Freak
Wed Jul 11, 2012 6:40 am UTC
Forum: Coding
Topic: Is the Right Tool a Matter of Preference?
Replies: 123
Views: 35262

Re: Is the Right Tool a Matter of Preference?

It's probably more correct to say "C++03 is almost a strict subset of C89", because since C99 there have been a couple of divergences (which may have been reconciled in C++11? Not sure about that one). But in C89 there are only a few differences that prevent it from being a strict subset o...
by Sc4Freak
Sat Jul 07, 2012 5:21 pm UTC
Forum: Coding
Topic: Is the Right Tool a Matter of Preference?
Replies: 123
Views: 35262

Re: Is the Right Tool a Matter of Preference?

But that's mostly because I can't stand using my own code when it's shitty, much less somebody else's. Unless I was explicitly instructed otherwise, I'd probably rewrite a code-base of any size if I had to work with it and I didn't like its design. I think that's really common - almost everyone fee...
by Sc4Freak
Sat Jul 07, 2012 7:53 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Yes, I know . I already stated that several times. And this is exactly that - a pipe dream. Oh, how I would love it if people didn't cling to legacy systems. If everyone always upgraded to the latest version of their chosen browser. If all Windows customers didn't prefer to keep using a decade old O...
by Sc4Freak
Sat Jul 07, 2012 7:40 am UTC
Forum: Coding
Topic: Is the Right Tool a Matter of Preference?
Replies: 123
Views: 35262

Re: Is the Right Tool a Matter of Preference?

all I want is There's that false premise again. When have programmers ever only wanted one thing? As a meta-programmer you can have it all. Yes you can use your favorite functional language to write games for iOS using whatever pre-existing game engines exist. So in other words the entirety of your...
by Sc4Freak
Sat Jul 07, 2012 3:35 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I don't deny that XP still holds a huge marketshare. Or even that Vista was a failure. That wasn't my point. What I have a problem with is people's expectations for MS to continue supporting outdated, legacy software. Yes, I understand the reasons why. Yes, I know your customers are all still runnin...
by Sc4Freak
Sat Jul 07, 2012 3:15 am UTC
Forum: Coding
Topic: Is the Right Tool a Matter of Preference?
Replies: 123
Views: 35262

Re: Is the Right Tool a Matter of Preference?

@sourmìlk Is your definition of best "Most Profitable" ? That's actually another good question. What is the best definition of "best"? Does it depend on the situation? If so, how do definitions of "best" map to different situations? Well that's the point I was trying t...
by Sc4Freak
Sat Jul 07, 2012 2:10 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Oh Microsoft, I don't know how you manage it, but you managed to fuck up VS 2012 that bad. (They are fixing it, due to loads of developer complaints). Short version: Programs compiled with Visual Studio 2012 may not work on Windows XP. We didn't find out till we released the beta of something we we...
by Sc4Freak
Wed Jul 04, 2012 4:09 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Like a lot of things, a lot of C#'s annoying quirks are due to legacy. Like non-generic containers: (the first version of .NET didn't have generics due to time constraints) ArrayList a = new ArrayList; a.Add(5); List<int> b = new List<int>; b.Add(5); // safer, faster And array covariance: (needed to...
by Sc4Freak
Sun Jul 01, 2012 12:27 am UTC
Forum: Coding
Topic: Is the Right Tool a Matter of Preference?
Replies: 123
Views: 35262

Re: Is the Right Tool a Matter of Preference?

I'm going to clarify something: I certainly don't mean to imply that there are tools one shouldn't even learn how to use. Even if functional programming is the stupidest choice ever for my purposes, I certainly agree that it's worth learning. (I've been taking a look at it, and it's cool, but all t...
by Sc4Freak
Sat Jun 23, 2012 6:07 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I have actually yet to see an elegant solution for multi-level breaks in C or C++ that don't involve goto. Sometimes, it's just necessary to nest loops several layers deep (eg. initializing a 3D texture). And if you want to break out early, you have two options: use a goto, or use a boolean to signa...
by Sc4Freak
Tue Jun 19, 2012 5:20 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Yeah, that's basically the gist of it. The IL isn't really a very useful indicator of performance, because obviously the CPU doesn't run IL. The JIT compiles the IL into machine code at runtime, and performs optimizations along the way (like eliminating superfluous method calls for empty properties).
by Sc4Freak
Tue Jun 19, 2012 5:36 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I think this just confirms my suspicions that JIT compiling and inlining is deep magic. Here you go.... IL from a release mode build tl;dr version: Yes, using properties is definitely slower. Especially if you don't hand-edit the IL to optimize the method for calling the resulting mutator methods. ...
by Sc4Freak
Sat Jun 16, 2012 6:42 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Range-based for is in VS2012 if that makes you feel any better. :P
by Sc4Freak
Sat Jun 16, 2012 4:36 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Protip: prefer nonmember begin and end over .begin() and .end() member functions. For types that have member begin and end, the non-member versions do the same thing. But the nonmember versions are more generic (they work with more types). You save a whole character, too! (begin(v) instead of v.begi...
by Sc4Freak
Fri Jun 15, 2012 5:53 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

On the topic of C++11, is the following legal C++11? auto x = [](bool b) { if (b) return 1; return 2; }; It seems to compile in GCC but I was under the impression that you could omit the lambda return type only if the lambda body consisted of a single return statement. The above compiles in GCC but ...
by Sc4Freak
Thu Jun 14, 2012 5:24 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I think as a software company, Microsoft is past the point of posting screenshots of their applications on the frontpage of their website. I don't think Office or Windows have screenshots on their frontpages either. :P I've been following VS2012 reasonably closely and it's astounding just how much a...
by Sc4Freak
Wed Jun 13, 2012 9:43 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Also, booleans aren't convertible to integers in C#, so | must necessarily mean logical OR because bitwise isn't meaningful.
by Sc4Freak
Thu Jun 07, 2012 6:18 am UTC
Forum: Hardware
Topic: Hard drive seek performance
Replies: 9
Views: 3369

Re: Hard drive seek performance

Ok. I guess my question really boils down to: does it count as random access if you're jumping around within ten megabytes? Or a hundred? Is it sequential only if the information is literally 'touching', or is there a bit of a fuzzy region? "It depends". The OS is liable to readahead and ...
by Sc4Freak
Thu Jun 07, 2012 5:00 am UTC
Forum: Computer Science
Topic: feasibility of a new(?) kind of object in graphics engines
Replies: 3
Views: 3183

Re: feasibility of a new(?) kind of object in graphics engin

Yes, what you describe is essentially raytracing. People have been working on it for decades but compared to traditional rasterization rendering, it's never been able to produce equal image quality at the same processing power. If you have unlimited processing power and no realtime constraints, rayt...
by Sc4Freak
Thu Jun 07, 2012 2:22 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Speaking of parallel code... Take a look at microsofts amp project: http://msdn.microsoft.com/en-us/library/hh265137%28v=vs.110%29.aspx it (ab)uses the restrict keyword (so you can say "this function is restricted to using a reduced feature set of the language", which they need to be able...
by Sc4Freak
Wed Jun 06, 2012 6:14 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Do you care about ordering? If not, then when you remove a component just swap it with the last element and then remove the last element. That makes removal an O(1) operation.
by Sc4Freak
Tue Jun 05, 2012 5:49 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

Looks like a form of fuzz testing.
by Sc4Freak
Tue Jun 05, 2012 6:34 am UTC
Forum: Coding
Topic: RegEnumValue in Windows 7
Replies: 8
Views: 3376

Re: RegEnumValue in Windows 7

Have you tried running through a debugger? If not, that's your first step. If you're able to reproduce it and you can attach a debugger, then diagnosing the problem should be fairly trivial.
by Sc4Freak
Sat May 26, 2012 2:05 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I think x86 is basically the only architecture that allows unaligned memory access.
by Sc4Freak
Tue May 22, 2012 10:18 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9870
Views: 1781791

Re: Coding: Fleeting Thoughts

I think there are two different sets of semantics we're talking about here. One is the shared_ptr semantics, where locking a weak_ptr extends the lifetime of the object until the code block has completed execution. As I think you already realize, that's self-contradictory when applied to unique_ptr....

Go to advanced search