Blog

  • Which programming language should I learn?

    I’ve been asked this question twice in the last 2 weeks by people wanting to write their first Web application. So I’m going to answer it here for anyone else interested:

    If you want to write Web applications you need to learn the following languages: Javascript, PHP, HTML, CSS and SQL. It sounds like a lot, but it really is not. You can learn enough of each of these languages to write a basic Web application within a week. Trust me. It’s easy!

    PHP is the guts of your Web application. It is the language that runs on your web server. It is also the only language where you have a choice about learning it or learning another language. You must learn HTML, CSS and Javascript and 99% of web programmers learn SQL to talk to a database. But there are many other languages to choose from that can do the same thing that PHP does.

    However, if you are starting out writing web applications, PHP is the first server language you should learn and here is why:

    1. PHP is used by a huge number of websites, both big and small. Most of Facebook is written in PHP. Wikipedia powered by Mediawiki is written in PHP.
    2. WordPress, the worlds most popular open source blog platform is written in PHP. If you know PHP you can change it any way you like or even contribute to the community. WordPress is used by eBay, Yahoo, Digg, The Wall Street Journal, Techcrunch, TMZ, Mashable and of course the whole of WordPress.com is powered by WordPress written in PHP.
    3. Most of the worlds best content management systems are written in PHP.
    4. The PHP community is massive and supportive, unlike the Ruby on Rails community for example.
    5. 99% of web programmers can understand PHP, even though some don’t realize it. (like Perl Developers)
    6. PHP is a mature language which means the bugs have all been ironed out and it runs fast!
    7. If you Google a question you have about PHP, you have a much higher likelihood of finding an answer than any other server programming language.
    8. Don’t learn Perl because even though it’s a mature, fast and popular language, it’s harder to learn than PHP.
    9. Don’t learn Java because Java is better suited to launching spacecraft and running systems that control oil rigs or banking software than Web applications. It is strongly typed which means that you need to write more lines of code to get the same thing done. It’s also harder to learn because it’s a purer object oriented language . It also is owned by Oracle which means it’s a commercial language and that means Oracle will continually be trying to sell you stuff by making things seem harder than they are and claiming they have the answer to the problem they created in your mind.
    10. Don’t learn .NET because it’s also a commercial language and pretty much everything made by Microsoft either will cost you money or will break a lot.
    11. Don’t learn Ruby because the guys who run the community are total a-holes who will insult you for asking beginner questions. Ruby is also way less popular than PHP or Perl even though it’s used to power Twitter. It’s also the reason Twitter is down so often.
    12. Don’t learn Brainf*ck, Cobol, D, Erlang, Fortran, Go, Haskell, Lisp, OCaml, Python or Smalltalk because these are languages that people tell you they know to show off. Some of them have specific advantages like parallelism, being a pure object oriented language or being compact. But they are not for you if you are starting out. In fact, the combination of PHP and Javascript will give you 99.99999% of what all these languages offer.
    You also need to learn two presentation languages: HTML and CSS. They are actually part of each other because HTML is not too useful without CSS and vice versa.

    HTML tells the browser the structure and content of a page. e.g. Put a form after a paragraph and have one field for email and one for full name.

    CSS tells the browser how to make that page look e.g. Which fonts to use, what size they should be, what colors, how wide or tall things on the page should be, how thick borders should be, how much padding to use and how thick to make margins.

    Then you also need to learn a data storage language called SQL which lets you talke to a database to store things like visitor names, email addresses and so on. For example, using SQL you can tell a database to store an email address and full name by saying “INSERT INTO visitors (name, email) values (‘Mark Maunder’, ‘mark@example.com’);. There are other ways to store data and a popular terrorist movement calling itself NoSQL has formed in the last 4 years and they spend their time sowing fear and doubt about SQL and confusing beginners like you. The reality is that 99% of web applications use SQL and continue to use SQL. It works, it’s fast, it’s easy to learn and everyone understands it. It’s used by WordPress, Wikipedia, Facebook and everyone else who counts, whether they like it or not. Just learn SQL!! I also recommend you use MySQL to store your web application’s data (even though it’s owned by Oracle) because it’s the most popular open source database out there. PHP applications use MySQL more than any other database engine on the web.

    To summarize, so far you need to learn:

    • Javascript (a programming language that runs on inside your visitor’s browser)
    • PHP (a programming language that runs on the server)
    • HTML (a presentation language that tells the browser the structure of a page)
    • CSS (a presentation language that tells the browser how to make a page look once it’ knows the structure)
    • SQL (a data access language that lets you store and retrieve data from a database)
    Each of these languages runs or executes in a certain place or environment:
    • Javascript runs inside the browser of someone who has visited your website. What’s cool about this is that it uses your visitor’s CPU and memory instead of the resources on your server.
    • PHP runs on your own web server. Most websites use a kind of “container” or application server to run PHP called Apache Web Server with something called mod_php installed. Apache handles all the web server stuff like receiving the request for the document and making sure it’s formatted correctly. It then passes the request to mod_php which is executing your PHP code. This actually runs your web application written in PHP, your program sends the response back to Apache which sends it back to your visitor.
    • HTML is interpreted by a visitor’s browser and tells the browser how to structure the page as it loads.
    • CSS is also interpreted by a visitor’s browser and tells the browser how to make the HTML look.
    • SQL is a language that you use inside your PHP application to talk to a database like MySQL. You will actually write SQL in your PHP code but it will be sent to the database engine which is where it is interpreted and executed. The database then sends your PHP code whatever it asked for, if anything. (sometimes you’re just inserting data and not asking a question)
    As you progress you will get familiar with the platforms you run each of these languages on. They include:
    • Linux is the operating system you will run on your server. Everything else on your server runs on top of Linux. Linux lets your web application talk to the server’s hardware.
    • Apache Web Server running mod_php. This is the application server you will use to run your PHP code. It will receive the web requests, forward them to your PHP code, and receive the response which is forwarded to your visitor.
    • MySQL database engine. You will talk to mysql using SQL which is written inside your PHP code.

    One last note to help you in your language decision making. It’s important that you understand there are a few phenomenon that may confuse you in your language research:

    The first is that some software developers have little life beyond writing software and have large egos. One of the few things they have to impress you with is their own intelligence. They will try to make programming sound harder than it actually is. It’s not hard. It’s easy.

    Secondly, an arrogant programmer may regale you with a list of programming languages to choose from and tell you that he or she knows them all. They may make the choice sound complicated. It’s not. They’re just showing off. Choose PHP and the set of tools listed above and you’ll be fine.

    Third, remember that there is always something new and shiny coming out that will get a lot of attention and is advertised to “change the way we…” or will “make everything you know about programming irrelevant”. Ignore the noise and stay focused on the basics. Until a new language, operating system, application or piece of hardware has been around for a while (usually at least 5 years), it’s going to be full of bugs, run slow, break often and it will be hard to get help by Googling because few people are using it and have had the problem you’re having.

    Lastly, many companies like Google and Facebook spend a lot of time and energy trying to attract the best software engineers in the world. Google associated themselves with NASA purely for this reason, even though they’re in completely different businesses. To draw attention to themselves as thought leaders in software they talk a lot about languages like Erlang, Haskell and so on. The reality is that their bread and butter languages are pretty ordinary – languages like C++ and PHP. So don’t get confused when you see Facebook talking about using Erlang for real-time chat. They’re just showing off. Their bread and butter is PHP, HTML, CSS, SQL and Javascript, like most of the rest of the Web.

    Who am I and how dare I express an opinion on this? I’ve been programming web applications since 2 years after the Web was invented. I’m the CEO and CTO of a company who’s web apps are seen by over 200 million unique people every month. I also own the company.  I’ve seen languages and platforms come and go including Netscape Commerce Server, Java Applets, Visual Basic, XML, NetWare, Windows NT, Microsoft IIS, thin clients, network computers, etc.

    The Web is Simple. Programming is Easy. Now go have fun!!

     

  • So… Greece just defaulted

    Here’s a little reminder that sovereign debt is unsecured. Greece just defaulted. And for some reason only Reuters are calling it like it is. Expect fireworks tomorrow. Here’s the story:

    http://blogs.reuters.com/felix-salmon/2011/07/21/greece-defaults/

  • Trial, Error and the God Complex

    My new favorite economist Tim Harford did a great TED talk recently chatting about our assumption that an expert approach is needed to problem solving. He argues that instead we should rely more on trial and error, a method that has proven very effective both in nature and business.

     

    If the loading animation won’t disappear then try viewing the video on this page.

  • Mimes, Bakers and Bankers

    As I sat drinking espresso chatting to my experienced entrepreneur friend who prefers to remain anonymous, we decided there are three classes of businesses:

    Mimes

    Mime businesses perform a service similar to a mime in a Parisian public square. The mime can try and charge the audience, but it doesn’t always work and it’s tough. Smart mime’s know that the audience is the product and the mime’s customers are those that pay him for access to that product. The amount of money a mime can make is directly proportional to the amount of product he has to sell.  Mime’s need a lot of product to be successful. The audience doesn’t get any direct value from the mime’s performance so they don’t need the mime. If he goes away the audience will be just fine.

    Examples of mime businesses: Huffington Post, TMZ.com, Facebook, Twitter.

    Bakers

    Bakers sell a product that has clear tangible value. You know this because if you wanted to you could resell the product to someone else for a price not too distant from the one you paid. The amount you pay for a baker’s product is worth less to you than the value of the product itself. What the baker charges is whatever it cost him plus whatever the market will bear. If all bakers disappear there won’t be any bread and panic may ensue.

    Examples of bakers: Walmart, Barnes and Noble, Costco, Linode, Apple, Microsoft, Dell.

    These might be bakers or mime’s. You decide: FT.com, NYTimes.com.

    Bankers

    Bankers (investment bankers in this metaphor) sell a product that can help you make more money. A banker’s product can improve your circumstances. In rare cases it can make you wealthy. Bankers are selling a product that has real value, bundled with hope which means they can charge more.

    Examples of bankers: Ebay, Amazon’s seller program, Paypal, SEOMoz, Authorize.net, Google AdWords, Google AdSense, iTunes and Android market for developers.

  • timthumb.php fix for blogs.dir directory on WordPressMU

    If you’re using timthumb in your wordpress theme on WordPressMU and it’s not finding certain files, this may be why:

    WordPressMU uses the blogs.dir directory to store uploads. timthumb’s search routine when looking for images to resize doesn’t include this directory.

    Here a modified version I created that does include the dir:

    https://markmaunder.com/timthumb.txt

    You will need to add the following query param to all your timthumb.php URL’s when using this version:

    blogid=<?php echo get_current_blog_id(); ?>

    That way timthumb knows which blogs.dir directory to look in for images.

  • Awesome Cape Town Restaurant Reviews

    My sister who is an amazing chef has just launched an awesome blog reviewing cape town restaurants. Her latest review is of Hesheng in Sea Point, a chinese restaurant that serves authentic chinese cuisine – as opposed to what American’s think of chinese food. Check out the amazing photos (sorry Lyn, I had to borrow this one!).

  • Great podcast on US Bankruptcy Law in the context of GM and Chrysler

    David Skeel of UPenn’s law school talks with Russ Roberts on econtalk about the mechanics of bankruptcy law and whether the government should have bailed out the auto industry. Bear in mind you’re getting the Hayekian view on Russ’s show (to which I subscribe). For the Keynsian argument, check out NPR’s Planet Money blog and podcast.

    Skeel discusses the bankruptcy process including voting rights, creditor seniority and the role of a judge in an ordinary bankruptcy which is required knowledge for any entrepreneur. Even though this is the last thing anyone aspires to, you should know the worst case scenario, the process and your options and rights.

  • When is the worst time to submit a story to Hacker News?

    The worst time to submit a story to HN is right now. From about 2am to 10am Pacific time the ratio of votes to submissions is at it’s lowest:

     

     

    This is from an app I whipped up yesterday that tracks stats for Hacker News continuously.

  • The Adverse Selection of Free

    I’ve had this blog entry saved as draft for a month, and Tom Buck’s post earlier today titled “Failure: Building a $50/month web app” inspired me to post this. He remarks in his post “My mistake quickly became obvious: I had built a tool for an audience that didn’t like to spend money.”. Here’s my take (and my verbatim draft from a month ago):

    “The curious task of economics is to demonstrate to men how little they really know about what they imagine they can design.” — Friedrich von Hayek

    Hayek’s wonderful quote captures both the wisdom and arrogance of economists and their field, so consider it my caveat for the observations below.

    The canonical example of adverse selection comes from the industry that invented the term: In the insurance industry, customers who are more likely to die tend to buy more life insurance. Because the insurer doesn’t have all information on the health of buyers, life insurance as a product tends to select the wrong customer i.e. customers who are less profitable because they die sooner.

    In the online world, “Free” is a popular model for gaining “Traction”, meaning access to many customers. The assumption is that a reasonable percentage of those free customers will at some point become buyers. Therefore success is gauged by growth in the population of a company’s free customers because at any time a company can pull the “revenue lever”.

    The problem and a realization I had during the last year, is that “Free” can adversely select against paying customers.

    Customers who use many free products online are less likely to pay for a paid service. Conversely, customers who have recently paid for an online service are far more likely to pay for other online services. And what you may view as incentives to upgrading may be further selecting against customers who will pay in future.

    One might argue that this is simply the old sales adage that customers who are most likely to buy something from you are those that just bought something from you. But I’d argue that this works across company boundaries e.g. if a business refers customers who recently bought their service to another business, those customers are far more valuable than referrals from a free service – because they’re the kind of customer that pays.

    Adding disincentives to using your free product (or incentives to upgrading if you flip it around) strengthens the adverse selection problem because those who adopt your free product, presumably prior to upgrading to paid, have a strong desire to never pay. Their desire is so strong that they will tolerate whatever irritant you’ve introduced in the free product which makes the likelihood of them upgrading to your paid product even less.

    So is Free useless? No it’s not and it can be a method of establishing a relationship and trust provided you target free customers where other criteria qualifies them as likely to pay in future and the free product doesn’t disqualify them.

    For example, you could choose to only provide your free service to customers who have recently paid for an online service somewhere else. In addition, the free product must not adversely select against those customers once you’ve recruited them e.g. Your free product must be something that a paying customer is more likely to use and like, rather than a gatekeeper that irritates until the customer either leaves in frustration or upgrades.

    Free works, provided it targets the correct customer and continues to incentivize them on their journey to becoming a future paying customer.

     

  • Best Light Bulbs for all night coding

    I went down to walmart late last night in frustration because the power saving bulbs I had in my main light with a dimmer weren’t working. So I switched them (two bulbs) to GE Reveal 71367’s (not an affiliate link), the most expensive bulb I could find at $4.50 each and one of the few to claim to work at different voltages. I’m in love with these things, mainly because they work perfectly with the dimmer in my office and they change color from a cooler (more yellow/orange) color temp to warmer (more white) as you crank up the voltage. The highest setting has a very natural looking light, closer to daylight which keeps me from dozing at my keyboard.

    Let me know if you’ve found something better!