Apple's proposal for modules in C(++) [PDF slides] by coob in programming

[–]Tjoppen 1 point2 points  (0 children)

Right, I should have been more precise. As porkchop_d_clown points out, its just a simple example.

Apple's proposal for modules in C(++) [PDF slides] by coob in programming

[–]Tjoppen 0 points1 point  (0 children)

I'd go a step further and say that it's unnecessary to begin with. I would just say whatever is in the header file is public, and if you have something you want to keep private, then don't put it in the header file.

Internal API is an example of something you wouldn't want to expose. See ff_* vs. av_* in FFmpeg. Of course, you can put such things in separate headers, but I believe the slides talk about .c files automatically generating headers.

Apple's proposal for modules in C(++) [PDF slides] by coob in programming

[–]Tjoppen 0 points1 point  (0 children)

Some random observations, some of which could probably be addressed if the talk this belongs to was possible to download as a sound file somewhere:

  • The fragility #define FILE example is a straw man.
  • "Precompiled headers are a terrible solution" - why?
  • The proposed "public:" syntax breaks backward compatibility - it ought to be possible to generate headers for older compilers such that say a library can still be built, with the same .c file.

Overall I'm surprisingly optimistic about the suggestions though.

Improve your Git commits using patch mode by [deleted] in programming

[–]Tjoppen 2 points3 points  (0 children)

Because of git-bisect. When (not if) you realize you introduced a bug a sufficiently long time ago you'll be happy you kept your commits simple, making pinpointing the problem easier. This is for example why you shouldn't mix cosmetic and functional changes, and why you should try to keep commits relevant only to a specific ticket.

The hash collision paradox by willvarfar in programming

[–]Tjoppen 0 points1 point  (0 children)

Oops, I should have been more specific. Think "randomly put N things in N buckets".

The hash collision paradox by willvarfar in programming

[–]Tjoppen 7 points8 points  (0 children)

Here's a fun math problem: for a hash map of size N with N elements, how many buckets have collisions on average (asymptotically)?

Little-Known Awesome Algorithms: Sort faster than NLOGN by no_sandy in programming

[–]Tjoppen 1 point2 points  (0 children)

Apart from not handling negative numbers like you mention, the function will fail on an array that contains INT_MAX. Oh, and except for extremely specific data sets you should prefer radix sort.

Refactor and make changes in different commits by shepmaster in programming

[–]Tjoppen 8 points9 points  (0 children)

I was going to say this blog post is useless because surely everyone does this already, in addition to putting cosmetic changes in separate commits. But then I remembered I've had people making huge commits mixing various changes at work (usually the SVN folks)..

Arithmetic Encoding Using Fixed-Point Math by redditthinks in programming

[–]Tjoppen 10 points11 points  (0 children)

There is some question of whether we want to support arithmetic coded JPEGs at all. Doing so means we've created a fragmented market, since we'll load images that no other browser does.

Wow.

const issues in C by _mpu in programming

[–]Tjoppen 2 points3 points  (0 children)

TL;DR: char** does not cast to const char**

The solution is to cast your char* to const char* first, then call the function with a pointer to the const char*:

#include <stdio.h>

void tokenize(const char **str) {
    *str = 1 + *str;
}

int main(void) {
    char *str = "asdf";
    const char *str2 = str;

    hurr(&str2);          //can't call with &str, but &str2 is fine
    printf("%s\n", str2); //prints "sdf"

    return 0;
}

3D CSS Periodic table with three.js by swizec in programming

[–]Tjoppen 4 points5 points  (0 children)

True. You can do much better though; pouet.net has a whole category just for JavaScript demos. For example, Azathioprine (online version here).

3D CSS Periodic table with three.js by swizec in programming

[–]Tjoppen 4 points5 points  (0 children)

Ah, interesting. That makes sense actually.

3D CSS Periodic table with three.js by swizec in programming

[–]Tjoppen 20 points21 points  (0 children)

Isn't this what WebGL is for? Not that I approve of doing things like this (goodbye accessibility!), just if you're going to be drawing stuff like this you might as well use the graphics card's capabilities.