HNHacker News
TopNewBestAskShowJobs

DavidMcLaughlin

932 karma · joined December 7, 2008

Software developer @ Twitter david @ dmclaughlin.com

blog: http://www.dmclaughlin.com

submissionscomments
DavidMcLaughlin··on Verbosity is not Java’s fault
Why are private methods good for documentation? They shouldn't even be documented save for inline comments. The whole idea of privacy in my mind is that the only person or people who should know that these functions even exist are those who maintain the class/library/framework. This helps immensely because when you want to refactor you know EXACTLY which method signatures or attributes have to be supported for backward compatibility. You can really keep on top of things, and as long as you took the time to create a flexible API, you can handle change gracefully. I don't even unit test my private methods because I don't even care about them or what they do. I only care that some data is passed to a public API and returns the correct result. They are there, as you say, purely as a means to organise my code.

For example, in my last company I wrote this ORM in Moose. I released it. And the guys I was working with just didn't get the concept of Moose. They kept accessing the attributes from the underlying blessed hash like they did before rather than the accessors. It still worked because internally Moose stores stuff the way Conway recommended in OOP Perl (which was a weird decision imho). One day I renamed one of my database columns and so had to rename my accessor and created a manual function that warned of "obselete call to accessor x" whilst returning the new column name... backwards compatibility, yay! But they didn't see this because they didn't use the accessor and now all their manual hash accessing was returning undefined or null or whatever it is.

Of course it only took me going over to their table and explaining to them how Moose worked or getting together for a meeting. Fine. But that was a company with a technical team of around 10 people. Now I work for a big tech company, and I'm in charge of a framework again except now its JavaScript which has the same problems when people force this classical inheritance pattern and now when some guy doesn't get it he's in another building or another country and did so in a repository I didn't even know existed and his code that breaks my encapsulation is in a production device and when I refactor my code I have the possibility that I break live code on some project or some device I don't know about.

So yeah, privacy is an important concept and if you don't think so I would say it is you who lives in a superficial bubble where everyone who uses your API or works on your code can be trusted to have good sense.

DavidMcLaughlin··on Verbosity is not Java’s fault
Please don't misunderstand my point - I agree with what you were saying and I think Java is far too verbose. I just think by comparing a framework to a language you are misrepresenting the capabilities of Perl and the first Java programmer who knows how much of a hack OOP is in Perl could completely tear your post apart.

I mean, in Java can you do this?

    class MyClass {
        private String foo;

        public Class(String foo) { 
            this.foo = foo;
        }    
    }

    var inst = new MyClass();
    inst._foo = 'I just broke your encapsulation.';
Because you can with psuedo-privacy in Perl and Moose.

The other thing is that OOP in Perl without Moose is even more verbose than Java. I will never get over having to write my own new subroutine :)

P.S. MooseX::Declare absolutely did not compile on Windows last time I tried back in August. When I asked about this on IRC, it was a "known issue."

DavidMcLaughlin··on Verbosity is not Java’s fault
I completely agree with the point you are making about accessors, but something I don't agree with is the way you made your point:

> In Perl, I can just say:

Moose is an OOP framework built on top of Perl, comparing it to out-of-the-box Java code is quite misleading and I'm not sure what point it proves? It's like saying MVC in PHP is verbose compared to Django or Rails rather than Python or Ruby. Using MooseX::Declare is even more misleading. Does that even work on Windows yet?

DavidMcLaughlin··on U.S freelancers pretend to be from other countries to get jobs
The beginning of the "World Wage?" I believe the concept you describe is outsourcing and people have been worrying about that for years. Amazing how predicting a little doom can garner head nodding though.

For me the market that is most open to being outsourced is web development. I happen to love developing web applications, always have. From the dynamic languages to the openness to just about every detail, I love it. I also happen to have a Computer Science degree. It's a lonely place being a Computer Scientist working in web development. Nearly everyone I've ever worked with has a career path like this:

1) Messed around with HTML. Copy and pasted some "DHTML" scripts and was blown away by how easy it was.

2) Picked up CSS. Became an overnight "separation of concerns" advocate and part of the dedicated few that "gets it"

3) Picked up PHP and MySQL in a week, built a dynamic web app. Became "multi-skilled," a "fast learner" and a "jack of all trades"

4) Became a professional developer, out-earning just about everyone they know, including people who have spent decades in their career

5) Years later, still does everything in the same LAMP stack and honestly believes that they should be working at Google if only they would be given a chance.

And the best part is that within 2 years of those people going through that, there will be someone with exactly the same background except update the technologies to the one dominating the blogosphere. I had to experience self-taught programmers come in and be all arrogant and condescending about Perl code simply because they picked up PHP or Ruby on Rails or Prototype in a weekend and it was much easier to grep. They all have the same stories about being frustrated that no one they work with seems to "get it," no clue that a Django/PostgrSQL/jQuery guy is coming right round the corner to make them a dinosaur.

The arrogance and delusion of these people, particularly self-taught people who have this mindset where they are superior because they didn't even NEED to go to college to learn what some guy with a CS degree did. Hell, the "head of software development" I used to work for used to tell a story about how he interviewed for Google and the first technical question they asked him was "what is 2 to the power 10?" and he didn't know and that was that. He told me this story like "look how random it is - that's not even related to coding, I mean who would know the answer to that off the top of their head?" and laughed it off like "google so crazy." When I replied instantly that 2 to the power 10 is a megabyte, he would neither tell that story nor confide in me again.

Point is, web development has been THAT easy to get into for years, and it still is. Even when it gets tough, generally the answer is "memcache" or throwing another server at it - luckily the places where quality is that little of a concern tend not to need more than two or three servers anyway. People talk about some Russian high school student outbidding them on odesk for a Wordpress installaton like it's some sign of things to come, but is that supposed to be a bad thing? Or should we be more concerned about the fact that people who know just enough to tinker with Wordpress for a living can earn more than doctors and nurses?

As for my job being outsourced, I left that web development company I worked for and now work for Nokia. I am specialising in JavaScript, a language that I used to love but then got pushed out from when a bunch of HTML/CSS guys picked up jQuery and changed their titles to "Front End Developer." Fortunately at Nokia, when I need to build applications that run fast on a mobile phone like the N900, neither jQuery nor throwing another server is the answer. So, honestly? I'm not worried.

TL;DR: the only people that need to be worried about a "World Wage" are people whose knowledge or expertise can be picked up in a week's worth of "PHP/MySQL for dummies."

DavidMcLaughlin··on Writing Compilers Quickly
> Or anything but just hand-hacking your own tokenizer.

I've only just got into parsing and I know for sure that there are more challenging problems, but for a dynamic language like Javascript there is a pretty major example of where this worked. JS Lint: http://www.jslint.com/fulljslint.js

1) Split source into lines

2) Run each line through a regex: /^\s([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\(jslint|members?|global)?|=|\/)?|\[\/=]?|\+[+=]?|-[\-=]?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/

3) Look at the resulting token character by character and define what kind of token it is.

Once it has these parsed tokens JS Lint then uses a Pratt Parser to check syntax and style, but you could easily use the same tokenizer and build a parse tree as part of a translator or compiler instead.

DavidMcLaughlin··on What's the Deal with Fish Oil?
I was a one-time subscriber of Men's Health and let me tell you something: everything, absolutely everything is potentially bad for you.

In one issue they could say that drinking a beer a day in moderation can prevent certain cancers and taking too much health supplements can cause irreversible, long-term damage to your liver. Then six issues later they could say to get the dream abs you've always wanted, you must take these same health supplements every day and cut out all beer.

They can provide facts and statistics to sell you any nutritional scare story, and the whole game is this: they want you to think that you NEED them, so that you will continue to buy their magazine. Most people take one story or more from this type of scare tactic and run with it. Every diet has its secret. Every nutritionist has his angle to keep you living for longer or to get results in the gym faster. No wants makes money on the obvious: eat equally from every food group and without bias, exercise regularly (cardiovascular and weight training) and most importantly - have a bit of luck on the way - and you'll be fine.

DavidMcLaughlin··on Hugh MacLeod on career prospects
I got the point, I just don't agree that it's essential or even all that effective to become niche. In fact I can think of many examples were becoming niche will hurt you in the long term - I mean, hey, my niche used to be Perl :)

Which I guess is my point - if you're a programmer and looking to add a language to your toolkit, surely a programming language would be the better choice?

DavidMcLaughlin··on Hugh MacLeod on career prospects
If I'm a one-in-a-million programmer in a population with one billion people (which I assume is what you were getting at), to have a thousand people better than me would assume that 100% of that population are programmers. They are not. Say for arguments sake that 5% of the Chinese population are professional programmers, then if I'm one in a million then I have around 50 other people on my level in the entire country.

On the other hand if my entire gimmick is "I'm a decent programmer but I can speak Japanese!" and you limit yourself to that market then the reality is that your opportunities are drastically smaller than even "American programmer who is self-qualified with good experience, solid skills and good work ethic looking for a 9-5 job in America."

DavidMcLaughlin··on Ask HN: how do you avoid burnout and getting taken advantage of?
Classic workaholic. You probably think your utopia is to have so much money that you don't feel the need to work so hard and don't feel so guilty about spending some cash, but even if you make a million you'll find another way to challenge yourself and leave yourself wanting more. Maybe your next challenge will be to make a billion. And if you achieve it like so many have these days, then so what? You'll decide you want to become famous or make a difference in the world or write a book or help the starving or all of the above. It's what driven, competitive, workaholics do.

One of my favourite examples is Will Smith. This guy went from working class family in Phillie to an A-lister as a breakthrough "rapper". Then he got offered his own TV show and decided to try being a television actor. Once he had a hit TV show, he wanted to become a blockbuster movie star. Once he became one of the most bankable leading males in Hollywood, he decided he wanted an Oscar. So he started doing "serious" performances like Ali, I Am Legend and Pursuit of Happiness. And you can see the pain in his face when he talks about how he missed out for The Pursuit of Happiness and Ali. This despite the fame, the wife and kids and the millions and millions (and millions) of dollars. He will not stop until he gets that Oscar and it will be a major regret for him if he never does. Or if he does get it? Simple, he'll do what other actors do and become a politician or a director and start all over again.

Another favourite example of mine is Donald Trump. As a billionaire in the 80s who pretty much had it all, Donald decided he wanted his own NFL team. The problem was that the people who run the NFL decided this tabloid star wasn't the guy they wanted associated with their league. Did that stop Donald? No. He wanted his NFL team so badly that he created a franchise in a league which made a point of not competing head to head with the NFL - the USFL. Once he was in the door he then moved the USFL schedule to go head to head with the NFL and then tried to slap an antitrust suit on them when that move failed big time. His goal was to get the NFL to agree to merge with the USFL and thus he would finally have his own team. This of course failed and the USFL ceased to exist and now he will NEVER own an NFL franchise and he's still bitter about the whole thing to this day, as evidenced by the recent ESPN documentary about the whole thing.

The point I'm trying to make is, you are not alone. It's not a programmer thing. It's not something restricted to people at the bottom of the ladder or only a few rungs up. It's something every ultra-competitive person has and you need to recognise it and channel it in the right ways. You seem to have realised that you're reaching the point to which hard work alone can take you. Your depression probably stems with the likelihood that any attempts to progress come with big risk. As others have mentioned, now you need to take those risks and be willing to fail. This is probably the hardest part for aggressive competitors to accept. But the real successful guys like Donald Trump don't dwell on repeated bankruptcy or lack of NFL teams or other failures. They go out and start the next challenge, like creating a successful TV show and dating a former Miss World or whatever the hell Trump's doing these days.

Long term, embrace your ambition and drive and try to achieve all that you can - maybe try and learn how to be patient. Short term, get your act together! No offense, but right now you sound like one of those guys who gets to 21 and starts reminiscing about high school, or gets to 25 and starts getting nostalgic about college. Channel your competitiveness in healthier ways so that your career is not the only outlet. Join a gym or play some sports or something, anything that you can get some wins in and feel satisfied again. Your mojo will be back in no time.

DavidMcLaughlin··on Most of Slicehost is Down
The service I'm getting from Slicehost has really went to hell ever since Rackspace took over. I had something like a year solid of uptime with them when I was actively writing in my blog and getting traffic from the front pages of HN and proggit.

Now my server freezes up all the time despite little traffic.. I haven't written in my blog since May and yet I've had my server require a hard reboot three times in the last three months. I get so little traffic that I don't really care, but my mail forwarder for my personal domain is sitting on the same server and now I'm really having to consider moving my mail forwarding off to some other service.

DavidMcLaughlin··on Want 50Mbps Internet in your town? Threaten to roll out your own
I have to laugh at the idea that 20Mbps is slow. I just got upgraded to 16Mbps (from 2Mbps) and still can't believe I can download a full HD movie in 30 minutes.
DavidMcLaughlin··on I wrote this essay on procrastination as a way of not completing another task.
First paragraph seemed good, I'll read the rest later.
DavidMcLaughlin··on How Indian Immigrants Have Changed the face of Silicon Valley
I interviewed someone last week for a European multi-national. He was a dream candidate, with much more experience than me (I wasn't interviewing him as a manager, but as a potential colleague) and for much bigger companies than me (Yahoo! to name one) and I probably over-compensated in the technical interview because his resume put mine to shame, but he answered all the questions and we had a good chat about various technologies relating to the position. The only reason he wanted to leave San Fran was because he had to as he is an Indian and having visa issues - so now a European company gets the talent. Thanks, America!
DavidMcLaughlin··on [dead]
> "I am absolutely sick to death of hearing about Susan Boyle, both in the traditional media and online. Nothing personal, you understand, I'm sure she's a perfectly lovely person. But I don't talk about Susan Boyle, because talking about her gives Susan Boyle power and currency. I just ignore Susan Boyle. I wish I had two brains so I could ignore her twice as hard. I. Just. Don't. Look. And if we could convince enough people to ignore her, she .. disappears. Poof. Like magic."

Unbelievable.

DavidMcLaughlin··on The speed, size and dependability of programming languages
> Perl-beating and PHP-matching

Which is interesting considering Perl beats PHP on both axis in the linked article.

DavidMcLaughlin··on BBC iPlayer serves nearly 1000 requests per second with Catalyst
Ah, right. I picked up the OO part from them using Catalyst, so I thought mentioning it as part of their stack meant they used something other than mod_perl.
DavidMcLaughlin··on BBC iPlayer serves nearly 1000 requests per second with Catalyst
> Apache2.2/OOperl/Catalyst/memcached

What is OOperl?

DavidMcLaughlin··on Ruby style guide
Firstly, it's basic DRY principles. Rather than have code dotted around your system dealing with data integrity issues, put it in one place and make your business logic more readable and easier to maintain. When trying to understand a subroutine or Class I should not have to wade through all the lines of code that try to make sure the input is 'safe.'

Secondly, something I've noticed about defensive programming is that generally it creates a culture of "meta rules" that only exist in the system architect's head. When someone else reuses one of their models, then the danger is they don't know all these different rules because they are scattered around different controllers or scripts. This has been a particularly vicious source of bugs in our legacy systems. Domain experience becomes critical.

Lastly, defensive programming by its nature is also traditionally a big red warning sign that says "there is no data integrity strategy in place for this system." It doesn't matter if that data is coming from a CRUD form, a relational database or a file... there should be some validation layer that ensures the data is 'correct' before making it 'safe' to reuse across the rest of the system.

I've found that defensive programming is particularly rife in systems powered by MySQL databases. MySQL has traditionally lacked the data integrity mechanisms of Oracle or other Enterprisey systems and thus has created a whole bunch of MySQL 'experts' that actually don't know anything about data integrity. A system I'm working with this very minute has a function where the first 20 lines of code (out of 28 total) is compensating for potential orphan entries in the database. The reason? The admin tool for removing entries does not do cascading deletes. Rather than fix the root of the problem, we have this 20 line check everywhere that we need to access the data safely.

I could go on and on, but in short: defensive programming is one of the major 'code smells.'

DavidMcLaughlin··on Dealing with impossible crises - Relentless resourcefulness at work
If you really want to enjoy your job, learning how to become the 'Fire Prevention and Safety Officer' is much more rewarding.

Firefighter, janitor, whatever you call it: either way you end up cleaning up someone else's mess.

DavidMcLaughlin··on How FriendFeed uses MySQL to store schema-less data
Excellent article. I work in an environment where we have serious vendor lock-in and the people in charge of infrastructure have a real fear of change. I have free reign to implement in any improvements in our performance and code so long as I don't make things difficult for them.

Thus, the idea of a MySQL cache system is something I've been planning to look at for a while as it plays with the existing infrastructure. This (seemingly proven) system will make things a lot easier, so thanks for sharing.

DavidMcLaughlin··on Things I Wish I’d Been Told: Tips For Students with a Bachelors in Computer Science
I totally agree... this is especially true for web development where almost anyone with a passion for solving problems will do some sort of personal projects or freelancing due to how easy it is to get set up and competing. In my first interviews straight out of University, after four years of intensive Java, all we talked about was some PHP CMS I did for a friend. I got the job too.

The other rule I'd add to your list is:

5. The first job you get is vital for the future direction of your career. You REALLY need to be working with talented people who are better than you and know what they're doing or your progress will suffer.

DavidMcLaughlin··on Joel on Software: The new Fog Creek Office
I'm not sure recruiting desperate and socially akward dudes who are going to get all creepy weirdo on the female staff is the best recruitment strategy I've ever heard.
DavidMcLaughlin··on URL Routing in Recess my upcoming PHP Framework
How would this handle backwards engineering?

When debugging an application someone else has written, generally I'll be given a problem - and I want to find out all the code behind whatever is broken or needs looked into. So you start from a URL, go to your centralised dispatcher router whether that be your Zend bootstrapper, a mod_rewrite rule in a .htaccess file, your django URLs file or.. whatever. From there you'll be able to work out which controller and action you need to look at. In this case I'm looking through a whole bunch of controllers and then their doccomments to see which route matches. Not pleasant.

As someone said, this is pretty clever, but I'm not convinced it leads to maintainable code. Which is the entire point of frameworks and the MVC pattern. There are other ways to implement DRY in a dispatcher without resorting to inlining a pattern into a comment. For example, you could delegate a base pattern to another URLs conf like you do in django.. or use nested routes like the Perl Mojolicious framework:

http://search.cpan.org/~sri/Mojo-0.9/lib/Mojo/Manual/Mojolic...

DavidMcLaughlin··on How I learnt to love Perl
CPAN strikes again, I was actually hoping someone would show me a better way when I posted that. So thanks!
DavidMcLaughlin··on How I learnt to love Perl
We're getting down to personal choices here. What you think is readable depends on how well you understand the language. Some people don't like sigils, which Perl uses in abundance.

Taking a look at your PHP example, you have:

function foo($bar, $baz, $quux = array('quux' => "default")) {

What is $baz supposed to be here? I have no way of knowing that it's supposed to be a scalar, array or associative array.

The strength of sigils for readability is revealed in the equivalent Perl code:

my ($bar, @baz, %quux) = @_;

Here I know instantly, without reading any further documentation, that this subroutine expects a scalar (which in OOP would be the current object instance), an array and then a hash. It took a while, but I find this readable.

What PHP has over Perl, and indeed every other language right now is lowest-barrier-to-entry for web development. Out of all the other languages, it's the only one designed for the web.

On top of that, developing Perl ,Python or Ruby on a Windows machine is NOT fun and it's not easy. You want to play with PHP? Wampserver or Xampp can get you up and running on XP and Vista in seconds. Even if you manage to set up a Perl environment, you've still got CGI and DBI to install before it matches what PHP does out the box. Already I've installed Strawberry Perl, Apache, mod_perl and standard CPAN modules and all I wanted to do is a simple contact me form on my website!

That's why PHP is such a success.

DavidMcLaughlin··on How I learnt to love Perl
I didn't say I liked anything in Perl better than Python. There may be a couple of things, but it would just boil down to personal taste.

Conversely, I like Python better than Perl in two major departments though:

1) The way you import stuff in Python. If you have a long namespace in Perl you have to type it out every time you instantiate an object. Example:

use Organisation::Project::App::Models::Feature;

my $feature = Organisation::Project::App::Models::Feature->new();

In Python you would do: from organisation.project.app.models import feature;

feat = feature();

It's a small point, but when you have multiple views/actions inside a controller that all use the same model you start to get annoyed typing that namespace in Perl.

2) The native OOP system in Python is much easier than Perl. With Moose this is far less important than it used to be, but comparing core Perl to core Python it is an issue.

DavidMcLaughlin··on How I learnt to love Perl
Good to see you read the article. I already have a VPS set up running django for my band website. Python is great, but Perl is great too.
DavidMcLaughlin··on How I learnt to love Perl
When you're passing parameters to a subroutine in Perl, all you're doing is passing a list. Not an array, but a list. The foo subroutine you posted, just wouldn't be written in Perl.

Besides, have you seen the syntax for passing arrays in PHP? Zend Framework is fugly:

    protected static function _assembleRoutes()
    {
        $routes = array();
        $routes['entry']  = new Zend_Controller_Router_Route_Regex(
            "[0-9a-z._!;, \=\-%]+-(\d+)",
            array(
                'module' => 'default',
                'controller' => 'entry',
                'action'     => 'view'
            ),
            array(
                'id' => 1
            )
        );
        return $routes;
    }
10 lines to create an object = foo($bar);
← PreviousPage 3 of 3