Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  Faster than C

Judging the performance of programming languages,usually C is called the leader,though Fortran is often faster.New programming languages commonly use C as their referenceand they are really proud to be only so much slower than C.Few language designer try to beat C.What does it take for a language to be faster than C?Better Aliasing InformationAliasing describes the fact that two references might point to the same memory location.For example, consider the canonical memory copy:void* memcopy(void* dst, const void* src, size_t count) { while (count--) *dst++ = *src++; return dst;}Depending on...

3,266 1       C PERFORMANCE SPEED FORTRAN CRITERIA


  Function Pointers in C are Underrated

The function pointer in C is, in my opinion, one of the most ignored gems of the language. It’s the kind of feature you rarely need, and then suddenly, one day, you find yourself in dire need of it, as evidenced by the real-life use-case below.If you don’t know what a function pointer is in the first place, here’s the meat of it: it gives you the ability to pass a function around like a normal variable. If you know Python / Ruby / Lisp, you might know it by the name ‘lambda’, or if you come from a JavaScript background, you might’ve used it under the na...

4,314 0       C ANALYSIS POINTER


  In-memory key-value store in C, Go and Python

Subtitle: Wow Go’s net library is fastOn paternity leave for my second child, I found myself writing an in-memory hashmap (a poor-man’s memcached), in Go, Python and C. I was wondering how hard it would be to replace memcached, if we wanted to do something unusual with our key-value store. I also wanted to compare the languages, and, well, I get bored easily!The code is on github as Key-Value-Polyglot.Each version implements enough of the get and set commands from the memcached protocol that we can test them with a memcached client.If you write a version in a different language (...

4,404 0       MEMORY C PYTHON GO KEY-VALUE


  sorting in C++: 3 times faster than C.

If you don't know C++ well, you might be surprised how fast C++ can be sometimes. This is especially true when code involved is small, because then inlining - which is what C++ is very good at - and templating, which makes excessive inlining possible in the first place - has the most effect.The following code compares C and C++ sorting:  #include <iostream>#include <algorithm>#include <vector>#include "stop_watch.inl" // see https://gist.github.com/2057981#ifndef COUNT#define COUNT 100000000#endifint compare_int(const void* p1, const void* ...

3,878 0       C C++ EFFICIENCY FASTER SORTING


  Using C for a specialized data store

Pixenomics stores and transports 1.2 million pixels from the server to the client. During development we played with various methods to store and process this. Our ultimate goal was to send the entire board in under 1 second.During the stages of prototyping we used a MySQL database without thinking too much about performance. With a mere 2,000 pixels we quickly realised this wasn’t even usable as a demo. Changing the storage engine to memory was much better but still obviously unusable.The problem wasn’t to store the pixels but to retrieve all 1.2 million pixels quickly as well a...

2,552 0       C PERFORMANCE EFFICIENCY DATA STORE


  Why Lua

In this article, I would like to discuss why you should use Lua. Thisall started with a message that recently popped up on theLua mailing list regarding why isn't Lua more widelyused? The answerswent from randomness to lack of libraries to a variety of other things, but theone that resonated with me most was that there are fewer people who enjoy thedo it yourselfapproach, which Lua fully embraces. I've come to think of Lua as the ArchLinux of programming languages. Which, almost bydefinition, means fewer people will enjoy Lua rather than more. So then whywould you want to use Lua? In no...

2,816 0       C FEATURE LUA SIMPLE PORTABLE


  C/C++ Pointer Declaration Syntax – It makes sense!

I never really liked the way pointers are declared in C/C++:int *a, *b, *c; // a, b and c are pointers to intThe reason is that I am used to reading variable declarations as MyType myVar1, myVar2, myVar3; and I always read “int*” as the type “integer pointer”. I therefore wanted the followingint* a, b, c; // a is a pointer to int, b and c are intsto mean that a, b and c all were of type int*, i.e. pointers to int. and I therefore found it slightly annoying to repeat the asterisk for every variable. This also meant that the symbol * had two sligh...

2,764 0       C POINTER DECLARATION ATTEMPT


  Preprocessor magic:Default Arguments in C

This post is for programmers who like C or for one reason or another can't use anything else but C in one of their projects. The advantages of having default arguments is not something that needs convincing. It's just very nice and convenient to have them. C++ offers the ability to define them but C under the C99 standard has no way to allow it. In this post I will detail two ways I know of implementing default arguments in C. If a reader happens to know additional ways please share in the commentsSuppose we have a struct that contains some data and we want to initialize it//! The struct we wa...

12,244 0       C PREPROCESSOR DEFAULT ARGUMENTS