It wouldn't be a stretch to say that this journal has gotten awfully technical in the last year or so. This is largely because, well, my interests have become a lot more technical in the last year or so; I've always been girl-who-makes-stuff, and more and more these days, the Stuff that I make is code rather than, say, fiction or clothing. I think about it a lot, and by extension, I write about it a lot.
When I write about technical subjects, I try to be as accessible as I can, because most of y'all aren't technical people. I'm very glad that you're not, just for the record; I value having technical friends, but I also value having a wide range of friends from all walks of life. I don't try to dumb things down, but I do find myself spinning out more long-winded explanations where a word or two of jargon would convey the same information to a smaller set of people. This is actually pretty useful to me, as well, because it forces me to think about what I'm doing in explicit detail -- it's the principle of The Best Way to be Sure You've Learned Something is to Teach It.
I wonder, though, whether it's useful to anyone else. Do people actually read the posts where I'm rabbiting on about the current code project? Do they make sense? Would you rather I wrote about the non-work things going on in my life instead? (Be warned, though, this journal might get kinda quiet if that was all I talked about. Some day I will have a life again, but that won't be for another few months.)
When I write about technical subjects, I try to be as accessible as I can, because most of y'all aren't technical people. I'm very glad that you're not, just for the record; I value having technical friends, but I also value having a wide range of friends from all walks of life. I don't try to dumb things down, but I do find myself spinning out more long-winded explanations where a word or two of jargon would convey the same information to a smaller set of people. This is actually pretty useful to me, as well, because it forces me to think about what I'm doing in explicit detail -- it's the principle of The Best Way to be Sure You've Learned Something is to Teach It.
I wonder, though, whether it's useful to anyone else. Do people actually read the posts where I'm rabbiting on about the current code project? Do they make sense? Would you rather I wrote about the non-work things going on in my life instead? (Be warned, though, this journal might get kinda quiet if that was all I talked about. Some day I will have a life again, but that won't be for another few months.)


Comments
Do you see a good middle ground? (In this specific case, I think a quick definition of typesafety was probably in order, ditto why void*'s emphatically aren't typesafe -- but explaining casting, beyond "it's a way of telling the compiler to treat one type as if it were really another type", strikes me as more information than is really needed.)
Type information lets the compiler know how much storage to reserve for a variable. Just how much gets reserved is architecture-dependent (and I believe also compiler-dependent), but the C standard gives you a few (vague) guarantees, such as "long int will always be at least as long as int, which is always at least as long as short int". (Yes, they can legally all be the same length, and on some architectures, such as PIC microcontrollers, they are.) char is typically one byte (corresponding to the ASCII characters); on 32-bit platforms, int is typically 4 bytes.
Now then. When you define a struct type, that tells the compiler, "Hey, every time the programmer declares a variable of this struct type, reserve enough space for all the components that make up the struct." And, indeed, if all you do is declare a variable of that type and make assignments to and call functions on the members of that struct directly, you are pretty much okay. However, when you introduce pointers, things get hairier.
A pointer is a sort of meta-variable: its value, instead of being the variable in question, is actually the memory location of whatever variable you're talking about. So if you have an int* p, the value of p is the address of the first byte of however much storage needed to be allocated for an int. You can access the actual value of that memory location by dereferencing the pointer (the dereference operator is also *, which confuses the hell out of many beginning C programmers. At least it did me.)
All memory addresses are given as integers. This means, then, that all pointers are the same size (and are typically the same size as int, though I suppose that could be implementation-dependent too, even though I can't imagine why anyone would.) So, if you have a pointer to a struct of one type, you can lie and tell the compiler to treat it as a pointer to a struct of another type. The compiler doesn't know any better, and will blithely let you dereference data members in the struct-of-another-type, even if they were never initialised in the first place. (In which case you will get a segmentation fault at runtime, as you are trying to "dereference a NULL pointer".)
To make a long story short (too late!), a pointer doesn't really know what kind of data it points to, even though in the syntax it pretends to. In other, more type-strict languages, you don't get pointers; you get references, which do know what they're pointing to. Paradoxically, this leads to lazily typed languages like Python, which will blithely let you do things like creating a list of arbitrarily typed references and then throw errors at runtime when you try to do things like use arithmetic operators on classes which don't have those operators defined.
Crap. I wasn't planning on making this that detailed.
You've obviously never programmed on an Alpha, and possibly not on any other 64 bit arch either :)
typical 32-bit: short int=16, int=32, long int=32, long long int=64
typical 64-bit: short int=16, int=32, long int=64, long long int=64
So the best approximation of a pointer integer type is usually actually a long int.
That is correct :) Well, mostly correct. One of my dev boxes on campus is a dual-Opteron, but I haven't yet done anything intending to take advantage of its architecture, so I haven't sat down and really learned much about it yet.
Thanks for the heads-up.
Although in their defence, the original code may have been written by a 16 year old on work experience, or a 12 year old hacker, and no-one's bothered to clean it up. ;)
But the shorter the better, for me; I've got my own code and I tend to use LJ as a break from a programming task, so groking another complex programming situation isn't what I'm looking for. But short pieces saying, (for example) 'here's a funky bit of code you can use to...' or 'there's a package that...' or 'this community is really helpful...' - that's something that can help lighten the load.
Any help?
But putting the challenges into words helps me codify the problems and their solutions, so I end up inflicting them on you lot. Now if only I could do so in a way that didn't bore people stupid :)
Oh well. In another week this project is done, and then I can think about something else.
taking some very hard sums and integrating them into a database backend in such a way that the end-user never realises, [...] making his life easier
is exactly the kind of general stuff I find funky. There's a principle there worth considering, abstract enough to apply across many fields. I don't have to deal with Postgres engines, but I do have to deal with making people's lives easier by making mine harder.
Now, this ties into my headspace in ways you can't know about. When I read this, I thought of Anagram by Textual and Specification by Example and Subtext - which are all ways I really like to take the difficulty out of a user's life and give it to a machine intelligence.
Now, I think my point is this;
(1) It's in the nature of LJ and the web that we scan, so big chunks of text get less attention per word.
(2) you can't know what's going to make my brain pop and fizzle with new ideas. But something is - that's why I like reading.
(3) Short, abstract chunks are more likely to (a) get attention, and (b) be applicable to my own thinking, and so (c) cause brainfizz.
On the other hand - the detail in your posts is very, very useful for the right audience. Some googling programmer will love you for adding it to t'internet. So write; I'll scan, and google will crawl. Everyone's happy.
(pick any of: 1. "the more technical, the better!" 2. "I wasn't asking YOU, I was asking the people who AREN'T the programming geeks" 3. "I wasn't asking you, I was asking the people I've talked to for more than five minutes" 4. other)
And the comments are welcome anyway. :)
To be honest, I frequently glaze over with some of your coding posts, but no more than I did with the Steinbeck story I mentioned the other day, and I have a passion for literature. So, it's nothing you ought to take personally; it's just part of who I am.
In other words, keep up the good work. :)
I'm a pesudotechie: I get most of the concepts but very little of the specifics. I know what pointers are, and if I think about it, I can figure out the relevant facts about how they must be implemented, but I have no idea what * means (at least not in C; if it's a Kleene star, I'm fine). I took a couple of undergraduate CS courses, but that was back in the days when U of T was still teaching them in Turing (they've since switched to Java).
The upshot is that I really enjoy reading about notable instances of cleverness and stupidity in coding, and if they're described in sufficiently abstract terms, I can even understand them.