Why boost is impractical
March 29, 2010 on 6:15 pm | In .english, coding | No CommentsIn the C++ programming world, the peer reviewed boost libraries are a gold standard to measure every other library on. Several parts of this library are being made standard in the next C++ standard, C++0x.
So, everybody would be using boost, right?
Well, no… You see, boost is a BIG library. It installs 64Mb worth of header files alone, 24Mb of libraries, and takes 20 minutes to compile on my machine, an average dual-core.
Now suppose I have a simple C++ program, a few files long, that uses some boost to parse the commandline. that would build in some seconds… why would i wait for 20 minutes for the code to arrive to simply parse the commandline? I’m not very happy that parsing the commandline this way requires you to redistribute a 300K+ .dll file.
GNU getopt on the other hand, compiles to less than 5K of code that you link in directly, so no .dll needed.
And they both do more or less the same thing. Sure, boost.program_options does a lot more, but it just is too excessive. And that’s why boost is impractical. You want a sip, but you get a bucketload shoved down your throat ![]()
Turing machines
March 18, 2008 on 4:37 pm | In .english, coding | No CommentsI was surfing the web and found this blog article on Turing machines, and it mentions this great Turing machine java applet.
New C++ feature: concepts
March 1, 2008 on 2:51 am | In .english, coding | No CommentsThere is a new language feature in C++ going into the upcoming standard, ‘concepts’. If you seriously want to know more about them, there is a google talk about them (There is a google talk index site here and at youtube). Below is the shortest usable example of using concepts. Remember when reading the code: a concept defines which functions and operations a type, used to instantiate a template with, must provide. The code below compiles and runs with ConceptGCC.
// list all operators and functions used in the
// template 'add_t' (below) into concept AddType.
concept AddType<typename T>
{
T::T(const T&);
T operator+(const T&,const T&);
}
template <AddType T> // notice 'AddType' instead of 'typename'
struct add_t
{
// uses the required operator+, and copies
// the result using the copy constructor
T add(const T& a, const T& b) { return a + b; }
};
// an 'int' can do all that's required by AddType...
concept_map AddType<int> {}
int main()
{
add_t<int> x;
int result = x.add(1,2);
return result;
}
As you can see, all this is just a complicated way of writing 1+2, so if you optimize properly, all this boils down to: int main() { return 3; } as it should.
C# Coding
October 6, 2007 on 1:32 am | In .english, coding | No CommentsWith my new job i’m confined to the C# coding, but not all is lost, i’ve already more or less accepted that windows coding must be C# .NET.
However, the language C# is easy to work with, and has many possibilities for writing good code. And the Visual Studio IDE allows RAD for various types of projects.
And if you really want native code in those C# programs, like zlib or libpng, you can use C++ assemblies to do that.
So not all portability is lost, but certain parts require specific windows coding, and that’s O.k. for now.
Unittesting and c++ templates
May 2, 2007 on 7:43 am | In .english, coding | No CommentsI’ve been doing some C++ templates recently, and I found out that ‘unit testing’ is absolutely handy when making templates. Say you have a template like this:
template<class T> struct foo { T data; foo() { data = 0; } };
I could define an operator ‘+’ on it using complicated syntax, but say I have done that, and I want to test that it works. (And, say, you want T is ’std::complex<float>’ and ‘float’, for example.) Okay:
template<class T>
struct foo_test
{
inline foo_test() /* here we test the whole 'foo' class on syntax */
{
foo<T> x,y,z;
z = x + y;
}
};
inline void foo_test_instantiate() /* here we instantiate *the test* for our supported types */
{
foo_test<float> tmp1;
foo_test<std ::complex<float> > tmp2;
foo_test<std::complex<long double> > tmp3;
/* done testing supported types */
}
I suppose you can place this kind of syntax checking right into the header file, as it has zero code overhead, if it wasn’t for the fact that those get too big as it is, and testing doesn’t belong there anyway.
C++ braindump on iterators
April 28, 2007 on 9:40 pm | In .english, coding | No CommentsIterators are really fun, because when you implement them in your own class, you can have all STL algorithms at your disposal. It’s typical in current C++ to want this kind of things. Here is a few links about that: [gpwiki.org] and (less interesting), [codeguru.com].
AMD Quad Father
October 21, 2006 on 11:28 pm | In .english, coding | No CommentsOkay, the cpu industry goes fast at the moment. Just as I laid my hands on my first Intel Core Duo processor, AMD is gonna bring out a Quad processor configuration.
This is pretty awesome stuff:
” During our session, AMD was quick to point out the inherent benefits of their “Direct Connect” architecture, which is brought to the system via serial HyperTransport links.
In the architecture Memory, CPUs and certain IO subsystems are all directly connected to each other via HT and it affords AMD a huge advantage in scalability. So much so that they’re already speaking of octal core implementations. In addition, it’s our early estimation that this is the single most important advantage that a quad-core AMD architecture has over Intel’s Kentsfield CPU that is soon to be launched.
(…) The board has no less that 48 lanes of PCI Express connectivity brought out to its four full-length X16 PCIe slots. This will provide a ton of room for expansion for not only graphics but other technologies like PCI Express RAID cards for example. Also note the 12 X 3G SATA ports — holy RAID Batman.
(…) Specifically the machines had two instances of City of Heroes running, two HD video streams playing, including a Battlefield 2142 trailer, and a video conversion going on, all at the same time. In this case all four cores are pegged at 100% utilization but in fact there is plenty of horsepower left to navigate around Windows XP and launch other applications. AMD is citing that more than 20 mutli-threaded game titles are targeted for release in 2007. We’d offer that is even perhaps a bit conservative, as without question the world has now officially gone multi-core, whether you consider the developer or end user community.”
So. That’s a shitload of horsepower. Do I need it? Sometimes, but surely not all the time. Right now all what i’m doing is typing this blog entry. I could do some video conversion in the background, but I’m probably done coverting that few video’s pretty soon.
Moving from 32 to 64 bits
January 25, 2006 on 11:53 pm | In .english, coding | No CommentsWindows Vista will mean several things: DRM, 64-bit multicore processors, more than 4GB memory (true 64-bits, ddr3), and DirectX 10.
C/C++ compilers generate great assembly code, but sometimes you want to get down to the metal and do every instruction yourself. Under the x86 architecture, this usually means you want to do specific MMX/SSE stuff in your application.
compiler code generation
To support modern architectures, you basically need to recompile. x86-64 issues are handled by recompile for that architecture, sse2 stuff requires your compiler to be very good at vectorizing code, and multi-core is handled by using multithreaded coding (Boost.Threads, for example).
x86-64
Most issues are straightforward, but there are a few big differences. First of all, the x87 floating point is not supported under amd64. You must use sse2. Secondly, the 64bit version of MSDEV does not support inline asm anymore. gcc however obviously supports inline asm. In either case, you can use fasm for 64-bit asm modules.
Qemu for Windows
January 19, 2006 on 1:13 pm | In .english, coding | No CommentsI’ve installed qemu 0.8.0 for windows yesterday, and installed windows XP on it. It works like a charm, but I’m still working out the details on the network device.
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
[rss feed: http://blog.superstring.nl/feed/rss/]