c wtf

Sep. 16th, 2019 11:13 am
juan_gandhi: (Default)

Reading this book: https://www.oreilly.com/library/view/programming-rust/9781491927274/ch01.html

It says:
 

Consider the following C program:

int main(int argc, char **argv) {
  unsigned long a[1];
  a[3] = 0x7ffff7b36cebUL;
  return 0;
}

According to C99, because this program accesses an element off the end of the array a, its behavior is undefined, meaning that it can do anything whatsoever. When we ran this program on Jim’s laptop, it produced the following output:

undef: Error: .netrc file is readable by others.
undef: Remove password or make file unreadable by others.

Then it crashed. Jim’s laptop doesn’t even have a .netrc file. If you try it yourself, it will probably do something entirely different. 

juan_gandhi: (Default)
Turned out all the delays were caused by two things:
- reading the files in parallel, as opposed to sequential (don't ask, will investigate)
- parallel output to stdout, instead of linearising the output. That was obviously my mistake, have to group the data, not mix them.

Now it's still 3 times faster than FP version. Got a suspicion that in JVM method dispatch is much heavier than plain if/else. It should be. But it's the staple of FP, never use booleans or ifs, but dispatch by the type. So, well... have to investigate.
juan_gandhi: (Default)
A couple of days ago I spent half of the day working with some c code. Not a beautiful one, regular. Plain c.

Well, it fast like a lightning. It's been a while; and I remember compiling c in two compilers for 4 memory models; I did remodel my apartment while this was going on. It was 25 years ago, well, the world has changed, but c has not.

So maybe I should use it from time to time, I don't know. Forth must be fast too.

Or is it just me.

I know, neither is scalable. Or it could be, could it? 
juan_gandhi: (VP)
So, I just bumped into this problem being mentioned. "For performance", bounds are not being checked by c programmers, who mostly don't care about any cases except the ones they like.

But well, what's the point in these checkings?

I know three cases.

1. We know during compile time the size of the vector we need, and we should not accept the smaller ones; we should rather not accept the larger ones, but mostly we don't care. This is the case for tuples. It's not an array. If someone wants to pass into the code an array pretending to be a tuple, this fact should be checked at the border. Ok, yes, there are no tuples in C or C++. Well, bad luck, and say hi to the three morons interesting people that provided you with such a language.

2. We don't specify the size, but we have some constraints, like the height of one matrix should be equal to the width of another; or maybe that a vector must contain not less than so many members. Ok, why not have it all in a specialized class? Once the class is instantiated (optionally, with all the checks), there's no way the sizes will change, right? So we don't have to check the bounds.

3. A loose collection of ancient libraries with loose, frequently unknown, requirements. I guess these libraries should be wrapped and hidden from the eyes of a modern human. It's like a slaughterhouse, hardly any modern city dweller wants to see what's going on there.
juan_gandhi: (VP)
https://www.cs.princeton.edu/~appel/papers/conteq.pdf

(That's what I was talking about when I was talking about the difference between AB, the 'type of all functions', where equality, if given, is extensional, and Hom(A,B), where equality is intensional, they are just arrows in a certain category, and, for practical purposes, are identifiable library functions (or their combinations in expressions).

Big thanks to [livejournal.com profile] thedeemon, see http://thedeemon.livejournal.com/104205.html

long id

Oct. 1st, 2015 02:02 pm
juan_gandhi: (VP)
I think I got it where all this bs about passing around numerical ids of entities instead of entity references (maybe lazy) come from. It's like 'error code'. It comes from the ancient c programming, where we just could not allocate a string for a readable piece of text, or for the data that may need some efforts to instantiate or allocate.

In short. It's stupid to pass around "ids" in a program.
juan_gandhi: (Default)
When: Wednesday, August 8, 2012
Topic: An Introduction To The POCO C++ Libraries
Speaker: Günter Obiltschnig
Time: 6:30pm doors open
7:00pm meeting begins
Where: Symantec
VCAFE building
350 Ellis Street (near E. Middlefield Road)
Mountain View, CA 94043

(me not coming)
juan_gandhi: (Default)
(10x [livejournal.com profile] polycode
source
#define COLORS \
    X(Cred, "red") \
    X(Cblue, "blue") \
    X(Cgreen, "green")

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 1213141516
17181920212223
24252627282930
31      

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 12th, 2025 03:12 pm
Powered by Dreamwidth Studios