Improve your VS2010 performance under VMWare 7

Posted by HippieHunter Sat, 19 Dec 2009 02:02:00 GMT
Finally in VMWare 7 you can enable 3d acceleration and not just have VS2010 Beta 2 crash outright. you would hope this would improve performance when doing things like scrolling in the code editor. well it does, just not as much as it should. The WPF guys are doing some nifty eye candy scaling based on your hardware level. So if we want the full performance boost we need to disable the graphical goodies. Ive not seen a way to do this from inside VS but you can do it from regedit HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\General Has AutoAdjustExperiance and VisualEffectsAllowed. If you set them both to 0, Visual studio 2010 will perform much better.

It's actualy working now

Posted by HippieHunter Wed, 15 Jul 2009 07:38:00 GMT

 So after fighting with typo a little, idleing in the typo irc chan on freenode and diffing the current source tree I've managed to patch togeather typo that works the way I wanted. The culperate: a missing "only_path => true" on to_url for the comments form. So all is well and people can comment about things....

 

Edit: atom and rss should be working correctly now to(ive put my code samples in code sample boxes)


Hello World!

Posted by HippieHunter Wed, 24 Jun 2009 04:27:00 GMT

Welcome to the new home of my blog. I’ve moved to typo from live journal, mostly because I’m ramping up archverse hosting and have a nice platform availible to me.

So far typo seems nice but I think I’m going to need to hack in an OpenID client/server. I would really like to have OpenID as the primary means of identification in everything I do. The reason for this is two fold, first stackoverflow.com has a perfect implementation as far as I’m concerned, so good that everyone should have it. Secondly it’s really cool and I wish it was the primary form of ID everywhere on the net. 

As a side note the install of typo went a lot smoother once I learned to stop worrying and love lighttpd/fcgi. In fact I like fcgi(really the concept of multiple worker processes for a web server) that me next synergy enews article is on how you can serve wcf hosted in worker dbr processes.


Compiler safety and typing

Posted by HippieHunter Thu, 11 Jun 2009 18:03:00 GMT

As far as the internet is concerned C++ is a staticly typed language (also some people who think its strongly typed), academically we know this is untrue but this isn’t about what’s actually correct it’s about the perception of safety or lack of, from the C++ compiler. Certainly C++ lets you break all the rules and use void* for all types throwing caution to the wind but that’s not really all that common in non ancient C code. 
 
This particular rant is brought to you by a stack overflow response to a blatant flame war question "C++ slow, python fast? (in terms of development time)" one part of the large response caught my attention "That being said, static typing might be helpful if you're just making the move to larger programs. The compiler will catch some things that will only show up at run time with Python." While this is certainly true to an extent it’s really ignoring a very important reality. Inexperienced C++ programmers (the op clearly is) are wholly incapable of writing safe (read: compiler checked) C++. Remember that bit about all types as void*, rope, hanging and shooting one’s self? Well there are many shades of void* and most of them are used more frequently. at one of the more nitpicky ends is const correctness, it really is a pretty massive pain in the ass to maintain 100% const correctness but it’s got the odd habit of producing categorically better code. So why am I brining up const incorrectness and void* programming? Because that’s how people who are new (or old) to the language go about solving problems, with unsafe hacks to fill in their language feature knowledge gaps. 
 
My point in all of this is that people who believe they are effectively relaying the strengths and weaknesses of languages almost never say anything useful at all. Argument generalization is not the friend of general purpose programming languages. So here comes the mother of all generalizations, in all things if you are bad there is no tool that will make you good, only tools that will make you less bad. There are however tools that can make you worse, so if you're a badie at programming no amount of thinking C++ is faster or more type safe will ever make your code faster or more type safe.

boost.Assignment and other romps through syntax

Posted by HippieHunter Tue, 27 Jan 2009 12:03:00 GMT

 

 here is a bit of code from AV, don't think of this as c++, really it should be thought of as an AV built ins scripting DSL that happens to get compiled by the c++ compiler.

void somemethod()
{
        class PhilosophersStone
  {
  public:
    PhilosophersStone(vector<uint32_t> buildings, Project&; proj)  
    {
      buildings.push_back(proj.Id());
      proj.OnUpdateTurn = OnUpdateTurn;
    }
    static void OnUpdateTurn(Council& council, Player& player, Territory& territory, ControlModel& controlModel)

    {
      controlModel._commandAndControl += 5;
    }
  } philosophersStone(philosophy._buildings, PROJECT_TABLE.CreateProject(5000, 
    10000, 
    "Philosophers Stone",
    "its super cool and stuff",
    list_of( PREREQUISITE_TABLE.TechRequisite(philosophy))));
}

as you look at this you may notice that ive managed to get way to much code into a class declaration, yes infact the last ';' you see there is the ';' you normally see on class rawr {}; <---- that one. You might be saying to your self "holy shit wtf is he doing", well one of the features inherited from C is that you can create an instance of a struct/class directly after the definition of the type. well since this is c++, i can add a constructor and put that sucker on the end. Next up I create a project with mostly simple parameters but wait!!!! wtf is this list_of thing? list_of comes from boost.Assignment and it allows me to define a collection inline. the somewhat odd syntax for multiple elements would be list_of(5)(4)(3)(2)(1), just a bit of an eye-full there with all the overloaded operator() action. Still this once again demonstrates to me how vastly superior C++ is to every other language on the planet(that includes spoken languages).

 

 

 

 

 


baking with function pointers

Posted by HippieHunter Fri, 23 Jan 2009 00:41:00 GMT

One of the more interesting features in C++ template(IMHO) is being able to bake a compile time constant value directly into a template instance. One nice thing about function pointers is that they have a constant for an address. I'm not 100% sure what I can really use this for but it certainly looks cool! Of certain interest is template deduction on a function pointer, I was very surprised(pleasantly) to find this code compile.

#include<iostream>
#include<string>

using namespace std;

template<typename T, T (*F)(T)>
class rawrg
{
public:
  rawrg(T val)
  {
    F(val);
  }
};

template<typename T>
T method(T t)
{
  cout<< t << endl;
  return t;
}

int main()
{
  rawrg<const string&, &method> rawr("trivial");
  rawrg<float, &method> rawrg(5.5);
}

Everyone else sucks

Posted by HippieHunter Fri, 02 Jan 2009 21:05:00 GMT

 

Great title if somewhat deceiving. reading around on stackoverflow I noticed this block

Ive read all the arguments and comments and ive come to the conclusion that almost all programmers are terrible. Im not really sure why I havent encountered more of them in my daily life( maybe I am just oblivious). I am getting the distinct feeling that anyone who doesnt love programming, is terrible and shouldnt be doing it. Some people who love programing are terrible and shouldnt be doing it. Most people who bitch and moan about how xyz project got canned because of poor management  are terrible and shouldnt be programming. people who go on an on about how all my co-workers are bad at their jobs and i have to clean up after them...... you guys suck to, gtfo away from the keyboard and go do something less important. occasionally it is possible for other people to destroy a project but really..... if you were better you could have saved it(or not gotten involved in the first place) and provided a shining example to your apparently less fortunate  fellow employees.

Also any programmer that thinks maybe they should go into management.... get the hell out of my industry, you dont belong here. Programming is not middle management, we do things, productive things. As for the question, "Are we in demand", yes but only if you're not a whiny, incompetent moron that comforts their own ego by going on and on about how much better you are then some other person at work. Another thing, many of the nay sayers seem to be ashamed of their geekdom. Saying things like, "Get a life nerd." . Alternatively all good programmers  are "usually the ones that are unmarried and don't seem to have any non-geek friends or hobbies" wow.... way to be closed minded or something like that.

As for me, I figure if I keep finding ways to cleverly (ab)use language features and throw out enough TLA's(blinded by science!) no one will ever know :p Up next, more things I love about boost;

 


Ridiculus coolness

Posted by HippieHunter Mon, 22 Dec 2008 05:19:00 GMT

 This is a snip of code from AV and I am about to tell you once again, the single coolest thing in C++ is member pointers(function and data). oh and local class declarations are also THE shit. I suppose this isnt neccisarily the most readable code in the world but.... the most awsome things rarely are. Now if only synergy supported this :d

void MessageBox::SendMessage(ArchverseCore::Game::DiplomaticMessage &message)
{
  Player sendingPlayer, recivingPlayer;
  if(PLAYER_TABLE.Exists(message._senderId) &&
    PLAYER_TABLE.Exists(message._targetId))
  {
    class PushMessage
    {
    private:
      uint32_t _messageId;
      vector<uint32_t>& (MessageBox::*_target)();
    public:
      PushMessage(uint32_t messageId, vector<uint32_t>& (MessageBox::*target)()) : _messageId(messageId), _target(target) {}
      bool operator()(Player& player)
      {
        (player.Messages().*_target)().push_back(_messageId);
        return true;
      }
    };
    MESSAGE_TABLE.SaveMessage(message);
    PLAYER_TABLE.LockedTransaction(message._senderId, PushMessage(message._id, &MessageBox::Sent));
    PLAYER_TABLE.LockedTransaction(message._targetId, PushMessage(message._id, &MessageBox::Inbox));
  }

}

functional programming in Synergy/DE

Posted by HippieHunter Thu, 18 Dec 2008 17:46:00 GMT

 Yes it is possible to do the basics of functional programming in Synergy. It is missing some of the conveniences of C++ or ML but still it works. sometime in the future I will explain how this is useful to the average user.

import System.Collections
namespace functor
  
  ;;; <summary>
      ;;; The main entry point for the application.
      ;;; </summary>        
  main
  record
    al, @ArrayList
    ii, int
  proc
    al = new ArrayList()
    for ii from 0 thru 100
    begin
    data iii, @int
      iii = (@int)ii
      al.add(iii)
    end
    open(1, o, "tt:")
    for_each.Call(al, new MyFunctor())
  endmain
  
  class for_each
    public static method Call, void
    al, @ArrayList
    func, @SimpleIntFunctor
    endparams
    record
      ii, int
    proc
      for ii from 0 thru al.Count - 1
      begin
        func.Call((int)al[ii])
      end
    endmethod
      endclass
  
  abstract class SimpleIntFunctor
    public abstract method Call, void
    i, int
    proc
    endmethod
    
  endclass
    
  class MyFunctor extends SimpleIntFunctor
    
    public override method Call, void
    i, int
    proc
        writes(1, %string(i))  
    endmethod        
  endclass      
endnamespace

C++ is the greatist and most terribleist!

Posted by HippieHunter Sat, 26 Apr 2008 07:56:00 GMT
template<typename T>
class MemberPointerContainer
{
  typedef int T::* MEMPTR;
public:
  MemberPointerContainer(MEMPTR element)
  {
    _element = element;
  }
   
  template<typename R>
  static MemberPointerContainer CreateMemberPointer(R T::* element)
  {
    return MemberPointerContainer(reinterpret_cast<MEMPTR>(element));
  }
 
  template<typename R>
  void Set(T& t, R value)
  {
    typedef R T::* MEMPTR_SPECIALIZED;
    t.*(reinterpret_cast<MEMPTR_SPECIALIZED>(_element)) = value;
  }
  MEMPTR _element;
};

class NetworkEntity
{
public:
  int field1;
  int field2;
  double field3;
};
#include<vector>
void main()
{
  std::vector< MemberPointerContainer<NetworkEntity> > vect;  
  vect.push_back(MemberPointerContainer<NetworkEntity>::CreateMemberPointer(&NetworkEntity::field1));
  vect.push_back(MemberPointerContainer<NetworkEntity>::CreateMemberPointer(&NetworkEntity::field2));  
  vect.push_back(MemberPointerContainer<NetworkEntity>::CreateMemberPointer(&NetworkEntity::field3));
  NetworkEntity net;
  vect[0].Set(net, 5);
}
the nice thing is that even with all this indirection going on getting and setting is just like calling a member via 'this' as far as the actual x86 instructions are concerned. Why might this bee cool and terrible? Well the basic readability of it defines the terribleness, that combined with the general idea that you can do literally anything with C++ is a reasonably straight forward yet often obscure manor. As for the greatness, well this bit-o-code is going to help me write persistence layers that dont suck to code for. Something along the lines of boost::serialize only light weightier and more specialized to dealing with my style of data structures.