MultiLinks 6-12-2015

Posted: June 12th, 2015 | Author: | Filed under: MultiLinks | No Comments »

What Is Code?

If you don’t understand computer programming or how computers work, this is absolutely the best explanation I have ever seen. It’s accurate, simple, and clear. If you’ve ever wanted to understand computers and computer programming, read this.

 

The Vagus Nerve: A Back Door for Brain Hacking

I am extremely skeptical of this. Lots of promises, but we’ll see. I’m suspicious that this is going to turn into the next pop-med cure.

 

High Frequency Trading Model

It’s rare to see an actual, functional algorithm for HFT methodologies. This is a simple example of statistical arbitrage. In the coming weeks, I’m hoping to port this to QuantConnect’s Lean Engine in a few weeks.

 

Is Russia’s space program in crisis?

So Russia’s program is corrupt and falling apart. Still better than the US, since the US program cannot currently put people into orbit.

 

Airbus unveils Adeline, its clever answer to SpaceX’s reusable rockets

Speaking of space: Airbus now has a plan to reuse lower stages, and reduce launch costs. Thanks, SpaceX. Unlike the UAL’s insane-sounding mid-air recovery plan, Airbus’ plan actually sounds like it might work.


Swift has had a successful year

Posted: June 12th, 2015 | Author: | Filed under: Programming | Tags: , | No Comments »

As expected, Swift’s adoption is picking up quickly. It’s a nice language, with the modern look and feel that defines current languages:

  • Simplified method declarations
  • No semicolons on end of line
  • Functions as first class citizens
  • Lambdas
  • Some sort of memory management (ARC in Swift’s case)
  • Implicit typing
  • Etc.

It’s going through growing pains, as the language spec and tools are still immature. However, it’s a language with all the buzzwords and behaviors programmers currently want. Plus, if Apple follows through with it’s plan to open source Swift 2.0, a major hurdle to adapting Swift on other platforms will be removed.

As far as general non-Apple programming goes, Swift has some serious competition for mindshare in Google’s Go and Mozilla’s Rust. Go has a serious head start, and is solving real problems at Google and everywhere else these days; unfortunately, Google has a bad habit of abandoning projects. Rust looks like an absolutely amazing language, and I think it is the best-designed of the three (better type system than Go, better memory management than Swift). I’ll be curious to see if anyone actually uses it.

Swift, on the other hand, is Apple’s “language of the future.” Apple and Swift are in a similar position to Microsoft and C#. With a large development community eager to/forced to lap up whatever Apple brings down the pipe, I suspect Swift will continue to gain popularity.


MultiLinks 6-5-2015

Posted: June 5th, 2015 | Author: | Filed under: MultiLinks | No Comments »

Intel will acquire FPGA maker Altera for $16.7 billion
Whoa. This is a huge deal. I’ll be very interested in seeing what Intel does with this.

Kubernetes – The Future of Deployment
This is an incredible technology. While Docker has slowly tried to add orchestration features like Machine, Swarm, and Compose, they are still somewhat immature and don’t fully work together well. You can read more about Kubernetes here and here. This is still immature and ambitious, but with Google’s experience behind it, I think it will develop quickly — assuming they don’t get bored. 😉

Majority of websites have serious, unfixed vulnerabilities
I’m shocked, shocked I tell you!

Play 2.4.0 “Damiya” released, adds new DI support and test APIs
Play 2.4 FINALLY adds built in DI — using Guice, my favorite Java DI container. They also look like they’ve added some useful methods for adding mock dependencies to FakeApplications when unit testing.

The U.S. Navy’s Big Mistake — Building Tons of Supercarriers
Super carriers are great for power projection — as long as you aren’t fighting a technologically even foe.


R.R. Wilson’s Congressional Testimony, April 1969

Posted: June 4th, 2015 | Author: | Filed under: Science | Tags: , | No Comments »

Going through some old links, I rediscovered this old testimony. This is the most beautiful defense of scientific research I have ever seen:

SENATOR PASTORE. Is there anything connected in the hopes of this accelerator that in any way involves the security of the country?

DR. WILSON. No, sir; I do not believe so.

SENATOR PASTORE. Nothing at all?

DR. WILSON. Nothing at all.

SENATOR PASTORE. It has no value in that respect?

DR. WILSON. It only has to do with the respect with which we regard one another, the dignity of men, our love of culture. It has to do with those things.

It has nothing to do with the military. I am sorry.

SENATOR PASTORE. Don’t be sorry for it.

DR. WILSON. I am not, but I cannot in honesty say it has any such application.

SENATOR PASTORE. Is there anything here that projects us in a position of being competitive with the Russians, with regard to this race?

DR. WILSON. Only from a long-range point of view, of a developing technology. Otherwise, it has to do with: Are we good painters, good sculptors, great poets? I mean all the things that we really venerate and honor in our country and are patriotic about.

In that sense, this new knowledge has all to do with honor and country but it has nothing to do directly with defending our country except to help make it worth defending.


MultiLinks 5-29-2015

Posted: May 29th, 2015 | Author: | Filed under: MultiLinks | No Comments »

In College and Hiding From Scary Ideas

This is the best thing I’ve read this week, possibly the best thing I’ve read this year. I couldn’t find a single point of disagreement.

 

I Fooled Millions Into Thinking Chocolate Helps Weight Loss. Here’s How.

This is the 2nd best thing I’ve read this week. Journalists who don’t understand how science works mislead people who also don’t understand how science works, in pursuit of readership.

 

Arms control treaty could land security researchers like me in jail

Once again, software is being subjected to arms trade regulations. We did this in the 90’s, and it lead to SSL downgrade attacks like POODLE and FREAK, which hurt everyone — including the government responsible for forcing their adoption. This foolishness will bite us, hard.

 

Higgs Machine Learning Challenge

Crowdsourced data science and ML algorithms being used to solve problems in high energy physics? Oh be still, my beating heart!

 

10 Books Every Programmer Should Read

I really love everything Javin Paul writes about Java. I haven’t read all of these, but I can highly recomment GOF Design Patterns, The Mythical Man Month, Martin Fowler’s Refactoring, and Joshua Bloch’s Effective Java.

 

TDD Gamification

I really don’t think this would work well for production development. However, this could be an amazing system for training new developers in TDD.

 

How can we Build Better Complex Systems? Containers, Microservices, and Continuous Delivery.

Long title, and an extremely long article, summarizing a talk (which I didn’t watch). It has a great summary of principles for developing microservices. I strongly agree with this point:

While microservices certainly lower friction they also increase risk from wiring hell and bad partitioning.

I’ve experienced wiring hell and bad partitioning (particularly, wiring hell from bad partitioning). It’s a real problem, and a good example of why, as the article says:

Microservices usually grow successfully from monoliths. In creating a monolith developers learn how to properly partition a system.

I love microservice architectures, but they must be approached correctly.

 

8 Questions You Need to Ask About Microservices, Containers & Docker in 2015

I love Docker and containers. However, they raise some very salient issues. Points 2 and 3, in particular, have been challenging me lately. Point 6, however, is the elephant in the Docker room, and leads directly into the next link…

 

Over 30% of Official Images in Docker Hub Contain High Priority Security Vulnerabilities

… Yeah. We need to get on top of this. For deployment, nocache is your friend…

 

Harvard’s Asian-American Quota Turns Diversity on Its Head

Apparently, it’s ok to be racist against successful minorities.


Kicking the tires…

Posted: May 26th, 2015 | Author: | Filed under: Personal | No Comments »

Maybe I should write more here. I am paying for hosting, after all…

I’m going to try one lengthy post a month, and a weekly link roundup. We’ll see how this goes.

 

 


Understanding Multithreading Through (flawed) Analogies

Posted: July 31st, 2014 | Author: | Filed under: Programming | Tags: | No Comments »

Prelude
All through the 90’s, the performance of CPUs grew at a breakneck pace. Each generation added more and more hardware features to make code run faster and faster. As transistor technology continued to advance, CPU manufacturers pushed exotic and complex tricks and logic into their CPUs. They added advanced logic to predict the next instruction, to dynamically reordering code instructions, to merge and break apart groups of instructions. This is an attempt to cram yet more work into each fraction of a second. However, in recent years CPU makers have found it increasingly harder to make meaningful performance gains in simple execution speed.

To make use of the extra transistors, CPU makers have glued together many CPU backends into a single CPU unit. Instead of building a bigger, more powerful engine in a car, we cram several engines into the car, and make them work together.

We call each of these engines “cores”. This has given us in the software world a bonanza of resources to work with. Unfortunately, taking use of those resources is a significant challenge.

What is a thread?
To take advantage of CPUs and CPU cores, we have a software concept called a “thread”. On a simple level, a thread is a container for a sequence of instructions, that an operating system can put on one core. We can have many threads running on one core, or many cores, or have only one thread running on one core with the other cores idle.

This is a lot to digest, so let’s look at some examples, using some real world analogies.

Several threads, one core
Let’s imagine a TA is grading student assignments. In this analogy, the TA is a core, and he treats each paper as a single thread. So he starts grading paper one, works on it for a minute, then stops. He starts grading paper two for a minute, then stops, and so on. When he has worked on all the papers for one minute, he goes back to the first one.

Several threads, several cores
So, as you can imagine, this poor TA is taking a really long time to finish. So the professor decides to speed it up by adding a second core, another TA.

Now, TA1 takes a paper, starts working on it for one minute. TA2 takes another paper, and starts working on it for one minute. Each then does the same pattern as before, grabbing a paper from the top of the pile, working on it, and putting it on the bottom.

Context switching
Now, as you have probably noticed, this is not very efficient. It would probably be faster for each TA to start a paper, grade it all the way through, then start the next paper. It takes time to put a paper back, pick up a new paper, read the paper, figure out how far along the paper has been graded, and start working on it again. This is, however, the way computers work; this is a very real performance cost, called “context switching”. So why do we do work like this on computers? Because usually, the tasks each thread needs to run don’t all take the same amount of time. Some tasks take a really long time to complete (such as burning to a CD). Some tasks are very fast, like scrolling down a document or webpage. Sure, if we didn’t switch threads, burning a CD might complete a few seconds sooner; but would you really want your entire computer to lock up for several minutes while that task completed?

Parallel Algorithms
As you can see, using multiple threads can speed up completing a task, but at a cost of context switching. There are many ways we can use threads to speed up tasks, but they come with many other pitfalls, as well. Let’s look at ways to use multiple threads to speed up tasks.

For this example, we will look at cashiers ringing up groceries at a store. Let’s ignore the problem of context switching; lets pretend we have infinite cores.

Single threaded
Let’s take a case of one cashier (thread). There is only one line. The one cashier rings up the groceries, bags them, and assists taking the groceries to the car. Obviously, this does not scale well, as the line gets longer. So how do we use two cashiers?

Multithreaded
First, we can use them in parallel. Each cashier gets a line, and assist shoppers at the same time. Another way to use them is to create a pipeline. One cashier rings up shoppers, while the second bags the groceries and assists shoppers to the car.

Note that these can be done together. If we have four cashiers, we can create two pipelines, and assist two lines of shoppers at the same time. Also note that while this can improve throughput, it also increases cost. However, it  doesn’t always increase throughput; if there aren’t enough shoppers, most of the cashier threads are going to be idle, waiting for a job to do. Another issue is that, when using a pipeline, the work can be stalled if one task, such as taking groceries to a car, takes much longer than other tasks, such as ringing up, or bagging groceries.

Thread Pooling
How can we use threads more efficiently? Instead of tying each person to a specific task, we let each of them take whatever task is available. We have three tasks (ringing up, bagging, assisting to car), and a group of three cashiers. This group of cashiers are called a thread pool.

Each cashier then takes whatever task is available. If the cashier who assists to the car is not back when the cashier finishes bagging, that cashier then assists to the car, and so on. Of course, this can lead to issues, as well. If assisting to the car takes a very long time, it’s possible that all three cashiers are busy assisting, and no one is ringing up customers. So we need to prioritize the tasks. We assign ringing up as a high priority, bagging as a medium priority, and assisting to the car as a low priority. Now, a cashier will only take the highest priority task that is available. The cashier bagging groceries will only assist someone to the car if there are no more groceries to bag. This is called priority scheduling.

Resource Contention
So, how do we use two cashiers in parallel? Well, let’s try having them both check out people on the same register. That doesn’t work at all, because one person’s grocery bill is getting mixed in with another, and leaving the bill in an entirely incoherent state. So we need to manage access to the register. In programming terms, the first cashier will “lock” the thread while ringing up groceries, then “unlock” it when finished. Then the next cashier can take control and start ringing up the next customer. Now, we have fixed the data integrity issue, but introduced a very serious performance bottleneck. This is called resource contention.

Deadlocking
There is also another potential issue this has introduced. Imagine the cashier who has locked the register gets a call, to handle an emergency. The cashier then goes on break to handle the emergency, but forgets to unlock the register. Now the other cashier and all the customers have to wait. If the first cashier never comes back, the customers and other cashier will be waiting forever. This is called deadlocking.

Solving Resource Contention
The easiest way to solve this issue with resource contention is to not share resources. In our grocery store, we solve the issue by installing a 2nd cash register. Now, both clerks can process customers at the same time, without interfering with each other. But this came with some cost, the cost of buying a cash register; in computers this comes with cost too; more memory, and more time spent building the resources. Additionally, we now have two sets sales records that now have to be rectified.

Sometimes, we simply have to share resources. In this example, let’s add a manager. We want there to be only one manager, as only one person should have the accountability and responsibility for certain problems. Now, only one clerk can use the manager at a time. Imagine a clerk calls the manager over, and says, “hey, I might have a problem, so stay here just in case.” Now, that manager is “in use”, and any other clerk who needs manager assistance has to wait. This is another bottleneck. To alleviate this, we instruct our clerks to only call the manager when needed, and let the manager leave when the problem is resolved. Minimizing the time a shared resource is locked can significantly improve performance, and minimize the chance of deadlocking.

Postlude
There are many more possible problems when dealing with multithreading: Live locking, false sharing, and race conditions to name a few. Even when we write correct multithreaded code, it can be hard to extract serious performance benefits. CPU makers continue to give us more and more raw power, but using that power to actually benefit the user is a significant challenge for programmers to overcome.


The Dive

Posted: May 20th, 2013 | Author: | Filed under: Personal | No Comments »

Sweltering under Florida’s summer sun, wearing wetsuits necessary for a prolonged dive in the 72 degree water, we assemble and test our diving gear and review our dive plan. 100 feet below us is one of the spring-fed caverns that has made northern Florida a diving mecca for cave divers all over the world.

Though excited, we buddy check each other’s gear with the utmost care; a rapid surface ascent would be far too dangerous from such depths. First, the air pressure gauge; 3000 psi, a full tank. Next the primary and backup regulators; both flow easily. Next tested is the inflatable vest known as a buoyancy compensator, or “BC”. All is secure and functional. The diver’s weight belt is verified, and the dive computers have fresh batteries. We are ready to dive.

As we slip below the waves, the senses change. The sounds of the surface world are immediately muted; the rustle of the breeze, the chirping of birds and clucking of squirrels, the everyday sounds to which we are accustomed are immediately quenched and replaced with the sound and sensation of one’s own breath. First the sharp hiss of the intake, followed by the exhale, a slow gurgling rumble. Each breath is intensely cold and dry, yet soothing as it fills the lungs. Thus encased in a sensory cocoon surrounding us with self awareness, we sink further below the still surface.

The waters are clear as glass, but the sun’s light becomes ever more attenuated. In our monochrome world, the soft turquoise of the shallows has given way to a dark navy blue at the opening of the cave. We activate our waterproofed torches and continue into a different world.

The floor of the cave is soft silt sand, but the walls and roof are limestone pockmarked from years of erosion. The ceiling shimmers with pockets of air, trapped and unable to flow back to the surface. We follow the lead of our guide; we remove our fins and rotate upside down. We inflate our BCs, and float until our feet touch the ceiling.

After a moment of vertigo, the world rotates; the change of perspective is a breathtaking transformation. The ceiling is our floor, cratered like the surface of the moon. The air pockets are a silver liquid that pools at our feet. We cup it in our hands; it flows through our fingertips and falls back to the ground. With buoyancy as our gravity, we bounce with each step, slowly returning to the surface like an Apollo astronaut. Some distance away, the circular opening of the cave hangs in our sky like a blue marble. We are no longer on anything recognizable as Earth.

We explore for a minute or a day; time no longer passes in a comprehensible way. The sound of breathing is finally punctuated by high pitched beeps; our dive computers are signaling it is time to leave. The chill of the water is taking its toll, but we moderate our ascent. Rising too quickly risks the bends, or a pulmonary embolism.

Our alien landscape sinks away below us, and we return to the bright, clear waters just below the surface. 15 feet away, we stop; our computers don’t advise a decompression stop, but our tables do, and we are risk-averse divers. 5 minutes later we break surface, and the senses return: the sounds of nature, the warmth of the sun, the smell of the breeze and the plethora of colors. To an alien world and back again, in under a half hour.


New Facebook UI

Posted: February 4th, 2010 | Author: | Filed under: Technology | Tags: , | No Comments »

For some reason, I seem to have been randomly selected to beta test the new Facebook UI. There is no opt-out of this, and I wasn’t notified. After posting a snarky and sarcastic status update, I found that I was seemingly the only friend online who had the new UI.

Good UI designs constantly change in arbitrary and unpredictable ways. Muscle memory is a bad thing. People love to constantly learn new ways to perform common trivial tasks, especially if the new ways are not noticeably better than the old ways. Good to see that Facebook is learning well from its business partner Microsoft!

So, in case you are interested in what you may soon be using, here is a screenshot:

New Facebook UI Screenshot

New Facebook UI Screenshot

A quick tour:

  • The icons in the top left, next to the word “facebook”, are your new links to messages, notifications, and friend requests. The new tiny and arbitrary icons, in addition to having terrible contrast, are drop-down menus with live previews. While slick, the icons are annoying to click. On the plus side, you can click the message directly in the pop down menu.
  • The “Friends Online” list on the side is annoying– unlike the popup menu (still in the bottom right), it is limited in the number of friends displayed, and it doesn’t respect your list groupings. Also, when you click “see all”, it doesn’t expand in place; no, it triggers the OLD chat popup in the bottom right to expand, on the other side of your screen. This is all manner of retarded, I haven’t seen a UI do something that terrible since I last had to use Pro/Engineer.
  • The “Accounts” menu, in the upper right, now has a shortcut to “credits”. Gee, thanks, Facebook.
  • Overall, the look and feel seems more hodge-podge. Why is the search bar in the middle now, instead of the top right as is standard? Why did they feel the need to split common tasks across toolbars separated by the entire screen? What utility are they trying to add? What workflows does this UI intend to facilitate?

At any rate, I hope this beta UI is merely a temporary trial of design features. I doubt that is the case; Facebook didn’t notify me in any way that my UI was going to change or had changed. There is no way that I see to change UI versions. In addition, there is no special offer of a feedback or bug reporting link. I suspect this is not a trial of the UI design, but merely a staged rollout. While I am glad that Facebook is working to improve UI behaviors while adding new features, this feels like a step backwards.

If you are curious about any of the new feature behaviors, let me know in a comment.

UPDATE: 3 hours after changing the UI, Facebook finally posted a notification on my homepage, saying, “Check out your new, simplified homepage!” They conveniently provided this link: http://www.facebook.com/sitetour/homepage.php


Google: Scary? Awesome? Scary Awesome?

Posted: December 15th, 2009 | Author: | Filed under: Technology | Tags: , , | 1 Comment »

After my recent acquisition of an iPhone, I decided to fix up my long-neglected Google Reader account, to feed into NewsNetWire on my handsized crack.

After adding my feeds, Google — apparently using my emails from Gmail as a reference — took it upon itself to suggest several new feeds I may enjoy:

AMERICAN.COM — A Magazine of Ideas, Online

E. Kowalski’s blog

Firearms and Training

Residents of Gainesville, FL

Soul of Star Trek

Apparently, Google thinks that I am a libertarian(ish), mathematically-inclined, gun-loving Sci-Fi nerd who lives in Gainesville, FL. Google is, in fact, entirely correct.

This is awesome, because I found at least one blog I would like to follow.

This is scary, because Google’s CEO, Eric Schmidt, doesn’t understand privacy. Of course, Google’s PR Fire Dept claims poor Schmidt was terribly misquoted.

Years ago, Wired ran a story portraying 2 worlds of pervasive surveillance. One was a dystopian world, a police state where the government used a network of hidden cameras to maintain order and eliminate crime. The feeds from this video, of course, was entirely protected and secret. The other world, less dystopian, was also a world under constant surveillance — but all the video feeds were publicly available. Want to know if your friends are already at the bus stop? You can check the feed. Want to know what the lines at an event are? You can check the feed.

While many look at both worlds with some level of disquiet, the truth is we are approaching both worlds. The former, the government is instituting without a peep from us — in the US, traffic cams are everywhere. On the other hand, we are freely creating the later world through social media; why bother installing public surveillance? People surveil themselves and proudly submit it for public consumption via YouTube, Facebook, or Twitter.

In a way, the very act of publishing information might be an abandonment of anonymity and information we normally consider private. A couple of years ago, researchers discovered they could easily link data sets, despite anonymizing attempts. Have we ever truly had anonymity and privacy, or has it merely been an illusion created by insufficiently advanced data collection and mathematical techniques?

If privacy (or the illusion of such) dies (and some say it already has), who has killed it — the Googles, the Governments, the Statisticians, or the Tweets?