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

 ALL


  Go vs C benchmark. Could Go be faster than C?

During last semester I was attending Multiprocessor Architectures course, given at Facultad de Informática where I study my Computer Science degree.As part of the assignments due to pass the course, we had to do several programs written in C to benchmark matrix multiplication by testing different techniques and technologies. First of all we had to do a secuential program in three different versions:A normal one where the result matrix is ordered by rows and the loops range the matrix by rows tooAn “inter” version where the result matrix is ordered by rows but the loops range the...

4,102 0       COMPARISON C SPEED GP BENCHMARK FASTER


  C Preprocessor Hell

Lisp programmers should stop reading right now because they'll likely suffer severe injury of the jaw muscles as they laugh themselves silly at how hard it is to do some things in C. The C language has a pre-processor (typically called cpp) that is both infuriating and powerful. How powerful is usually best described as 'just too little' and it has happened more than once that I found myself almost - but not quite - able to do what I wanted to do.The frustration can run very deep at times like these. Recently I had another battle with the C pre-processor to write a set of macros to accompl...

5,709 0       C PREPROCESSOR LISP HELL


  The "C is Efficient" Language Fallacy

I came across an article yesterday about programming languages, which hit on oneof my major peeves, so I can't resist responding. The article is at greythumb.org,and it's called Programmer's rant: what should and should not be added to C/C++.It's a variation on the extremely common belief that C and C++ are the best languages to use when you need code to run fast. They're not. They're good at things that need to get very close to the hardware - not in the efficiency sense, but in the sense of needing to be able to fairly directly munge the stack, address specific hardware registers, etc. But...

2,928 0       C EVOLVEMENT GCC FALLACY


  Replacing small C programs with Haskell

C is the classic go-to tool for small programs that need to be really fast. When scripts.mit.edu needed a small program to be a glorified cat that also added useful HTTP headers to the beginning of its output, there was no question about it: it would be written in C, and it would be fast; the speed of our static content serving depended on it! (The grotty technical details: our webserver is based off of a networked filesystem, and we wanted to avoid giving Apache too many credentials in case it got compromised. Thus, we patched our kernel to enforce an extra stipulation that you must be runnin...

2,705 0       C HASKELL SMALL PROGRAM


  The ugliest C feature:

<tgmath.h> is a header provided by the standard C library,introduced in C99 to allow easier porting of Fortran numerical software to C.Fortran, unlike C, provides “intrinsic functions”, which are a part of the language and behave more likeoperators. While ordinary (“external”) functions behave similarly to C functions with respect to types(the types of arguments and parameters must match and the restult type is fixed), intrinsic functions accept arguments of several types and their return type may depend on the type of their arguments.For example Fortran 77 provid...

45,755 0       C FORTRAN INTRINSIC FUNCTIONS C99 UGLY


  Notes on Programming in C

Introduction      Kernighan and Plauger'sThe Elements of Programming Stylewas an important and rightly influential book.  Butsometimes I feel its concise rules were taken as a cookbookapproach to good style instead of the succinct expression ofa philosophy they were meant to be.  If the book claims thatvariable names should be chosen meaningfully, doesn't itthen follow that variables whose names are small essays ontheir use are even better?  Isn't MaximumValueUntilOverflow a better name than maxval?  I don't think so.      What follows is a set...

1,985 0       TIPS C NOTES


  Smuggling data in pointers

While reading up on The ABA Problem I came across a fantastic hack.  The ABA problem, in a nutshell, results from the inability to atomically access both a pointer and a "marked" bit at the same time (read the wikipedia page).  One fun, but very hackish solution is to "smuggle" data in a pointer.  Example:#include "stdio.h"void * smuggle(void * ptr, int value){  return (void *)( (long long)ptr | (value & 3) );}int recoverData(void * ptr){  return (long long)ptr & 3;}void * recoverPointer(void * ptr){  return (void *)( (long long)ptr & (~3) );}int main(...

3,056 0       C DATA POINTER BIT ATOMIC SMUGGLE


  Objective-C Is The Language

My good friend Brent Simmons invokes a historical email from Linus Torvalds, about his disdain for C++C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it.Brent affirms his support while paying homage to plain-old C:But I will admit to an enduring love of C. I still think of C not as C but as the language.I loved C. Emphasis on the past-tense. As object-oriented programming concepts became popular, those of us who were programming in C or simi...

3,566 0       OBJECTIVE-C C APPLE OOP C++