HNHacker News
TopNewBestAskShowJobs

ShellfishMeme

267 karma · joined January 29, 2012

submissionscomments
ShellfishMeme··on [dead]
It's actually slightly annoying that Github sorts the commits by commit date instead of the author date. When you rebase your branch a few times to clean up the history, you may end up with a PR commit overview that does not chronologically reflect what happened during development.

Makes PR reviews a bit confusing at times.

ShellfishMeme··on First Mechanical Gear Found in a Living Creature
5. A gear is no longer (and was never) either mechanic or organic, it's simply a pattern for solving a certain type of problem. Humans and evolution both found it, but it's more useful for humans.
ShellfishMeme··on The Hackathon Experience Is a Hack
I was at the BattleHack in Berlin. The event itself was absolutely fantastic. It was definitely the best organized hackathon I've ever been part of.

Still, the final results felt similarly weird. The winner was a (non-technical) dude who had been pitching his startup for months already and found himself an amazingly talented developer at the hackathon. They made use of most of the sponsor APIs and added PayPal as a payment option for the already existing service. To me it felt like the guy was just going to random hackathons so he could get work done on his website for free. Even though the developer seemed to be exceptionally good, it seemed like he was just being taken advantage of by a guy who couldn't get his startup to have more traction.

There were definitely much more impressive hacks out there. (Mine honestly wasn't one of them, so it's not just jealousy talking). In addition, the theme of the hackathon was 'solving local problems'. Now if not having a platform to get product X in city Y is a local problem, it might fit. For me though, the interpretation was more 'making the world a better place' and not 'building a purely profit-oriented application to sell stuff using PayPal'.

I think they simply chose the most monetizable product that was in the competition. Made the whole event, which, I repeat, was about the best organized and executed hackathon I've ever seen, suddenly feel cheap.

ShellfishMeme··on Promises/A+
If you make your `db.load` method resolve the promise with `this` (where `this` is `db`), and do the same for `setupDB` and `collectData` you can easily chain them without having to have a reference to `db`.

    db.load()
        .then(setupDB)
        .then(collectData);
That way it looks much more like your blocking code.

You are currently basically throwing away the value you `resolve` with, where you should instead resolve with what would be the return value if it was a sync function so you can `.then` the function that takes the return value and returns a promise to be resolved with its return value.

    // Sync
    var foo = function () { return 'foo' };
    var addBar = function (foo) { return foo + 'bar'; }
    addBar(foo()) == 'foobar'

    // Promise using Q
    var foo = function () { return Q.resolve('foo') };
    var addBar = function (foo) { return Q.resolve(foo + 'bar'); }
    foo.then(addBar).done(function (result) {
        result == 'foobar'
    });
ShellfishMeme··on What does O(log n) mean, exactly?
But the size of the number is such a programming-centered view of things. In my opinion it doesn't at all reflect the mathematics behind it. It's completely dependent on the representation of the number, which could really result in anything.

The only thing that really matters is the size of the set of numbers that you do your computation on.

What's really going on here (not in code but conceptually) is that you have two steps. First you take a number `n` and basically convert it into a generator for the set of numbers `{0, ..., n-1}`. We can assume that to be a O(1) step. Then in the second step you apply a O(1) function for every number in the set which is clearly O(n). So you end up with O(1) + O(n) which boils down to O(n).

So we have functions

`g(n) -> generator for {0, ..., n-1}`

`f(x, funct) -> funct(n) for n in x`

and we combine them into

`p(n) -> f(g(n), print)`

Clearly, the input size of the arguments to `p` is no longer meaningful for the total runtime. You have to assume it is a set of numbers to make any sense.

So in my opinion while anonymouz is technically correct, it does not make any sense to see it that way. BigO notation/analysis is there to gain some understanding about your algorithm complexity and not to link the amount of digits in a number to the complexity of your algorithm.

ShellfishMeme··on Keep calm and continue rebasing
I think you're both talking about the same thing. Basically, if you realize you had a typo somewhere in an early commit, or some other random easily fixable error that you simply overlooked and thus isn't part of the evolution of development, you should use rebase -i to squash the fix commit together with the one that introduced the error.

It's not about squashing together the entire history of development.

ShellfishMeme··on Keep calm and continue rebasing
I think the intended point was that you should always work on feature branches, never on master, rebase your feature branch work against upstream/master which is the one true published history and thus never rebase master.

In this workflow there is no pushing to master because you never work on master. So there is no reason to ever rebase master. Master is always assumed to be published history.

ShellfishMeme··on Patterns for Managing Large Scale Backbone Applications
I honestly don't feel like any of the "large scale (JS|Backbone) applications" posts really addresses the difficulties you run into when scaling JS applications. Most of these things are common sense (eg. "use namespaces", "make use of consistent naming conventions" etc.) and should hold for any kind of application development.

For me, one of the main problems when scaling the Backbone app I work with is decoupling View interactions. Now the usual recommendation you receive is using an event bus. In the link @analog just posted [1], Addy Osmani talks about using the Mediator pattern to achieve the decoupling, which certainly does help, but imho his example does not fully reflect the purpose of the Mediator pattern. His Mediator is barely more than just an event bus.

A Mediator can make use of an event bus, but an event bus is not automatically a mediator. It still forces the views to know about events triggered from other views and react to them. This still causes coupling, and even worse, it keeps the coupling in the views. The mediator should exist to take care of that coupling and pull it out of the views.

Let's take for example a checkout page. The checkout page has a view containing a form for address data. It also has a view that lets you pick the payment provider, a view that allows you to enter a coupon and a view that shows the order total.

Here are some of the required view-to-view interactions:

* If the user email changed, revalidate the coupon to make sure the "new users only" constraint applies and show the status

* If the payment type is changed to Paypal, add an additional charge to the order total and display it.

* If a coupon is entered, update the order total

This means that in many cases, views need to know exactly how the public event interfaces of the other views look, even if they communicate by an event bus and not by direct references and method calls. To make the application maintainable, we need to get rid of the knowledge about the other views' events as well.

This is where the Mediator comes into play. We make the mediator aware of the different event interfaces of the Views and have it decide which events to retrigger or which methods to call in what View. Instead of having the views subscribe to the other Views' events, the Mediator wires them up and encapsulates the View interactions. The Mediator now knows that the `change:email` event from the AddressForm triggers the `validateCoupon` method on the CouponView or the `validate:coupon` event to which the CouponView listens. The CouponView no longer needs to know about the existence of the `change:email` event.

Now the Views only need to specify their public (event) interfaces and the Mediator knows about how the different Views interact. This is a lot more scalable than the naive event bus approach.

I really wish there were more articles about scaling really big JS applications. In the end they will probably heavily borrow from GoF's Design Patterns book, but it always helps to see the patterns in action. I appreciate the author's effort, but I always feel disappointed when I read "Large Scale (Backbone|JS) Applications" and don't find advice to solve and real problems what come up with scaling "Large Scale (Backbone|JS) Applications".

[1] http://addyosmani.com/largescalejavascript/

ShellfishMeme··on Ask HN: Where is the Hostility on HN Coming From?
> If I am working with someone on a design and they bring me something as bad as that redesign, I'm going to tell them it's awful. That redesign is rubbish and it very clearly was done without thinking about what was important, and nobody benefits by pretending that's not true. As a designer, you should not be offended by people telling you things you've made don't work, so long as they're providing reasons. Those people are doing you a favor. You cannot remain emotionally attached to your own work and be a good designer.

I think that's a terrible and even dangerous attitude - especially when done in public - for several reasons.

Firstly, if you heavily criticize something when many people are watching, it might keep you from receiving balanced feedback. Some people probably liked some of the aspects of the redesign, but with dozens of people in the thread saying how awful it was, they will rather not speak up and talk about what they liked. If you tell a mass of people "X is rubbish and whoever came up with this is stupid", and some more people join in, the others will probably assume they are idiots for liking it and say nothing. As an analogy: When I was younger I really liked a girl in my class but all my friends were going on about how ugly and weird she was, probably because of some kind of social feedback loop. So instead of telling her that I liked her, I started joining in with the "X is stupid" meme because I didn't want to look like a fool in front of my friends. Had they not talked about it in such an extreme way, things might have went differently, but because of the situation, I lost all my courage to admit it to her and my friends.

Secondly, if you mix valid criticism with being a dick about it, people will more likely think that your criticism is less valid since it's easier to just assume you are an asshole. Most people are emotionally attached to their work. If they weren't, their work would probably suck. They'll learn how to handle criticism, but that doesn't mean it won't hurt or demotivate them if you tell them it's rubbish.

Thirdly, there is absolutely no need to ever mention that it's rubbish or awful. All you need to do is to list the points where they failed and maybe give advice on how to improve it. Calling their work rubbish helps nobody and makes you feel smarter and more powerful than you actually are. If you treat people like this, their work will become worse, not better, and at the same time they will probably stop asking you for advice because you can't stop being a dick about it instead of just encouraging them to improve on what they did by giving valid advice.

People aren't just machines that you can tell "this is all awful, throw it away and start over" without hurting their feelings in at least some way. You should learn to use these emotions to steer them in the right direction, not condemn them and call people who express them unprofessional. You'll get a lot further by nicely packaging your criticism.

ShellfishMeme··on Who 'likes' my Virtual Bagels?
>Why is it so obvious to you that these likes are 'cheaper'?

I was thinking the same thing. Maybe it's not so much that people in India click a like button ten times as much, but that more people in India get to see the ads. I assume Facebook somehow reserves ad space for you, but since many more people advertise in the UK, they can only show the ad to the target audience every 1 out of 100 page views, while it might be 10 out of 100 in India. If you advertise in India and the UK at the same time, Facebook will probably reserve a lot more slots in India, because that's cheaper for them. If they want to maximize their revenue, it would be smart to sell the sought-after UK slots to companies that can pay a lot. Indian likes are cheaper because more people want to advertise in the UK but there are fewer slots, so UK likes become more expensive.

ShellfishMeme··on Gabe Newell Wants to Support Linux, Because Windows 8 is a 'Catastrophe'
Interesting, I didn't realize that. Thanks for informing me. I guess 'hype' travels a lot faster than truth.
ShellfishMeme··on Gabe Newell Wants to Support Linux, Because Windows 8 is a 'Catastrophe'
> RELEASE ANOTHER DAMN HALF LIFE 2 EPISODE

Probably not going to happen before they release their new gaming console. They need a good launch title and you know how long it takes them to build a game.

ShellfishMeme··on Facebook has now a patent granted on having a user privacy settings page
From what I understand, this is not about cookies. It's about cookies storing information about pending server-side background tasks so the cached parts of a website can be sent out immediately and the slower server-side tasks can send over the results later without that resulting in a delayed response. If your slowest task takes 500ms, you simply spawn a worker who takes care of the task, immediately send out all things that are in the cache and then have your website render in <100ms. At 500ms, the rest will be filled in. It also seems to include a mechanism to figure out what resources are the most cacheable ones from the usage patterns of the clients.

It's still a joke, but it's more than just setting cookies.

ShellfishMeme··on Facebook has now a patent granted on having a user privacy settings page
The original link you submitted is very interesting as well. From what I understand this massive text describes a simple automatic caching strategy.

A part of the system figures out what resources are requested the most and caches them. Then it sends them over to the client together with a minimum page skeleton that can request more things once it's loaded. Based on the cookie, the system knows what additional parts that are being rendered in the background so once the cached parts are loaded, the remaining things can be delivered. This makes it possible to instantly respond and start rendering the website so tasks that maybe take 200ms to compute on the server side don't delay the response.

This is the first time I read an entire software patent. If all it takes to get one of those patents is taking a simple concept and blow it up to 11000 words, I must really ask myself why I spend my time writing software and not software patents.

Even though I think this is a nice idea for scaling high-traffic websites and having them be responsive also when server-side rendering takes relatively long, this is something that belongs in a technical blog post, not a patent. Being able to patent those kind of "inventions" really doesn't seem to benefit anyone.

The impression I get from the (software-)patent system is that its only current purpose is to have a cold war style arms race so large companies don't just nuke each other. In the end, all the big players have tons of "nuclear weapons" in their basements that they cannot get rid of and everybody else has to be afraid of pissing them off by competing with them.

The longer patents like this one are allowed, the worse the effect on business and innovation. This really has to stop.

ShellfishMeme··on Ask HN: Anyone making a living from Desktop apps?
I just looked at http://www.instadesk-app.com and noticed that you forgot to add

    class="teaser-imag-container"
to two of your slider image containers. That causes the padding to be off and the images overlay the text. Just thought I'd tell you.
ShellfishMeme··on Backbone.js: Hacker's Guide
I used Knockout.js on a project before switching over to Backbone. My experience was that while Knockout is great for simple projects, it becomes a lot more complex than Backbone once things get complicated. All those data-binds in the HTML get really annoying and the application becomes difficult to maintain. I like my templates clean.

Backbone takes care of syncing your data with the server, provides you with an event system so you can subscribe to changes, gives you a sane convention for how to structure your views and then gets out of your way. It's also easy to extend, so you could write your own data-binding system if you really need it. A simple 1-way data-bind is quite easy to implement.

If you aren't writing a single page app and only need to make a primarily static page more interactive, Knockout is probably the right choice. If you are writing a single page app, you often need to sync your models and collections with the server, or if your UI is very complex, Backbone is probably better.

ShellfishMeme··on An iPad Lover’s Take On The Nexus 7
The Nexus 7 has the same resolution that most 10" tablets have now, so why would you need reflow? Shouldn't everything look the same as on the current 10" tablets, just sharper?

It might be because my eyes are still young, but I prefer smaller screens with a high pixel density to larger screens with a lower pixel density.

← PreviousPage 3 of 3