7 ms·
I think there is a valuable lesson to be learned from this piece of spaghetti. I can't quite formulate it from the top of my head. But it's something like: if y
by a1a 13y ago
I think there is a valuable lesson to be learned from this piece of spaghetti. I can't quite formulate it from the top of my head. But it's something like: if you wanna be rich, don't waste your time being pedant - your users couldn't care less.
- pestaa 13y ago... unless your users actually care about messages being delivered, whatever being reported as saved being truly saved, et cetera... There is a whole world out there where people want to rely on software to do what it says it does. I know Facebook can live in its own bubble and get away with every possible stupid bug a messy PHP spaghetti causes.
- Encosia 13y agoI remember listening to an interview with Markus from Plenty of Fish, where he essentially said that he didn't worry too much about site errors because most unsophisticated users would attribute them to things like their ISP, browser (if they knew what that was), or their own error more often than to the site itself. Personally, I can't bring myself to not care like that, but it seems to have worked pretty well in the early days of many now-popular sites. Especially in 2007, when Facebook was still in real competition with MySpace, moving as quickly as possible was probably much more important than a few messages dropping through the cracks.
- pestaa 13y agoI must admit my comment was unneccessarily bitter, but my observation is completely different. Many friends and family members are now seeing data loss on Facebook weekly at least. I wouldn't call them tech savvy either, yet they can attribute the issue to Facebook, after having learnt the simplest basics of how the web should actually work.
- jafaku 13y agoThat's probably by design. Would you prefer one unimportant message lost here and there, or be able to handle 1/1000 of the current traffic to make sure every single message is delivered?
- pestaa 13y agoThis is exactly the problem. You do not know the message is not important. In fact, every message is important to someone.
- jafaku 13y agoIn your first comment you implied that it was a problem with PHP. I told you they are doing it on purpose, and not because their code or language is bad, and you now agreed. So I don't know where you are trying to get with this discussion. They have to choose between maximum performance and perfect consistency. They can't have both. So what they are doing is saving money in infrastructure, and letting some messages get lost from time to time. Your family being a little annoyed made them money. Also, when we say "important" in this context, is almost like asking "are you willing to pay for it?". Most people wouldn't pay a dime for ensuring the consistency of all their Facebook messages. So Facebook chose the right option.
- pestaa 13y agoActually the trade off is not between consistency and performance, but scalability and performance (CAP theorem). Although related, they are not the same concepts. My opinion is that you can have both performance and consistency, and work your way toward scalability as required. I recall that Facebook has a very high server-per-engineer ratio (though I acknowledge that the user-per-engineer ratio is even higher in comparison to other startups). I also realize it is not cost-efficient to write bugfree software, but saying they did it the other way on purpose is forgiving them too much. You never write bad software intentionally. They didn't care, and the world should have relied and should continue to rely on better software.
- TelmoMenezes 13y agoThis piece of code is doing something very simple and sequential in nature: putting together the (then) Facebook front page. I'm not sure I agree it's spaghetti. Are there any complex relationships that become hard to follow because of an inadequate level of abstraction? It doesn't look that way to me. Many programming methodologies are proposed these days, but the entire "field" smells of pseudo-science. Unless studies are done that can show statistically significant differences in relevant metrics (defect density, time required to add a feature, etc.), it's just a matter of opinion.
- a1a 13y agoYou make a fair point and I guess everything is relative. My post was not meant to trash the code, but rather to point out that this code shows us that the primary objective shouldn't necessarily be writing the perfect code.
- TelmoMenezes 13y agoOops sorry. Ok, we agree!
- 7Figures2Commas 13y ago> My post was not meant to trash the code, but rather to point out that this code shows us that the primary objective shouldn't necessarily be writing the perfect code. That's a dangerous argument. I mean, if startups stopped pursuing the most elegant code, they wouldn't need, nor would they be able to hire, the "best" developers. And then what? 1. Lots of startups would be able to get off the ground and grow with less cash because they wouldn't have to pay six figures to every developer on staff. 2. It would be a lot easier to find acceptable candidates (no more "you have five minutes to implement sort on a whiteboard...to prove that you can build a web form" challenges during interviews). 3. There would be a lot less premature optimization and use of the framework or NoSQL database du jour. 4. Egos would be hurt as engineers with the most impressive educational backgrounds and deepest technical expertise would be forced to come to grips with the fact that, while they are valuable and have a big role to play at some companies, people with less formal training and knowledge can build working, commercially-viable CRUD applications. This would be the end of the Silicon Valley startup world as it exists today, I tell you!
- sergiotapia 13y agoMy mantra: Shipped code > Well architected incomplete features. Your user does not care in the slightest if you're using a design pattern, or if you are using dependancy injection, or if there is 100% code coverage. Just make it work! Then make it faster! Then make it more readable! In that order.
- kaolinite 13y agoYou might ship faster but this can easily lead to poorly written, hard to maintain and insecure spaghetti code. In fact, rushing to ship / meet deadlines is probably responsible for most of the vulnerabilities in software.
- Killswitch 13y agoBingo. Do it right the first time. I'd rather take an extra hour on a bit of code the first time then go back and spend 2 hours refactoring it later on.
- g8oz 13y agoShip too late and none of it will matter.
- kaolinite 13y agoI guess shipping is more important to you than the possibility of losing user details (or worse). Christ, I hope I never give my details to a company you found. Shipping quickly is important but it's also important to write quality code. Small bugs that can easily be fixed are fine but security problems or bugs related to payments, for example, are not.
- MAGZine 13y agoso, maybe, just maybe, you take a bit more time on parts involving security (that is to say, handling of user credientials (includes session management, cookies, etc) and payment related things)?
- logicallee 13y agoall of computer science was created by an undocumented spaghetti code that evolved over a few hundred million years: DNA is 700 MB or so of uncompressed undocumented base pairs. We seem to be doing all right.
- Blahah 13y agoYeah, and because the code is completely undocumented and obfuscated it's taking us biologists a few hundred thousand man-years to figure out what the hell it means. The only time spaghetti is a good thing is when it's covered in sauce.
- lelf 13y agoIt'd be somewhat weird to stumble across comments in that code. // TODO:
- Blahah 13y agoI quite often see words (or nearly-words) in protein sequences. The best I've seen are (when reading DNA translated in all frames): EVQLVE LAMARCK ELVISISGAY SALTYSATAN
- PhineasRex 13y agoIs SALTYSATAN a metal band or a sex act?
- Tossrock 13y agohttp://dresdencodak.com/2009/07/12/fabulous-prizes/ http://dresdencodak.com/2009/07/12/fabulous-prizes/
- deleted 13y ago[deleted]
- troels 13y agoI'm pleasantly surprised. It's actually fairly well structured in my opinion.
- nilved 13y agoAre you a PHP programmer?
- troels 13y agoI don't know. I can program in PHP. Does that make me a PHP programmer?
- kops 13y agoLOL:-) I know the feeling. Someone recently mocked a full-stack-developer on HN as "I can javascript and servers too..". Oh man, how it made me cringe...In another 10 years, may be I won't have to. Off to dreaming...and coding...where is google....and stackoverflow of course...
- Killswitch 13y agoI'm a PHP programmer, but I haven't done much in terms of procedural code in a long time, I'm more or less OOP all the way using modern libs like Composer... This code although not bad per say, does make me twitch because of how it is.
- vinhboy 13y agoRemember that evolution article the other day? It's not "survival of the fittest". It's "survival of the fit enough".