Common Core Math Vs Old Math In PHP

Love it or hate it, Facebook brings out the passion in people. People get unfriended and feelings get hurt. There’s no better way to experience it than to post an opinionated political viewpoint. Still, politics are far from the only fuel for these fires. Recently, I’ve seen heated discussions about Common Core Math, a relatively newer way to approach learning math principles. Some of the concepts seem, on the surface, to be a big, crazy departure from the concepts many of us learned as children and that’s what I’ve seen most of the noise about. In some instances, friends share an image from an angry parent whose child’s math solution was marked incorrect because the common core methods were not applied. In other cases, frustration is voiced because it appears that the new methods are actually worse than the old ones. Whatever side you’re on, be sure to open your mind to learning new things and making your own mind up.

I’m still on the fence, so as a software engineer, I decided to throw ones and zeros at the problem and see what stuck. In this case, I decided that the problem I wanted to solve would be to determine which method might be faster for subtracting numbers. The “old way”, as seen on the left in the image below, involves lining up your numbers and borrowing from the next digit to the left as you subtract each digit on the bottom from the one on the top. The new way involves essentially rounding up the number you’re subtracting until it matches the number you’re subtracting from and adding all the numbers you had to use to round up in order to get to the difference. The simplest explanation I saw for this was 9 minutes into this video, in which the teacher describes the process of counting change back to a customer at a cash register.


To solve my problem, I used PHP to try to mimic the process we go through as humans to subtract one number from another. I programmed functions for the old and new ways to solve a subtraction problem and added code to time each and loop lots of times to create a more visible comparison. The Commmon Core math in PHP code is on GitHub for anyone who would like to try it out or improve it and below are some example results.

1,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 0.0071358680725098 seconds
Total time for the new way : 0.01004958152771 seconds

100,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 0.71134495735168 seconds
Total time for the new way : 0.97455978393555 seconds

1,000,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 6.9777636528015 seconds
Total time for the new way : 9.8461444377899 seconds

100 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 0.00092959403991699 seconds
Total time for the new way : 0.0014877319335938 seconds

100,000 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 1.0502970218658 seconds
Total time for the new way : 1.6906788349152 seconds

1,000,000 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 22.028552055359 seconds
Total time for the new way : 34.783274650574 seconds

It’s worth noting that computers and the human brain work in very different ways. This experiment is not intended to prove anything either way, nor is it intended as scientific data in the slightest. It’s merely an experiment on the process and I welcome discussion and open-minded debate in the comments.

Dedicated, Hybrid, or Cloud – Which Is Best?

In addition to programming, I am also very interested in data science, the art of manipulating “big data” to extract useful information from it. But what does this mean for hosting? Should I have a dedicated server, cloud hosting, or a hybrid solution?

What Is A Dedicated Server?

A lot of people have traditional shared hosting, which is well and good if you have just one simple site and you’re not concerned about sharing resources. If you have several sites, a need for more security, or don’t want to share resources, that’s where a dedicated server comes in. In my case, all three reasons apply, so I have a dedicated server. You’re reading this article from it. In fact, I’ve had my dedicated server from Codero for years and it would take a lot to convince me to go back to shared hosting.

Codero provides me with an unmanaged dedicated server. This just means that I prefer to do my own updates, install what I like, and customize it. For those who are less comfortable with this kind of thing, managed services can be had at an additional cost every month. Managed hosting provides a hands-off solution with all the benefits of dedicated hosting.

What Is Cloud Hosting?

You really can’t be online these days without hearing about “the cloud”. Apple and Google want to store your music in the cloud, some services want you to back up your files to the cloud, and others want your software to run in the cloud. So what, exactly, is this cloud people are talking about? The could is not some big computer in the sky, but rather a concept for storage and processing.

In terms of storage, the cloud can be thought of like a mass of storage space that you connect to over the internet to store (usually securely) and retrieve your images, documents, and other files. In terms of computing, the cloud is a way to use the power of multiple computers at the same time. Remember when you could suddenly get a “dual-core” processor in your home computer? That meant it could do two things at once. It’s like that only to a much larger degree. Cloud solutions are also highly scalable. This means that the more you use, the more becomes available to you.

What Is A Hybrid Solution?

We know about dedicated servers and cloud computing, so I bet you can guess what a hybrid solution is. To steal the words right from Codero’s blog, a hybrid solution is “…a very specialized and custom proposition that requires an architecture that combines the best of cloud computing and traditional hosting.” Some applications will be well suited to traditional cloud environments while others may need this hybrid solution. Take data processing for example. Dedicated servers allow you to have bare-metal systems for optimal processing. Combine that with the scalability and speed of cloud computing and you have a perhaps ideal hybrid solution.

Final Thoughts

So, what does this mean for you and your needs? This is the part you’ll have to decide for yourself. Figure out your requirements in terms of speed, scalability, cost, and any regulatory concerns. Is your focus just on scalability or maybe just customization? Consider all of your needs both today and in the near future and one of these solutions should fit the bill.

Databases Part 1 – How To Select The Right Database

So you want to build a data driven web site but don’t know what database to use? Maybe it’s an IOS or Android application and not a website at all. Either way, if you collect data, you’re going to want to determine the best way to store it for later. In this article, I’ll talk about what a database is, how to choose the right one, and what comes next.

What Is A Database?

By definition, a database (also commonly referred to as “DB”) is a collection of organized data. For example, if you have written down a list of all the CDs you have in your music collection, a database to represent that might include a table for artists and a table for albums and you could even link them together. This organization of data gives us the ability to work with data in just about every way imaginable, which is so much better than just a list. Examples of this can be seen right here on Articles on the main page of the site are shown newest first by sorting the article data, the search option at the top brings back specific articles by using MySQL searching and indexing tools, and your comment on this article gets stored in a comments table so that it can be retrieved later. There’s a lot to know about how databases work, but let’s start with some basics.

Types Of Databases

New databases (like MapD) pop up all the time, and it would be impossible to cover them all. In an effort to keep things simple, I’ll stick to some of the more popular DBs in use.

Some common object oriented databases that have been around for quite a while include MySQL, PostgreSQL, SQLite, Microsoft SQL Server, Microsoft Access, Oracle. Each database system has its own features and flaws. Oracle is well known for its enterprise stability and support while SQLite is fast, free, and well adapted to smaller data sets. MySQL and Microsoft SQL are extremely popular for use with PHP or ASP/.NET applications, respectively.

In what sounds like competition for the traditional database systems, NoSQL databases have emerged in recent years and have grown quickly in popularity. Known for their ability to easily scale horizontally and store a lot of simple data (like Tweets), NoSQL databases often compromise by lacking a lot of functionality like normalizing across a large number of tables. Some popular NoSQL DBs include MongoDB, memcached, Redis, and CouchDB and can often be easier to get started with due to their simplicity.

A third category of databases that is coming into the light but not a highly used is NewSQL. This category includes new DB technologies that allow for highly scalable databases without the loss of critical functionality for broad data sets. These are perhaps not as critical when you’re starting out, so I won’t go into further detail.

How To Choose The Right Database

Choosing the right database can be paramount to the success of your project and the larger the project, the more important your choice will be. With so many choices, how do you pick the right one?

Before anything else, you need to know your goal. What kind of data – and how much of it – do you expect to store? One thing I look at is how many tables I plan on storing. If it’s just a few, I might default to a NoSQL solution, but if it’s a bunch, I’ll look to a traditional object-oriented DB.

After narrowing down the category of database to use, you’ll need to pick the best one for the job, your budget, etc. If you plan to house your site on a Windows server and program it in .NET, MS SQL is probably a good bet. If you want free and need to have everything on a Linux server with your code in PHP, MySQL is often the way to go. When the client (or your company) demands support contracts and has a budget to deplete, Oracle could be a contender. Look at the specific features and pitfalls of each database before making a decision.

What Comes Next?

Knowing the right database to use is only the beginning. Depending on your hosting environment, you may need to take steps to get the database software installed and then you should:

– Think through all the data you plan to store – every little detail
– Design a database schema – more on schemas in Part 2
– Normalize, index, and otherwise optimize your database – Part 3?
– Connect to your database from your site’s code
– Secure against hacking and injections

As you can see, there’s a lot to consider when it comes to storing data for your website or application, but if you take it one step at a time, it’s not so bad. Stay tuned for additional pieces to the database puzzle.