Jach's personal blog

(Largely containing a mind-dump to myselves: past, present, and future)
Current favorite quote: "Supposedly smart people are weirdly ignorant of Bayes' Rule." --William B Vogt, 2010

Mixing Python with C

A common point of rhetoric up the sleeve of any Pythonista is this: "...and you can always write the slow parts in C if you have to!" It's typically said off-to-the-side and rarely elaborated on.

It's not a bad piece of rhetoric, I even use it from time to time. But it's only useful on programmers who haven't stepped much beyond their own narrow interest in technology--anyone who's done work across a variety of languages ought to realize that "can interface with C" isn't a feature that's supposed to be marketable, it's a hard requirement. They may have never had to do this themselves, but they should at least know in principle it can be done. In practice it's often a lot more difficult than it should be. If Python's C-interfacing capabilities were as slick as Clojure's Java interfacing ones, I wouldn't want to write about it.

What do I mean by "can interface with C"? A language that can interface with C is a language that can directly call functions in a compiled shared object that was written in C, and also where C can get at the language's internals as well to call its code and have interactions. This is distinct from using the other language to instruct the operating system to run a compiled C program and give it the results, and vice versa. Java interfaces with C, and Python interfaces with C.

See Full Post and Comments

An attempt at a practical exploration of Python for newcomers

In open office format here. (I know, I know, LaTeX heresy!) This post may be more up to date if I corrected anything though.

This document isn't explicitly about the syntax and 'overview of language features' of Python. Figure out the syntax of Python yourself from examples, Google, guessing, or error messages. Some features will be mentioned in passing when they're not obviously inferred from the example.
If you're looking for a style guide (sometimes the best way to learn syntax): check out “PEP 8”: (I disagree with some of it, of course, but PEP 8 explicitly is fine with that.)

Pro tip 1: never use tabs.
Pro tip 2: read what an error message actually says before asking for help. They're very unlike C++ compilers' vague template-related errors over which people tend to get glazed eyes.
Pro tip 3:
“Very often it will be faster for you to try something out on the computer than to look it up in the manual. Besides, the computer is always right, and the manual could be wrong.”
--Apple II Basic Programming Manual

See Full Post and Comments

Answers to two questions about government

I just sent out an email answering two questions, I'm going to copy them here because they're a good reference point for my current views going into 2014. Previously in the email I had mentioned as a decent source of anti-libertarianism, though not without its own problems. The first question, referencing that link:

Some of his arguments are worth thinking about, but It seems to me that many of his argmumetns can be turned on their head fairly easily. What do you think of his marginal utility argument using the movie ticket example?

I think the concept of marginal utility is sound, but by itself it does not justify progressive taxes. So what if I'm so wealthy that an extra dollar is more or less useless for me personally because I already have everything I desire materially? It's still my dollar. What was left unjustified is that 'burden' should be the basis of a taxation policy. But the real problem with the movie ticket metaphor is that it ignores a crucial power of money: the power to create more of it through investing.

See Full Post and Comments

Basic Income and borrowing from the future

When I look at economic growth numbers for the United States over the past century, I sometimes get the sense that we as a country have stumbled and for a while now have been trying to sprint faster and faster so that we can avoid doing a face-plant. The face-plant isn't inevitable, if we can just pick up enough speed, and if we don't run into anything...

One non-show-stopper obstacle that affected us has been the introduction of the standard 40-hour work week, whereas in previous times working much longer than that wasn't uncommon. Also getting rid of a lot of child labor affected us. But we've compensated with adding women to the workforce, and the tremendous amount of power the computing and automation ages have given us. Individuals have also compensated by going deeply into debt, borrowing from the future that in theory will have access to more resources than the present. But it still seems like we're barely capable of sustaining our incredible growth, and recessions like the kind we're more or less out of have almost ended us.

See Full Post and Comments

User testing ought to include extra dimensions on the User attribute

Disclaimer: I'm not a designer, but I wear the hat from time to time. I think by now in 2013 a majority of interface designers have arrived at the conclusion that user testing is really important to help shape an interface and designers who don't do user testing are met with "wat?" as the response. This user testing can take many forms: from hallway usability testing with an actual web mockup, or paper and sticky notes, or a whiteboard, to live A/B testing, and beyond. Designers try to find the best interface for everyone, and that's what gets deployed.

There's a problem, though: some users are different in important ways. Is the user young and presumably knowledgeable about modern UI idioms (like pinch-to-zoom), or is the user old and this is their first time with a touch device? Is the user English-speaking or alternate-language-speaking? Is the user introverted or extroverted? Is the user an active user or infrequently-active user? Is the user a "technical/power user" or a "non-technical user"? Don't you think it's worth exploring alternate designs for each of those alternate categories? You should be exploring alternate designs anyway, but if you have some theory driving some of your choices, you can apply what theories say about different user groups.

For instance, generally "flat" designs work better for technical users who are willing to spend some time learning and remembering where everything is on the screen, and "nested" designs work better for non-technical users where they are presented with only a very limited set of choices. Sometimes you might want to support just one or the other: for instance, who would design an airplane cockpit for someone who's not a pilot? And who would design an installation wizard with all sorts of power user features and a single screen when almost every user just wants to install the thing and go through the steps as quickly as possible, with the only choice they want to have being the "Next" button?

See Full Post and Comments

Kings make swift policy changes

In a democracy, or any form of government that relies on voting to get anything done (such as America's "constitutional representative republic"), it's really hard to change anything about society. This includes a resistance to changing the 'good' things about society (perhaps an indication why it took so long for the US constitution to just be slightly ignored during the civil war to more or less completely ignored in our present time), but it also includes a resistance to changing the 'bad' things about society. To escape the issues of good and bad, it also makes it hard to change stupid and smart things about society.

With an absolute monarch, his word is law. The stability of his beliefs is all the protection his subjects have against change. Therefore it's very important that an intelligent monarch is in charge. Suppose a kingdom had a king with multiple personality disorder -- not a very good choice! One day gay marriage is okay, the next day people of the same sex caught holding hands are sentenced to prison for 5 years. Suppose instead the king represents the best the kingdom has to offer: he is a man of many talents, possesses an even temperament, has a high IQ, and so on... Now suppose other smart people in the country start believing something about the society is stupid. Such as daylight savings time. They make some noise, and they only have to convince the king that it's stupid, and the king being a smart individual will tend to agree with other smart people, and daylight savings time could be abolished overnight.

Contrast that with the US, where "pretty much everyone" who is intelligent or who has thought about the matter thinks DST is a dumb idea, yet no one seems to have the authority to end it. A few states have individually ended it, which just makes matters even worse for the rest of us. What would it take to end it nation-wide? In theory, enough political pressure to make Congress get around to drafting a bill that ends it and voting on it. I hope the word "Congress" has made the reader sigh and start imagining all the bureaucracy and arguing and politicking that would have to go on to even have a chance. The bill would need to go through committees and avoid getting extra stuff added on, but it would be attractive because if "both parties want it" they both have an incentive to add party-line things to it and then complain the other party is rejecting the thing they both want when really they're rejecting the add-on that opposes their party's beliefs. Ugh. This is what democracy has wrought! I'd much rather have the king who, in his wisdom, would see that DST is pointless, write up a one-page document saying as much and setting a fixed time(s)-of-the-land forever more (or until he changes his mind, which if he's smart he wouldn't do without good reason), and that would be that.

See Full Post and Comments

Two Simple Solutions to the Abortion Problem

I've mentioned these two here and there on my blog and other places, but I realized it's useful to have a centralized post for them. Especially if I ever do more in-depth research and want to share my notes.

The first simple solution is kind of totalitarian and I don't think it's likely to be done by America. Maybe one day in Asia. Basically as part of a larger eugenics program to create more perfect humans, the State forces every male to undergo a RISUG treatment with follow-up treatments every 5-10 years. People are thus free to fornicate as they desire, and if they want to reproduce they must demonstrate fitness for such to the State and the State will arrange to reverse the RISUG. Since the State will only select breeding partners that are serious about it, there will be no abortions -- and as a bonus, no unwanted children.

The second simple solution, which I think may be more feasible in America, is to alter the abortion procedure into cryogenically preserving the embryo until such a time as a mother wishes to carry the embryo to term. This could be the original mother or not, and the birth-mother may not end up as the parenting mother. (There is a market for infertile women to pay fertile women to carry the preserved embryo to term and then the infertile woman adopts the child.) If you the original mother decide you don't want the child but are too far along in the pregnancy where cryogenically preserving the baby gives less than say for argument 50% chances at survival post-revival/thaw, then too bad, you have to carry it to term (and probably put it up for adoption) or be tried for infanticide. Research will be done into extending the period where a mother can have second-thoughts all the way up to birth (with the research also being useful for adult cryopreservation).

See Full Post and Comments