Shkreli Got Prison Time, Holmes Didn't. Is That Fair? - <AUTHOR> https://www.nytimes.com/2018/03/22/business/shkreli-holmes-fraud.html <comment><USER2> Shkreli Story time.

Not all that long ago, Shkreli was doing a stream on periscope where he asked people to call his personal number and tell him why they hated him. Most people were calling him and making up stories about the drug price killing their grandma or complaining about the wu-tang album, and his response was to be friendly, down-to-earth, and even charming in a way while re-framing the complaints into stuff that worked towards his favor (ie: "I gave the drug for free to people who couldn't pay, nobody died" and "Wu-Tang needed money, I like them, and they liked the offer I made"). For the most part it worked. He was trying to make the point that he wasn't an evil, awful guy, and that any "hate" people held for him was more of a trend of directing general anger towards him, rather than genuine, personal, hatred.

On a whim though, a friend of mine and I called in, and by chance, we got through. The friend told him we hated him, but not for any of that stuff in the news. We hated him for squandering his wealth, time, and talents on ridiculous social media trolling (like the periscope thing). This actually seemed to get to him a bit, the conversation lasted at least 10 minutes. He justified it by saying stuff like "Some people relax by drinking and doing drugs, some people play sports, I like trolling people. What's the difference?". Ultimately, he tried to convince us that he was still trying to do meaningful stuff and that he wasn't obsessed with his social media presence (he even held up some book about AngularJS he said he was reading for a new startup to prove it, which we sorta laughed at). But he seemed a little unsettled by how the whole thing ended (us hanging up on him after he kept trying to maneuver out of the conversation in a way that made him look good).

I got the feeling that he truly thought anyone who spent more than a few minutes with him would like him, and see through what he saw as an unfair media assault on him. Maybe he had this same attitude going into court too. Only reason I can think for him to behave so brashly throughout.

<comment><USER3> I remember that one. He said he was learning to program (maybe it was angular JS, but are you sure it wasn't a book on mongodb?).

I know that if someone were to question how I spend my time, it would strike a chord. Anyone who prides themselves on their work ethic would take the question personally.

What was the end goal of asking the question?

<comment><USER2> It was a book about the "MEAN stack" (Mongo, Express, Angular Node), so we're probably remembering the same thing.

Not sure what you mean by end goal of the question. You mean end goal of calling in?

Partly, I wanted a good story to tell. But I suppose I did entertain the idea that "maybe just this once, I can influence one person who has more power than me and everyone I know. maybe this can go somewhere". But nope, to him social media trolling is the same as having a beer. Fast forward some months later and he gets his bail revoked for trolling on Facebook.

It really is disappointing. I do think he's intelligent. Likewise, I do think he should have done better things with his time and hate to see him act out like a toddler wanting attention. He's wealthy, educated, has experience leading companies. He doesn't need to learn some particular web stack to prove he's a hard worker or troll social media to prove he's fun. Why does a person with so much opportunity at their disposal care so deeply about what the internet thinks?

Now he's going to prison and his potential is going to be squandered for a while longer. Hopefully it will be a learning experience for him as a person at least. He's got issues to work out.

<comment><USER4> First, "Minor" correction: his bail was not revoked for trolling on Facebook; he asked for sample of Clinton hair to reserch her DNA and some people rightfully felt its a threat and reported him.

OP was asking why he is wasting time, like Shkrelli supposed to work 24/7\. Like he said - better to chat with people online than go and draink/smoke until you puke. The mere fact OP wanted to call and talked with him indicates Shkrelli did something more than average Joe with whom I presume OP wouldnt want to talk, unless OP daily picks anrandom number and call to chat.

Second, I dont blame Shkrelli for playing harsh about the drug price because he still played same game as everyone else, called capitalism. I witnessed bigger scumbags in my life; worked for company who hired HR manager for $250k/annul only to come back with pink report after one year and getting rid of 10% work force and therefore saving $500k by pushing their work on current employers that already were making 10 hours a day. Then they gave him $150k bonus and everyone consider him being "a great and successful guy".

Finally I dont worry about Shkrelli. He has money ergo after less than two years he will be at home confinment for another year so three years from now we gonna hear from him, healthy free and ready for another startup.

</comment></comment></comment></comment><comment><USER5> No, no it's not. Shkreli wasn't even that bad of a dude. He was evil in the public eye because he wanted to be and honestly helped out a lot of bullshit happening in the pharmaceutical industry (that we already knew). Shkreli went to jail because reddit thought he was the worst dude in the world and he was the perfect skapegoat in the situation. People think justice was served even though it never will be.

Sidenote: Hope his WuTang album goes into the public domain after this.

<comment><USER6> Please don't distort the record. He committed a crime (defrauding investors) which carried potential prison time as a sentence. Prosecutors sought 15 years. The judge sentenced him to just 7. Considering he displayed disdain for the law and showed little hope for reform, putting him away for 7 years seemed reasonable to the judge, as he would have likely committed more crimes had he gotten off with a wrist slap.

[https://www.nytimes.com/2018/03/09/business/martin- shkreli-s...](https://www.nytimes.com/2018/03/09/business/martin-shkreli- sentenced.html)

<comment><USER7> I heard but didn't confirm that he made the investors whole. No one lost any money. Seven years for that, while people who have committed murder/rape get less, is ridiculous.

<comment><USER8> That's a very strange way of looking at money. What about opportunity cost?

Lets say it's 2011 and you have $50,000 saved for a down payment on your dream house. I steal that money from you, but return you ~$56,000 7 years later (I've adjusted for inflation).

Technically you haven't lost any money.

But you missed the opportunity to purchase your dream house during a dip in the housing market while interest rates were low. Now, not only is your dream home 30% more expensive, interest rates are higher. You also missed out on 7 years worth of mortgage and real estate tax breaks. Your credit score isn't as robust either, since you don't have 7 years worth of mortgage history on it.

You are way behind despite getting every penny back.

<comment><USER9> Shkreli paid investors back with interest.

[http://money.cnn.com/2017/06/29/news/martin-shkreli-fraud- tr...](http://money.cnn.com/2017/06/29/news/martin-shkreli-fraud- trial/index.html)

> After their meeting, Sarah Hassan invested $300,000 in MSMB Capital, a fund > Shkreli ran. He later told her that investment had increased to $435,000, > she said. [approximately 2 years later]

> Hassan eventually settled with Shkreli and she even made money off her > original investment. She told the court she received $400,000 in cash, plus > 58,000 shares of Retrophin that were eventually sold for an additional > $900,000.

</comment></comment></comment></comment></comment><comment><USER10> No, it isn't fair. Moreover Shkreli's crime isn't within an order of magnitude of what Holmes did in terms of financial damage. Shkreli wasn't endangering lives with fake products.

I'm pleased the Shkreli is doing time. That sends the right message. Holmes skating with a fine does not send the right message.

</comment><comment><USER11> For people who claim it wasn't fair but he was responsible: that is a contradiction.

If it isn't fair, it isn't fair because his behavior -- however off-putting -- should not have lead to such severe punishment.

I don't have an opinion as to whether it was fair because I don't know the details.

I suspect the things that he did legally were often far worse than the things he did illegally.

</comment><comment><USER12> "Typically you get more sympathy from the criminal justice system if you're an attractive young woman than a brash, arrogant young male"

The proper comparison would be to "brash, arrogant young women". You can even keep attractive as in "attractive, brash, arrogant young X" if you must. As in, large factor seem to be that Holmes was better at following layers advice about how to act in public and during investigation. She might be sociopath or whatever, but she managed not to be one publicly during the time the case was processed.

Alternatively you can compare attractive polite young man to attractive polite young women. Or leave gender out. But hell, keep "ability to follow lawyers advice and not tease people in justice system while it is litigated" constant.

Maybe justice system should be less eager to take offense. It just so happen that cops, prosecutors and judges are extremely easy to offend and have quite a lot of power. But you know, not calling prosecutor idiot while he is deciding about you is an important life skill if you plan to break the law.

<comment><USER5> Yeah maybe, but I don't think he really cared. I hope more people care about the corruption in this sort of industry after this.

</comment></comment><comment><USER13> It's not over yet - Holmes could still do time for fraud.

Re Shkreli, as soon as he was convicted for security fraud and paroled he offered money to assault Hillary Clinton. What would you do as a judge? [http://www.bbc.com/news/world-us- canada-41262249](http://www.bbc.com/news/world-us-canada-41262249)

<comment><USER14> Hair falls off of people's heads all the time. Especially older people's hair.

To call it assault is overblown.

</comment></comment><comment><USER15> Not fair for Shkreli, but he brought it upon himself. He made such a spectacle of his situation that prosecutors and judges had to hit him hard. They would have been highly criticised otherwise.

Also, Holmes had so many high power people associated with the company that the media would have had a field day reporting on that and it would have been highly embarrassing for them. I'm sure they all helped her get the best deal.

My view is that they both broke the law so they should have gotten time.

Lesson learned, if you get in trouble with the law don't poke the bear.

<comment><USER16> Shkreli sure did like to poke the bear, didn't he?

<comment><USER17> So did Holmes: brazenly and knowingly lying to everyone qualifies as poking the bear in my book. She's just much better connected, so she gets to live under another set of laws.

</comment></comment></comment><comment><USER18> It seems premature to ask the question in the title at this juncture, doesn't it? DoJ is still investigating Holmes.

</comment><comment><USER19> I find it typical that Shkreli was convicted for ripping off rich people, while his ripping off poor people turned out to be totally legal. Fair? Not remotely.

<comment><USER20> How did he rip off poor people?

<comment><USER19> He's mostly known for extreme price increases for medicine.

<comment><USER20> A medicine for approximately 5000 people in the entire country. People with AIDS and toxoplasmosis. IIRC the increase is distributed among the entire population and he gave the drug for free to the small portion of people who didn't have insurance and couldn't afford it.

If anything he ripped off insurance companies.

</comment></comment></comment></comment><comment><USER21> Let's stop pretending that we, as a society, care about fairness here. Rich people always get away with more shit. Let's just enjoy one rich asshole getting part of what he deserved instead of lamenting about how a second rich asshole didn't. And yes, I said to enjoy it because don't pretend these stories means anything more to you than the entertainment value. Either you ignore them or you acknowledge it is tabloid drama that you enjoy (I am in the latter group). Dude was a rich asshole who took internet trolling from a middle school hobby to a lifestyle. The deck was stacked in his favor and he still blew it. That's what we care about and why we like this story.

<comment><USER20> Dude was poor with poor parents who worked his ass off to become a multimillionaire.

And a lot of people do care about fairness. He wouldn't have delved in this troll personality if the witch hunt hadn't happened.

Don't put everyone in the same bag.</comment></comment>


Why HealthCare.gov, the Obamacare Website, Doesn't Work - <AUTHOR> http://www.thedailybeast.com/articles/2013/10/18/why-healthcare-gov-the-obamacare-website-doesn-t-work.html

<comment><USER2> "because they're not allowed to mess up we've created a system where it's also very hard for them to do things that are new and innovative. The rules all favor incumbents."

So true. From this article:[http://www.infoworld.com/t/e-government/how- federal-cronies-...](http://www.infoworld.com/t/e-government/how-federal- cronies-built-and-botched-healthcaregov-228724) _______________________________

"All but one of of the 47 contractors who won contracts to carry out work on the Affordable Care Act worked for the government prior to its passage," the report reads. Some of the names ought to be familiar: Northrop Grumman, General Dynamics, Deloitte, and Booz Allen Hamilton, all of whom assumed different roles and worked on different aspects of the project.

As familiar as those names might be, especially to those who follow Beltway lobbying practices, few of them would be as commonly associated with large- scale IT projects as, say, Google, Amazon.com, or Dell would be -- especially when it came to building the public-facing components of the system. (Techdirt concurs.)

Why did they get the work? The report hints at a likely reason: The companies were big lobbyists, with "some 17 contract winners reported spending more than $128 million on lobbying in 2011 and 2012." Granted, some experience with government work is vital for any contractor, and the federal procurement system is geared to favor those already doing government work, but Sunlight pointed out that the list tips heavily toward those with both existing contracts and political leverage." _______________________________

Unfortunately the US government procurement system is set up to reinforce cronyism. There are a lot of mechanisms in place to try to prevent it, but the way proposals are structured, it's very tough on new entrants. The factors of a typical US Government IT proposal are Past performance, Key personnel, Technical, Management, and Price. Sometimes these factors are blended or worded differently but in nearly all cases, the technical approach can become a small portion of the overall decision. This favors incumbants with some track record (and perhaps some ex-government employees that are still buddies with some of the key players) over ones with no government experience, even if it's not great like CGI Federal.

Adding more issues, procurement officials are under a ton of time pressure and often don't have the skills to understand that the relevant most past performance qualification in the development of a health exchange is not simply having worked on previous contracts in the government health space.</comment>


These Diagrams Reveal How To Negotiate With People Around The World - <AUTHOR> http://www.businessinsider.com/communication-charts-around-the-world-2014-3

<comment><USER2> Very nice. I was a bit surprised to find that the closest one to my native culture (Ireland) seems to be Bulgaria.

BTW, 'hygge' on the Danish one is a Danish word for (something like) cosy or convivial, a kind of comfortable intimacy. Dutch people have a similar concept (gezellig), but not until after the deal has been concluded.</comment>


This Tech Bubble Is Bursting - <AUTHOR> http://www.wsj.com/articles/this-tech-bubble-is-bursting-1462161662 <comment><USER2> These journalists, along with most people outside the tech industry, fail to see the overall picture. 4 out of 5 of the largest companies on earth are tech firms, and none of them were even close to that position 10 years ago. Software runs the world and tech companies are the single largest driver of the modern American economy, making the overall pool of companies that may go belly up at any given time larger. Public consciousness just hasn't caught up to that fact yet since it happened so fast.

<comment><USER3> I'd have to disagree. It may seem like tech is driving the US economy when you're standing in Silicon Valley, but it's not even in the top 5.[1]

Energy, manufacturing, transportation, healthcare and agriculture have seen the most growth lately.

Of course tech can play a role in all of those industries, but overall tech is not that big a part of the US economy.

[1][http://www.investopedia.com/articles/investing/042915/5-indu...](http://www.investopedia.com/articles/investing/042915/5-industries- driving-us-economy.asp)

<comment><USER4> Technology isn't just an industry - it's a way of doing things and is becoming ubiquitous. When people think "tech" they may think of sharing status updates or searching for a restaurant. What about driverless trucks (transportation), gene sequencing (healthcare), industrial robotics (manufacturing), automated warehouses (retail), solar research (energy), farm-specific yield optimization (agriculture)?

This stuff is all being driven from within the tech industry, even when it will benefit "other" industries.

<comment><USER5> I think the point the previous commentator was trying to make is the distinction between the 'tech industry' a la Silicon Valley versus other industries - and it would be unfair to credit the former with any innovation in the latter. Pretty much every industry since we have invented fire has grown through advances in 'tech'. So what makes a firm a 'tech' firm - in this day and age it's hard to say, and I'm not sure if it's a useful exercise.

<comment><USER6> A "tech" company is a company that provides a good or service that is either completely new and only possible because of a technological innovation, or is a new company providing an existing service using a different vertical stack based on technology which came available after the incumbents were started.

Uber is a "tech company" because as they are providing a new business model for a livery service based on using an application to make a market that is distinct from the previous market.

Facebook is a "tech company" because they are providing a business model around sharing information between acquaintances (a social network) using an application and a web site.

Fedex is not a tech company as they are augmenting but not replacing their model or their processes. Foster Farms is not a tech company as they have not fundamentally changed the way in which they raise chicken.

I go back and forth on Tesla or SpaceX. Consider Tesla, they are a car company but electric cars have been around forever, their most successful incarnation, the Golf Cart, has dominated golf courses for decades. It wasn't the "idea" or the "product" that made the Roadster and then the Model S successful, it was the execution on the vision. Similarly SpaceX rockets are just rockets with better execution and better alignment with available technology.

<comment><USER7> A better definition might be, how much revenue (measured % of sales) does this firm reinvest back into R&D?

Let's try a few examples: P&G: Not a tech company. They spend tons of money on advertising to get products on shelves and on TV that tons of Americans buy. They can innovate in packaging and distribution, but honestly not that much.

Tesla: tech company. Spending tons of R&D. I don't know how much, but it's a lot.

Pepsi: Not a tech company.

Your local grocery store: tight margins, probably not a tech company.

AmaGooFaceSoftPle: Billions/yr on new product development. Tech companies for sure.

<comment><USER8> This search gives a nice summary of P&G's supercomputing-driven research:

[https://www.google.com/search?q=procter+and+gamble+high+perf...](https://www.google.com/search?q=procter+and+gamble+high+performance+computing)

It's not just packaging and distribution. Now it's fair to point out that P&G spends less on R&D than tech companies, but it's not zero.

</comment></comment></comment></comment></comment></comment></comment><comment><USER9> If journalists keep writing articles about tech bubbles every few months, someone is bound to be correct. Looks like this "trend" started up again in 2013.

[https://www.google.com/trends/explore#q=tech%20bubble](https://www.google.com/trends/explore#q=tech%20bubble)

<comment><USER10> I lived through 2001. This is not a bubble. As exhibit one I point out that everyone has been calling bubble since 2012. Real bubbles have more rah rah and less skepticism and more crazy.

I do see a slowdown but this is nothing like dot.com. Seems like a normal correction and is not really separate from the rest of the economy being uncertain. Nothing tech specific.

Bubble is an overused term. An inflated market is not a bubble, and a correction is not a bubble bursting. Markets go up and down all the time.

<comment><USER11> It is not a bubble in that market caps are not "popping" \- disappearing instantly, overnight, leaving shares worthless and dissolving fortunes. The current tech market is more like a punctured soccer ball, slowly leaking air. Regular people won't see this as a crash in their etrade portfolios; rather, they will notice a long, slow decline in the value of their pension/retirement funds.

<comment><USER12> So... what you're saying is that it's a standard part of the normal cycle where things grow for a while, plateau or shrink a bit, then grow again?

i.e. Not A Bubble.

<comment><USER11> Yeah, it's not a violent growth/crash cycle that people usually refer to as the outcome of a "bubble" (1929, 1987, 2001). I.E. the velocity is different.

Right now it looks like a gentler reversion to the mean in GDP growth from the peak of this 6-year business cycle, which was much less pronounced than previous business cycle peaks.

But who knows - the failure of a large firm that was generally thought to be solvent could set off another crash.

<comment><USER12> It could, but if anything was going to do that then Yahoo would be the best candidate and I don't see panic over that situation.

</comment></comment></comment></comment></comment></comment><comment><USER13> Shouldn't a bubble burst be sudden and definitive, like fancy tulip bulbs being worth a king's ransom one day and close to nothing the next?

I guess "the high tech sector may experience a reasonably paced contraction" wouldn't get as many clicks.

<comment><USER14> You are more correct than you think. A reasonably (see:boring) contraction with no real 90's style drama is more likely what is happening.

</comment></comment><comment><USER14> If everybody is a couple of layoffs away from profitability or multi-year runways, where are the big falls? Who is the Pets.com this time around?

P.S: Also mixed messaging ([http://www.wsj.com/articles/fidelity-in-reversal- raises-valu...](http://www.wsj.com/articles/fidelity-in-reversal-raises-value- of-many-tech-startups-1462041176?mod=e2tw)). Maybe its not all sky-is-falling doom and gloom.

<comment><USER15> I know it'll be an unpopular opinion, but I really think Uber could be in for a big fall. Not because they haven't been successful, but because they've been _too_ successful - they've opened the market up for themselves but also competitors.

Most Uber drivers I ride with have at least one other ride share app open, none of them have a loyalty to the company. In fact, many actively dislike it. And riders I talk to aren't loyal either - they'll happily flip between Lyft, Uber, and whatever else is available, depending on who is offering a discount code that week. I don't doubt that Uber has a better investment in the future (self driving cars and the like) but it remains to be seen if they'll make it that far - that future is still a ways off.

By itself that wouldn't be so drastic, but Uber has taken on a _lot_ of funding and obstinately refused to go public. It could put pressure on other companies that are currently quite happily staying private, too.

<comment><USER16> Agree - Uber suffers from the same problem as Square. They created a new product expecting it to be stickier than it actually turned out to be.

In Uber's case it turns out "better than a yellow cab" is a pretty low bar to clear, and neither drivers nor consumers have much loyalty and are highly price sensitive, creating a race to the bottom.

In Square's case it turns out merchants will gladly use a slightly-worse iPad UI for payments if the fees are lower, and consumers don't really care regardless. Again, race to the bottom.

Right now it looks like Uber is engaged in an epic price war in many markets where the prices are unsustainably low - and these prices are sustained by a combination of setting VC cash on fire and squeezing driver pay. Having no insider information into Uber, I'm a bit skeptical that they're _that_ close to be sustainably profitable.

<comment><USER17> Uber's problem seems to be that they need to raise prices and cut driver rates once they've captured a market and driven out competition. Either that, or they need to switch to driverless cars to eliminate that component of their business - but that seems to be a ways off, and there's no reason to think other players won't be just as successful when you're able to remove drivers, one of the larger variables, from the overall equation.

[https://twitter.com/neilanalien/status/627873374505562112](https://twitter.com/neilanalien/status/627873374505562112)

</comment></comment></comment></comment><comment><USER18> While I don't think that the bubble is bursting, it does seem that the values some companies which have been massively overvalued, are being adjusted. I'd much rather see this than companies loosing 90-99% of the value overnight - That's a burst.

If interns are making $80k a year, I think most of us are safe (for the time being).

<comment><USER19> There are many making around $102K now.

<comment><USER20> What do you mean by "many"? And do you have a source for that?

Lucrative internships are generally like $25/hr. 102k is twice that.

<comment><USER19> "Many" meaning the 1000's of interns working at places like Facebook (~8k + housing), Dropbox, and Jane Street.

I personally wouldn't consider $25/hr to be particularly lucrative in the grand scheme of things considering how highly paid many interns in SV/SEA/NYC area. In my area, yes.

</comment></comment></comment></comment><comment><USER21> This is one of those articles that consists mainly of speculation, anecdotes, and quotes from phone interviews. It's hard to tell if Mimms ever left his office to do the foot-soldier work that serious journalism requires.

<comment><USER22> With everything moving online, just how important _is_ going places in person these days?

<comment><USER21> Gathering information online and by phone is probably not sufficient to find out all the facts and to develop leads. For example, insiders may be reluctant to reveal everything they know in phone calls and email. It's too easy to eavesdrop on electronic communications.

</comment></comment></comment><comment><USER23> There is no bubble. There may be a dip in funding for companies of a certain stage, which could be due to any number of factors. Fund vintage (funds raised optimally at bottom of 2009 are now fully allocated); shift in focus away from sectors (no money for social media); random variance in relatively small pool of VC (tiny portion of total capital invested in small businesses).

</comment><comment><USER24> How many people with a WSJ login actually read this before commenting?

<comment><USER25> Tip: If you copy and paste the title into Google and choose the first result, you can view the full article. The paywall only applies when the article is redirected from another website.

</comment></comment><comment><USER26> Buy Credit Default Swaps for private tech unicorns!

<comment><USER27> How does that work exactly? Can you also do that as an employee of that company to limit your risk?

<comment><USER28> I believe it was a joke - [http://www.venrock.com/why-you-cant-short-private- company-st...](http://www.venrock.com/why-you-cant-short-private-company- stock/)

</comment></comment></comment><comment><USER29> Burst already God damnit, I'm sick of this slow motion train wreck.

</comment><comment><USER30> If the funding bubble for startups has burst, fine, look to crowdfund startups and projects that people actually want to use.

I wanted to validate ideas early and tighten the feedback loop for products I was building, so we built Baqqer in the hopes it would create transparent projects and companies that help grow community from day one. Less time floating around until launch going "I hope someone uses or pays me for this." and more time spent figuring out what people actually want.

</comment><comment><USER31> I honestly think this constant talk of tech bubble is the best thing that can happen to this industry. It keeps people skeptical and allows the industry to make course corrections. It's a much needed regularization.

</comment><comment><USER32> Credit is much cheaper than it was in 2000. It's simply not as appealing for investors to make hasty exits when cash is so easy to come by from other sources.

</comment><comment><USER33> I have a feeling it's going to be a "soft-landing" in terms of the tech scene in SV. I was hoping for a burst and a bit of a fall-out, but unfortunately everything I'm seeing is that the bubble is deflating slowly which is allowing for another round of inflation in the subsequent year, without the cleansing effect of a true burst like 2000. That would be unfortunate because it will mean that the next burst 5 years from now will be all the more painful, and we don't currently get any relief from high housing/rent, traffic, etc.

</comment><comment><USER34> If we think about the future of technologies, I am pretty sure there is a bubble:

[https://medium.com/@tbsmartens/is-iot-the-end-of-rocket- inte...](https://medium.com/@tbsmartens/is-iot-the-end-of-rocket- internet-2697f4b7a3d1#.r0mgmh3hy)

It´s all about singularity: How many services do you need that all do the same? Not too many, not too many - and this realisations will hit everybody, from ad-tech to server technologies to consumer services.

</comment><comment><USER35> not bursting, deflating

</comment><comment><USER36> FINALLY someone predicts the tech bubble bursting!

</comment><comment><USER37> To Read the Full Story, Subscribe or Sign In

</comment><comment><USER38> stock markets does not believe that yet.

<comment><USER39> So long as the Fed's policy is effectively 0% interest rates, that will continue to support significantly inflated valuations (privately and publicly). And the Fed isn't going to raise rates meaningfully (they can't), they've been lying about that for years. At this point negative rates in the US are more likely than any sort of normalization is.

</comment></comment><comment><USER40> Drivel like this is why I refuse to pay for WSJ.

</comment><comment><USER41> no, it isn't.

</comment><comment><USER42> I guess I'll never know how exactly it's bursting since that information is behind a paywall.

<comment><USER43> Google the article to get through the paywall. Or if you aren't poor like me, buy the subscription. It's a pretty good newspaper.

[https://www.google.com/#q=site://www.wsj.com/articles/this-t...](https://www.google.com/#q=site://www.wsj.com/articles/this- tech-bubble-is-bursting-1462161662)

<comment><USER44> The cost is $28.99/mo for anyone who's interested

</comment></comment></comment><comment><USER45> I'm sure there is a bubble bursting, whatever that means. But it's interesting that this narrative always involves mentioning Zenefits, which is suffering because it ran afoul of the law, not due to an economic downturn.</comment>


CoreBitcoin - Bitcoin library for Objective-C - <AUTHOR> https://github.com/oleganza/CoreBitcoin

<comment><USER2> Unfortunatly a missing open source bitcoin library in Objective-C is not the reason for the missing Bitcoin client for ios. It seems Apple does not allow Bitcoin clients in the iOS App Store. [http://www.bitpak.com/?p=34](http://www.bitpak.com/?p=34)

<comment><USER3> Apple doesn't ban 100% of apps, Glyph lets you send and receive bitcoins through Coinbase: [https://itunes.apple.com/us/app/gliph/id501269250?mt=8](https://itunes.apple.com/us/app/gliph/id501269250?mt=8)</comment></comment>


What jobs can you do if there is no tech jobs for you - <AUTHOR> <comment><USER2> Just a suggestion. I'm not being snarky, I really mean this with best intentions of helping you. If you really want someone on HN to give you advice, give us more context. Where are you located, what skills do you have, what is your goal, what job skills do you think you lacking, if you had these skills could you get a job, etc? Why do you think this? What have you tried? What is your current life situation? No one can give you good advice because what you are asking is way to vague and lacks needed details. People on HN come from many walks of life, and typically have good advice on this subject, but if you don't give them enough to quickly work with upfront, you will not get anything out of it.

You also need to prefix your title with "Ask HN: " for questions.</comment>


Twitter tweets are 40% 'babble' - <AUTHOR> http://news.bbc.co.uk/2/hi/technology/8204842.stm <comment><USER2> Twitter is a fad. Not newsworthy at all.

<comment><USER3> 40% of blog posts are probably babble as well - another fad.

<comment><USER4> yeah but the non-crappy twitter posts are almost always just links to these same blog posts</comment></comment></comment>


javascript: don't start doing it, without learning it. - <AUTHOR>

If you're a server-side programmer like me, javascript is a language you learn just to get by on. However, in my case, I never took the time to fundamentally learn the language. I would pick it up along the way to because i needed to, or because i was forced to used it.
Then of course jquery came long, which made using javascript a whole lot easier. However, whenever it came to writing raw js code, (instead of copying and pasting snippets off another site.) i was lost. Especially when it came to writing proper oop, or using closures. - these problems also slowed down my productivity time, as well, leaving a frustrating experience in memory.
The youtube link: http://www.youtube.com/watch?v=hQVTIJBZook is Doug Crockford talking about misconception about javascript.
He also wrote a book called: "Javascript: The Good Parts" - which many JS coders are probably be already familiar with
I would also recommend (which is recommended by many other programmers):  JavaScript - The Definitive Guide <comment><USER2> Nah, I don't need to relearn JavaScript because I already know it quite well. I should start learning jQuery though. Maybe even node.js

</comment><comment><USER3> This disagrees with my personal learn-as-you-need-it mantra.

 _(works if you're already fluent with programming fundamentals)_

<comment><AUTHOR> You're right. But only to a certain extent. If you are building medium to heavy based JS web apps (without using frameworks like JQuery) JS can throw some unexpected/questioning curve balls along the way, due to the design flaws of how it was built.</comment></comment>


Ballmer: There's no doubt Windows 8 will be a success - <AUTHOR> http://www.geekwire.com/2012/ballmer-theres-no-doubt-windows-8-will-be-a-success/ <comment><USER2> Does anyone still listen to Ballmer's predictions?

"There's no chance that the iPhone is going to get any significant market share. No chance. [...] I'd prefer to have our software in 60% or 70% or 80% of them, than I would to have 2% or 3%, which is what Apple might get."

</comment><comment><USER3> I read this as "Ballmer screaming: There's no doubt Windows 8 will be a success." Can the Siri voice be changed to Ballmer screaming everything? Has anyone made a "Ballmer" voice for OS X or Windows text-to-speech?

</comment><comment><USER4> more accurately "There's no doubt Windows 8 will be a success"...when we make it the only option.</comment>


Node.js in Flame Graphs - <AUTHOR> http://techblog.netflix.com/2014/11/nodejs-in-flames.html <comment><USER2> The moneyquote:

 _" We made incorrect assumptions about the Express.js API without digging further into its code base. As a result, our misuse of the Express.js API was the ultimate root cause of our performance issue."_

This situation is my biggest challenge with software these days. The advice to "just use FooMumbleAPI!" is rampant and yet the quality of the implemented APIs and the amount of review they have had varies all over the map. Consequently any decision to use such an API seems to require one first read and review the entire implementation of the API, otherwise you get the experience that NetFlix had. That is made worse by good APIs where you spend all that time reviewing them only to note they are well written, but each version which could have not so clued in people committing changes might need another review. So you can't just leave it there. And when you find the 'bad' ones, you can send a note to the project (which can respond anywhere from "great, thanks for the review!" to "if you don't like it why not send us a pull request with what you think is a better version.")

What this means in practice is that companies that use open source extensively in their operation, become slower and slower to innovate as they are carrying the weight of a thousand different systems of checks on code quality and robustness, which people using closed source will start delivering faster and faster as they effectively partition the review/quality question to the person selling them the software and they focus on their product innovation.

There was an interesting, if unwitting, simulation of this going on inside Google when I left, where people could check-in changes to the code base that would have huge impacts across the company causing other projects to slow to a halt (in terms of their own goals) while they ported to the new way of doing things. In this future world changes, like the recently hotly debated systemd change, will incur costs while the users of the systems stop to re-implement in the new context, and there isn't anything to prevent them from paying this cost again and again. A particularly Machievellan proprietary source vendor might fund programmers to create disruptive changes to expressly inflict such costs on their non-customers.

I know, too tin hat, but it is what I see coming.

<comment><USER3> You're assuming that your closed source vendors are perfectly aligned with you. In practice they almost inevitably seem to cause capture ([https://en.wikipedia.org/wiki/Regulatory_capture](https://en.wikipedia.org/wiki/Regulatory_capture)).

Open/closed is a red herring here. Projects slowing down as they succeed seems to be a universal phenomenon, from startups to civilizations. Specialization leads to capture. I think almost exclusively about how to fix this: [http://akkartik.name/about](http://akkartik.name/about) (you've seen and liked this), [http://www.ribbonfarm.com/2014/04/09/the-legibility- tradeoff](http://www.ribbonfarm.com/2014/04/09/the-legibility-tradeoff)

Disclosure: google employee

<comment><USER4> Yep, closed source doesn't solve the problem either. If you believe that just because you're paying money for someone to take responsibility for a problem, they will actually solve the problem in a way that's amenable to you...well, there are numerous closed-source software vendors looking to sell you something.

In practice, the way to avoid this is to keep the software as simple as possible. Try to adjust to your user's most pressing current needs, not every need they might conceivably have. Killing features and deleting code is as important as launching features and writing code; make sure that your incentive systems reward this. Very often, third-party code gets pulled in to scratch one particular itch; if it's no longer itching, rip the code out. If it is still itching and you've built significant parts of your system around it, you may want to think about replacing the innards with a home-grown system.

<comment><USER5> When a software provider I use starts ripping out features I relied upon, I start looking for an alternate provider, one that isn't so eager to kill features. And in particular, I try not to learn or rely on any new features, if there is past behaviour of feature removal by the provider.

It's better to be careful - very careful - about what you add, and to have a story for migration, than to remove features.

<comment><USER4> This depends on industry, of course - in consumer web it's much better to risk pissing off a few customers but make the majority of them happy than to keep all your existing customers but risk losing out on a new innovation that gives a competitor a toe-hold. Enterprise SaaS probably has different trade-offs, and software infrastructure probably different still.

This paradox, BTW, could be thought of as the full-employment theorem for entrepreneurs. As long as it is rational for a business to avoid change for fear of having to remove or support it later, then there will exist changes that a company with no customers and no codebase could implement that no incumbent would dare. Some of these are bound to be useful to some segment of the market, and that's why you get continued disruption in technology markets.

</comment></comment></comment></comment></comment><comment><USER6> > It's unclear why Express.js chose not to use a constant time data structure > like a map to store its handlers.

Its actually quite clear - most routes are defined by a regex rather than a string, so there is no built-in structure (if there's a way at all) to do O(1) lookups in the routing table. A router that only allowed string route definitions would be faster but far less useful.

I can't explain away the recursion, though. That seems wholly unnecessary.

Edit: Actually, I figured that out, too. You can put middleware in a router so it only runs on certain URL patterns. The only difference between a normal route handler and a middleware function is that a middleware function uses the third argument (an optional callback) and calls it when done to allow the route matcher to continue through the routes array. This can be asynchronous (thus the callback), so the router has to recurse through the routes array instead of looping.

<comment><USER7> A lot of people here are right, the right way is with an NFA. I just want to add that the solution is not even hard, you can do it with string concatenation and capture groups using regexps. Regexps are NFAs, and are highly optimized C code in just about every JS engine.

If I have the routes /foo/bar and /foo/bar/(\d+) I can generate the regexp ((^\/foo\/bar$)|(^\/foo\/bar\/\d+$))

I'm not at all surprised, the quality of software in node is pretty low, I've seen numerous issues in node libs being just as boneheaded. I swear, the fact that the express devs overlooked a key optimization is crazy. Rails, by way of example, uses the Journey engine to solve this problem ([https://github.com/rails/journey](https://github.com/rails/journey))

<comment><USER6> > I can generate the regexp ((^\/foo\/bar$)|(^\/foo\/bar\/\d+$))

And how would you know which one got matched? The regex match isn't going to tell you that. Also, it needs to recognize if multiple were matched, which is definitely not going to be done by the built-in regex matcher.

It's certainly possible, but pretending it's trivial isn't helping, either.

<comment><USER8> For more concrete syntax, consider the following Python:

      >>> import re
      >>> route = re.compile(r'(?P<fb>^/foo/bar$)|(?P<fbd>^/foo/bar/\d+$)')
      >>> route.match('/foo/bar').groupdict()
      {'fb': '/foo/bar', 'fbd': None}
      >>> route.match('/foo/bar/1').groupdict()
      {'fb': None, 'fbd': '/foo/bar/1'}

If the fb group is set, act on the first route. If the fbd group is set, act on the second.

<comment><USER9> I know very little of NFAs/DFAs/FSMs, or even string parsing in general, but a year ago I built a URL matching engine using exactly this method in Python, in combination with Google's RE2 library ([https://code.google.com/p/re2/](https://code.google.com/p/re2/)). It was far faster than anything else I experimented with, and RE2 also improved the speed dramatically by eliminating backtracking.

Nice to know that what I made is considered the best solution algorithmically.

</comment></comment></comment></comment></comment><comment><USER10> I'm surprised nobody has mentioned that express has a built in mechanism for sublinear matching against the entire list of application routes. All you have to do is nest Routers ([http://expressjs.com/4x/api.html#router](http://expressjs.com/4x/api.html#router)) based on URL path steps and you will reduce the overall complexity of matching a particular route from O(n) to near O(log n).

</comment><comment><USER11> I wonder what the thought process was behind moving their web service stack (partially?) to node.js in the first place. For a company with the scale and resources of Netflix it's not exactly an obvious choice.

<comment><USER12> I share this thought, I'm not trolling, I really believe node is a bad solution for something like Netflix.

Node has its perks but for a money making machine that relies solely on being available and providing a good customer experience, not so much.

I can't imagine the ops nightmares at that size, one buggy code path and the entire cluster could be down. These are issues that drove me away from Node to Go, in my opinion Node has way too many issues to run in money-making scenarios.

<comment><USER13> > in my opinion Node has way too many issues to run in money-making scenarios.

You can say that about a lot of languages other than node. How many billion dollar companies have their software written in PHP - a language that many people would agree has far more glaring issues than node.

My point, is that I believe your comments miss the larger picture. There is far more involved with deciding which language to build a product with than "which language is best."

I don't disagree with you about Go being a great language - but for most companies, it is not even remotely practical to use. Hiring talented Go developers is hard because there are so few. Their current employees may or may not know Go, what do you do about that? Etc.

<comment><USER12> For sure, but jumping into Node from a clean slate is probably not the best idea, legacy is different.

If anything the comment on hiring highlights the use of Node being problematic. It's difficult to write robust systems in Node even as a seasoned Node developer.

</comment></comment></comment></comment><comment><USER14> TIL, SVG's can display labels on element hover: [http://cdn.nflximg.com/ffe/siteui/blog/yunong/200mins.svg](http://cdn.nflximg.com/ffe/siteui/blog/yunong/200mins.svg)

Nice, contained way to show data like this.

<comment><USER15> SVGs can contain ECMAScript, video, canvases, animation, all sorts of things. They're the replacement for Flash that nobody seems to use.

<comment><USER16> Well, there was a good reason for that, for a long time: IE didn't even begin to support .svg until version 9, which means that it isn't a realistic option for deployment for anyone who needs to support pre-evergreen browsers.

I investigated them a year or two or so ago, because I found that AngularJS could work quite nicely within an .svg document, which opened up some exciting possibilities. My recollection is that at the time, there were some critical cross-browser problems with font rendering that made the topic very kludgy and complicated. I except that matters have improved since, but I do not know to what extent.

<comment><USER17> And IE still doesn't (nor do they plan to) support declarative animation in SVGs. (SMIL) Someone there decided that script based animation is more robust so they just bypassed that capability. I think it's a terrible idea because you forego having tightly integrated SVG animation modules that can just be dropped in as needed.

</comment></comment></comment></comment><comment><USER18> > ...as well as increasing the Node.js heap size to 32Gb.

> ...also saw that the process's heap size stayed fairly constant at around > 1.2 Gb.

This is because 1.2 GB is the max allowed heap size in v8. Increasing beyond this value has no effect.

> ...It's unclear why Express.js chose not to use a constant time data > structure like a map to store its handlers.

It it is non-trivial (not possible?) to do this in O(1) for routes that use matching / wildcards, etc. This optimization would only be possible for simple routes.

<comment><USER19> That seems like a pretty low size to me... how are people getting around this when they need to handle >1.2GB of data on Node?

<comment><USER20> Native code modules I assume.

</comment></comment></comment><comment><USER12> Sounds like a documentation issue, or lack of a staging environment. I've written and maintained countless large Express applications and routing was never even remotely a bottleneck, thus the simple & flexible linear lookup. I believe we had an issue or two open for quite a while in case anyone wanted to report real use-cases that performed poorly.

Possibly worth mentioning, but there's really nothing stopping people from adding dtrace support to Express, it could easily be done with middleware. Switching frameworks seems a little heavy-handed for something that could have been a 20 minute npm module.

</comment><comment><USER21> I read:

"This turned out be caused by a periodic (10/hour) function in our code. The main purpose of this was to refresh our route handlers from an external source. This was implemented by deleting old handlers and adding new ones to the array"

 _refresh our route handlers from an external source_

This is not something that should be done in live process. If you are updating the state of the node, you should be creating a new node and killing the old one.

Aside from hitting a somewhat obvious behavior for messing with the state of express in running process, once you have introduced the idea of programmatically putting state into your running node you have seriously impeded the abiltity to create a stateless fault tolerant distributed system.

<comment><USER22> When I concluded what they had to be doing and then read the actual confirmation of what they were doing I was somewhat shocked. Why on Earth would you want to programatically recreate the routes in an express app?!?!? It would be really interesting to see a write up on what/why they think this kind of behavior is needed in the first place ....

</comment></comment><comment><USER23> > benchmarking revealed merely iterating through each of these handler > instances cost about 1 ms of CPU time

1ms / entry? What is it doing that it's spending 3 million cycles on a single path check?

<comment><USER24> Running (uncompiled?) regular expressions, it seems.

<comment><USER25> So I was a bit unclear on the parent's post but I don't think this time was on a route lookup if I'm reading the thread and post correctly the static file handler getting inserted multiple times. This handler will generally match on any route but then is doing something like "if file exists, return static file, if not look for the next handler" in this case the "if file exists" part was the "path check" thats taking 1 ms and was happening multiple times.

I could be wrong but it seems like the design of the route lookup mechanism (the global array) was actually a bit of a red herring, the real issue was the ability to attach multiple instances of the same handler to the same route.

 _Something was adding the same Express.js provided static route handler 10 times an hour. Further benchmarking revealed merely iterating through each of these handler instances cost about 1 ms of CPU time._

<comment><USER23> A simple "if file exists" check shouldn't take 1ms on average.

OSes cache directory entries for a reason.

I mean, even Python manages 40,000 checks / second:

      >>> timeit.timeit("os.path.exists(data)", setup="import os; import random; import string; data = os.path.join(r'C:\Windows\System32', ''.join(random.choice(string.ascii_letters) for _ in range(10)))", number=40000)
      0.9998181355403517

</comment></comment></comment></comment><comment><USER26> > I can't imagine how we would have solved this problem without being able to > sample Node.js stacks and visualize them with flame graphs.

This has me scratching my head. The diagrams are pretty, maybe, but I can't read the process calls from them (the words are truncated because the graphs are too narrow). And I can't see, visually, which calls are repeated. They're stacked, not grouped, and the color palette is quite narrow (color brewer might help here?).

At least, I _can_ imagine how you could characterize this problem without novel eye-candy. Use histograms. Count repeated calls to each method and sort descending. Sampling is only necessary if you've got -- really, truly, got -- big data (which Netflix probably does), but I don't think the author means 'sample' in a statistical sense. It sounds more like 'instrumentation', decorating the function calls to produce additional debugging information. Either way, once you have that, there are various common ways to isolate performance bottlenecks. Few of which probably require visual graphs.

There's also various lesser inefficiencies in the flame graphs: is it useful (non-obvious) that every call is a child of `node`, `node::Start`, `uv_run`, etc.? Vertical real-estate might be put to better use with a log-scale? Etcetera, etc.

<comment><USER27> > The diagrams are pretty, maybe, but I can't read the process calls from them > (the words are truncated because the graphs are too narrow).

Flame Graphs provide SVGs by default. You should be able to zoom if your broser supports it. The current version also supports "zooming" in to any frame in the stack, resetting that frame as the base of the display. Also WRT the base frames of 'node' et al its because Flame Graphs are a general use tool for stack visualization, it might be 'main' for a c program or the scheduler looking at a system.

> They're stacked, not grouped, and the color palette is quite narrow (color > brewer might help here?).

Colors by default have no meaning and the palette is configurable. The current lib can also assign colors by instruction count/ipc and width by call count, if you have access to that.

> Sampling is only necessary if you've got -- really, truly, got -- big data > (which Netflix probably does), but I don't think the author means 'sample' > in a statistical sense.

It is sampling. Flame graphs re typically used with something like perf/dtrace/oprofile which dumps stacks at a couple hundred to thousand hertz. Actual call tracing is (typically) not feasible for large/prod stacks.

</comment></comment><comment><USER28>
      > our misuse of the Express.js API was the
      > ultimate root cause of our performance issue

That's unfortunate. Restify is a nice framework too, but mistakes can be made with any of them. Strongloop has a post comparing Express, Restify, hapi and LoopBack for building REST API's for anyone interested. [http://strongloop.com/strongblog/compare-express-restify- hap...](http://strongloop.com/strongblog/compare-express-restify-hapi- loopback/)

</comment><comment><USER29> From the article:

> What did we learn from this harrowing experience? First, we need to fully > understand our dependencies before putting them into production.

Is that the lesson to learn? That scares me, because a) it's impossible, and b) it lengthens the feedback loop, decreasing systemic ability to learn.

The lesson I'd learn from that would be something like "Roll new code out gradually and heavily monitor changes in the performance envelope."

Basically, I think the approach of trying to reduce mean time between failure is self-limiting, because failure is how you learn. I think the right way forward for software is to focus on reducing incident impact and mean time to recovery.

<comment><USER3> Without over-training on this one incident, and without guidance on how to get from here to there (I'm still working on that):

1\. Don't get suckered by interfaces, share code. If you create code for others to share ("libraries"), stop trying to hide its workings.

2\. You don't have to learn how everything works before you do anything. But you should expect to learn about internals proportional to the time you spend on a subsystem. Current software is too "lumpy" \-- it requires days or months of effort before yielding large rewards. The first hour of investigation should yield an hour's reward.

3\. "Production" is not a real construct. There will always be things that break so gradually that you won't notice until they've gone through all your processes. Give up on up-front prevention, focus instead on practicing online forensics. And that starts with building up experience on your dependencies.

More elaboration: [http://akkartik.name/post/libraries2](http://akkartik.name/post/libraries2)

My attempt at a solution: [http://akkartik.name/about](http://akkartik.name/about)

My motto: reward curiosity.

</comment></comment><comment><USER30> My biggest takeaway from this article is that Netflix is moving from Express to Restify, and I look forward to watching the massive uptick this has on [https://github.com/mcavage/node- restify/graphs/contributors](https://github.com/mcavage/node- restify/graphs/contributors)

<comment><USER31> Yes, but their original bug was from dynamically loading routes from an external source. I don't see how Express is to blame for this. Moving to Restify is not a solution, but they state having different reasons for moving (support for bunyan logging? But Express already supports this too).

<comment><USER32> the bug was related to dynamically loading routes, but the true cause was that express allowed duplicate handlers. They were loading routes dynamically correctly, that wasn't a problem, it was that when doing that express let them duplicate routes.

<comment><USER33> That's a feature.

From the API docs:

> Multiple callbacks may be given; all are treated equally, and behave just > like middleware. The only exception is that these callbacks may invoke > next('route') to bypass the remaining route callback(s). This mechanism can > be used to perform pre-conditions on a route, then pass control to > subsequent routes if there's no reason to proceed with the current route.

</comment></comment></comment></comment><comment><USER34> If I had to pick one line to highlight (not to criticize, but was a wise lesson worth sharing) it would be this one:

"First, we need to fully understand our dependencies before putting them into production."

<comment><USER35> In my experience developers constantly overestimate the gain of using a new dependency and underestimate the amount of effort it will take to sufficiently understand it. (Or fail to make the effort, not understanding the risks.)

This is why developers without significant experience should not be making decisions about the tech stack.

</comment></comment><comment><USER36> I would like to mention that Netflix could have consulted the express maintainers (us) but didn't.

Source: myself - [https://github.com/strongloop/express/pull/2237#issuecomment...](https://github.com/strongloop/express/pull/2237#issuecomment-59681175)

</comment><comment><USER37> A surprising amount of path recognizers are O(n). Paths/routes are a great fit for radix trees, since there's typically repetitions, like /projects, /projects/1, and /projects/1/todos. The performance is O(log n).

I built one for Java: [https://github.com/augustl/path-travel- agent](https://github.com/augustl/path-travel-agent)

<comment><USER38> How does your radix trie implementation handle variables in the URL paths, in a nutshell?

<comment><USER37> This is one of the reasons for why I call it a "bastardized radix tree" in the README :)

The routes are stored as "nodes". There's a root node. It has a hash map of child nodes, by name. It also has a list of "parameterized" nodes. When a node gets a path segment, it will first look in its hash map. If nothing is there, it'll call the parameterized nodes in sequence. Typically there's just one parameterized node.

For the following paths:

      /projects
      /projects/new
      /projects/special
      /projects/:project-id

The root node will have a single item in its hash map, "projects". No items in the parameterized node.

The node for "projects" will have to items in its hash map, "new" and "special". It will have a single item in it's parameterized node, for :project-id.

I updated the README just now with a slightly more detailed explanation :)

<comment><USER38> Very cool, thanks for taking the time to explain! I recently learned how tries work so it was cool to see a real-world implementation like yours.

</comment></comment></comment></comment><comment><USER39> tl;dr:

* Netflix had a bug in their code.

* But Express.js should throw an error when multiple route handlers are given identical paths.

* Also, Express.js should use a different data structure to store route handlers. EDIT: HN commentors disagree.

* node.js CPU Flame Graphs ([http://www.brendangregg.com/blog/2014-09-17/node-flame-graph...](http://www.brendangregg.com/blog/2014-09-17/node-flame-graphs-on-linux.html)) are awesome!

</comment><comment><USER40> It's not just the extra lookups -- static in express is deceptively dog-slow. For every request it processes, it stats every filename that might satisfy the URL. This results in an enormous amount of useless syscall/IO overhead. This bit me pretty hard on a high-throughput webservice endpoint with an unnoticed extra static middleware. I wound up catching it with the excellent NodeTime service.

Now that I look at it, there's a TOCTOU bug on the fstat/open callback, too: [https://github.com/tj/send/blob/master/index.js#L570-L605](https://github.com/tj/send/blob/master/index.js#L570-L605)

This should be doing open-then-fstat, not stat-then-open.

</comment><comment><USER41> I am upset that the title has been changed from "Node.js in Flames". Which is not only the real title of the article, but also a reasonable description of what they've been facing with Node.

#moderationfail

<comment><USER42> I can see why you would feel that way, but the title, while clever and (I'll take your word for it) fitting, was arguably misleading and unarguably baity. The HN guidelines call for changing such titles, so the moderators were just doing their job. There likely would have been more complaints about the title if we hadn't changed it.

<comment><USER41> Understood. And thank you for following up, I really do appreciate it.

</comment></comment></comment><comment><USER43> This is the first I've heard of restify, but it seems like a useful framework for the main focus of most Node developers I know, which is to replace an API rather than a web application.

<comment><USER30> You're going to love restify. We use it at TrackIf and can't imagine our API running on anything else. Couple it with Swagger and you won't be looking back :-)

</comment></comment><comment><USER44> > This turned out be caused by a periodic (10/hour) function in our code. The > main purpose of this was to refresh our route handlers from an external > source. This was implemented by deleting old handlers and adding new ones to > the array. Unfortunately, it was also inadvertently adding a static route > handler with the same path each time it ran.

I don't understand the need of refreshing route handlers. Could someone explain they needed to do this, and also why from an external source?

<comment><USER45> We refresh periodically as we dynamically deploy new UI code, which can be accessed at new routes. (/home and /homeV2 for example) This allows us to not have to restart our servers or push out new server code just to serve a new UI at a different (or the same) route.

</comment></comment><comment><USER46> The express router array is pretty easy to abuse, it's true. For example, as something you probably shouldn't ever do:

[https://www.exratione.com/2013/03/nodejs-abusing- express-3-t...](https://www.exratione.com/2013/03/nodejs-abusing-express-3-to- enable-late-addition-of-middleware/)

I guess the Netflix situation is one of those that doesn't occur in most common usage; certainly dynamically updating the routes in live processes versus just redeploying the process containers hadn't occurred to me as a way to go.

</comment><comment><USER47> Responses are already firing in: [https://news.ycombinator.com/item?id=8632220](https://news.ycombinator.com/item?id=8632220)

</comment><comment><USER48> I love these kinds of investigations into problems in production. I mean, you really have to admire their determination in getting to the root of the problem.

In some ways, these engineers are not that different from academic researchers, in that they are devising experiments, verifying techniques, all in the pursuit of the question: why?

</comment><comment><USER49> I would have written my apis in golang and not nodejs. Go is way faster in my experience and it feels leaner to create something because creating a web service can be productively doneout of box. Node apps tend to depend on thousands of 3rd party dependencies which makes the whole thing feel fragile to me.

</comment><comment><USER50> Would someone explain what I'm missing about the flame graphs? Why are they indispensable here? In a normal profiler, you'd just expand the hot path and see what had the most samples. Apart from making recursion very explicit, what special aspect do flame graphs expose?

</comment><comment><USER51> Why are they loading in routes from an external source? Is that normal, I have never seen that before.

<comment><USER45> We like the option of dynamically loading new routes, that point to new endpoints. We also have the ability to release new versions of our UI without redeploying (or restarting) our servers.

<comment><USER51> Ok you add a new route but how do you reference what code should be executed when that route is hit?

<comment><USER45> We have something that loads up, via requires, the action (or route) that should be run when a URL is encountered.

<comment><USER51> Second dmak, would love to understand more. I can following dynamically loading routes but can't follow how that would be implemented end to end. Some things I would be interested in: \- Where do the keep the code that gets executed for new routes? Is that deployed dynamically as well? \- If you are changing routes dynamically how do you test in non-prod, are you constantly syncing non prod with prod? \- How do you control what you deploy dynamically vs what you migrate through the environments?

</comment></comment></comment></comment></comment><comment><USER52> Interesting article. I have a lot of experience dealing with ETLs in WPA on the Windows side - it's an awesome tool that gives you similar insights. I haven't used it for looking at javascript stacks before though, so I don't know if it'll do that.

</comment><comment><USER53> > We also saw that the process's heap size stayed fairly constant at around > 1.2 Gb.

> Something was adding the same Express.js provided static route handler 10 > times an hour.

Why didn't it increase the heap size? Maybe it was too small to be noticeable?

</comment><comment><USER54> _Second, given a performance problem, observability is of the utmost importance_

I couldn't agree with this more. Understanding where time is being spent and where pools etc. are being consumed is critical in these sorts of exercises.

</comment><comment><USER55> So the lesson is to actually know the code you deploy to prod? Is that not obvious?

<comment><USER56> Your webserver, your dns resolver, your database, your operating system, the compilers they used, how about the bios, or the northbridge

</comment></comment><comment><USER57> NodeJS Project has already a similar issue about recursive route matching.

[https://github.com/strongloop/express/issues/2412](https://github.com/strongloop/express/issues/2412)

</comment><comment><USER58> Doesn't this seem like a bug in the express router? All of the additional routes in the array are dead (can't be routed to).

<comment><USER59> No, because the route list is also used for middleware. The recursive search is because middleware routes have a third next parameter that allows the search to run asynchronously.

</comment></comment><comment><USER60> I wonder how Netflix would perform with using Dart with the DartVM. I reckon it would be faster than Node based on benchmarks I've seen. Chrome DartVM support is right around the corner ;)

</comment><comment><USER61> Crazy talk. In 1ms, I can perspective transform a moderately big image. NodeJS cant iterate through a list.

We really need a 60 fps equivalent for web stuff. You have 16ms, thats it.

<comment><USER4> FWIW, a lot of the stuff the Chrome+Polymer team is working on explicitly has a 60fps goal and 16ms frame budgets. I remember in my last project at Google, I spent a lot of time working with the Chrome team to get various parts of websearch rendering under the 16ms budget. (I couldn't manage it given the amount of legacy code we had to work with, but various other people have continued the work since I left, so hopefully they've had more luck.)

</comment></comment><comment><USER62> I must admit I could enjoy just doing this type of analysis all day long. Yet I hate non computing puzzles.

</comment><comment><USER63> wow. I love that Netflix us using Node and even more curious that they would use express.

</comment><comment><USER64> this is why you stick to tried and true methods folks. this is such a typical node.js fanboy mentality. "reinventing the wheels is justified because asynchronous". or "i want this trendy way to do things just because everyone else is jumping on the bandwagon".

Give me flask + uwsgi + nginx anyday.

<comment><USER65> In the end of the day Node.js is just a Reactor Pattern implementation in a form of bunch of scripts.

</comment></comment><comment><USER66> an unfortunate title. Ha ha "flames" ha ha "Node.js" but the article is really about express. Not so "ha ha"

<comment><USER67> They renamed it "in flame graphs."

For the audience, this was originally titled: "Node.JS in Flames"

</comment></comment><comment><USER68> A very good reason to go with express is TJ. He was the initial author of express and he is quite brilliant when it comes to code quality. Of course, TJ is no more part of the community but his legacy lives :-)

</comment><comment><USER69> OFFTOPIC: "Today, I want to share some recent learnings from performance tuning this new application stack."

The word you want is "lessons".

<comment><USER70> "learnings" is a perfectly cromulent word: [https://books.google.com/ngrams/graph?content=learnings&year...](https://books.google.com/ngrams/graph?content=learnings&year_start=1700&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Clearnings%3B%2Cc0)

<comment><USER69> Nope. You see an option for a plural here? [http://www.merriam- webster.com/dictionary/learning](http://www.merriam- webster.com/dictionary/learning)

<comment><USER71> Dictionaries are _descriptive_ , not _prescriptive_. They can only tell you if something _is_ a word, not whether something _isn 't_ a word.

<comment><USER69> Well certainly there is no law against using made-up words. If that's what you want to do, have at it.

At least it will help people get their buzzword bingo cards filled up sooner.</comment></comment></comment></comment></comment>


MeARKET beta - <AUTHOR> http://www.mearket.com/ <comment><AUTHOR> If, perchance, the team behind this happens to read my comment: I wish I didn't have to give so much permissions to your app on my [Facebook|LinkedIn|Twitter] account just to request an invite. That being said.. I'm interested, but would love to see more about your service.</comment>


KaTeX: Math typesetting for the web - <AUTHOR> http://khan.github.io/KaTeX/ <comment><USER2> Heavy mathjax user here. Couple of use cases I'd love to know more about:

\- does KaTeX work pretty reasonably across the platforms? The simplest way I figured out for rendering math notation in-app on mobile devices was through web views + mathjax. E.g. say I wanted to use it in a web view in iOS or Android, would it work as intended? MathJax comes by default with a giant folder of various fonts / ways of rendering, what's the KaTeX story for this?

\- would KaTeX work just fine in a headless environment? e.g. say I'm using [http://wkhtmltopdf.org/](http://wkhtmltopdf.org/) to generate PDF from some HTML

\- how does KaTeX compare to MathJax from a payload size? Mathjax takes quite a bit to load from basic connections even though you have to cache it only once.

<comment><AUTHOR> We try to test in lots of different environments, so it should work reasonably in most environments. To get the speed we wanted, we had to ditch much older browsers (we don't support IE 7 and earlier), and we only render to HTML/CSS, not things like MathML. However, we're so far very happy with the look of the math in the environments we've tested.

KaTeX works great in a headless environment. You can even do server side rendering if you want a browserless environment which can serve up straight HTML with no JS.

Both KaTeX and MathJax's biggest slowdown is the font loading. However, since KaTeX's CSS can be included manually (instead of letting MathJax put it in the DOM after load) it should load a little faster.

Also, looks like your use cases are similar to ours at Khan Academy! We've been struggling with MathJax on slow computers and iPads for a while, which is why we made this. Let me know if you want more info!

<comment><USER2> We actually work in the same space you guys do :)

We're all dealing with having to display more complex math to students once you get past 5th grade in the Common Core, also on web and iPads. Appreciate you folks taking the time to release something like this to the public. People haven't been hounding us down because of the slow UX yet, but I can see that happening down the line. I'm hoping we can open source some of our tools as well once we're your size :)

My only other question was: is KaTeX 100% interchangeable with MathJax as far as syntax goes? What I'm asking is if we already have a lot of content written for MathJax, will we need to massage it into a new syntax or should it work for the most part?

<comment><AUTHOR> The syntax will be almost entirely interchangable with MathJax; we also have a lot of content in MathJax-flavored-TeX and need it to work. However there are a couple small things that MathJax did strangely that we'd like to fix.

However, there are some features we don't support yet, notably environments (with \begin/\end) and some symbols. If you're using more advanced features, you might hit some snags. If you're trying to do something simple and it's not working, feel free to submit an issue on github, we'll see what we can do for you.

</comment></comment></comment></comment><comment><USER3> A great idea would be that when you copy a math expression from the browser, it would put the LaTeX code in the copy-paste buffer:

      f(x) = \int_{-\infty}^\infty
        \hat f(\xi)\,e^{2 \pi i \xi x}
        \,d\xi

So then I could paste it in an email, in a text editor, in my own LaTeX document, etc.

<comment><USER4> I recently discovered this works in wikipedia,i.e. if copying the first rendered formula in a page[0] I get latex code.

Not sure if it's just the alt text.

[0] Try [http://en.wikipedia.org/wiki/Axiom_of_choice](http://en.wikipedia.org/wiki/Axiom_of_choice) and you get \forall X \left[ \emptyset \notin X \implies \exists f \colon X \rarr \bigcup X \quad \forall A \in X \, ( f(A) \in A ) \right] \,.

<comment><USER5> That's just the alt text.

</comment></comment></comment><comment><USER6> I'm curious: why does this work so much better than MathJax? What's the technical "secret sauce" that makes this tick? I was looking for that on the site and in the README, but it doesn't seem to have any explanation as to the tricks that make up KaTeX.

<comment><AUTHOR> There's no real "secret sauce", it's mostly just "do things smart". For example, while MathJax tends to do a bunch of calculations about exact positions of where different characters should go, KaTeX manages to get away with offloading most of that into the CSS, so the native CSS renderer can handle it.

MathJax also does strange things involving inserting elements into the DOM to look at metrics that it uses in its calculations, then removing them, which takes a lot of time. We make sure that the same input is rendered the same every time, and try to make sure it looks good everywhere (there are a couple cases where we aren't the best at this, mostly because browser font rendering isn't great).

We also support less environments than MathJax, for example we only support HTML+CSS output (for now, though MathML is in the works for accessibility reasons), whereas MathJax supports HTML+CSS, SVG, MathML, and older browsers like IE 6. This means it can't rely on things like good CSS rendering like we do. It's a worthwhile tradeoff for us, because we can make ours so much faster, but it is a tradeoff.

</comment></comment><comment><USER7> I have been incredibly impressed with Khan Academy's output and how engaged my kinder-gardener has been with it. The site keeps improving as we continue to visit it, and I am happy to see so many repositories up on github!

</comment><comment><USER8> Is there support for matrices?

Neither

        \begin{bmatrix}
        a & b \\
        c & d
        \end{bmatrix}

nor

        \begin{array}{ccc}
        a & b & c \\
        d & e & f \\
        g & h & i
        \end{array}

works.

<comment><USER9> Doesn't look like it:

[https://github.com/Khan/KaTeX/wiki/Function-Support-in- KaTeX](https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX)

<comment><USER8> Sad. I mean, for sure blazing speed needs some limitations, but I use a lot of matrices in my stuff.

</comment></comment></comment><comment><USER10> Ben Alpert, Emily Eisenberg and the Khan Academy team never ceases to amaze me. This is a great MathJax replacement in the making.

</comment><comment><USER11> MathML, MathJax and now KaTeX

Not that there isn't a usecase for this, but is this fully MathJax compatible?

<comment><AUTHOR> We're not compatible yet, but we're working on it! In the meantime, you can fallback to MathJax on things we don't support. That way, most things can be rendered fast, and anything super complicated gets special treatment. We'll be releasing something soon on how to do this, and if you use React you can use the KA TeX component: [http://khan.github.io/react- components/#tex](http://khan.github.io/react-components/#tex)

<comment><USER11> So is your goal to be a faster MathJax-compatible alternative? We currently use MathJax, but there's definitely a need for faster rendering. As an example, we sometimes run a page load through wkhtmltopdf, and MathJax content can take a LONG time

EDIT: Thanks for replying to my comment in spite of the downvotes

<comment><AUTHOR> Yep, that's our goal. Khan Academy does a bunch of math rendering, and our exercises were suffereing because of it. Hopefully some time we'll be able to stop using MathJax.

<comment><USER11> Well you've convinced me. I'm gonna go ahead and download it now and try to use it everywhere MathJax is used. If it works with what we have I might be able to sell this to my bosses

<comment><AUTHOR> Sounds great! If you have any problems, feel free to report issues on github, or join the #katex room on freenode.

</comment></comment></comment></comment></comment></comment><comment><USER12> What choices did you make that make KaTeX faster than MathJax? (i.e. 'how is it done?')

<comment><AUTHOR> There's a lot of choices. We support a smaller subset of browsers and outputs (only IE8+, only HTML+CSS, no SVG), so we gain some speed there. We also try to push as much of the calculation into CSS as possible, so that the native browser does as much work as possible, instead of the javascript. MathJax does a lot more manual positioning.

</comment></comment><comment><USER13> Is there support for alternate math fonts (not sure what the proper term is) like \mathbf, \mathcal, \mathbb? Couldn't get it working. Looks fantastic though.

<comment><AUTHOR> There isn't yet, but we're working on it! We have the fonts ready, just haven't added those functions yet. Could you make an issue on the github page so we make sure we don't forget?

<comment><USER13> Will do right now.

</comment></comment></comment><comment><USER14> Related: KaTeX on Gitter [https://news.ycombinator.com/item?id=8324991](https://news.ycombinator.com/item?id=8324991)

</comment><comment><USER15> Looks great! Will KaTeX support (c.q. integrate with) ASCIIMathML.js¹,²? AsciiMath is dubbed "TeX without backslashes", or as "markdown for math".³ (La)TeX input can become laborious, and the syntax gets difficultly readable, very rapidly.

With AsciiMath syntax⁴ (and Unicode!⁵) you can write δA instead of `\delta A`, ½ instead of `\frac{1}{2}`, ((a,b),(c,d)) instead of `\begin{pmatrix}a & b \\\ c & d \end{pmatrix}`, &c.

¹ [http://en.wikipedia.org/wiki/ASCIIMathML](http://en.wikipedia.org/wiki/ASCIIMathML) ² [http://www.asciimath.org](http://www.asciimath.org) ³ [http://boolesrings.org/krautzberger/2014/08/10/asciimathml-t...](http://boolesrings.org/krautzberger/2014/08/10/asciimathml- to-the-rescue) ⁴ [http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.html](http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.html) ⁵ [http://www.johndcook.com/math_symbols.html](http://www.johndcook.com/math_symbols.html)

<comment><AUTHOR> We won't support ASCIIMath yet. There's a lot of content on the web already in LaTeX syntax (and on our own website), and a lot of people already know it. It is difficult to use and read, but it gets the job done. Maybe once we've gotten all of the core LaTeX features done, we'll start looking to this. Thanks for the info, though!

<comment><USER16> yes, would love asciimath support. most of the math that'll exist on the web isn't there yet, and it'll be so much easier to the next billion internet users than learning latex.

katex looks great though. we (socratic.org) might start using it if we can find a good asciimath=>latex converter.

<comment><USER17> Check out [https://github.com/mathjax/asciimathml/blob/master/asciimath...](https://github.com/mathjax/asciimathml/blob/master/asciimath- based/ASCIIMathTeXImg.js). It uses the AsciiMath parser to generate latex to be fed into mimetex for rendering, but it could probably be daisy-chained with katex. I keep it current with the latest AsciiMath revisions.

<comment><USER18> I created such a daisy-chained page that uses ASCIIMathML input with KaTeX rendering where possible, and it falls back to MathJax when KaTeX can't handle the expression. See

[http://www.intmath.com/cg5/asciimathml-katex- mathjax.php](http://www.intmath.com/cg5/asciimathml-katex-mathjax.php)

</comment></comment></comment></comment></comment><comment><USER19> I wish there was an entire LaTeX-like templating language. Not just the math typesetting; the typesetting is, for the most part, raw TeX.

Markdown is very deficient in, say, organizing a blog post in several sections and subsections. There's formatting syntax, but not semantic syntax. No support for different styling at a higher level (in the template renderer); no support for generating indexes, footnotes.

(The state of footnotes on the web in 2014 is lamentable).

All these valiant efforts in having portable math typesetting that like to make puns with "LaTeX" fall regrettably short of enabling one to make a short blogpost detailing a mathematical curiosity, or even heavily-referenced semi- scholarly output. LaTeX is a template engine that happens to leverage a programmable typesetter. We have a programmable typesetter with modern JavaScript, can we focus on semantic templating already?

<comment><USER20> If only we had some sort of standard, perhaps XML based syntax which is both standardised and well supported cross-browser, doesn't need JavaScript except for a few enhancements as and when it's needed.

</comment></comment><comment><USER21> I may be the odd man out, but especially for the case where I modify a small part of an expression I like MathML because those small parts can be uniquely identified and altered without altering or reformatting the rest of the expression. MathJax supports MathML, so this is possible with MathJax.

For example, the event handler that updates r at the bottom of this page: [http://www.vizitsolutions.com/portfolio/gausslaw/](http://www.vizitsolutions.com/portfolio/gausslaw/) does not know anything about the expression as a whole, it only knows to update elements with a certain class with the new r value.

Of course I will take a look at this and see how it works for my content. It seems though, that this would be a case of interest to Khan Academy as it is comparatively common in instructional material.

<comment><AUTHOR> We don't use features like this at Khan Academy. However, most of the time the problems with MathJax were with the inital problem load, not with changing expressions later. It might be interesting to support something like that eventually! Let me know how it works for you.

</comment></comment><comment><USER22> Are there any plans for an interactive equation editor supported by KaTeX? I think this is something the web is missing. I've been following the MathJax dev google group, and it seems like there aren't any solid plans for them to implement this feature.

Some examples:

My attempt: [http://camdenre.github.io/src/app/html/EquationEditor](http://camdenre.github.io/src/app/html/EquationEditor)

Mathway: [https://www.mathway.com/](https://www.mathway.com/)

Mathjq: [http://www.mathjq.com/math-editor/](http://www.mathjq.com/math- editor/)

It would be nice to have something officially supported by a large project. I think that there is a lot of potential on the web for interactive math lessons with symbolic input using a CAS (not multiple choice).

<comment><AUTHOR> There aren't any plans at the moment. We've struggled with this problem before, and wrote something similar with [https://github.com/khan/KAS/](https://github.com/khan/KAS/) but we've never worked at doing something inline. We use MathQuill in a couple places, which does the input decently (writing works, but typing something like x^2_2 gives you x^{2_2} not x^2_2), but the output doesn't look great. It's hard to do what the user wants, have clickable bits, and still have good looking output.

<comment><USER23> I recently made this little tool for writing latex macros: [http://kasperpeulen.github.io/PressAndHold/](http://kasperpeulen.github.io/PressAndHold/) It works the same as the OSX press and hold accent picker. I have also a unicode version which I think is much more appealing for young mathematicians: [http://kasperpeulen.github.io/PressAndHold/Unicode/](http://kasperpeulen.github.io/PressAndHold/Unicode/)

All MIT licensed if you are interested in using it.

</comment></comment></comment><comment><USER24> This is great news for server-side tex rendering. Valiant efforts on behalf of projects like svgtex ([https://github.com/agrbin/svgtex](https://github.com/agrbin/svgtex)) notwithstanding, MathJax is abysmal for pre-rendering content.

</comment><comment><USER25> Did Mathjax just become obsolete?

<comment><AUTHOR> Not quite yet, but we're working on it. There are some significant features that KaTeX doesn't yet support, but we're working to add them in the near future.

In the meantime, you could use our TeX React component to use KaTeX when possible, and fall back to MathJax only when necessary: [http://khan.github.io/react-components/#tex](http://khan.github.io/react- components/#tex)

<comment><USER26> Sorry to tl;dr your code, but how exactly is it based on TeX? Do you actually run Knuth's TeX code to make this work, or did you reimplement it?

Also, kind of irrelevant, do you think we'll ever get something better than (La)TeX syntax? I've been frustrated by obscure error messages from LaTeX in big documents because it's a macro language, so the interpreter doesn't actually see what you're typing. How does KaTeX handle errors?

<comment><AUTHOR> We reimplemented the TeX formatting algorithms in JavaScript. Most of them are in [https://github.com/Khan/KaTeX/blob/master/src/buildTree.js](https://github.com/Khan/KaTeX/blob/master/src/buildTree.js) (there are references to the pages from the TeXbook that the algorithms are on).

Also, we attempt to have relatively good error handling! If you open up the javascript console on the main page and type in a bad expression, you can see what the errors we throw look like. We're not planning on supporting anything other than LaTeX syntax for now though, unfortunately.

</comment></comment></comment></comment><comment><USER18> You may be interested in my setup that accepts ASCIIMathML, converts it to LaTeX, delivers it by KaTeX where possible and falls back to MathJax when necessary.

Here it is: [http://www.intmath.com/cg5/asciimathml-katex- mathjax.php](http://www.intmath.com/cg5/asciimathml-katex-mathjax.php)

Here's how it was done: [http://www.intmath.com/blog/katex-with-asciimathml- input-and...](http://www.intmath.com/blog/katex-with-asciimathml-input-and- mathjax-fallback/9456)

</comment><comment><USER27> I love this. One question: how much emphasis was put on security? Can I safely let the users of my website input any string and feed it directly to the render function?

<comment><AUTHOR> We never do any unsafe dom manipulations, like using .innerHTML, only createElement and appendChild, so things should be fairly safe. Also, if you do server-side rendering, we escape code that users type in, so that should work well also.

</comment></comment><comment><USER28> I'm wondering how heavy the server-side rendered version is. I assume you don't have to load the JS file anymore for that one, but you still need the CSS and the fonts. Is there an estimate on how large those are in total?

How large is the performance difference between the server-side rendered version and the JS version?

</comment><comment><USER29> Props to the coders for improving upon the LaTeX/Web use case space, but I can't help but feel something other than LaTeX is going to be necessary for the internet. LaTeX was fundamentally about document-level typesetting, and the internet is fundamentally not a place where that happens.

<comment><USER30> I suppose by "internet" you mean "web" and in particular the fundamental problem you see is that LaTeX assumes the input contains everything needed for the final output, whereas hypertext on the web can be remixed in an open-ended way? I.e., it's hard to get pleasing results out of a process of composition of disparate LaTeX sources?

Otherwise could you clarify the conflict you have in mind?

<comment><USER29> Minimal example: LaTeX embedding as practiced on the web doesn't reflow. TeX was intended for documents that knew their width, height, margins and etc.; no guarantees in a web page.

</comment></comment></comment><comment><USER31> I wish this effort was put into browser engines' MathML support, so that math could be interoperably declarative like text (HTML) and vector graphics (SVG).

If you don't see the value in browser built-in features, consider how badly the upgrade to retina worked with JS+canvas compared to SVG.

</comment><comment><USER32> Are you also using the STIX fonts? If yes: I am working on a web application which downloads those STIX fonts anyway, can I point KaTeX to use my already downloaded fonts instead of downloading its own?

<comment><AUTHOR> Unfortunately, we're not. We might support that in the future though.

<comment><USER32> Very cool anyway. Because you are just using CSS instead of the DOM trickery of MathJax I should still be able to use it for my purposes.

<comment><USER33> Even though we're using CSS as much as possible, we do need the character metrics in order to do positioning properly. (For example, $x^2$ and $F^2$ differ in the vertical position of the 2.) You'll need to update these metrics to use it with a different font -- see

[https://github.com/Khan/KaTeX/blob/master/src/fontMetrics.js](https://github.com/Khan/KaTeX/blob/master/src/fontMetrics.js)

and the "make metrics" Makefile rule. We haven't added the ability to swap font metrics at runtime or to easily build a version with different metrics but I'm not opposed to the idea.

</comment></comment></comment></comment><comment><USER34> Any benchmarks against MathJax beyond the visual at the bottom of the page?

<comment><USER35> They have a benchmark page, where you can benchmark for yourself: [http://jsperf.com/katex-vs-mathjax](http://jsperf.com/katex-vs-mathjax)

<comment><AUTHOR> Yep! Also, ignore the IE 8 data on that page, there was a fluke with IE 8's .innerHTML. You can see [http://jsperf.com/katex-vs- mathjax/2](http://jsperf.com/katex-vs-mathjax/2) for a version that IE 8 supports.

</comment></comment></comment><comment><USER36> This looks really nice. Are there any handwriting recognition projects for being able to write on a wacom tablet that could output to a format like this?

That was always my dream when doing homework at the university.

<comment><USER37> Microsoft has "Math Input Panel" built into Windows 7. It does not create LaTeX output and it is far from perfect, but it does allow you to write down an equation which is then typeset quite nicely.

[http://windows.microsoft.com/en-us/windows7/use-math- input-p...](http://windows.microsoft.com/en-us/windows7/use-math-input-panel- to-write-and-correct-math-equations)

</comment></comment><comment><USER38> Is there an wysiwyg equation editor that can produce the code for this? Would be interested in adding equations to our product but our users wouldn't be familiar with TeX.

<comment><USER39> The third-party program MathType ([http://www.dessci.com/en/products/mathtype/](http://www.dessci.com/en/products/mathtype/)) is an GUI math editor that can export to LaTeX. It costs $97 for end-users though. I think it supports embedding math objects in arbitrary third-party programs, since both Microsoft Word and Apple Pages support that.

</comment></comment><comment><USER40> Not bad, but MathJax is also pretty fast:

[https://trinket.io/latex/788599bf30](https://trinket.io/latex/788599bf30)

<comment><USER41> On my machine at least, the KaTeX demo is considerably faster.

This is very useful for big math threads like often on terrytao.wordpress.com, which can take up to a minute to render in my browser. On mobile it's even worse.

<comment><USER42> Do you have any handy pointers to particularly long threads on terrytao or elsewhere?

</comment></comment></comment><comment><USER43> Any plans to support equation numbering (like MathJax) and \eqref? I didn't see this in any of the examples or docs.

<comment><AUTHOR> This is definitely a goal for the future. Eventually we'd like to support everything that MathJax does (and maybe more!) Equation numbering involves more work than some of the other features (we've managed to get away with never calculating widths of elemnts, but we'd have to do that to get horizontal alignment working, we think), so we're pushing it back for now.

</comment></comment><comment><USER44> Any plans on adding support to \newcommand and \newenvironment?

</comment><comment><USER45> Just wonder if anybody already tried to implement web2js.

</comment><comment><USER46> works instantly on mobile! are there demo pages with more latex, for a tougher test?

</comment><comment><USER47> No xy support yet...

<comment><AUTHOR> I've never heard of this before, could you let me know what it is?

<comment><USER48> Probably: [http://www.ctan.org/pkg/xypic](http://www.ctan.org/pkg/xypic)

Support for tikz would be great, too.

More broadly: great project! Looks to bring us closer to the day when math on the web is easy and just works.

If you don't mind me asking, can you say why you didn't work with MathJax, and decided to start over?

<comment><AUTHOR> Ah. Yes, the diagram generating libraries are harder to implement. Since we don't actually implement the primitives that TeX uses, we can't just import libraries like xypic or tikz wholesale, we'd have to rewrite them from scratch. Maybe a project for when we've got most of the actual math working.

As for why we didn't work with MathJax, this started out as more of an internal project for making our own math fast, and has slowly built up to what we have today.

We also didn't think that we could get the speed we wanted while still supporting all of the obscure features MathJax does (like SVG rendering).

</comment></comment></comment></comment><comment><USER49> was mathjax not fast enough?

</comment><comment><USER50> Is it just me or is the style of this website a rip off of writelatex.com?

Edit: I guess I hit a nerve then.

<comment><USER33> I didn't design the KaTeX site (but I implemented it), and I hadn't seen writelatex.com before. Honestly, I don't see much resemblance other than the fact that both are green.</comment></comment>