Jump to content
  • Advertisement
Sign in to follow this  
irreversible

"It's when you...", or: little things you've discovered about your fave IDE and/or programming language

This topic is 1012 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a habit of documenting my progress just to see how much time I've spent coding and what I've been working on. I was going over what I've written in the past couple of weeks, and I recalled several new things I learnt, which prompted me to start this thread.

 

This thread really does apply to any programming language or any IDE per se, but my own weapons of choice happen to be Visual Studio 2013 with a personal license of VA X (which, to me, has been worth every single penny) and C++. It periodically amazes me how massive and deep Visual Studio is (which is just about the polar opposite if Windows itself these days) and there are genuine moments of eureka that make my day every now and then. Moreover, by throwing extensions into the mix, the whole thing gets a completely new spin. The same applies to C++. So with that in mine, let's play a game of "When you..."!

 

C++: For instance when you can't figure out why your static scoped std::mutex is crashing even though its state looks fine in the debugger and the Thread Window kind of rolls its eyes at you. And then... you discover that static scoped initialization is pure evil by design. It amazes me how neither the compiler nor the IDE warn you about it in any way.

 

VS exension: When you stare at CreateProcess, wondering how you're going to debug that crash after you launch a new copy of your program as a child process. And then you discover this.

 

C++: Or when you realize mutable is the best thing since const correctness.

 

C++: Or when you put a few hours into writing a basic networked logger instead of a console logger and you realize the performance gains are in the range of two orders of magnitude.

 

C++: When you realize you can use decltype to write this macro for parsing a binary stream (you know, if only to spite the damn template crowd): 

 

#define MEMREAD(mem, res) { if(mem) { res = *((decltype(res)*)mem); ((uint8*)mem) += sizeof(decltype(res)); } }

 

C++: Or when you write this "soft assert" macro, which you can use in a function with or without a return value:

 

#define debug_assert(x, ...) if((x) != 0) { debug_print("Assertion failed: '" #x "' cannot evaluate to NULL"); return __VA_ARGS__; }

 

VS: Or, when you've been frustrated with the uselessness of the Output Window, because there's too much stuff in it and you FINALLY bother to right-click on it...

 

VS exension: When you finally give in and accept working with a code formatter. Now, this one's tricky, because if you're like me and don't particularly fancy any of the more widely used styles, you'll find code formatters temperamental little beasts to tame. I've had to give up several habits of aligning certain things just the way I like them, but in the end I think this has saved me tens, if not hundreds, of hours of chore over the past couple of years. There are probably a few out there, but the one I'm using is purportedly 1) the best, 2) no longer supported, 3) has several bugs that I've uncovered, which make me dance to its tune every now and then (for instance, it can't handle really long and complex macros, it occasionally adds spaces to all strings in a file, including paths if you forget to close an include string or some such accidentally, which can be very disorienting and annoying, it keeps bloody changing my alignment if there's something very particular I'm after, and it has a different placement style for single line and multiline if blocks, which is unbelievably annoying if you have a tinge of OCD in you). Here are my own fairly tweaked settings for VS Productivity Power Tools' code formatter for your pleasure:

 

[spoiler]

--style=vtk --align-pointer=type --align-reference=type --attach-namespaces --attach-classes --attach-inlines --attach-extern-c --indent-classes --indent-modifiers --indent-switches --indent-cases --indent-namespaces --indent-preproc-define --pad-oper --unpad-paren --add-brackets --add-one-line-brackets --keep-one-line-blocks --keep-one-line-statements --remove-comment-prefix --mode=c

[/spoiler]

 

VS extension: When you give Tab Studio 11 a go (while Tab Studio is not free, this is NOT an endorsement - I just happen to have found this extension by far the most usable of the tab managers I've tried. I'm in no way affiliated with the developer or any some such.)

 

VS: Or when you watch this video about the VS debugger, which will make you feel utterly stupid before completely blowing your mind (in all fairness, I stumbled on this a while ago): 

 

 
 
Now share some of your eureka moments!
Edited by irreversible

Share this post


Link to post
Share on other sites
Advertisement

C++: For instance when you can't figure out why your static scoped std::mutex is crashing even though its state looks fine in the debugger and the Thread Window kind of rolls its eyes at you. And then... you discover that static scoped initialization is pure evil by design. It amazes me how neither the compiler nor the IDE warn you about it in any way.

I'm pretty sure that was fixed in C++11 http://stackoverflow.com/questions/8102125/is-local-static-variable-initialization-thread-safe-in-c11.

Share this post


Link to post
Share on other sites

When you realize a new technique to increment a variable.
 

#include <iostream>
#include <functional>

template <class Ret, class... Args>
struct ForLoop {
    ForLoop(std::function<Ret (Args...)> func) : func(func) {}
    operator const ForLoop*() const { func(); return this; }
private:
    std::function<Ret (Args...)> func;
};
int main()
{
    int b = 5;
    ForLoop<void> fl([&]() { ++b; });
    **********************************************************************fl;
    std::cout << b << std::endl;
}

Share this post


Link to post
Share on other sites
Just recently I was exploring Visual Studio 2015's options, and I ran across the "Team" stuff and decided to play with it a bit.

I ended up discovering that Microsoft now has private source control hosting with free account limitations almost identical to BitBucket (5 team member max for free) which they call "Visual Studio Team Services". I switched a few of my repos over to try it out (using a git repo, NOT a Visual Studio Team Server repo), and it's pretty nice compared to my previous setup (BitBucket + TortoiseHg + Visual Studio with the terrible mercurial plugin).

It's even got a task tracking thing that I'm totally using instead of the local bare-bones task list that older versions of Visual Studio had. I use JIRA at work, so I really appreciate full-featured task tracking even for my own personal projects.

The integrated diff viewer inside Visual Studio HAS INTELLISENSE IN THE DIFF WINDOW. This is like the most amazing thing ever.

Source control, task lists, all cloud-backed up, AND smoothly integrated into my IDE, for free??? Sure, why not!


The git integration in VS2015 is limited; it can't currently handle SSH-secured Github-style remotes for some reason (no SSH auth, seriously Microsoft??), which means I can't use its fetch/push functions on our github repos at work (all local operations still work though). It only works perfectly with whatever authentication method VSTS uses. Edited by Nypyren

Share this post


Link to post
Share on other sites
I recall my mind being blown when I first saw the parallel stacks window in Visual Studio.

The git integration in VS2015 is limited; it can't currently handle SSH-secured Github-style remotes for some reason (no SSH auth, seriously Microsoft??), which means I can't use its fetch/push functions on our github repos at work (all local operations still work though). It only works perfectly with whatever authentication method VSTS uses.


Really? I could have sworn I'd used it with my personal BitBucket which should require SSH. Maybe I don't have my account configured properly.

Share this post


Link to post
Share on other sites


I recall my mind being blown when I first saw the parallel stacks window in Visual Studio

 

Holy crap, I've been using Visual Studio for the better part of 20 years and I've never seen that before. 

 

I am in your debt.

Share this post


Link to post
Share on other sites

The git integration in VS2015 is limited; it can't currently handle SSH-secured Github-style remotes for some reason (no SSH auth, seriously Microsoft??), which means I can't use its fetch/push functions on our github repos at work (all local operations still work though). It only works perfectly with whatever authentication method VSTS uses.


Really? I could have sworn I'd used it with my personal BitBucket which should require SSH. Maybe I don't have my account configured properly.


It could be a problem specific to our company's GitHub installation itself, too. It has funky issues like not being able to clone from https://... even when I use command line or TortoiseGit (and that might be why Visual Studio also fails, if it's only able to use https endpoints or something). It only lets us clone using the git@whatever:...git format endpoint.


I didn't try any other git repos other than my VSTS and my work ones so far. My BitBucket repos are in mercurial right now, too. sad.png

(edit) I tried it out with a random public github repo and it clones it just fine. I didn't try any operations that would require account authorization (pushing), though. Edited by Nypyren

Share this post


Link to post
Share on other sites

This thread is probably more suited for Coding Horrors section.

 

I've encountered people who don't know this so I'll mention:

  1. Hold ALT and drag vertically to edit multiple rows in same location. Allows easy aligning, copy/paste works as well.
  2. Use this extension to add extra functionality to ALT - hold ALT and click arbitrary locations to add carets there.

Share this post


Link to post
Share on other sites

When you realise that after all these years there is still yet more C++ syntax to learn, like function-try-blocks:

int func(int x) try {
   throw x;
} catch(...) {
   return x;
}

Which are more useful on constructors since they wrap around the initialiser list:

struct S
{
    S() try : foo(1), bar(2), baz(3)
    {
        // constructor block
    }
    catch (...)
    {
        // tada
    }
	
}

(Personally I learnt this a few years back - but it was at a point in time when I thought I knew the standard inside and out - which showed me not to be so presumptuous!).

Edited by dmatter

Share this post


Link to post
Share on other sites


When you realise that after all these years there is still yet more C++ syntax to learn, like function-try-blocks:

 

Wow. I actually checked the standard to confirm that it's really standard C++ and not some strange extension, but I'm pretty amazed right now. I guess that's how you felt when you learned it a few years back!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!