29 September 2014

New website is live!

I'm keeping everything book-related there, just to keep this a programming-oriented blog.


26 September 2014

Flashover: A new hard science fiction novella

Here is the first chapter of my new novella: Flashover.

It's available for purchase at Amazon, on Smashwords, and soon on other platforms.

I know it's odd for an Egyptian to write in English, but that's what you get when you drop him  in the cauldron of literature and let him boil over for a decade. Oh wait, I did it again!

Anyway, the story follows the life of Darren Swenson: a New Orleans teen who loves coding, as he goes about his life. He makes an important breakthrough, and things just evolve from there.

This is a story about growth, about how the greatest things can have the humblest of beginnings. A cliché? Perhaps. It's just a beautiful one.

Three of the chapters have already been posted on wattpad


I find it funny how I used to wonder what an Artificial Intelligence would feel like.
Would it soar through cyberspace in unparalleled freedom? Or would it feel like a bird forever trapped in a metal cage?
I would have never guessed that one day I’d find out the answer for myself.
We all take our steps through life, and from the time we learn how to walk, we keep going. Yet all that walking could only lead to a single inevitable destination: a grave.
At least that’s true for you.
I still remember taking my first step.

1 Sparks

When I was little, my mother used to tell me that the universe was made in sparks. Would that mean that at the beginning, someone had clacked two cosmic stones together?
I was flitting through the code on my screen. This damn bug was driving me insane.
“Stack corruption.” I whispered the most dreaded words a programmer could ever hear.
A stack corruption was a special kind of bug. Somewhere along the line, the program had overwritten a small piece of memory, a tiny piece, but it was located on the stack, and that changed everything.
I clicked through the corrupt stack trace in my debugger, trying to find the culprit. No use.
The stack was the map with which a program could tell where it had been and what it had been doing. There was no telling how badly a program would misbehave after overwriting part of the stack, and you know what the worst part is? That kind of bug gets the debugger itself confused.
I sighed and shut down my debugger, it would have to wait.
I checked my email. Nothing yet.
I should have received the message by now. I was starting to get worried. Did it lose power? Was the process interrupted somehow? What’s with the delay?
I checked the estimated completion time on my phone again and realised it was two minutes past the original estimate. I had to go check it myself.
I got up, turned off the computer, and left the library.
My name is Darren Swenson, and I’m seventeen years old.
The year is 2022, and last week, I finished writing the first Structural Molecular Compiler.
The SMC was a piece of computer software. A suite of compiler programs. Only it didn’t compile code into computer programs. It compiled code into complex molecular machines, simply known as nanobots. It compiled from a new programming language I’d invented specifically for this purpose.
The language was called C@ – pronounced ‘cat’ – and it was weird. It certainly looked like C++, but had its own idioms and special keywords for automata.
It was hard work, and the compiler was very slow. It had to account for millions of atoms interacting simultaneously within a molecule, and produce something meaningful out of the code it was fed. It would take days to compile anything of moderate complexity.
At the moment, I was having it compile my second invention, it was a mere 12,382 lines of C@ code, but when passed through the compiler, it produced a peculiar piece of nano-machinery: the Structural Molecular Assembler. I won’t get into its function right now, but if you’ve studied biology, the best analogue for it is a Ribosome on crack.
But the compiler was taking too long. I checked my message queue again. Nothing.
I entered the basement.
Designing those things wasn’t easy. It took me two years and a lot of unrelenting work. I had to study so many things in so many fields, I think it’d be fair if I’d turned into a raving lunatic in the process.
What made it ironic was that I was somewhat of a failure at school. History, geography, languages, crafts, and art weren’t on my list of interesting subjects. Well, maybe geography and crafts were mildly interesting.
As I walked into the basement, I could smell something in the air. Something was wrong.
I turned on the lights and went to my terminal, I woke it up from standby and signed in.
“Oh shit!” “Shit! Shit! Shit!”
My compile farm had crashed.
I’d made it using old computers. Instead of using a single computer for my work, I figured a long time ago that it was much more efficient to network many cheaper computers into a cluster. Well, in terms of cost versus performance that is. But my father had told me not to worry about the power consumption. “Son, you let me worry about that. You do your thing.” he had said, but I’d still contributed through my freelance work online.
Well, now that it had crashed, I was having second thoughts. All of that for nothing!
I ran a diagnostics routine and found 3 unresponsive nodes. I spent two hours figuring out what went wrong.
Overheating. God damn heat. I needed better air conditioning. Yeah, right. Fat chance of that.
I disconnected the nodes and started the process all over again. I lowered the processing priority. It would take longer, but it would mean less heat.
There we go again, two weeks down the drain.
It’s not like I could use the schematic yet anyway, I still had a stack corruption bug to overcome.
“Hey Kat.” I greeted Katherine as I walked through the living room on my way to the kitchen.
“Hey.” she said without looking back from the TV.
“What are you watching?” I asked.
“Just one of my stupid soap operas.” she said nonchalantly.
“Is it any good?”
“Not particularly.”
“All right, good talk.”
I stepped into the kitchen and fixed myself something to eat, then went upstairs into my room.
It was time to fix this bug, once and for all. I delved in with all I had.
It took me a month to fix all bugs and finish my tool. A whole damn month.
Thankfully, it was over. The compiler was finished processing the schematic for the assembler as well.
The problem with the schematics that my compiler generated was that, to build them, you’d need an assembler.
Since the schematic for the assembler was generated by the compiler, you’d need an assembler to assemble one. A chicken-egg situation.
When confronted with this problem, I decided to cheat. Why not have something that already builds molecular machinery do my work for me?
That’s why I wrote the RNA converter, and now I had a working converter and something to convert.
The RNA converter was a one-time-use tool at this stage of my plan. I would use it on the schematic for the Structural Molecular Assembler to convert it into something organic. Something that a common bacterium could understand.
Something tangible.
I ran the converter and waited for several days, once finished, I went online and made my order with a gene synthesis company. Commercial DNA synthesis services were readily available since the early 2000s. It was cheaper nowadays, thankfully.
It cost me my allowance for almost a year. The RNA strand was huge. No way around that. There was just no way to optimise it further when forced to use a biological Ribosome as my medium.
Now it was time to wait for the bacteria to arrive. I opened up my code editor and toyed with some ideas. I was preparing for the next step.
Two days later, I got the call.
“Hello, this is Dr. Patrick from Triple Helix. May I speak to Mr. Swenson, please?”
DNA synthesis labs would only call you if something went wrong, and something going wrong meant that they’d run the strand against common and dangerous viral sequences and thought you were attempting to synthesise a bioweapon of sorts. I didn’t want to get my father involved and I certainly didn’t want a visit from homeland security. My heart skipped a beat, but I kept my composure.
“This is Darren. How can I help you?”
An awkward moment of silence passed as Dr. Patrick overcame his shock at the voice of a teenager greeting him.
“Um. Well, Mr. Swenson. We just ran the sequence you submitted against our early detection database.” his voice sounded perplexed.
Just what I thought.
“Anything I should be worried about?”
“Oh no, no, nothing like that. It’s just… the strand is unique. I know this might come off as unprofessional, but my colleagues and I were just wondering why it looks like nothing we’ve ever seen, and the structure is almost…”
I could hear whispers around him, and he tried to block the microphone. I heard some scrambling and a new voice took over.
“What the hell are you trying to do, son?” a gruff voice asked.
“Just a science project, sir.” I replied.
“Should we be worried, anything we need to report?” the voice asked.
“No sir, it’s just a hobbyist project.”
“That’s a damn big project, I’ll tell you that.”
“I appreciate your discretion.” I said calmly.
He sighed and handed the phone back to Dr. Patrick, who promptly apologised and ended the call.
I sat there, smiling, and visibly shaking.
I think that the ‘unprofessional’ phone call paid off in the end. Because I got my package only something short of a month later. That must have been their way of apologising. They must have bumped me up the processing queue. Well, it was either that or they hadn’t been getting a lot of work lately.
The day the package arrived, I was haunched over the computer in my room reviewing some simulations.
Dad called from downstairs, and said there was a delivery for me. I lurched in excitement and went to receive it.
I talked to the delivery man and signed the papers, then moved the box to the basement, which I’d partially converted into something resembling a makeshift cleanroom in anticipation of this moment.
I deposited the bacterial culture into the incubator and adjusted its parameters. It would take one day for the culture to grow.
It was time to move my development computer down here, so I went upstairs.
“Hey son, what’s the latest? Did you get it?” my father was asking about the package.
“Yes, dad. It’s already incubating.”
“All right. Now prove that it actually works and I’ll personally clean your room for a month.” he said with a smirk.
“A challenge! Now I definitely will.” I said with determination and a smile. “Could you help me move my computer downstairs?”
“Oh no, I have work to do. You take care of that.” he said as he picked up his briefcase and headed for the door.
“All right, dad. Thanks anyway. Good luck at work!” I said as I strode towards the stairs.
“I guess I won’t be moving the desk downstairs.” I murmured to myself.
A day later, I had the first organic Structural Molecular Assembler. Now let’s talk about its function.
Think of it as the offspring of a Rubik’s cube mating with a Swiss army knife.
The Structural Molecular Assembler does absolutely nothing, until it’s fed with a radio signal.
Once it confirms its transponder ID, it starts decoding the payload, which – as you might have guessed – is the same format that the Structural Molecular Compiler produced. Once it decodes the payload, it begins the assembly phase, where it rapidly interprets the molecular schematic and constructs it atom by atom. It also had a mode where it executed arbitrary instructions, step by step. That mode was used to reconfigure the molecule, split it apart, and make it do all kinds of crazy things, but more on that later.
First order of business was the construction of the first generation of synthetic assemblers. I plugged my handmade communication adapter into my computer and initiated the process.
Once they self-diagnosed and pinged the ready signal, I ordered the organic ones to kill the bacteria and self-destruct.
You see, organic is dangerous. Things could go wrong at any point. The host bacteria could mutate, and transcription errors were common. The assemblers would be destroyed if they didn’t pass routine diagnostics by other assemblers, and I took extra precautions with the organic version, but who knows? It might mutate and decide it wanted to live. Evolution is bad in that regard, and very unpredictable.
Remember when I mentioned arbitrary instructions? Well, those do serve a purpose. The assemblers could reconfigure themselves on request. I designed them to be as modular as could be. You know how carbon atoms can form fullerenes? Well, the assemblers were just as versatile. They could form nanotubes and other allotropes just as easy.
And so, I wrote more code and had them manufacture flagella, molecular propellers, and what-have-you. They attached the new appendages to their modular bodies and could now move with purpose.
Once the deed was done, I had the synthetic assemblers migrate to a new environment and incinerated the original culture.
The original culture numbered in the thousands, but for what I wanted to do next I needed millions. I set it to reproduce and went back to my normal routine. I was positively shaking as I contemplated a grey-goo scenario, but I assured myself that this would work.
A few days later, a forming mound of very fine dust greeted me. I set down my sack of coal and got to work grinding it down into dust.
“Hey dad! could you come down for a minute?” I called out from the basement.
“One second!” I heard the reply.
A moment later my dad entered the basement.
“What’s up?” He asked.
“I just wanted to show you something!” I said, unable to keep excitement from my voice.
“Okay. I’m here. What is it?”
I uncovered the object in the middle of the room with a big smile.
“Holy shit! Is that diamond?” my father asked in awe as he leaned in to inspect it.
“Damn right it is.”
“That means that you did it, son!” he exclaimed and reached for a bear hug. I hugged him back.
“I sort of flopped it with this desk though.” I said after a silent moment.
“I wanted to make a carbon-fibre desk for my computer and this happened.”
“Why not just use wood?” he asked.
“Don’t toy with me dad? Nanobots can’t manufacture wood, it’s made from trees.”
“I meant the way they make you do it in your crafts classes.” he said with a smirk.
“Oh please, don’t remind me.”
“I guess this makes it official. Now I have to clean your room for a month.” he said with fake dismay in his eyes.
“I have been waiting for this moment for so long.”
“You’re still picking up your own dirty laundry. I’m not touching that.”
I stashed the small diamond into my pocket and set out for a jeweller’s shop down-town.
After a long thoughtful walk I arrived there. A young man greeted me.
“Hello. How can I help you?” he asked.
“I’d like to sell this diamond.” I said as I lowered it to the counter.
“Oh. Can I see your license please?” he asked.
License? I should have researched this before trying.
“A license? I don’t have one.”
“Well, I can’t buy it off of you if you’re not a licensed jeweller.”
“All right, thank you.” I said as I reached for it.
“May I take a look?” he asked before my hand found it.
“Sure.” I pulled my hand back. He picked it up.
“Hmm… Here’s what I can tell you. This is a pure rock, probably synthetic. I can’t tell for sure without a thorough inspection.” he said as he inspected it with his implements.
The assemblers produced 100% pure diamonds. No flaws, no imperfections. It was simply impossible to occur in nature with this purity. I definitely should have done my research.
“Where’d you get it?”
“I found it.”
“I see. Interesting. I don’t see any laser engravings, either.”
“What does that mean?”
“Most synthetic diamonds are engraved by the manufacturer.”
“Is that bad?”
“It’s a little odd that this one isn’t, that’s all.”
He handed it back, I picked it up and turned to leave.
“No problem, please come again, and hey… here’s my card. Feel free to call me if you… find anything else.”
“Uh… sure.”
I got the hint, and I felt mildly offended. I left the store and went home.
It took longer than I expected to get rid of the diamond desk and the diamond, but it was eventually done. I’d programmed the assemblers with the ability to disassemble, which makes the name ambiguous at best.
I vowed to never synthesise diamonds for profit again. I’m being careless, I thought. I needed to start small.
I needed the money for the raw materials, so I sat there thinking, then it hit me.
I didn’t need money at all.
I spent some time working on the new code and modifying the assembler, and that’s how the collectors were born.
The little machines did nothing more than seek a certain material and haul it back to a certain point. If they went too far or couldn’t get back, they self-destructed.
My prototypes worked great. They could seek target molecules and atoms efficiently, but a large scale application would prove difficult. I couldn’t use radio signals for this, it would be insane. Coordinating the individual actions of billions of collectors using radio was out of the question. I needed a better method for communication.
I decided to study quantum mechanics in more depth, and began experimenting with my creations.
The first couple of experiments were a complete failure, then I made a breakthrough.
Using magnetostatic crystallite containment cages that acted as atom traps, I managed to trap hydrogen atoms and push them into one another. The process had a high chance of success.
Things had just got back on the right track. I’d managed to develop a reliable procedure for entangling two particles.
“Hey Kat, what would you do if you had a machine that could answer anything?” I asked my sister out of the blue.
Our relationship had improved after she found out that I had actually ‘invented’ something. She was happy to see father happy, and dad couldn’t have been happier ever since. It was the best we’d seen him since mother died.
“Anything?” she pouted slightly as she asked.
“I’d ask it why we’re here.”
“What do you mean?”
“I mean… I’d ask it why we exist. Nobody told us why when we were made.”
“God would disagree.”
“Oh, please.” Katherine said.
“You don’t believe in God? I took you for a believer.” I asked in shock.
“It’s not that. God doesn’t tell you why you were created, he just tells you how to live. The big DOs and DO NOTs. Do you believe in our lord and saviour?” she asked with a smirk.
“If you’re talking in biblical terms, then no. I don’t.” I replied candidly.
“Then what do you believe in?”
“I believe in the Great Architect.”
“The what?”
“The Great Architect. If God exists then he’s the greatest programmer and engineer to ever be.”
“Dear lord. Do you have to invent? Even in religion?” she giggled.
“I’m not inventing anything, and it’s more of a philosophical take than a religion.” I defended.
“Okay. I’m interested, tell me more.”
“The basic principle is this: where there’s a program, there’s a programmer.”
“Oh, I see, and you think we’re programs?”
“No, I think we’re basic automata. The program is reality.”
“So, you think that the universe is a simulation?”
“It has to be.”
“So, we’re like… living inside The Matrix? There’s more to us outside the box?”
“Might be, or we could just be a part of the simulation like everything else.”
“You do know that Stephen Hawking would disagree with your theory?”
“Why do you say that?”
“Stephanie made me watch one of his videos where he talks about how this universe is just one of an infinite number of different universes.”
“Oh yes, I’ve watched that one. The Story of Everything. You’re talking about the bit where he says that a grand designer doesn’t have to exist, right?”
“It’s the one where he tells you to imagine an ancient mechanism that churns out universes with different laws of physics, and attributes our existence to that. The one where he says that this universe is the only one where we can exist, right?” I asked.
“I think so.”
“Well, he’s right about the last part, but we have a name for such a mechanism in computing. One that explores all possible outcomes in parallel.”
“What’s that?”
“A universal search algorithm. Levin Search. A program.”
I needed a silent mode of communication. Something that didn’t broadcast and receive. Something that two nanobots could use to talk to each other.
Quantum entanglement hadn’t been proven useful for communication. You could entangle two particles such as that when one was measured, it would pick a state, and the other peer would instantly be affected in the same way. That didn’t mean you could use this for communication.
The No-communication theorem stated that it was impossible to communicate information from one observer to another while measuring the state of a particle.
I cheated. I didn’t measure it at all.
All communication ‘happened’ during superposition. If observed, the transmissions simply stopped, but every time the two systems simultaneously entered superposition, something beautiful would happen: communication would take place. When the wave function collapsed, any consequential actions were carried out.
From the observer’s point of view, the system just ticked.
This was of no use achieving faster-than-light communications for practical uses, but it worked at the nano scale, and my next step was using this technology to my advantage.
The next generation of assemblers had sixteen ports, each housing a collector and a supercooled quantum-entangled particle, and each collector housed a peer. This communication system allowed the assemblers to request materials from the collectors instantaneously, noiselessly, and directly.

Now all I had to do was finish the code for my next invention.