2016-05-22

The barren rockscape and the Garden of the Mind

Xara woke up one day, back when she didn't yet know she was a gardener. She thought her garden was a field, and she didn't much tend to it. So the field had some flowers in it – those that were hardy enough to grow; and it also had a lot of weeds. She liked to take walks in her field, enjoying the flowers she found. She ignored the ugly weeds, and cursed at the nasty ones that scratched her.

The weeds pestered her a bit, the nasty ones even more so. She thought that she should tend the field, from time to time, but the task seemed so much harder than the problem. She tried to pluck a weed here and there, but almost as soon as she did that, it seemed another one popped up. And the nasty ones, oh boy. They were easier to avoid.

This day though, she would find something different. In the corner of her field, she found a new flower. It was more beautiful than anything she'd seen, with vivid blossoms and mesmerizing leaves. She had seen plenty of decent enough flowers; but they were sturdy, ones that could grow among the weeds. This one... This one grew as if it was blessed with magic. Within a month, it had covered the entire field, and Xara enjoyed the view like she never did. But then... the vivid blossoms fell. The leaves withered, lost their color, and shrank into thorns. The incredible flower became a weed. A weed that now smothered the entire field it had overgrown, and made it impassable with thorns.

Xara cried, but she hadn't lost hope. She thought to herself, "Maybe it's a seasonal flower." So she waited. Seasons went by. She tried to enjoy the other flowers, which had slowly again started to grow. But nothing compared to the beauty of the mesmerizing flower that had turned her field into a thorn labyrinth. She waited in sadness, as the remains petrified. The magical flower would not grow.

She talked to her neighbors about the mystical flower. Some of them had also just noticed the flower in their fields, and had no idea why and how. Some of them had seen the flower also overgrow their fields and turn into weed, and were sad about it like she was. Some had never seen this flower, and thought she was insane when she described it. But none of them knew how to help.

There was word of a sage; a sage that lived on the outskirts, and knew about many things. Xara visited the sage, and explained what happened in her field.

The sage nodded. "Xara, your problem is clear."

"It is?" she wondered.

"You see, Xara, your problem comes from the topsoil. From where do the weeds grow?"

"Well, from the soil," Xara affirmed.

"Indeed. And where do the flowers grow?" he inquired.

"Well... also the soil."

"You see therefore, that as long as there is topsoil, there will be flowers, as well as weeds."

Xara thought. "Well... I guess... probably."

"Tell me. Have you ever dug under the soil?"

She would have liked him explain about the magical flower; but she did not dare ask. "I... have not."

"Then you have not seen what's under the soil. Do you want to know what's under it?"

"I... do," she replied timidly.

"Under the soil is bedrock." The sage paused, then proceeded ponderously. "Your field has these things happening in it – the small flowers, the small weeds; the magical flower, and now the encroaching weed – all because of the topsoil. You are attached to the flowers that grow from topsoil. But with flowers come also the weeds."

Xara began to see his point. The sage continued.

"Look how impermanent the flowers are. They grow, they blossom, they die. How can you find lasting joy in something so ephemeral?"

"Hmm," she pondered.

"Stillness is found in removing the soil. Then no flowers will grow, and neither will weeds. When you look out on your field, you will see the bedrock; permanent and unchangeable. This is beyond flower and weed. It is emptiness. It is stillness."

Xara thanked the sage for advice, and returned to her field. She pondered his words, and decided. She's going to remove the topsoil. There was a lot of it, so removing it took a long time.



At long last, the soil was gone from her field. The weeds and the flowers kept trying to grow as long as there was still something to grow in. But now the bedrock was exposed, as far as the eye could reach.

She knew that, even so, there was soil in the pockets and cracks. Plants were hardy, and could take root there. No matter; she removed them, she washed out the cracks, and the bedrock was bare. There were no flowers or weeds apart from this, but there was beauty in the rockscape. It had colorful gradients. It appeared still and permanent. Within timelessness, rain would fall. Puddles would form, and evaporate.

Xara forgot about the magical flower that had turned to weed. Hers was now a very different field.



Years later, a new neighbor moved in nearby. Xara paid him a visit.

"Howdy there, neighbor. How is your field?"

"It could be worse," the neighbor said. "It wasn't maintained when I got here. But I'm going to tend to it."

"You're going to tend to it?" Xara was puzzled. The very idea seemed silly. She remembered how ineffective it was, back when her field had topsoil, trying to remove the weeds. So much work, for so little reward. Now that she had bedrock, maintenance was easy.

"Oh, yeah," quipped the neighbor. "No problem at all. I have the tools."

Xara told him about removing topsoil from the field, and how much easier it made things. The neighbor nodded. He said, "Sure, some people prefer that. I suppose there is beauty in it." He didn't seem interested more, so she didn't push it.

A couple months later, Xara visited again. "Howdy, neighbor. How's your field?" She wondered if had given up on tending yet. Should she tell him again about removing topsoil from the field?

"Well, it's not a field any more! It's a garden. Do you want to come see?"

Xara was incredulous, but curiosity got the better of her. She followed the neighbor to his garden. It was incredible! Flowers everywhere; arranged in these beautiful shapes –

"This... is amazing," she said. "But don't you feel sad when they die?"

He chuckled. "It's natural for them to die. But then they grow again!"

She followed him on paths between flowers, beautifully arranged. And there - in the center - there was the mystical flower she'd seen, with the vivid blossoms she once wanted to see again so badly.

"This one..." She pointed, with her mouth agape.

"Ah yes, that's a beauty. Requires real special care. If I don't add nutrients to the soil every day, it uses what's in there, then overgrows everything looking for more, and when that runs out, turns to weed. Amazingly colorful though, isn't it? I have a sprinkler system here, for the enriched water it needs."



A few months from then, Xara had put the soil back in her garden. She learned that tending it is not as difficult as she thought it would be. It is different, certainly. There's lots to do, compared to the barren rockscape. But she learned from the neighbor to treat the work like it's fun, and just do it consistently. Day in and day out, her garden grew nicer and better, and she found great joy in this. She made room for all of the flowers. She found that some of the weeds are actually flowers too. The nasty ones especially! She put them off the path, so they wouldn't scratch. She enjoyed seeing them blossom in the spring.

And the mystical flower, it came back. Xara's smile was as wide as her face when she found it. And this time, she knew exactly how to tend to it.

2016-05-15

The benefit of some kind of authority

There are well-meaning people who like to question everything, who go around with ideas like:

"Hey, why should Government Guy be able to do things others can't? The very concept of government is oppression. Why do we need authority? Anarchy is freedom!"

Government exists (1) to serve as a mechanism of coordination, and (2) to prevent arising of a worse, more oppressive authority.

Authority, in general, is emergent. Wherever there isn't authority, one will arise. Not because people want to be oppressed, but because (1) coordination services are needed, and (2) there is no authority in place to prevent another from taking power with force.

In this sense, a situation without authority is in disequilibrium, whereas a situation with authority is in a local equilibrium.

Situations that are truly without authority are hard to maintain, and hard to get work done in. For an example, consider how long it took someone to invent Bitcoin, the first authority-less currency (or more accurately: a currency with truly competing authorities). It is currently an unsolved problem how to extend Bitcoin to process more than about 10 transactions per second without some type of centralization.

In comparison, Visa is a federated system that has no qualms relying on authority, and can process 20,000 transactions per second.

For another example, consider protocols for database cluster synchronization, like the Raft Consensus Algorithm. The link has a very nice visualization. One of the first things you might notice is that all the members of the database cluster are peers, they are equivalent to each other, but at any time they elect one of themselves as an authority to act as coordinator.

Most coordination problems are a lot easier to solve if you have authority. This is to the extent that you can have 20,000 transactions per second if you use authority, and 10 transactions per second without.

In this reality, authority is a natural consequence of the natural laws in place. It's up to us to design and maintain authorities that represent the best of our intentions.

That said, authorities are a liability – a single point of failure. When we can avoid authorities, we should. If Bitcoin survives the test of time – e.g. does not end up controlled by a cartel of 6 miners in China – I believe the internet Domain Name System would be best replaced with one based on Bitcoin. (I think not Namecoin, but a system backed by the full mining effort that goes into the Bitcoin blockchain.)

2016-04-20

On the desirable properties of a programming language

For the past 15 years, I've wanted to create a programming language. It is easy enough to do so, if one just wants to create something. But I've wanted to create something that improves in some substantial way on what already exists, and stands the test of time.

10 years ago, I created Flow. Flow is not widely known, but it's the asynchronous architecture that underpins Bitvise SSH Server and SSH Client. It's a message-passing architecture based on small, Erlang-like processes, implemented using fibers in C++. One of the main purposes of Flow was to make it easier to reason about a complex, asynchronous application, and I do believe it succeeded to an extent. Its grander motivation was to make it trivial to write complex applications that scale effortlessly to any number of parallel processors.

I believe that Flow would meet this second goal, but its ability to do so is yet untested. We do not actually need the type of scaling Flow would provide in our software. We use Flow inside traditional thread-based parallelization which works better with the architecture of our SSH Server. I have since written software such as a web server with an integrated database, and that doesn't need scaling on a component granularity either. While Flow has free scaling, it requires a shift in the programmer's perspective. Traditional thread-based approaches require no shift, and tend to work well enough.

I originally wanted to turn Flow into a language. I realize, now, that I could; but this language would have problems inherent in all languages that try to impose some way of thought on the programmer. By imposing this way of thought, the language alienates people to whom it is foreign. Secondly, the intentional restrictions of the language make it difficult to implement designs that people actually want to use. The language then has a choice: either condemn and not help with these patterns, so the language becomes obscure; or smuggle violations of its principal design through a backdoor.

And now, as prime example of backdoor smuggling of design violations, I present:

Haskell


Haskell is known as a pure functional programming language which is actually so well designed that it can run nearly as fast as C++. Or so we're told.

To achieve C-like speeds in Haskell, you have to brutalize the beautiful language by treating it, well, like C.

Exhibit one: Jan Stolarek's article where he presents the following algorithm that takes a list of machine-wide integers, and computes the sum of squares of odd numbers in it:
 
  sumSqrL :: [Int] -> Int
  sumSqrL = sum . map (^2) . filter odd

What a piece of beautiful code. But according to Jan's measurements, it performs 8 times slower than C. He fixes this by reimplementing the algorithm as follows:
 
  sumSqrPOp :: U.Vector Int -> Int
  sumSqrPOp vec = runST $ do
    let add a x = do
          let !(I# v#) = x
              odd#     = v# `andI#` 1#
          return $ a + I# (odd# *# v# *# v#)
    foldM` add 0 vec -- replace ` with ' here

This is not only practically unreadable; it is practically imperative. It looks like it would look in C++, except that C++ is actually designed for this, and doesn't make it look so ugly.

If this is not sufficiently convincing, consider the problem of efficient string concatenation in Haskell. Of course, Haskell can append to a string:
 
  xs `append` x = xs ++ [x]

The only problem is that, when repeated, this has quadratic performance. A string, you see, is represented as a list. So each time you append a single character, Haskell creates a new list; or if not that, at least traverses the whole existing list; and then appends the additional character.

I suggest exploring the Haskell solutions proposed in the above Stack Overflow link. Let me know if you think any of them are clear. In Haskell, string concatenation is an advanced topic.

Managed languages


The main shortcoming of managed languages; with prime examples .NET and Java; is that they require management infrastructure, which can't be written in the managed language. You can't write a garbage collector in a language that assumes there is a garbage collector, and in which you can't access memory.

The way I see it, managed languages are the wrong approach to solving the problem of reliability in software. Imagine there is a surgeon. As part of their job, the surgeon needs to cut people. The surgeon's hand is steady, but when cutting freehand with a scalpel, the surgeon sometimes makes mistakes.

To reduce the number of scalpel mistakes, we invent cutting templates. In the types of surgeries that are most common, the surgeon can now use a cutting template instead of using the scalpel freehand. This improves the safety of most surgeries, and is generally seen as a good thing.

C is like a surgeon without a cutting template. C++ is like a surgeon who has the choice of a cutting template, or a scalpel. Managed languages are like surgeons being treated like they're inept. You only get cutting templates; the scalpel is taken away. If the problem doesn't fit the templates – well – you can try to mangle it until it does.

Managed languages solve memory safety issues that were a problem in the 1990s and 00s, but are mostly gone in modern C++. What managed languages do not do is protect against incompetent programmers, who remain free to implement basic vulnerabilities to SQL injection and cross-site forgeries. Managed languages do not allow you to rely on programmers whom you couldn't trust with C++.

C++


So what's wrong with C++?

Not really that much. This:
 

  // Signed -> Signed

  template <class OutType, class InType,
    std::enable_if_t<(
      std::numeric_limits<InType >::is_signed &&
      std::numeric_limits<OutType>::is_signed &&
      sizeof(InType) > sizeof(OutType)
    ), int> = 0>
  inline OutType NumCast(InType value)
  {
    // Input type is larger
    EnsureThrow(value >= std::numeric_limits<OutType>::min());
    EnsureThrow(value <= std::numeric_limits<OutType>::max());
    return (OutType) value;
  }

  template <class OutType, class InType,
    std::enable_if_t<(
      std::numeric_limits<InType >::is_signed &&
      std::numeric_limits<OutType>::is_signed &&
      sizeof(InType) <= sizeof(OutType)
    ), int> = 0>
  inline OutType NumCast(InType value)
  {
    // Input type is NOT larger
    return (OutType) value;
  }

The above are two out of eight template functions that use SFINAE to implement NumCast - a mechanism we use to ensure at run-time that the value of one type of integer can be safely converted to another.

I show this to emphasize the clunkiness of C++ metaprogramming. The entire language is not so much designed, as it is undesigned. Each individual step in the language's evolution was carefully chosen. But from a bird's eye view, C++ ends up looking like a hack, built upon a hack, built upon a hack. These hacks mostly fit well together; there is actual beauty in their outcome, and satisfaction in using the language. But the above is not an example of intuitive metaprogramming.

Go? Rust?


I like Rust. Rust is smart. It has the obvious feature of rigid single-reference memory safety. I suspect this may be an "overarching idea" problem, and may require smuggling of design violations by the back door.

"Go" seems like a language you design if you want everything simple, and have high developer turnover. It's a systems language for when your developers are from JavaScript, and don't want to learn C++.

Where to go?


The kind of language I think is worthy of creating:
  • Can express any type of program. Not just a garbage collected program, or just a user-mode program; but also a kernel-mode program, a boot loader, or an embedded real-time program.
  • Does not impose limiting paradigms which then need to be broken through a backdoor. No functional Fata Morgana, no object-oriented Fata Morgana, no message-passing Fata Morgana. The language should allow these concepts to be expressed, but not foist them.
  • Has regular structure and strong built-in metaprogramming. This is a lesson that can be learned from LISP (hint hint hint). The main problem with LISP is all the parentheses.
It might not surprise that I have in mind a design for just such a language. :) In a future post, I would like to introduce Seed – a list-based, self-building front-end language, with a simple but powerful basic structure, from which a versatile platform can be built for any purpose. It will first be intended to target the LLVM intermediate representation; but there's no reason it could not also emit .NET or Java bytecode, platform-specific machine code, HTML, PDF, or text files.

Seed is also intended to not have subtly incompatible implementations, which continue to be an issue with C++. The idea is for most of the language to be defined in the language itself. Implementations are then much more likely to be compatible, as they use the same language definition.

And if you don't like the language? Change it. Most of the language will be defined in the language itself, so its definition is under your control.

2016-04-16

"Hello world" in LLVM IR language without CRT

The LLVM Language Reference Manual has a "Hello world" example that uses the C run-time library.

I wanted a bare-bones example, using only the Win32 API, without a CRT dependency. Here it is:
  @.str = private unnamed_addr constant [13 x i8] c"Hello world\0A\00"

  declare i64 @GetStdHandle(i32) nounwind
  declare i32 @WriteFile(i64, i8* nocapture, i32, i32* nocapture, i8*) nounwind

  define i32 @Entry() {
    %hwStr = getelementptr [13 x i8]* @.str, i64 0, i64 0
    %handle = call i64 @GetStdHandle(i32 -11)
    %bytes = alloca i32
    call i32 @WriteFile(i64 %handle, i8* %hwStr, i32 12, i32* %bytes, i8* null)
    ret i32 2
  }
Compile and link steps:
  llc -filetype=obj hw.ll
  link hw.obj kernel32.lib /entry:Entry /subsystem:console
The resulting executable has 2,560 bytes, prints "Hello world", and returns exit code 2.

My main observation is that the language is clumsy. It's meant to be read by humans, but in most cases, generated automatically:
  1. No syntax for hexadecimal integers. If you want to enter a value like 0xC0000005 – good luck! :-)
  2. The types of all values have to be explicitly qualified each time they're used. This is irritating when writing, but may serve as useful documentation when reading.
  3. Interestingly, there's no "address-of" operator. Instead, alloca creates space for a value on the stack, and gives you the address. Neat!

2016-04-12

Over-education and free college

I agree with most of Sanders' policies, much more than any other candidate. However, I cringe somewhat about his views on education, which seem only kinda half right. Sanders wants to give everyone free access to college, which would be better than what we have now. But...

What he doesn't say (or realize?) is – over-education should be discouraged, because it's competition for a positional good. Hanson and Caplan have had a good conversation about this over the years.

Compared to early employment, college is ineffective at conveying useful skills. It's a competition between individuals about who's going to be "better educated". In this competition, the nation can't do better as a whole by throwing more resources into it. You just get a lot of college graduates who then make for reluctant baristas, many having to settle for something "below" their degree.

The current college loans are unambiguously bad. They drive up the cost of participating in this competition that is pointless to begin with, and yet cannot be avoided because it's seen as the herald of everyone's economic success.

Making college free or low-cost can certainly be part of a solution. There will always be competition for this positional good, and it's important that this competition does not favor rich people. So good so far, I think.

But most importantly, people just shouldn't be going to college as much. For most folks, there's nothing to learn there.

And of course, this is unpopular because it hurts people's fetish for being educated. sigh There's so much identity invested into this.

2016-03-29

Libertarian confusions

Since I gave up on libertarianism, I have struggled to explain concisely why it doesn't work to people who still buy into it. This is an attempt to do so.

Incompatibility with desirable outcomes


Bluntly – libertarianism is a delusion that unconditional property rights can be had at the same time as some non-dystopian social outcome.

More specifically – we cannot have all three of the following:
  1. Unconditional property rights.
  2. Freedom of reproduction.
  3. Equality of opportunity. (Not of outcome!)
You can have any two of those, but not all three. The combinations that work are:
  • Unconditional property rights + freedom of reproduction: poor people give birth to more poor people, who do not have equality of opportunity and live and die in squalor.
  • Unconditional property rights + equality of opportunity: this combination has not been seriously attempted, but it means sterilizing poor people so they can't have children who would have unequal opportunity.
  • Freedom of reproduction + equality of opportunity: if you want to achieve this, you have to sacrifice unconditional property rights.
Not only that – but the following two are also not compatible:
  1. Unconditional property rights.
  2. Not letting people die in front of hospitals.
Here, you have only two options:
  • Choose unconditional property rights: this means you can't force hospitals to use their resources for poor people who lack insurance and can't pay for treatment.
  • Choose not letting people die in front of hospitals: this means you have to force hospitals to provide treatment; or force people to pay so that they provide it.
You can't insist on absolute, unconditional property rights, without basically being some type of Hitler.

But if you accept that property rights are conditional, then taxation is not stealing. It's how we work together toward agreed-upon common goals.

Applying business intuition to macroeconomy


Libertarian beliefs are often held by people with business intuitions. But business intuition does not account for that you can't do things as a country that you could do as a business, because they cause reallocations in the economy.

If you are a business, and you need more engineers or copper or doctors, you can spend more money, and get more engineers or copper or doctors. What you aren't seeing is that you're driving up the market price a tiny bit, and causing that resource to be less available to other business.

If you try to do the same thing as a country, it just falls completely flat. You can't increase the supply of engineers or copper or doctors in the short term. If you want to just "get more", all that happens is that you drive up the price, and end up paying more for about the same amount of the resource.

Another example is savings. Libertarians frequently rant against social security, as if it was some kind of scam. What is not being understood is that a country, as a whole, cannot save.

If a country attempts to save, what happens is what's going on in China. They have a centuries-old ethic of saving, rather than consumption. This causes an accumulation of bank deposits, which the banks then attempt to put to some use. But because everyone is saving, there is little consumption. Because there is little consumption, there is nowhere to invest the money that would pay off.

So what has happened is, they have built literal empty cities – whole new cities emulating Western places like Paris, with apartment buildings, factories, and stores. The only problem is, there is just no demand for these buildings and factories and stores. It's all overbuilt infrastructure that cannot be put to use because everyone is trying to save instead of consuming.

The only way for large-scale savings to work in a society is the way social security works. Any other way of saving that would actually work, would have to have the same practical effects. The people who are trying to save money have to somehow give it to people who are going to consume it, so the economy continues to function while you wait for your turn to collect social security from the next generation.

Your real investment is the next generation. Without it, your cash, stocks and bonds are useless, no matter how much you have.

For similar reasons, supply-side economics does not work. You can't just build things and expect people to buy them, when you haven't given them the bargaining power to buy your gadgets with.

You have to give people bargaining power. Then you can have an economy based on selling them things.

2016-03-25

The Louis Vuitton theory of happy marriage

Consider this:
  • Louis Vuitton bags are correlated with being rich.
  • Therefore, to become rich, purchase Louis Vuitton bags.
Does this seem silly?

Yet, people propose that we should aim to be monogamous, and stick with one partner; not because we want to be monogamous, and have found someone we want to commit to; but because monogamy is correlated with happiness.

Imagine three couples:
  • Couple A are both mentally healthy, and are a good match. Because they are a good match, they do not seek other partners. They live together happily, and for a long time.
  • Couple B are both mentally healthy, but are not a good match. Because they are not a good match, they divorce. They each find new partners, and become happy.
  • In couple C, one is mentally healthy, the other isn't. Because of this, the relationship suffers. Eventually, they divorce. The mentally healthy partner finds a good match, and becomes happy. The other goes through several relationships before getting help, and then finds happiness.
Consider the statistics this creates. Simply because of couple C, happiness is correlated with monogamy. But this does not mean couples B and C would be better off not divorcing.

In order to find happiness as part of a couple, you must first be a person who can have a relationship. Then, you have to find a partner who is a good match.

Once you have become this person, and found a right partner – it doesn't matter if you're monogamous. You probably will be monogamous, because neither of you will need other people. But if you want to explore non-monogamy with this partner, that is also just as fine.

2016-03-14

CamelCase vs. underscore_case

If the STL could be designed again, I wish it would have chosen CamelCase instead of underscore_case.

Since STL uses underscore_case, we're stuck with two unattractive stylistic choices:
  • Use underscore_case in our programs, and suffer its drawbacks.
  • Use CamelCase in our programs, and suffer the inconsistency with STL.
A couple years ago, I tried to get over my distaste for underscore_case, and wrote a small library of 6,500 lines in that style. I thought I'd convert. Instead, I now want to burn underscore_case with fire.

Which person in their right mind decides to sacrifice 26 out of 63 perfectly useful symbols, and pretend they don't exist? Did this person spill Coke on the Shift key of their keyboard, or something?

If you allow uppercase – like normal people who aren't shooting themselves in the foot – you can do this:
    struct Thing { int thing; };
    Thing thing;
How do you do this with underscore_case? You don't. Both things have to be named differently.

You're constantly tripping over yourself due to the lack of orthogonality. With no uppercase, there is a strict reduction in expressiveness: it brings no benefit, and reduces flexibility. It requires using longer and uglier names, and you can't express in a name whether it's a type, or a method, or a member.

But this study...


Someone replied with this eye-tracking study, which claimed finding that CamelCase identifiers take 20% longer to read. Yet the paper disclaims: "One main difference is that subjects were trained mainly in the underscore style and were all programmers."

They even summarize another study, which used more participants trained in CamelCase: "Their findings show that camel-cased identifiers lead to higher accuracy among all subjects, and those trained in the camel-case style, were able to recognize camel-cased identifiers faster."

What both studies appear to confirm is that people do better in the style they are used to. No way. :)

For me, underscore_case requires effort to use. I can't easily tell where an identifier begins and ends, because underscores look like punctuation. But I understand this is due to training. I could get used to underscore_case, and use it equally well, if I thought it was the preferable style.

Type and variable names in underscore_case are not orthogonal. Given that we can get used to either style, it seems peculiar to make the less powerful choice knowingly.

2016-03-13

Against signed integer types

It is often mentioned that Google's guidelines call to always use signed integers, and avoid unsigned.

One could argue, if I were as smart as Sergey Brin or Larry Page, I'd be as rich as they are. This may be true. But we tend to succeed for the few things we get very right, and despite the many things we don't. I'm pretty sure this one is the latter.

The preference for signed integers opens opportunities for a whole panoply of unnecessary bugs. It's a mistake of the same order as nullable pointers. You almost never need negative values, but now you need to check for them always. Signed overflow is even undefined behavior, when unsigned overflow is not.

I have gone the opposite route, and always use unsigned types. I find a signed type is not needed 99% of the time. I would further argue that most uses of negative values are hacks, and potential containment and security issues. It overloads a variable with potential meanings that the variable should not have.

There's a distinct difference between MoveForward and MoveBackward, for example. A design that expresses reversion as MoveForward(-15) is both unsafe and unsound.

But but but...


A counter-argument is that it's dangerous to mix signed and unsigned types, so using only signed types helps. But this is not the only solution, or the best one. An example:
int main() {
    int i = -1;
    unsigned int j = 1;
    if (i > j) return 1;
    return 0;
}
If allowed to compile, this program returns 1. -1 is represented as 0xFFFFFFFF, which is more than 1.

But it should not compile. You should be enabling signed / unsigned comparison and conversion warnings. With MSVC, these are C4018 and C4365. With GCC, they are -Wsign-compare and -Wsign-conversion.

In addition, it's good practice to treat warnings as errors: -WX with MSVC, and -Werror with GCC.

Note that with GCC, -Wall does not actually enable all warnings. You have to go the extra step to enable -Wsign-conversion manually.

Serious projects should use -WX -Wall, enabling as many warnings as possible, treating them as errors, and manually disabling only selected, individually weighed warnings.

2016-03-05

"Unreachable" beauty standards

Half the time, I post because I'm slightly peeved. Today, it's because of censorship on Reddit. The following was a "Shower thought" post that got deleted:
I've never seen a man complain about a lack of plus sized male models.
This was removed by a moderator when it reached the front page of Showerthoughts, with 1104 upvotes. The post had a number of popular comments which were also deleted, apparently due to wrong-think. The following was one of them:
We claim women in magazines are "unobtainable beauty standards". Nobody cares that men have airbrushed abs in the same magazine. Nobody cares about the young men who are doing steroids to obtain these standards. They don't consider the whimpy kid with a healthy weight who feels inadequate because he's not ripped with a stone jaw. (Not to mention a 8 inch wang.) Because in our culture, a weak female ego is expected, but a weak male ego is pathetic. (/u/Snoozetrain)
Guess the reason moderators gave for these deletions.

Come on, guess.

"Removed for quality."



The comment I quoted is right. Here is some stereotypical female beauty – as curated by yours truly:



If anyone cares, the models are:
  • Saoli Sabatini;
  • Anjelica Ebbi (aka Krystal Boyd, and other names);
  • Scarlett Johansson;
  • Jana Bider.
I may only hope my wife will forgive me. ;) I include her to make a point. (Edit: She did. See below)

You don't need to be a professional to look like this. You don't even need Photoshop, or a decent photographer. (As it is plain to see, I'm not one.)

What you need is:
  1. Long flowing locks (optional).
  2. Botox.
  3. Do not stuff your mouth.
  4. Shave.
I cannot overstate item 3. Do not stuff your mouth. That's the most crucial.

If you're lucky like Jana, the "not stuffing your mouth" is easy. You just never have the urge to eat beyond what it takes to keep weight.

If you're less lucky – like me – you have to maintain a spreadsheet. I've kept a spreadsheet like this for 10 years. It's the best way I know to maintain muscle mass, and not get chubby.

If you're female, you don't need to focus on muscle mass. You don't need a spreadsheet. All you need is an app like MyFitnessPal. Possibly not even that. Possibly, all you need is to get used to the idea that most of the time, you need to be halfway hungry.

Now, that may seem cruel. Such harshness! Imposed on you by unfair cultural beauty standards! Who wants to be halfway hungry?

But this is not imposed by society. It is imposed by nature. If you're not halfway hungry, you're going to grow just slightly larger each year. In 10 years, you're going to start failing society's "cruel and unfair" beauty standards. In 20 years, you're going to be obese. In 30 years, you're going to have diabetes.

I almost got diabetes, from zero-calorie drinks. I can tell you, it's so much fun when you can't sit through a movie, because your bladder is too full and you need to pee. It gets so much more fun when you have to constantly prick your finger, and poke yourself with insulin. Despite your best efforts, you slowly go blind, and develop neuropathy, until one day your toes fall away.

So, let's recap. If you're a woman, society's beauty standards motivate you to not stuff your face. The payoff is that you look great, and you avoid diabetes.



Now, let us consider society's standards for men. From age six or so, these are the ideals of masculinity that I grew up with:


I think you recognize these men.

The last one is He-Man. It was a cartoon. For children. In case anyone wants to compare to Barbie.

Now, compare these übermensch to my following, paltry physique:


That's from 2013. It's the best pic I could make after seven years of moderate exercise and diet.

Then, there's Dan Bilzerian. Here's what I would have to do, in order to look like him:
  1. Awesome beard. Mine is just average.
  2. Every day, all day long – weight exercises and meat.
  3. Steroids.
  4. More exercises and meat.
  5. Cocaine.
  6. More steroids.
  7. Do you even lift?! Have more meat.
Beard and cocaine optional. None of the rest is.

My points are:
  • The male beauty ideal is at least as difficult to achieve as the female.
  • Stereotypes of male physiques are near-literal freaks, dedicating their lives to it.
  • Meeting the masculine stereotype requires enormous sacrifices in time, health, and effort.
There's no way you're going to meet the male stereotype unless you work out all day, eat meat all day, and let steroids kill your fertility and shrink your testes. Ironically – the male stereotype is impotent.

You meet the female stereotype by maintaining long hair; getting Botox twice a year; not stuffing your mouth; and treating yourself to manicures. Boob job is entirely optional – many men don't like it.

I appreciate everything my wife does to look good. However, it's not Schwarzenegger effort. She has time to do other things. She doesn't train all day. In fact – she does not train at all, other than chasing Aaron. She cooks; she's a wonderful mom; and plays WoW at a world-class level. Most women can look like this.

Most men cannot look like Schwarzenegger. That requires dedicating an entire life to it.

And not least – if we don't have one, there's no way to obtain an 8-inch dong. I wish!



Clarifications


Q. Did you actually not ask Jana before posting that pic? I can't wrap my mind around this!

I posted while she was asleep. So no – I didn't decide to wake her up for this. That's because I think I have a reasonable idea of what might be okay with my partner of 12 years. It seems that I wasn't far off. She appreciated I find her hot enough to brag, and was amused by the surprised responses.

You see – among other things; Jana and I are swingers. Sending naked photos to strangers is the first thing one gets used to, when participating in this. We have been naked online for – oh, about 11 years. After a decade of being "careful" – consider us tired of it.

The above is an example of our artful and more reserved pics. It's lingerie from Victoria's Secret. She even wears gloves! Every part of her body is dressed. It's more revealing when girls post snaps from the beach.

We have photos both hotter and more recent that would be unsuitable here. My mom also reads this. She's going to bitch as it is. :)

So, yeah. Deal with it. ;)

2016-03-04

Socialism and libertarianism: The two idiots

Following up to my previous post, here is what socialism and libertarianism get wrong. This post is harsh because responses to content in my previous post were harsh. Not on this blog – but elsewhere.

Socialism


"Socialism" refers to at least two different things.

Adherents of true socialism use the word to refer to an economic arrangement where all of the means of production are socially owned, and large-scale private property is abolished. These people scoff aloofly at others, who use the word to refer to a charitable state; often accusing such folks of ignorance.

The reason we use "socialism" loosely is not because we lack your clues. It's because the idea of "true" socialism is so stupid, we would prefer to ignore that people take it seriously.

The central failure of true socialism is that it takes an effective leadership promotion system, and replaces it with nothing. At best – it suggests to replace it with democracy.

Democracy does not select good leaders. Examples are frequent and many, at all levels. If George W. wasn't proof enough, Trump is going to be next. There's a mathematical model of democratic elections which shows that, if Dunning-Kruger is correct, democracy selects for mediocre leaders at best.

Those of us who grew up in socialist societies have personal experience how economies with social ownership failed because they selected for mediocre leadership, not just in politics but in business, everywhere and at every step.

Capitalism is bloody in its fangs and teeth, but there is one thing it does very well. It takes power away from people who invest it poorly. This is the single most important reason why capitalist economies have been so successful. The rules of capitalism are cruel and indiscriminate. But as long as they are respected, people with bad economic judgment don't get to waste a whole lot of resources. Unless appointed or elected, they're simply not put in charge of big heaps of money. The two exceptions are inheritance and lottery. In both cases, people usually tend to waste the money – but it's a one-time opportunity.

True socialism proposes no way to deal with these problems. Until it does, it's as good as a pie in the sky. Without a mechanism for leadership selection that's immune to Dunning-Kruger, socialist economies elect mediocre leaders, who appoint mediocre managers, who drive whole economies into the ground. Routinely. This has happened with literally every country that has attempted to adopt 100% social ownership.

Then there are those who think a true socialist economy doesn't even need leaders. That the economy is just going to coordinate itself: as if problems of coordination are not in fact very difficult, and lacking even theoretically efficient solutions that do not rely on central parties. Such people may think that businesses are just going to run themselves democratically; ignoring the vulnerability of committees to Parkinson's law of triviality (bike-shedding), or ruin via Dunning-Kruger (people not knowing the degree of their incompetence – e.g. when it comes to business planning).

This is why a lot of people, when referring to socialism, actually refer to a charitable capitalist state. The alternative is too absurd to contemplate.

Libertarianism


In contrast, libertarianism is a whole bunch of man-children – indeed, mostly men – in pursuit of a Fata Morgana of liberty.

Absolute liberty is not achievable. Not while we are humans, at least. As humans, we are dependent on work and resources. Our very existence is slavery. We need resources to live.

Libertarianism is the attempt to free ourselves of coercion via ideology. It is the pretense that property rights aren't coercive in themselves – practiced by those who can't imagine not having property.

If the entire Earth had been appropriated, and all the resources we need were private – there would be nothing for a newly born person to do, except to whore themselves out, in exchange for what they need to live. The price would be dictated by those who actually have property.

It seems to be no accident that most libertarians are technologically competent males. Being competent, we are in high demand. Being self-centered, we try to pretend that everyone has the same opportunity. Why don't the other people just learn programming? Oh, they could be hampered by a disability? Either physical or mental? They might lack the IQ? Hey – maybe our talents are actually rare; and that's why we're in demand, to begin with?

Well, that's inconvenient. It's much more pleasant to pretend that everyone could be in demand like us. If only they wanted, damnit.

And then, for the other part. Males. Why is libertarianism not as popular with women?

Here is my suggestion why. Women have periods. As a woman, you benefit from a monthly reminder that there are aspects of your body over which you have no control. Aspects which cause you real pain and disability. With a reminder like that, it's hard to forget how we're slaves to nature.

Competent young men have no reminder like that. We're healthy and free of hindrance. So we imagine taxes as oppression – because it's the only oppression we have.