Why Blacks Aren’t Prevalent in Tech

wholenewworldI’ve been asked to chime in on this topic many times. Why aren’t there more blacks in tech? The answer is clear. To me, it’s the equivalent of “Why aren’t there more whites in the NBA?” Maybe not exactly the same, but let me explain.

First I think we should define tech. Tech today seems to be synonymous with silicon valley, startup culture, and entrepreneurship. When I say tech here, I mean any computer science field – software, systems, network, etc.

I’ll start with my background and my introduction to computers outside of school. I grew up in a middle class family. If you walked into our family room, you would see Jet and Ebony magazines on the coffee table (remember this fact). At the same time, we also had an office with a complete set of Encyclopedia Britannica, and a couple of other scientific based encyclopedias that had topics ranging from physics to biology and aerospace engineering. I spent many Saturdays watching cartoons and music videos on BET, and to be honest, I think my father was disappointed that I wasn’t too into sports. Our first computer in the house was a Macintosh Quadra 610. My father got an investment from my grandfather to start a graphic design company and Macs were the way to go. It was about 1996/97. I was 11 years old then. It was all about America Online dialup and those ugly 56k modem noises when you wanted access to the internet and I loved every bit of it. I made a lot of friends in the America Online chat rooms. I still talk to a couple of them to this day. This would also expand my taste in music beyond what I listened to on BET and the radio. The first songs I ever downloaded were a bunch of drum ‘n’ bass remixes of Björk songs. Luckily, my father grew tired of me spending so much time on the computer that they needed for work, so in 1998 he bought me my own computer, It was an e-machines with an Intel 800Mhz Pentium || processor and Windows ’98. The first day I got it, Napster and I had a good time together, and I started making my first websites on Angelfire for myself and my online friends when I was 12/13. I understood the magnitude of the internet when I was chatting with people from around the world and I instinctively wanted to know more about how it was all possible. For me it was a natural progression. I wanted to learn how to build dynamic webpages and work with databases so I learned to code. When that wasn’t enough, I wanted to learn about the systems my code was running on so I learned to dual boot my computer with linux. Then I wanted to learn about how all of these systems were connected together so I learned about network engineering which was what I went to college for. With the exception of network engineering, I’m all self-taught. My dad had no clue about the things I was doing on that computer. He considered it a toy until I was much older and he saw and understood what I was doing.

Fast forward to about 3 years ago. I lived in Los Angeles. A good friend and I took a trip to San Francisco. She was going to see her brother run at a college track meet and I was going to meet my friends for the Bay to Breakers footrace. Her parent’s house was being renovated so they were house sitting for a couple they knew. My friend showed me around the house briefly when we arrived, but I was tired from driving so I didn’t pay too much attention to the details in the house. I wake up in the morning and have some time to check out the house before I leave and… WOW! In the family room, there were multiple scientific and intellectual magazines on the coffee table. Browsing the bookshelf, I remember spotting a series of books and essays written by Napoleon Bonaparte in the 1700’s-early 1800’s – first run editions I might add. I was afraid to open one because it looked like it was about to fall apart. There was a music studio in the basement. I walked into the foyer and looked at the artwork on the walls only to discover a few original Picasso drawings and in this moment it felt like Aladdin had taken me on his magic carpet and started singing “A Whole New World” to me minus the lovey dovey crap. The wealth of sheer knowledge and art and anything else you would need for inspiration and to pique your curiosity was there in that house.

Upon leaving the house, on my drive through the hills on the way to San Francisco, I compared this to my own upbringing and the upbringing of others I knew that grew up in impoverished neighborhoods and came to a simple answer. It’s all about access and exposure. A majority of the black population, like other minorities, live in impoverished neighborhoods with schools that don’t have much resources. It’s up to the parents in these communities to expose their children to as much as possible. However, in these communities, black kids are shown that the best way to make it out of their environment is through sports or music. The hunger that is created in these children to get out causes them to pursue sports and music careers with great passion, which white people cannot match – going back to my question earlier, “Why aren’t there more whites in the NBA?” Music and sports are what’s cool in these communities. A career in IT doesn’t even come close in cool factor mainly because there aren’t as many examples. IT won’t appeal to these communities until they see other black people doing big things in IT. Perhaps a better question is, “Why aren’t there more rednecks and other impoverished minorities in tech?” This isn’t a racial matter. It is instead a socioeconomic matter.

Some people believe there is institutionalized racism within the tech community that keeps blacks from excelling and I’ll be the first to call bullshit on this notion. Engineers don’t play games. You either know your shit or you don’t and you will be tested to see if you know what you say you do. If you know your stuff and you know the right people and make the right moves then you can go wherever you want in this field – no matter your race. It’s a highly specialized field, and to touch on another point, it’s not for everyone and learning to code is not as fundamental as reading, writing, and arithmetic.

For me the solution is two-fold:

To the parents of children in these communities, I urge you to expose your child(ren) not just to computers, but to many fields and take advantage of the free libraries and museums that are around. You and your child(ren) may not even know they are apt in a certain field until they are exposed to it. Once they find a topic of interest that they gravitate towards, do your best to nurture that interest. I had no idea I’d enjoy telling computers what to do until we got our first one in the house that I had full control over, and I had been exposed to computers in other environments already. I can’t say I don’t know what I would be doing now if my father had not bought me my own computer (I would be doing something in music, aerospace, astrophysics). As a matter of fact, many black musicians and athletes also know what they would be doing if they had not made it in their career. They’ll tell you that they would be selling drugs, in jail, or dead. A rule that is important in my life is “don’t knock it ’til you try it.” You never know what you will like. Teach your child(ren) to expose themselves to as many things as possible while reserving judgement until after trying something new. This is something that should stay with them as they grow older as well. The more you expose yourself to, the more opportunities become available. Spend time with different people doing different things. You won’t just learn about others, but you’ll learn a lot about yourself in these experiences.

To the people with time and/or money who are so concerned with why there aren’t many blacks in the tech scene, put your time/money where your mouth is and invest in black communities and setup tech centers where these children can at least be exposed to a little bit of what goes on in the field (shout out to Ben Horowitz). I’ll come teach some of what I know. Or at the very least, invest money in the schools to provide computers for learning what we do in tech. It doesn’t take long to learn something new, but it takes a while to learn how to do it well. The younger they are introduced to different things, the better.

My role in the solution is to show that blacks can excel in the tech scene as well. If I want to see more blacks in the field then I have to show that learning about computers can be as cool as dunking a basketball or spitting some hot bars on a mic. I haven’t figured it out yet, but I’m working on it. I do have some pretty cool stories from my career though.

AND BLOCK WORLD STAR HIP HOP! This site is atrocious and does absolutely nothing to help the black community advance. As a matter of fact it reverses advancement. Coon shit like this pisses me off, but at the same time, WSHH gives people insight as to what exactly black children in impoverished neighborhoods are exposed to when there aren’t enough resources in the community and at home to fill in the gaps.

*Mic drop*

P.S. At about 37 seconds into the video, a lot of white people in the crowd say the word “nigga.” I’m not mad at all and neither is Kendrick Lamar. It looks like I have a topic for a future post, but hopefully you get my point in posting the video/song. The world is changing and I believe it’s for the better. Just because black people aren’t prevalent somewhere does not automagically constitute that there is institutionalized racism.

One might argue that the reason these neighborhoods are impoverished in the first place is because of institutionalized racism, but there comes a point where we have to stop blaming racism and expecting handouts from the government to fix everything and do what we can ourselves to uplift these communities and empower them to uplift themselves.

Featured Image

Dependency Injection using PHP’s Reflection API

So, I had a HUGE problem with my website phanteye.com. Just to give you a little background, it runs on Zend Framework 2 with PHP 5.5. We only use ZF2 for its MVC and I18n components. We don’t use its database functionality. Instead we built our own composer library that contains all of the interfaces to our databases and specialized classes/methods that use them.

We were originally using the MySQL extension. The cause of the problem was because of poor coding that relied on the behavior of the MySQL extension that returns the same MySQL connection link when mysql_connect() is called multiple times with the same parameters. This sounds great until you migrate to the MySQLi extension which does not exhibit this same behavior. MySQLi will create a new connection to your db each time you try to establish a connection. So, when we migrated over to MySQLi, we started getting MySQL errors stating there were too many connections on certain pages… womp womp. Based on this, you can tell another part of the problem was our library was written in a way that causes several of our classes to make a new database connection call whenever it was instantiated… another womp womp.

We have a class called IObject that is extended by other classes and is used for general MySQL functionality (fetching rows from tables, getting column names, etc). It is essentially a model class. It used to look something like this:

Class IObject
(
	public function __construct($objectID = null)
	{
		$this->Db = new Db;
		...
	}
...

Our classes looked like this:

Class User extends IObject
(
	public function __construct($userID = null)
	{
		parent::__construct($userID);
		...
	}
...

We would instantiate our classes like so:

$User = new User(1234);

There were a few ways we could solve this problem:

  1. Let ZF2 create an instance of the db connection and use the ZF2 service locator in our classes
  2. Use an old class we had called Spawn to inject a single Db instance wherever it was needed. Spawn was used to instantiate all other classes using a method called init().
  3. Create our own service locator

No matter which solution we went with, it would require major code rewriting, but we did have one requirement for whatever solution we implemented:

Our library must retain its independence from ZF2. So immediately #1 was out. Option #3 was more than what we needed at the moment. #2 would quickly solve the problem and at the same time give us the ability to implement #3 easily in the future.

So we re-tooled Spawn::init() like so using PHP’s reflection API:

class Spawn
{
	/**
	 * @var Db connection
	 */	
	public $Db;
 
	/**
	 * construct all other class objects needed for this class
	 */	
	public function __construct()
	{
		$this->Db = new Db();
	}
 
	public function init($class)
	{	
		//get info on the __construct method of the class being called
		$m = new \ReflectionMethod($class, '__construct');
		$mParamCount = $m->getNumberOfParameters();
 
		//get the properties of the class being called
		$c = new \ReflectionClass($class);
		$props = $c->getProperties();
 
		//get the $deps property so we can fetch the other dependencies for the class being called
		if($props[0]->name == "deps"):
			$prop = $c->getProperty('deps');
			$deps = $prop->getValue();
		endif;
 
 
		//find the position of the $Spawn parameter in the __construct method so we can inject this instance into it
		foreach($m->getParameters() as $key => $p):
			if($p->name == "Spawn"):
				$spawnPos = $key;
			endif;
		endforeach;
 
		//inject Spawn instance into the correct parameter position
		$i = 0;
		while($mParamCount - 1 >= $i):
			if(isset($spawnPos) && $spawnPos == $i):
				$arg[$spawnPos] = $this;
			else:
				if(@func_get_arg($i + 1)):
					$arg[$i] = func_get_arg($i + 1);
				endif;
			endif;
			$i++;
		endwhile;
 
		$Class = new $class($arg[0], $arg[1], $arg[2], $arg[3]);
 
		if(count($deps)):
			foreach($deps as $name => $dep):
				if($name == "Db"):
					$Class->$name = $this->Db;
				elseif($name == "Spawn"):
					$Class->$name = $this;
				else:
					$Class->$name = $this->init($dep);
				endif;
			endforeach;
		endif;
 
		return $Class;
	}
}

To use this, we have to implement an instance of Spawn inside IObject’s __construct method so it now looks like this:

Class IObject
(
	public function __construct($Spawn = null, $objectID = null)
	{
		if(!($Spawn instanceof Spawn)):
			$this->Spawn = new Spawn();
		else:
			$this->Spawn = $Spawn;
		endif;
 
		$this->setDb($this->Spawn->Db);
	}

For more flexibility, it was built like this to allow classes to be called on their own without instantiating them using Spawn.

Our classes now start off like this:

Class User extends IObject
(
	public function __construct($userID = null, $Spawn = null)
	{
		parent::__construct($Spawn, $this->userID);
	}
...

Now we call our classes like so inside of our ZF2 controllers:

$User = $this->Spawn->init("\PhantEye\User", 1234);

So when this is called, Spawn::init() uses the reflection API to look for a Spawn parameter inside of the __construct method of the class being called. If it finds it, then the Spawn class injects itself into that parameter’s position inside of that class’s __construct() method and the class then passes it into IObject’s __construct() method.

So yes, we’re using constructor injection, but we also have setter injection using a method called setDb() inside the IObject class which you can see in the code above.

BUT WAIT! For those of you who are wondering how we got Spawn into our controllers:

/config/autoload/global.config
...
	'service_manager' => array(
		'invokables' => array(
			'Spawn' => '\PhantEye\Spawn',
		),
	),
...
/module/Application/Module.php

namespace Application;

use Zend\Mvc\ModuleRouteListener;

use Zend\Mvc\MvcEvent;

use Zend\Debug\Debug;

class Module
{
	public function onBootstrap(MvcEvent $e)
	{
		$eventManager->getSharedManager()->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e)
		{
			$controller      = $e->getTarget();
			$controller->Spawn = $e->getApplication()->getServiceManager()->get('Spawn');
...

There are some bits I left out. For example each class has a property called $deps which is an array of its dependencies. Spawn::init() looks at $deps and instantiates them and injects them into the class. A service locator would be useful here when a certain class is a dependency for multiple classes being instantiated through Spawn. All of this is to come later as I mentioned though. Honestly, we’re reinventing the wheel, but it’s necessary for us since our library must be able to operate completely independently of any frameworks we decide to use.

Have any of you been in this predicament? How did you solve it?