What are the most liberal-leaning and conservative-leaning news outlets?
Sometime last presidential election season I had this very thought. All kinds of dirt was being thrown around about both candidates; however, lots of it was coming from news sources I had never heard of. I probably still wouldn’t have if Twitter and Reddit didn’t exist, providing these outlandish stories a platform for mass exposure (and mass outrage).
So I could never really tell if what I was reading was from a legit source, completely spun, or flat-out fake. For example I would see a headline like:
FBI Arrests Hillary on Corruption Charges
Linking to a news outlet calling themselves “The Discovery Examiner Guardian“, or something. I thought, well… if The DEG is like the NYT, Hil-dawg is probably in deep shit. If the DEG is like Breitbart then I’m 99% sure the opposite is true.
I guess it makes sense given that any corporation attempting to appear as “the news” is trying to woo as many people as possible into believing they are thee most credible straight-shootin’, just-the-facts-you-decide, fair-and-balanced, no-underlying-agenda organization around. So, as nice as it would be, of course Fox News isn’t going to post on their homepage something like, “We are a 8/10 on the left/right political spectrum“.
So I had an idea… Reddit created this mess; let’s see if they can help fix it.
Using Reddit API (PRAW), I wrote python script to identify the favorite news sources of two subreddit communities on opposite ends of the political aisle.
This bot scraped the url from the top daily submissions to the main pro-Trump and anti-Trump subreddit communities, essentially determining these subreddits favorite news outlets. Nota bene: the validity of these data as a litmus for liberal-leaning and conservative-leaning news rests on the assumption that generally people prefer to post and upvote stories that align-with and support their personal world view.
I cross posted this project on Reddit’s Data is Beautiful, where a Googler, Filipe Hoffa saw my post and took it to the next level. Using data studio he expanded my original idea to all of reddit, and made it interactive. It’s something really worth playing around with for a few minutes. So go check it out!.
You can grab my code for scraping the reddit data from this github gist (with the caviat that it was hacked-together in a few minutes of spare time; so take it as a draft with lots of room for improvement ;)
There are probably a lot of people out there like myself that want to master a programming language, but don’t know where to start in choosing that perfect language. Getting started with a new language can be both challenging and time consuming. Being a busy person, I want to know that this time investment will pay off in big ways. Deep down, anyone with a penchant for scientific research knows that the mastery of the ‘right’ programming language will prove to be an essential skill in the near future (if not aready!). So I’m going to crack an egg of knowledge on ya’ll, and share what I’ve learned over the past few months in my search for the perfect language.
First, no matter which language is chosen, master it! All programming languages share a set of core attributes. If you have a solid understanding these core features and how to use them — a mastery of the programming language — you’ll probably find a way to code 95% of your needs in any language. Also, I’ve gleaned that once you master one language, any other language is infinitely easier to understand. You’ll find that all languages have logical operators (true, false decision makers), loops (if-then-else), advanced mathematical and computational libraries, text manipulation (search and scrape, rearrange), arrays (data in the form of matrices), and methods (a way to call up prefabricated scripts, send a piece of data through the script to manipulate it in some way, and return a new value).
That said, there is still the task of choosing the language best suited for your needs. Even though most languages are cut from the same stone, it will prove to be incalculably beneficial to master a language that makes it easy to do the things you don’t want to do by hand. At the end of the day you don’t want to be a programmer, you want to be a scientist that knows how to program. Writing the code is just a means to deploy your innovative earth-shattering algorithm.
So the first thing I asked myself was “What do I want to be able to do with with the programming language?” These are the things I came up with off hand:
+ Write applications.
+ Write small scripts that can interact with other tools (matlab or excel).
+ The ability to scrape web content and turn the information into data.
+ The ability to launch programs from a web browser.
+ The ability to have other people interact with the programs from a web browser.
+ The ability to interact with a dynamic data set, and choose my database.
+ Developer tools for Unix/Linux which makes for easy development on Mac OS X
+ Open source programming language!
Each point above will be addressed in some fashion in the next few paragraphs.
When I first set out to find a language that could do all of those things, I was skeptical that one language suffice. However, with so many languages to choose from, I had a good chance to find one that meets most of my criteria. But there are so many! It was time to initiate operation — process of elimination.
I knew a good chunk of languages were developed prior to the internet explosion. And if they can’t run in a web browser, it’s out! A web-deployable language is important because I want the option (when relevant) to allow other people to utilize the final product without having to install the language environment onto their own personal computer. Furthermore, I don’t want to worry about cross-operating system compatibility (mac OSX darwin vs unix vs linux vs windows). Certainly none of the pre-compiled languages were going to cut it (C++, PASCAL, cLISP) because they are nearly impossible to deploy in a web environment. Thus, it would have to be a scripting language with a just in time (JIT) compiler. With this in mind, and a little research I narrowed it down to the 5 most popular scripting languages: PHP, Perl, Ruby, Java, and Python. All of these are full-blown programming languages, but also have a ways to be deployed by a web browser.
Java was the first language I considered. I took a few courses at SDSU in Java, so I was already somewhat familiar with the language. Java is user friendly, and is becoming the de facto language for teaching introductory computer programming courses. Sun (now owned by Oracle) relicensed most of its Java technologies under the GNU General Public License, so it’s free to use and deploy. Java applications are typically compiled to bytecode that can run on any Java Virtual Machine regardless of the users operating system. Java was built to give programmers the ability code some pretty gnarly dynamic web applications. Overall it’s a great language with lots of financial support for future development. For me, the only flaw with Java is that it doesn’t have strong integration with databases. This is a deal-breaker.
You may be asking, what is a database and why is it important? Essentially a database is exactly what it sounds like — a place to store data. This data can be the entire content of a webpage (like it is on Wikipedia), it could store user-unique content (like the Facebook and WordPress web blog databases), it could hold user preferences (like on Amazon or Pandora), or any other type of dataset you want to manage and manipulate. As a researcher, I have little use for a programming language that cannot interact with a large dataset. That is why Java is out of the race. I’ve discovered that Perl and Python are both extremely robust scripting languages in their own right, and meet most of my criteria listed above, the two languages with the best database integration seem to be PHP and Ruby.
PHP probably has the best database integration of the two. In fact, you would be hard pressed to find anyone developing PHP code not intended for use with a database (specifically mySQL or PostGreSQL databases). PHP is a general-purpose server-side scripting language designed for web development to produce dynamic web pages. As a little nugget for you, PHP was created by a developer to tally the number of visits or ‘hits’ to his webpage, and display this content as a little counter at the bottom of the page. (if you never seen a ‘hit counter’ you are too young to be reading this). The down side to PHP is that the language was originally implemented as an interpreter; and while several compilers have been developed to decouple the PHP language from the interpreter, its still very lacking in the stand-alone application development department. While PHP has great database integration, it’s not really intended for programming non-web content (thus it’s pros and cons are essentially the opposite of Perl and Python).
So through the process of elimination, we have but one programming language leftSEE UPDATE BELOW — Ruby. Does Ruby have what it takes to be my language of choice? Yes! Ruby is a fully supported, dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl and has JIT compilation abilities. Ruby is available on many operating systems such as Linux, Mac OS X, Microsoft Windows and most flavors of Unix. Ruby on Rails is specifically designed to let Ruby interact with multiple types of databases including SQLite and mySQL. And last but not least, I’ve read a lot of articles where the programmers say it is “fun to program in Ruby”! Needless to say, I’ll be mastering Ruby over the next year. I hope you do too!
It’s been a while since I wrote this post, a few years now. I’ve been programming a lot at this point; and concede that the post above is outdated, a bit naive, and my opinions have changed as to what constitutes a good programming language for science and engineering. At the time I wrote this post, I was mostly doing web development; I am now programming almost exclusively for quantitative modeling (of neural networks and particle diffusion/interaction) — science stuff. Currently, I’m under the opinion that Python and Matlab are the greatest scientific inventions of all time. That opinion may change, but right now, that’s the way I see it. I wish I had the time to list out all the reasons why Matlab and Python are the leading scientific languages, however I will say that these now seem to be the universal scientific programming languages. If you’re curious as to why, I suggest getting your hands on a copy of Matlab and then head over to Cody. Then, when you start to get really good with Matlab, give Python a try. Happy coding!