Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411735 Posts in 69404 Topics- by 58457 Members - Latest Member: oiledsurvivor

May 22, 2024, 09:39:36 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)C++ is frequently reviled both by those who never use it and by those who use it
Pages: 1 ... 6 7 [8]
Print
Author Topic: C++ is frequently reviled both by those who never use it and by those who use it  (Read 18822 times)
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #140 on: October 22, 2009, 01:39:16 PM »

I just abandoned IDEs altogether.  I do most of my work on Linux now, with vim and a makefile. 

Replace "Linux" with "Mac" and "vim" with "TextWrangler" and this describes me. Although when starting a new project I use shell scripts instead of makefiles, because they're a lot easier to write. I only switch to makefiles when the project gets big enough.

I use a shell script to generate my makefile, since I can't for the life of me figure out to use the GNU autotools.

The big C++0x thing that everyone seems to ignoring are rvalue references.  These things are huge.  They allow 'pass by move,' which in some studies I've seen improves the performance of certain STL containers and algorithms by something like 90%.  The best part is that you won't need to change any of your code to get the performance benefits, just recompile against the C++0x standard library and you're good.

What pass by move does is it allows temporary objects to have their contents 'stolen' rather than copied.  Consider something like this:

Code:
class LinkedList
{
public:
    LinkedList();
    LinkedList(const LinkedList &copy); // Copy constructor.
    LinkedList(LinkedList &&copy); // Move constructor **NEW**
    ~LinkedList();
    LinkedList &operator = (const LinkedList &rhs); // Copy assignment.
    LinkedList &operator = (LinkedList &&rhs); // Move assignment **NEW**

private:
    struct Node
    {
        int data;
        Node *next;
    } *head;
};

LinkedList::LinkedList(const LinkedList &copy)
{
    // Usual deep copy.
}

LinkedList::LinkedList(LinkedList &&copy)
{
    // Steal the linked list from the other object.
    head = copy.head;
    // Make the original object safe to delete.
    copy.head = nullptr; // C++0x null pointer constant, NOT a macro.
}

LinkedList &LinkedList::operator = (const LinkedList &rhs)
{
   // Usual stuff, clean up current data, deep copy rhs data.
   return *this;
}

LinkedList &LinkedList::operator = (LinkedList &&rhs)
{
    // Clean up this object (not shown), then steal the list from the rhs.
    head = rhs.head;
    // Make rhs safe to delete.
    rhs.head = nullptr; // C++0x null pointer constant, NOT a macro.

    return *this;
}

Temporary objects bind to rvalue references before lvalue ones, so now if you return something like a vector of 1000 strings from a function, instead of being copied, it will moved into its destination.  The move process is generally constant time and extremely fast.

This also allows you to create objects that only have move semantics, by disabling the copy functions and only providing move functions.  This is something that I've wanted for a long time, but I haven't been willing to abuse auto_ptr to get it.
Logged



What would John Carmack do?
Glaiel-Gamer
Guest
« Reply #141 on: October 22, 2009, 01:45:29 PM »

]
The big C++0x thing that everyone seems to ignoring are rvalue references.

in my advanced c/++ class the professor mentions this like every day
Logged
increpare
Guest
« Reply #142 on: October 22, 2009, 02:26:22 PM »

this article contains some mild c++0x amusements, for those who haven't read it (not totally high-quality, but gave me a chuckle or two).

actually this is funnier, though c++ rather than c++0x related.
« Last Edit: October 22, 2009, 02:31:39 PM by increpare » Logged
Jason Bakker
Level 2
**


View Profile WWW
« Reply #143 on: October 22, 2009, 04:36:19 PM »

XCode is nicer in general, although the lack of tabbed source files still bites. Grar!

I like Xcode because it doesn't have tabs.

The tabs drive me nuts in VC++/Dev-C++/Code::Blocks because it seems like I only have two options:

No tabs at all.

Open a new tab every damn time I look at a new file.

What is it with IDEs doing this?  Do people actually want that?  Surely I'm not the only person that wants a tab when I ask for it, and only when I ask for it, just like a web browser.

Or have I just been overlooking that option for years?

Yeah, tabs could definitely be smarter. I generally have to clean up my tabs (just close everything and start again) every couple of hours or so Apoplectic But at least for me it's better having them than not.
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #144 on: October 22, 2009, 04:45:38 PM »

XCode is nicer in general, although the lack of tabbed source files still bites. Grar!

I like Xcode because it doesn't have tabs.

The tabs drive me nuts in VC++/Dev-C++/Code::Blocks because it seems like I only have two options:

No tabs at all.

Open a new tab every damn time I look at a new file.

What is it with IDEs doing this?  Do people actually want that?  Surely I'm not the only person that wants a tab when I ask for it, and only when I ask for it, just like a web browser.

Or have I just been overlooking that option for years?

Yeah, tabs could definitely be smarter. I generally have to clean up my tabs (just close everything and start again) every couple of hours or so Apoplectic But at least for me it's better having them than not.

If I could find out a keystroke to "navigate one tab let/right" or "move to first/last tab", even "move to last selected tab"(and from there they would switch back and fourth, rather than keeping a history of tabs) my life would be so much easier, and I would actually like using tabs.
Logged

Ivan
Owl Country
Level 10
*


alright, let's see what we can see


View Profile
« Reply #145 on: October 22, 2009, 05:33:43 PM »

command + option + left or right arrow
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #146 on: October 22, 2009, 05:51:05 PM »

command + option + left or right arrow

If only my Windows PC + Visual Studio combination supported Mac style keyboard shortcuts.  Beg

I've been working on file-heavy projects lately, and it's getting annoying.(using Visual Studio, since MFC can make a lot of the GUI work much, much easier.)

[EDIT]
Although, after taking a look through some shortcuts here I found out how to bring up a nifty dialog to switch tabs in VS(Ctrl+Tab)
« Last Edit: October 22, 2009, 05:59:53 PM by Jakman4242 » Logged

Ravine
Level 0
**


View Profile
« Reply #147 on: October 22, 2009, 10:51:31 PM »

often on Windows

[Ctrl + Tab] to move forward in your tabs
[Ctrl + Shift + Tab] to move "backward"
[Ctrl + F4] close selected tab

(works in most "tabbed apps" i used. Just tested in Firefox, still works)  Gentleman
Logged
Klaim
Level 10
*****



View Profile WWW
« Reply #148 on: October 23, 2009, 01:16:02 AM »

Indeed, just know your tools gentlemen.
Logged

Ann Ishman
Level 0
**


View Profile
« Reply #149 on: October 23, 2009, 10:46:11 AM »

XCode is nicer in general, although the lack of tabbed source files still bites. Grar!

I like Xcode because it doesn't have tabs.

The tabs drive me nuts in VC++/Dev-C++/Code::Blocks because it seems like I only have two options:

No tabs at all.

Open a new tab every damn time I look at a new file.

What is it with IDEs doing this?  Do people actually want that?  Surely I'm not the only person that wants a tab when I ask for it, and only when I ask for it, just like a web browser.

Or have I just been overlooking that option for years?

Yeah, tabs could definitely be smarter. I generally have to clean up my tabs (just close everything and start again) every couple of hours or so Apoplectic But at least for me it's better having them than not.

Tools > Options > Environment > Documents > [X] Reuse current document window, if saved

At least in Visual Studio 2008. Not sure about other IDEs/versions. I would think a similar option is somewhere in the scary dark corners of the app settings. I will admit not having a new tab button is mildly annoying, but hitting space on the active document if it has not been edited to get a couple tabs open to play with is minor inconvenience.
« Last Edit: October 23, 2009, 11:00:23 AM by AnnIshman » Logged
Glaiel-Gamer
Guest
« Reply #150 on: October 23, 2009, 11:17:40 AM »

Maybe it's just cause I'm a mac person, but I've never really liked tabs that much. I rarely use them when browsing, I hate adobe products forcing all the documents into tabs, I like xcode's lack of tabs.

OSX handles multiple windows very nicely with expose and junk and I've always found that a lot nicer than multiple tabs in one window.
Logged
Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #151 on: October 23, 2009, 01:42:05 PM »

I agree, besides, the tab adding algorithm makes it so I can never find the file I'm looking for in the tabs (Except when I have a low file count)  Grin.

I don't really mind tabs, they're just there and I usually don't use them.
Logged

Working on HeliBrawl
Kekskiller
Guest
« Reply #152 on: October 23, 2009, 02:03:31 PM »

I like tabs. Even if it's just used for some kind of simplistic overview.
Logged
Tycho Brahe
Level 10
*****

λx.x


View Profile
« Reply #153 on: October 23, 2009, 02:32:17 PM »

I find tabs both useful and annoying. Useful in that I don't have to manage multiple windows, but annoying in the way the programs I use organise them.
Logged
Jason Bakker
Level 2
**


View Profile WWW
« Reply #154 on: October 23, 2009, 03:56:29 PM »

Tools > Options > Environment > Documents > [X] Reuse current document window, if saved

At least in Visual Studio 2008. Not sure about other IDEs/versions. I would think a similar option is somewhere in the scary dark corners of the app settings. I will admit not having a new tab button is mildly annoying, but hitting space on the active document if it has not been edited to get a couple tabs open to play with is minor inconvenience.

A bit less minor if you're using source control, unless you're talking abut pressing space, opening the new tab, tabbing BACK to the previous tab to undo your space and saving that, then tabbing forward again to get to the tab you wanted to get to in the first place? Tongue

Thanks for the info though, I'm only using 2005 at the moment, but I'll file that option away for future reference when I upgrade...
Logged

Ann Ishman
Level 0
**


View Profile
« Reply #155 on: October 23, 2009, 04:48:03 PM »

Source Control doesn't complicate things all that much. After enabling that option:

  • Starting with a blank editor, project open with no tabs, open any old file and make a meaningless change to the file (checking it out first if applicable) such as hitting space or adding an empty comment - editing the file.
  • Open any other random file while the edited file is the active tab which will give you two tabs.
  • Go back to the edited file tab and repeat the previous step opening different files until you have as many tabs as you like (I like 6 or so).
  • Once you have as many tabs open as you like go back to the edited file and undo your check out. (This last step isn't really necessary unless trivial differences bother you in your version history. The better control systems will usually not even bother adding the file if only a space has been added anyway.)

Luckily VS will leave the tabs open next time you open the project so I find myself doing this only with new projects or the odd time I close a tab out of habit. Oddly enough the length of this explanation makes it seem much more complicated than it really is. Once you get it, doing the steps above takes all of 5 seconds to complete.
« Last Edit: October 23, 2009, 04:51:43 PM by AnnIshman » Logged
artanis
TIGBaby
*


View Profile
« Reply #156 on: October 27, 2009, 07:00:03 AM »

Tools > Options > Environment > Documents > [X] Reuse current document window, if saved

At least in Visual Studio 2008. Not sure about other IDEs/versions. I would think a similar option is somewhere in the scary dark corners of the app settings. I will admit not having a new tab button is mildly annoying, but hitting space on the active document if it has not been edited to get a couple tabs open to play with is minor inconvenience.

Thanks for the info though, I'm only using 2005 at the moment, but I'll file that option away for future reference when I upgrade...

The same option exists in VS 2005.
Logged
Pages: 1 ... 6 7 [8]
Print
Jump to:  

Theme orange-lt created by panic