Why are online comments so negative while product reviews are so positive? - <AUTHOR> http://akinokure.blogspot.com/2010/02/why-are-online-comments-so-negative.html

<comment><USER2> It's pretty simple. You bought a product. If it's a good product, you are smart because you chose it. If it sucks, you're the sucker who got duped. Therefor, there's an incentive to think that things you own are better than they really are. There's a real name for this, but I can't remember what it's called.

Take a look at Craigslist whenever you'd like some more examples.</comment>


TensorFlow can now run on £12 edge hardware - <AUTHOR> https://techerati.com/news-hub/tensorflow-can-now-run-on-12-edge-hardware/ <comment><USER2> "Cortex M4 processor is extremely low power, using less than 1 MW in many cases"

Talk about low standards. Data centers run into megawatts but I expect more power efficiency from embedded processors. (Why do articles so frequently mix up milli (m) and mega (M) like this? I get that it's just capitalization but they teach this in science classes, right?)

<comment><USER3> It's probably a typo. Easy to make when you've just been saying M4 a few words earlier.

<comment><USER4> Perhaps. Articles like this also frequently say "PC and MAC".

<comment><USER3> Ah yes, Media Access Control is my favorite operating system.

<comment><USER5> You never know, maybe they meant Mandatory Access Control.

<comment><USER6> Medium Attachment Cable.

<comment><USER7> MAC and Cheese

</comment></comment></comment></comment></comment></comment></comment><comment><USER8> "the model takes up only 20KB of flash storage space, the footprint of the TensorFlow Lite code just 25KB, and the app itself only 30KB of RAM."

Those guys on google and outside google surely worked hard to achieve this level of benchmark!

</comment><comment><USER9> Would be interested to hear how the most recent TFlite stacks up against ArmNN running the same model. ArmNN will run TF, TFlite, or caffe models and is built (by Arm) for speed on Arm hardware

<comment><USER10> Benchmarks about mobile NN frameworks : [https://github.com/XiaoMi/mobile-ai- bench](https://github.com/XiaoMi/mobile-ai-bench) , not sure it contains ArmNN, but it's a start and you could open an issue about it maybe

</comment></comment><comment><USER5> Actually you don't need the $15 Sparkfun Edge as STM32F103 boards can also be used [0], and you can have them for $3 (probably even less).

[0] [https://github.com/google/stm32_bare_lib](https://github.com/google/stm32_bare_lib)

<comment><USER11> the F means it has native floating point, right?

<comment><USER12> Nope, STM32F3 family and higher has it, though (Cortex-M4f)

[https://en.m.wikipedia.org/wiki/STM32#Overview](https://en.m.wikipedia.org/wiki/STM32#Overview)

<comment><USER11> They got tensorflow working without floating point!?

</comment></comment></comment></comment><comment><USER13> If you're interested in bringing deep learning to edge hardware, I'd suggest looking at XNOR nets:

[https://allenai.org/plato/xnornet/](https://allenai.org/plato/xnornet/)

</comment><comment><USER14> Here's Pete demonstrating / talking about it too: [https://youtu.be/bDZ2q6OktQI?t=6922](https://youtu.be/bDZ2q6OktQI?t=6922)

</comment><comment><USER11> The dev board: [https://www.sparkfun.com/products/15170](https://www.sparkfun.com/products/15170)

</comment><comment><USER15> How long would it take one of these boards to run e.g. Google's Inception v4 network?

In other words, how would this hardware compare in these benchmarks: [https://www.tensorflow.org/lite/performance/benchmarks](https://www.tensorflow.org/lite/performance/benchmarks)

</comment><comment><USER16> Title should really say TensorFlow _Lite_.

Training a model on £12 hardware would be really something.</comment>


Ask HN: Why do so many people want to see Tesla fail? - <AUTHOR> Tesla articles have been blowing up this week, and with good reason. The only thing I'm wondering is why are there soooooo many people that want to see Tesla fail? <comment><USER2> People who short Tesla stock have become an industry. Tesla is a volatile stock and they've made seriously good money on the dips.

So they have a vested interest in amplifying all bad news about Tesla. At times as some have commented Elon has been his own worst enemy.

It's messy but he's inventing the future with Tesla and SpaceX. I've got a friend with a brand new Tesla. He took bets a while back on when the first fully self driving car would be available. This week he drove on our town's main artery, Grand River avenue, from Dusty's Cellar in Okemos to Biggby's Coffee in East Lansing. There are many signal lights, varying speeds with MSU students dashing out in front of you. He drove the entire 3.9 mile stretch with one finger on the steering wheel to prove a point.

I guarantee you without Elon Musk's efforts to save Tesla this future would have arrived many years later. If that doesn't get you excited likely nothing will.

Just sorry my Dad who first had his drivers license in 1930 didn't live to see it.

<comment><USER3> > People who short Tesla stock have become an industry. Tesla is a volatile > stock and they've made seriously good money on the dips. So they have a > vested interest in amplifying all bad news about Tesla.

Sounds like Ken Lay at Enron. He continued to blame shorts and the media even after bankruptcy and criminal conviction.

Enron wanted to convince people they were a low-risk cleaner-energy (natural gas) company. In reality, they were a high-risk trading venture, whose losses in non-trading business were covered up by trading gains. When they stopped making money on trading, everything fell apart in a matter of weeks.

> He drove the entire 3.9 mile stretch with one finger on the steering wheel > to prove a point.

That's a very short distance. It is odd that Tesla doesn't report testing miles to California's DMV like every other self-driving venture. Waymo is at about 1 driver takeover per 10,000 miles. Tesla is nowhere near that, probably more like 1 takeover every 5 miles.

Odder still is Elon declining to release data backing up his statement that driving with AP on is twice as safe as driving with it off [1]. In his words,

> "I think reporting the details just gives those who are opposed to Tesla > that might data mine the situation and try to turn a positive into a > negative, ... so we're going to keep reporting the numbers at a broad > brushstroke level"

In other words, he won't release data backing up his statement about AP being twice as safe because he thinks some people will use that data to show his statement is wrong.

[1] [https://www.youtube.com/watch?v=HqvatzjHGyk&t=47m17s](https://www.youtube.com/watch?v=HqvatzjHGyk&t=47m17s)

<comment><USER4> > Waymo is at about 1 driver takeover per 10,000 miles. Tesla is nowhere near > that

2 Questions:

1) Anyone know what Tesla is at for km/takeover?

2) Is Waymo still testing inside tightly limited zones? If so I kinda feel this is unfair to compare controlled zone vs nationwide wherever customers choose.

<comment><USER3> 1) Tesla does not report their numbers, though one person who went for a ridealong in the autonomy day demo reported one takeover in 20-minutes [1], so at least once every 10 miles.

2) Waymo does testing on a lot of types of roads. They reported 1.26 million miles in CA last year [2]. It's not possible to apples-to-apples compare this to Tesla's numbers because Tesla does not share their data. Musk even turned down an analyst's request the other day for details backing up his claim of autopilot safety [3].

Tesla/Musk are being unreasonable when they claim stats show their system is 40% safer or 2x safer than normal driving because they are comparing to NHTSA stats which include all classes of cars (including motorcycles), all road types (whereas AP is mainly used on divided highways), and all weather conditions (nobody activates AP in the snow, I hope, and I doubt many do in rain).

[1] [https://youtu.be/2BZHXh1nbWc?t=450](https://youtu.be/2BZHXh1nbWc?t=450)

[2] [https://medium.com/waymo/an-update-on-waymo- disengagements-i...](https://medium.com/waymo/an-update-on-waymo- disengagements-in-california-d671fd31c3e2)

[3] [https://www.youtube.com/watch?v=HqvatzjHGyk&t=47m17s](https://www.youtube.com/watch?v=HqvatzjHGyk&t=47m17s)

</comment></comment></comment></comment><comment><USER5> Elon Musk is brash, impulsive, and overly self-confident. These qualities are what make some people follow him with a cult-like dedication, but they make many others want to see him fail.

Personally I don't care about all that. He's not a great person. He's a bit obnoxious. But I think that from a purely technological standpoint, Tesla is having an important positive impact on civilization. So I want to see it succeed despite Musk (and despite his best attempts in recent months to bring it all crashing down).

<comment><USER6> Elon can be obnoxious- I cannot, you cannot, everyone you know should not. We all know obnoxious people and none of them currently are walking around landing rockets on earth are they? When they also do something as such, they can be obnoxious too. I think people being critical of Elon for being obnoxious - are actually obnoxious and are missing the big picture for personal traits of one of the greatest inventors of our lifetime. How about- Sit the fahk down and have popcorn while your car drives you to work while you (and everyone else) watch a falcon heavy auto-landing its boosters.

<comment><USER5> I wouldn't call him "an inventor". He only knows enough about the technical side of things to make business decisions. Here's what's made him uniquely successful:

\- He was fortunate enough to be a founder of one of the dot-com boom's most successful companies, starting him out as an Insanely Rich Individual.

\- He has a smart mind for business, when he uses it.

\- He has a knack for envisioning products that aren't just incremental steps forward from what's out there, but multiple steps forward, and then unifying people smarter than him into implementing that vision (the "Steve Jobs effect").

He didn't invent rockets that can land themselves. He had the idea, figured out the business plan, and funded it with his piles of money. That's not nothing, but it doesn't make him Our Lord and Savior. And even if it did, that doesn't give someone a free pass on being a jerk to others (he hasn't been that big of a jerk, as billionaires go, but the principle remains).

<comment><USER7> I'm not a huge fan of Elon, mainly because he puts himself forward as a lone genius inventor, when in reality there's hundreds of engineering teams below him accomplishing his goals...

</comment></comment></comment></comment><comment><USER8> Why do you think people WANT to see Tesla fail?

I'll call out Musk as an unstable and (when it comes to things like the boring company) an ignorant idiot, and I'm absolutely amazed at the cult of personality surrounding him, and I think you'd have to be a fool to invest into tesla given his behaviour and all the financials/news about the company.

But I WANT solar panels and electric cars to take off in a massive big way, and i'd LOVE tesla to be able to provide an affordable electric car.

I think its everyone saying 'people WANT tesla to fail' who are exposing more of this personality cult, because the rest of us can separate the objective facts around the company and its leadership from our personal feelings towards its products and industry.

</comment><comment><USER9> Tesla is just a cult of personality around Elon Musk.

Most of its supporters, especially its die hard supporters, are just people that love Musk.

He's kind of an arrogant prick though, hence all the haters.

<comment><USER10> And yet Tesla produces a game changing product in it's industry against literally all odds. Hard to say how much of it just requires a certain brand of crazy.

</comment></comment><comment><USER7> _related topic:_ Elon's "Hyperloop" project has gained a lot of criticism too. Many [1] long video essays have been made to debunk why it's not a good invention.

Now the _hype_ has died down considerably and it seems a lot of people have lost faith in the idea... maybe they're losing faith in all of Musk's ventures...

[1] [https://www.youtube.com/watch?v=RNFesa01llk](https://www.youtube.com/watch?v=RNFesa01llk)

</comment><comment><USER11> Do that many people _want_ to see Tesla fail, or are just many people skeptical about what Tesla is saying and doing?

</comment><comment><USER12> One reason is because they work very long hours, below average safety, and have below average compensation. If they succeed, it's a signal to everyone else that they should also work under the same conditions.

Look at the inverse - Henry Ford wanted to pay people as much as possible, improve work conditions as much as possible, and work hours as short as possible. I'm sure people wanted him to succeed.

<comment><USER13> I think these are very valid reasons to push Tesla on.

</comment></comment><comment><USER14> Check your assumptions. Many people are simply calling out Elon Musk on his bullshit. He harms the whole cause. Personally, I dislike his hypocrisy around carbon offset credits. The way he sells them to polluters sets the whole world back a decade or more.

</comment><comment><USER13> $10M+ of funding by the Koch brothers to manufacture outrage against Tesla?

[https://cleantechnica.com/2018/08/26/tesla-musk-hit-by- trife...](https://cleantechnica.com/2018/08/26/tesla-musk-hit-by-trifecta-of- fossil-money-short-money-media-weakness/)

<comment><USER15> Wow that some of the most effective PR money ever spent then, isn't it?

<comment><USER13> It helps that the Koch network has probably hundreds of millions of dollars of already laid into relationships, think tanks, and academic centers, so the $10M is all action, with little need to foundation build.

</comment></comment></comment><comment><USER16> I think for a lot of people (this is just my personal opinion), it is based on arrogance of the leadership at Tesla. Especially their dismissals of the rest of the car industry which has been around for decades and knows a lot about how to build cars and wild predictions that turn out to be empty. I think lot of people have become emotional about this and want to see Tesla fail just because of the arrogance displayed by its CEO. There's an equal amount of emotions on the other side though. People who support Tesla no matter what and dismiss all negative facts.

<comment><USER17> I agree... my impression is that people want Elon to be "taken down a notch". Tesla's failure is merely the vehicle (heh) for that comeuppance.

It's interesting to note that SpaceX, another Elon venture, seems to have much more goodwill. I attribute this to the fact that Elon has been much more humble about every rocket launch ("we'll be happy if the payload makes it to orbit, forget about that landing nonsense") as opposed to the extreme rhetoric around the cars ("it will drive itself!")

<comment><USER18> I have no desire to see anyone taken down a notch. Except for maybe the wild fanboys who can't believe Tesla isn't perfect. I hope the company succeeds. I think they make a good product, though it has flaws, and I hope they continue to refine it. I think the hype is unnecessary, especially with regards to FSD. At this point I am planning to buy a Tesla myself, but only if they make through the next couple years and actually produce the Y.

<comment><USER16> I would like to see a proper SUV as model Y. What they revealed was just hacked model 3 with some custom plates at the back (the door gave it away). I don't believe that's what Y will actually look like (it won't sell if that's the final form as most people wouldn't consider it SUV).

They rushed the reveal because they are probably trying to get some hype going in order to raise capital soon. But I really hope they are planning to design Y from ground up as a proper SUV, not just a slightly modified model 3.

Although I get that having as many similarities with model 3 as possible would make it cheaper for them to manufacture it as they would have lots of parts in common. But when I think of SUV, I imagine a much bigger car with higher seating, model Y is not an SUV in my mind and in minds of most people I know.

</comment></comment></comment></comment><comment><USER19> One of the reasons some short sellers are shorting is they are pessimistic about the prospects of self-driving cars in messy real world scenarios.

Tesla seems to inextricably tie the two together. That's too much innovation at once (ergo, more than double the risk). If he just focussed on making awesome electric cars (with auto-drive as an option), it would 1) make Tesla's job easier, 2) make their PR reps job easier, and 3) everyone is positive about green tech. Winning over the BMW/Merc fans with high performance electric cars seems like a better strategy for a car company than trying to push a fleet of average performing occasionally fumbling self driving cars on the streets - from the perspective of the short sellers.

So in the current scenario, everytime there is some news about how the auto- drive confused one thing for another and crashed into it, the short sellers are convinced that there will be more of a negative public feedback cycle which will bring Tesla, or at least its equity, down. So they short.

Source - I have shorted Tesla in the past after the auto drive crashed and killed a driver. I am also technical enough to be paranoid about trusting human lives to a not-100% reliable piece of tech at high speeds. I only trust our attitude of move-fast-and-break-things with things like websites, not things which could kill you.

</comment><comment><USER20> It looks pretty similar to the typical Apple hating.

</comment><comment><USER21> Not a fanboy, just that I support Tesla and what they achieved in a short time. There are 2 main reasons in my opinion: 1) lots of short sellers which are very vocal online 2) many people hate Musk thus they hate Tesla as well.

I don't argue with hard-core haters or fanboys since most of them seem brainwashed.

Still, I haven't heard any good reason why someone should be against Tesla as a company.

</comment><comment><USER22> > The only thing I'm wondering is why are there soooooo many people that want > to see Tesla fail?

There are probably some people that want that (including people who have a financial interest in it, like shorters or people with long positions in competing firms), but it's also very easy for people who have positive aspirations or expectations of Tesla to mistake (or sometimes, misrepresent dishonestly) reporting of negative facts or negative expectations with wanting to Tesla to fail.

You see a similar thing very much in other fields, too (the most common egregious example being political allies of the status quo regime in a nation accusing people who advance the view that the existing policy will fail for the nation of wanting the nation to fail.)

</comment><comment><USER3> Because they're wasting money that would be better allocated to companies with better leadership.

Pre-Musk, they had a decent model. Sell luxury EVs. Now, they can't make a profit and still call themselves a startup after 16 years. Meanwhile, Musk keeps promising more and delivering less.

</comment><comment><USER23> I think what he has achieved so far is pretty impressive. He has a car company that is easily the most talked about of any car company and really put the electric car on the map, he has also made the public interested in space again and is really pushing new boundries there with his landing boosters.

With that said, his visions are sometimes too unrealistic like his vision of self driving cars. He really underestimates how hard that problem is. Saying he will have a self driving car before this year is over is borderline stupid and that pisses me off.

</comment><comment><USER24> I get the feeling that people are more fed up with Facebook than with Tesla. I don't own a Tesla but have family that does and they respect the big vision.

</comment><comment><USER25> I think what Elon needs is someone along side him who keeps his impulses in check. Tesla could go on to do many great things.

</comment><comment><USER26> Its cool to predict things. Every bump in the road for Tesla brings out the nickel and dime soothsayers.

</comment><comment><USER27> ELI5: disruption is difficult

</comment><comment><USER28> The Elon musk personality cult.

</comment><comment><USER29> Haters gonna hate. That's it.

</comment><comment><USER30> Two words: Elon time.</comment>


The Surprising Ease of Plain Text Accounting - <AUTHOR> http://www.vincecima.com/2016/06/12/the-surprising-ease-of-plain-text-accounting.html <comment><USER2> As a middle-aged, married man, my current view is:

1\. I had kept personal accounts for a while, until I realized my expenses swayed month-to-month, but within a narrow band (+- 10%). This made the "insights" less interesting and approximations worked well enough for my use case. I suspect that this is so, for most people.

For who have not kept personal accounts, what I am describing is similar to when you got your Fitbit - The first 2-3 weeks are full of glorious insights and a month goes by and you do not really need a fitbit to tell you how many steps you walked. Approximation approaches real count. Same for personal ledgers.

2\. I now focus my efforts on income expansion rather than cost control. Some of you may say, recording costs is not controlling it. In that case, I find accounting, even less useful (once I have arrived at approximate cash outflow). Income expansion, puts me in a different frame, which I find strangely empowering. Even more so than the satisfaction that comes from having controlled costs.

<comment><USER3> Oddly, this does _not_ end up true for dieting, as I've found out. I dieted, lost a lot of weight with a prescription pill and then more on Weight Watchers. I thought I knew what I was doing, and could "count calories" without actually tracking them.

What I found was that I might know certain things that I eat often, but anything even a _little_ new ended up being badly estimated. If I want to continue losing weight, I need to track.

And my estimates went both ways, too. I discovered this one day when I was _crazy_ hungry, and it turned out I'd massively under-eaten that day (or the day before? I forget), which can be as bad for dieting as over-eating thanks to the lowered metabolism and then compensatory over-eating that eventually happens.

<comment><USER2> A gentle remark - I accumulate calories when I am irresponsible. I stop accumulating them when I am disciplined. Converse is true with money.

<comment><USER4> This sounds like the same thing, phrased differently. According to the grandparent, categorising something new into the 'responsible' and 'irresponsible' buckets is hard and not something that generally gets better with experience.

</comment></comment></comment></comment><comment><USER5> Accounting for personal finances is a waste of time, in my opinion, if you plan to be upwardly mobile. Instead of making the most of what you have, just make more. Spend all the time and resources you need to to make yourself better. In five years, I've gone from making $30K / year to over $100K. Accounting will not get you there. Removing all the barriers in the way of success will.

Businesses need accounting. Humans need nurturing and growth. Don't nurture your business and account for yourself. Account for the business and nurture yourself. Your business can't love you back.

<comment><USER6> This is the most absurd thing I've read in the last couple months. If you're trying to troll, 10/10.

<comment><USER5> Wasn't trying to troll.

I was serious enough once about personal accounting that I built my own web app because I thought the standard double-entry system wasn't really suited to the task. After I got the basic system tweaked to my satisfaction, I used it for several months.

I started to take it to the next level, but had the curious realization that I cared more for the process of developing the app than I did for actually tracking my finances. Eventually I gave it up, and went out and got a better job where I'm more fulfilled professionally and way better paid. I learned then that working on the app was substituting for professional fulfillment and vowed never to let that happen again.

Tracking cash inflows and outflows is an essential business skill. But a business is a machine, and people are not. Personal productivity does not respond well to wringing unit economics out of daily activities. If your goal is to turn yourself into a machine, by all means use a mechanistic approach. But we are meant to build machines, not to be them.

<comment><USER7> Don't know why people are downvoting you, your comment was grey when I read it. I see nothing that makes your comment invalid and I think it contributes to the conversation.

Perhaps it's not the popular opinion, but in a lot of cases I agree with you. Watching over every penny meticulously can become a much too consuming habit that produces little net positive result. It's easy (at least for me) to get caught up in trying to never waste money, and it's really not worth it.

<comment><USER8> I guess people are downvoting him because of his assurance that instead of managing finances one simply has to earn more.

For most people earning more is not feasible, at least not while having some personal live, family matters and depends also on their education, upbringing and people they know.

Some people work a fuckton of hours for a measly pay, and so they can't get to earn more, because they have no time to improve themselves or even to go to interviews.

For these kind of people, that is the majority, some time of personal accounting will be easy and will bear lots of fruits, while they wouldn't be able to improve their jobs in the near future.

<comment><USER9> I didn't read it as "one simply has to earn more".

He's saying it's better to work on things that will lead to one earning more money, rather spending time monitoring how much one is spending. The first leads to an improved state, the second is just for ensuring one's state does not worsen. With one your increasing your 'cap', with the other you're just maximizing given a 'cap' (cap meaning the amount of money you can work with).

<comment><USER10> Its not an either or proposition though. It's frankly ridiculous to propose that I could give up actively managing my finances and use that extra time (an hour a week maybe) to significantly increase my income.

</comment></comment></comment></comment></comment></comment></comment><comment><USER11> Seriously, spreadsheets are born for these tasks.

I tried but didn't like accounting apps because they force you to do too much work and just aren't that easy to find the functions I need. In the end I designed an excel file tailored to my needs (and it's giving me more fun than writing code), which gives monthly view of my financial activities, with support for currency conversion. So at the end of every month I would spend about half an hour logging all the numbers and get a nice overview. I can also put in spending and earning projections so I can easily see how I will be at the end of year.

<comment><USER12> Indeed. Only last week I imported a year's bank statement (one single file downloaded manually) into Google Sheets (worked perfectly first time). Then I spent an hour scanning it by eye and constructing dirt-simple regexes to extract outgoings into categories. As a check I compared total outgoings vs total regex-extracted outgoings; it was out by £400 for the whole year, which I can tolerate.

It told me exactly what to needed to know: I spend a surprising amount on eating out, and a surprisingly small amount on holidays. Budget for the year: spend 50% less on eating out.

Two hours work total. Not perfect, but a piece of cake, and very valuable.

<comment><USER13> Devils Advocate: Ah! but now you have a budget, you need to track it to make sure you're sticking to it - how do you know if you're spending 50% less on eating out this month if the data arn't there in-front of you to check?

<comment><USER14> I felt like the parent comment didn't meant 50% exactly, just an approximation. So, if it were me, I'd just keep that in mind when deciding to go out to eat.. After 1 or 2 months it's easy to see if I'm on track to the ~50% or not and adjust accordingly.

</comment></comment></comment></comment><comment><USER15> A few years ago I volunteered to be treasurer of a small non-profit. They had been keeping their books on paper. I looked at QuickBooks, and it frankly baffled me. Being an old hand at command line and plain-text computing, I found ledger and immediately loved it. I used the emacs ledger mode to manage the ledger file. I kept the ledger file version controlled in mercurial, so I could easily see diffs between various points in time which was sometimes helpful.

When I turned the books over to the next treasurer, I helped him import into QuickBooks, which he was already familiar with. That's the one shortcoming of the tool, that you are unlikely to find anyone else (e.g. professional accountants) who's willing to work with it.

</comment><comment><USER16> These accounting apps never worked for me. I think I'm missing something, but how do you actually use them?

Do you really put every cent you spend into it? How is it possible? How do you remember all that. for example, during a weekend trip?

Next step: ok, assume we put every cent spent into the app. How does it help?

Even more: I already have all my transactions listed in my bank's mobile app. How to use it?

<comment><USER17> I track every cent. I used to just carry a small notebook with me and write in it every time I bought something. Now I share a budget with my girlfriend though so we keep a notebook at the house to track things. I just keep receipts in my wallet then every few days I take them out, record the amounts, and throw them away.

<comment><USER18> 1\. What's the point of it? 2\. How much hours/week does it cost?

<comment><USER19> The main point of accounting is planning for the future. If you know how much money flow you have over given time periods then you can plan ahead for large upcoming purchases, or possibly paying yourself if you wish to bootstrap a business, etc.

</comment></comment></comment></comment><comment><USER20> We are actually using this in our company and couldn't be happier. We're using Emacs ledger-mode and git to keep track of everything.

Ledger is also tied into our billing system. A couple of shell scripts and Latex easily beats everything that I have seen in the last 10 years in the market. That is, of course, a subjective statement and is meant to be such.

<comment><USER21> It sounds like you are try to build your own home-brew accounting system. That is absolutely insane. How do you ship this off to your accountant during tax season? How do you deal with accrual-based accounting concepts like invoices, accounts recevable, accounts payable, long term and short term debt, assets, etc?

Do you even know what accrual based accounting is and why you want to use it?

<comment><USER22> Ledger easily handles accounts receivable/payable, though it doesn't actually generate the invoices for you. Personally, I use org-mode for time tracking and invoice generation (invoices aren't even PDFs ATM, though I have had clients that insisted on them), then I add a corresponding transaction in a ledger file when I send the invoice or receive a payment.

</comment></comment></comment><comment><USER23> This is basically the old EMACS/Vim vs Sublime/Atom debate that developers have battled for years, moved across to the accounting world, isn't it?

Having been involved in accounting system implementation for > 30 years, I understand that people are usually used to doing things one way and find it hard to adapt to change, but even after all my years in the industry, command line accounting fills me with unease - and this is coming from someone who still loves working in the DOS prompt!

I am sure for a simple expense/budget ledger it will work OK, but when it comes to recurring journals, multiple reconciliation accounts, inter company transfers, control account tracing etc., give me a nice GUI any day...

<comment><USER22> Storing the data in a simple text format doesn't stop you from using graphics to understand it. What it does do is let you use tools you already know (your favorite text editor, version-control system, command shell, etc) for editing, queries, backups, graphs, and so on. These are all tools that you've already learned how to use, and which you use every day for other tasks involving text.

Whereas with some slick GUI you're probably trapped in that vendor's proprietary file format.

On the other hand, it's pretty obvious that plain-text files don't scale to a multinational, with hundreds of accountants of various types all trying to work with the same files. Even with proper use of Git I bet that would get old fast. You would instead want a real database, with a schema, and some data validation and some programs/webpages to smooth out the data entry and querying and whatnot. All of that can be done without any kind of lock-in to one data format, or one particular vendor's tools, but it's way too much overhead for a small business, let alone a single person.

<comment><USER23> I understand the speed of the command line when it comes to entering data, and honestly, I've never even considered using something like Git to handle accounting data, but I think it sounds like a neat concept (after all, who of us wishes we could completely undo a set of journals that were accidentally entered into the wrong period).

But my experience is mainly in medium to large businesses with multiple users working on the information in real time, and with strict audit policies around them. I would imagine that would be a nightmare to try and handle using a distributed version control repository, let alone having situations such as one user uncommit their nefarious journals funnelling payments into their own bank account etc. I can imagine the face of the auditors having to run commands like `git compare` on the ledgers to trace transaction history... :)

<comment><USER24> I imagine the biggest difficulty in these situations is dealing with other people: just like LaTeX might be better for certain kinds of documents, but the world still wants MS Word.

But if we look narrowly at functionality, it seems that plain-text and git might be _better_ for strict audit situations.

In a Git history every thing you do has to has a "paper trail" in the form of a hash chain (admittedly using an outdated hash function). People can only "uncommit their nefarious <anything>" is along as those transactions never found their way to someone else' hard disk.

</comment></comment></comment></comment><comment><USER25> This article mirrors much of my own experiences with using ledger. I wrote about my setup here [http://nibrahim.net.in/2015/11/07/ledger_and_personal_financ...](http://nibrahim.net.in/2015/11/07/ledger_and_personal_finance.html)

</comment><comment><USER26> Slight correction, if I may. Interest is piqued, not peaked.

</comment><comment><USER27> On plain text accounting, you should check out Beancount (I am unaffiliated, but know the author): [http://furius.ca/beancount/](http://furius.ca/beancount/)

<comment><USER28> Is there a comparison somewhere to help someone decide between ledger, hledger, and beancount? I can't determine from the website what sets it apart (or even how it really works...ledger and hledger both have lots of screenshots, examples, etc.

Oh, nevermind. The ledger website includes it in their list of "ports to other languages". Beancount is a Python implementation of the same basic system.

<comment><USER29> This extensive thread has some in-depth discussion of the subtler differences: [https://groups.google.com/d/msg/ledger- cli/__yuMVjrOH0/mgBYL...](https://groups.google.com/d/msg/ledger- cli/__yuMVjrOH0/mgBYLfMUm0YJ)

</comment></comment></comment><comment><USER30> I'm right on the verge of going with the new YNAB (first serious attempt to organize finances and budget outside my wife's use of Mint), but maybe I'll give Ledger a shot first.

<comment><USER31> The power of ynab isn't the tool, but the philosophy. The UI works well because it changes how you think of your budget. I'm a little disappointed the author didn't comment on how ledger compares with the budgeting side, as tracking expenses is only half (or less) of the battle. I'd recommend ynab because it forces you to plan instead of react. I think as far as software goes, that's the fundamental advantage- you think differently. It's kind of like how editing in vim you start to think in terms of verb-object.

I'm stuck on ynab4 for as long as possible, but you can try out the nYNAB (the SaaS offering) for free for a little more than a month. If you get it, be sure to watch the instructional videos.

<comment><USER15> ledger can do budgeting: [http://www.ledger- cli.org/3.0/doc/ledger3.html#Budgeting](http://www.ledger- cli.org/3.0/doc/ledger3.html#Budgeting)

<comment><USER24> That help section on budgeting only talks about periodic transactions. Is there also some notion of "estimated future, one-off, transaction"? I suppose you could implement that using ordinary transactions.

It's just that after fighting with gnucash, I got the impressions that budgeting and accounting are very different things and that I should not try to use the same tool for both jobs.

<comment><USER22> Yea, I thought that was a pretty incomplete part of the documentation when I looked through it recently. I haven't done any budgeting in ledger, but the section on virtual accounts seemed like it presented a better way to do a budget: [http://ledger-cli.org/3.0/doc/ledger3.html#Introduction- to-L...](http://ledger-cli.org/3.0/doc/ledger3.html#Introduction-to-Ledger).

</comment></comment></comment></comment></comment><comment><USER32> I might try this out. Right now, I'm using a combo of mint and my own google spreadsheet. Mint.com with the mojito plugin for chrome:

[https://chrome.google.com/webstore/detail/mojito-mint- with-a...](https://chrome.google.com/webstore/detail/mojito-mint-with-a- kick/akfnkdbpccapkganipclkhgppknhjlee?hl=en)

The mojito google spreadsheets look amazing, but I couldn't get things to work, and ran into a lot of errors.

The plethora of budget tracking software is frustrating. It seems no one tool is a clear winner. To me, this still looks painful. Mint is closest there, IMO. However, it's pretty much abandonware at this point.

</comment><comment><USER33> I still remember cringing the day I finally had to move my parents business off CA Simply Accounting for DOS. There was definately a learning curve for the text based app but it took far fewer steps to actually input the data and print off cheques, etc. 15 years of accounting easily fit on a 1.44MB floppy disk. Now, it's a monster database with a terrible UI. In subsequent years Simply has become anything but simple and I cringe at the thought of giving in and moving to the cloud. Ledger doesn't look like a great fit for business though, and accountants want data from accounting packages they know. Quite a racket.

</comment><comment><USER34> Related mini Show HN: Accounting is a small Java double-entry bookkeeping component.

Accounting is supposed to be integrated in applications that can make use of an accounting feature. It is not a stand-alone application. Accounting makes as few assumptions as possible about the used technologies which enables it to be used very flexibly. On the other hand, this means you will likely have to write glue code to integrate accounting into your application landscape.

Check out accounting on GitHub: [https://github.com/Nick- Triller/accounting](https://github.com/Nick-Triller/accounting)

</comment><comment><USER35> Here is a short dscription of how I do this: [https://news.ycombinator.com/item?id=12085755](https://news.ycombinator.com/item?id=12085755)

(It also works for repeating or future expenses - I often "initialize" future files with stuff like rent or an average monthly expense for stuff like groceries, then I update it with receipts I have collected on the last few days)

</comment><comment><USER36> I love the use of asciinema in this. It's handy for me all the time when I want to show a friend something.

</comment><comment><USER37> I am using Spacemacs so I like the idea of using plain text files. But until there is way to input new transactions via my smartphone easily, I will probably stick with classic YNAB for the foreseeable future. Otherwise, I might have to learn Android programming to create my own app to do so.

<comment><USER38> You could keep your ledger on Nextcloud, and tell the Android app to keep it available offline. Then edit in an Android text editor. Obviously a fancy Android app that reads/writes the text files would be great, though.

</comment></comment><comment><USER39> > I had tried similar services before (Mint, Buxfer, PocketSmith, etc) and > never found the sacrifice of privacy worth it. ... > With YNAB 4 now > unsupported, I started looking for alternatives. Would I finally surrender > to Intuit and start using Quicken? Was a Google Docs spreadsheet enough to > get me through?

So OP has privacy concerns with accounting services, but not with Google? Interesting.

</comment><comment><USER40> Just found this: [http://plaintextaccounting.org/](http://plaintextaccounting.org/)

</comment><comment><USER41> Can anyone comment on experiences with Quicken? I had been planning to set up accounting with Xero, but I don't like cloud services for something that requires focus. It can be more difficult to concentrate on something in the browser.

Quicken is the only desktop app that works for Canada and Quebec, I think. How is it?

I'm on Mac, but I can run it on a VM.

</comment><comment><USER42> Since September 2009, I have maintained a Google sheet outlining my net worth. Twice a month, I add a new column then list the balances of my bank accounts and credit cards and brokerages. Very easy to maintain and useful. I can see changes in my net worth at a glance over the last seven years.

</comment><comment><USER43> So what is this sacrifice of privacy the author mentions? I mean is this a legitimate statement? While I can sympathize with the author's mindset this seems like a loaded statement based on nothing. If I'm wrong and Mint is leaking my info like a sieve please tell me now.

<comment><USER6> I do feel _slightly_ uneasy when I use Mint. Primarily because Mint is essentially just a web scraper. They take the account credentials you give them (and presumably encrypt them) and periodically login your bank's web portal, scrape the .html file that contains all of your transactions, works some magic to parse through it, and then displays all of your transactions.

I'm not entirely sure if Mint sells your financial information (i.e., what you spend money on, how much you have, etc.) to outside companies (namely, financial institutions). But, they for sure analyze your transactions to show you paid "recommendations" of what financial products you should use. I've browsed through some of their recommendations before. The majority of them are middling or good, but a significant portion (<15%) are incredible awful.

<comment><USER43> All financial institutions sell your information, electronic or not. In my company we use services that allow us to pull tax data on every resident in the state (of CA) and we get their social, phone numbers, owned/rented properties, outstanding loans, etc. While I totally get the uneasiness of giving info to a third party, we all do that anyway in the analog world as well.

and yes, this means Mint probably sells your info, though they cover it in the privacy statement they have. [guess not actually (see reply from georgeglue1)]

EDIT: If your first statement is true, that tbh is a bit more of an alarming thing to know... oO

<comment><USER44> The data you describe is a standard credit report and public records, not personal consumption data.

<comment><USER43> This is very true. Keeping this in mind it's easier yet to get into why someone would want to shy away from 3rd party online services.

</comment></comment></comment></comment></comment><comment><USER45> the repeated usage of the phrase "my net worth" stings. i presume it's just a turn of phrase and does not really mean much, but it's ugly. you're worth more than any dollar amount! ;)

</comment><comment><USER46> hledger author and plain text accounting fan here! Thanks for this nice blog post and interesting discussion. There are some great questions raised here, perhaps I can steal them for a FAQ ? Here are some answers:

Isn't personal accounting a waste of time ?

People have very different needs and practise personal accounting for many different reasons. There is of course a point of diminishing returns; tailor your accounting practices to your needs. Needs change over time. Some of us would benefit from doing more (or better) accounting, some less (I would guess this second group is smaller).

In [The Millionaire Next Door]([https://en.wikipedia.org/wiki/The_Millionaire_Next_Door](https://en.wikipedia.org/wiki/The_Millionaire_Next_Door)) (highly recommended), one research finding was that above-average wealth accumulators spend more time on financial planning, which for many of us requires accounting as a foundation. "Minimal time dedicated to financial planning is a leading indicator of a UAW [Under Accumulator of Wealth]".

Isn't a command-line tool too limited for real-world accounting needs ?

"I am sure for a simple expense/budget ledger it will work OK, but when it comes to recurring journals, multiple reconciliation accounts, inter company transfers, control account tracing etc., give me a nice GUI any day..."

Understandable. The current plain text accounting tools provide a very generic double entry accounting system with which you can model such things, and script them.

There are a number of generic GUIs available (hledger has curses and web interfaces, and there are web/curses/GTK interfaces for Ledger and beancount). But there are not yet a lot of rich task-specific GUIs. There's no reason they can't be built, though.

Isn't a plain text format too limited for large organizations ?

"it's pretty obvious that plain-text files don't scale to a multinational, with hundreds of accountants of various types all trying to work with the same files. Even with proper use of Git I bet that would get old fast. You would instead want a real database, with a schema, and some data validation and some programs/webpages to smooth out the data entry and querying and whatnot."

I'm not sure. Current plain text accounting tools can do some schema definition and data validation, and will do more in future. The plain text storage format is open, human-readable, future-proof (useful even without the software), scales smoothly from simple to complex needs, and taps a huge ecosystem of highly useful tooling, such as version control systems. And, despite the name, there's no reason these tools can't support other kinds of storage, such as a database. (hledger has four storage formats and is designed to accept more).

Do you really enter every little transaction ?

Yes! Many folks in our community do it. Mahatma Gandhi reconciled to the penny every night. J.D. Rockefeller was famous for his ledgers.

It's not required. I started doing it as a temporary learning exercise, and still like it. It makes troubleshooting and reconciling easier.

How is that possible ?

Practice, and a process/toolset that suits you. Some folks import most of the data from their banks, so little manual data entry is required. A few prefer to manually enter everything, for the increased awareness and insight. "Manual" data entry is usually assisted in some way: interactive console tools (hledger add and similar), web-based tools (hledger-web and similar), GUI tools (ledgerhelpers), smart editors (eg emacs & ledger-mode), recurring transaction scripts. I currently use a mixture of bank CSV import and rapid copy/paste in emacs. I spend 15 minutes a day on average, and for me that's currently a good investment.

How do I use the transaction data in my bank's web or mobile app ?

If you can export it as CSV, you can import it and run queries against it. There are also some tools for converting OFX, QIF etc.

So I've got a huge list of transactions recorded, duplicating my bank statements. How does that help ?

Accounting is modelling flows of money (or other value). Such a model aggregates information from many sources, in one trusted place. With it you can efficiently generate reports, forecast things (cashflow!), answer questions, try experiments.

Some people need a very simple model, others benefit from a more detailed one, and we don't know up front what we might need in future. The most fundamental accounting data is a simple list of transactions (the journal). Once you have captured this, you can mine it for anything you may want later on.

Plain text accounting provides nice open data format(s), tools and practices for doing this, and could be a good foundation for more powerful tools.

Where can I see a comparison of hledger, Ledger, beancount, and the rest ?

Glad you asked! [http://plaintextaccounting.org](http://plaintextaccounting.org) gives an overview of these tools and practices. In particular see "Ledger-likes" and "comparisons" under "read more". hledger's FAQ discusses differences from Ledger. Beancount docs probably do too.

How do you do budgeting ?

Some notes are [here]([http://plaintextaccounting.org/#budgeting](http://plaintextaccounting.org/#budgeting)). I emulate YNAB-ish envelope budgetting (see third link).

Double entry accounting ? Where are the debits and credits ?

Most (not all) plain text accounting implementations use signed amounts instead of debits and credits. This makes them "double entry light" perhaps, but it has been a rather successful simplification, intuitive to most newcomers.

<comment><AUTHOR> Great additional info, thanks!

</comment></comment><comment><USER47> Cool. Now add those on fly on a mobile device. YNAB app does it in couple taps.

Also YNAB 4 won't just suddenly stop working.

<comment><USER48> As a YNAB user, I would be concerned that the mobile app cloud sync would stop working in the future and not get updated.

<comment><USER47> The only cloud sync in YNAB 4 is the one via Dropbox, where it shares the budget file with the desktop app. So the only issue is the DB API being updated.</comment></comment></comment>


I learned to play the piano without a piano - <AUTHOR> https://www.theguardian.com/lifeandstyle/2019/nov/22/experience-i-learned-to-play-piano-without-a-piano <comment><USER2> Can someone explain why there are age-based deadlines for starting formal music education? If a person can become an engineer or a lawyer regardless of their age, why is it the opposite in that field?

<comment><USER3> I am having trouble finding an exact study, but i believe the studies have shown that you pick it up easier before a certain age (languages are like this too apparently) and if you do, your brain will pick it up easier later on.

Its not hard/fast, but I think its just a huge leg up

<comment><USER2> That sounds common-sense to me, but it seems un-meritocratic to assume it a priori.

<comment><USER4> I agree with you. I think everyone should have a chance at what they'd like to do, without being blocked because "people like them" (in whatever way) tend to do poorly.

That said, age matters. Very, very few people can start programming at 18 and progress to the top 20% of the field. I can't think of anyone who's done so, though I'm sure there are exceptions.

<comment><USER5> Niklaus Wirth comes to mind. Admittedly, programming as a profession was very different at that time.

<comment><USER4> Hmm. Wikipedia says he had a BSEE at 21. No info on his early years, but I suspect he's one of the people we'd say started young.

I didn't "program" either before 18, since I grew up in a household (and part of the country) without any access to computers. But I was indeed drawn to it young, and "learned to program" by reading magazines and sending off for free vendor literature (which did indeed have lots of nuggets of knowledge about all things tech).</comment></comment></comment></comment></comment></comment>


Exception Safety, Garbage Collection etc. (a.k.a. Why Does Java Suck So Bad?) - <AUTHOR> http://www.slideshare.net/eplawless/exception-safety-and-garbage-collection-and-some-other-stuff It's very likely that you've been writing totally incorrect code without realizing it. Once you do realize it, it's usually not too hard to fix the problem, depending on the language you're using. <comment><USER2> Interesting how java is the only language included in the title, but the slides have the opinion that C#, Ruby and Python all suck as well.

Seems like a cheap way to get upvotes.

<comment><USER3> And there actually is an idiomatic way to avoid the problem in Ruby:

       File.open("...") do |f|
         firstline = f.readline
         ... stuff that might throw an exception ...
       end

If the "stuff" throws an exception, the file gets closed automatically. And while File is a library class, it's getting no special favors here --- any pure ruby library can easily implement similar APIs, and ActiveRecord's connection pool, for example, actually does.

<comment><USER4> Which counts as the sugar which he mentions. See also "using" in C#. These are pretty clearly design warts. WPF (C# UI library) jumps through some interesting hoops to make it look like all your resources can be properly garbage collected, but even then it tends to come back and bite you for any non-trivial application.

<comment><USER5> It doesn't really taste like syntactic sugar though; it's a special functionality of the standard library, and you could easily get away without knowing about the Java/C-style API of keeping a file handle that has to be controlled around.

<comment><USER6> Out of the three languages he mentions as having syntactic sugar, he was wrong only in Ruby's case. Like you said, it's not a specific syntactic sugar for Dispose pattern, unlike C#'s "using" and Python's "with".

<comment><USER7> Honest question: what's the difference between Ruby and Python/C# here?

<comment><USER6> Let's look at rst's example:

       File.open("...") do |f|
         ... stuff that might throw an exception ...
       end

The syntax you see here is for passing a block to a method. In this case, you're passing a block to File.open, which opens the file, executes your block with it and then makes sure to close the file no matter what.

In Python, you would do:

       with open("x.txt") as f:
         ... stuff that might throw an exception ...

What this does is evaluate open("x.txt"), call the __enter__ method on the resulting value (called the context guard), assign the result of the __enter__ method to f, executes the body of the with statement and makes sure to call __exit__ method of the guard.

The difference is that the syntax used in the Ruby example uses is not syntactic sugar for Dispose pattern, it's part of Ruby's syntax for working with blocks in general, whereas the syntax used in Python example is syntactic sugar meant for Dispose pattern (but can be used for other stuff too).

</comment></comment></comment></comment></comment></comment></comment><comment><USER8> The majority of the comments seem to be negative, yet many of them reflect a misunderstanding of RAII. I've argued the exact argument the author does many times before and got similar responses, it seems to be hard to convey the power of RAII to people who haven't practiced it before. The meaning of RAII is that you can tie a resource to the lifetime of an object, in an environment where the object gets destroyed deterministically. There are two practical uses: 1) You can hide the fact an object is holding a resource from users of the object. 2) You can leverage the power of objects within the language and apply it to resources. The part regarding languages allowing something that might look similar with syntactic sugar didn't convey it's message very well. The syntactic sugar other languages are introducing is great on its own, but it's inferior to the object based approach since it doesn't allow (1) nor (2). It's annoying that languages with garbage collection support have gained a lot of attention solely due to the fact that you don't have to worry about freeing memory, while languages with RAII support in which you basically don't have to _worry_ about freeing any resource, got none.

<comment><USER9> Amen.

RAII will be in the next great language, as it is a useful tool. This is not an academic concern, it is something that happens all the time due to rushed deadlines, stressed developers, or simple naivete.

People love to slag off C++ but the higher-level devs have done some serious thinking about how to engineer robust programs. Sutter's 'Exceptional C++' is eye-opening the first time around, and the concepts are applicable to any language that has exception handling. Programming in a transactional manner has visibly improved my designs -- mostly through the paranoia that almost any statement could throw an exception.

</comment></comment><comment><USER10> Python's "with" statement handles this scenario: <http://effbot.org/zone/python-with-statement.htm>

<comment><USER11> The author is aware of that, but you have to remember to use "with". If you forget to use it, you can still have unclaimed resources.

<comment><USER12> You also need to remember to use RAII, and that always requires creating a class. You also need to get RAII right, where as Python's with is implemented for you.

Also there's no mention about the fact that Java forces you to check for exceptions (well not for unchecked ones, but those should not be fatal, and I never really got their idea). You can't forget the try-catch.

<comment><USER13> The library author needs to remember to use RAII, but the client doesn't need to remember anything (as in his examples). Whereas with 'with' it's the opposite - the client has to remember to use it.

</comment></comment></comment></comment><comment><USER14> ...am I reading correctly that his argument for using C++/D (!) is that it's hard to remember to say this:

        try {
          mightFail();
        } finally {
          doCleanup();
        }

instead of this:

        mightFail();
        doCleanup();

<comment><USER15> The second example should actually be

        class C {
          void mightFail() { ... }
          ~C() { doCleanup(); }
        };

        C c;
        c.mightFail();

Anyway, I hate this slide deck so much.

1\. The author's point could be made in far fewer slides. As in, like, two slides. I hate presentations that are disrespectful of the audience's time for the sake of being cute.

2\. I am generally unimpressed by arguments of the form: (a) Language X has flaw Y. (b) Therefore language X is unsuitable for development. This can be instantiated for every language X for some flaw Y and is not an argument against any language. You need to additionally make the argument: (c) Y is so serious that it outweighs the considerations in favor of X and against the other languages one might reasonably use. Of course (c) is an incredibly high bar, which is why most anti-language zealot arguments do not even attempt to make it, and also why most anti-language zealotry is silly.

In order to do (c) in this case, you would have to make the case that writing finally clauses is worse overall than, e.g. debugging memory corruption errors, and writing copy constructors and overloaded assignment operators, and all the other baggage of C++, rather than handwaving them away with "the downsides have been exaggerated" _.

_ Which, by the way, is ironically the biggest flaw of this slide deck: the author vastly exaggerates the downsides of finally. try/finally is no worse than checking the result codes of C syscalls, and it is sometimes better. I don't recall the C style of programming stopping Ken Thompson from building great things and I doubt that try/finally is actually what stops Java programmers from building great things.

<comment><USER16> You seem to have failed to grasp that the slides are arguing for RAII. While admittedly mildly trollish, it disparages java along with C#/ruby/python implicitly in favour of C++ only because C++ has the most 'correct' implementation of RAII.

There is no argument against try/catch/finally, the argument is that the most common usage of try blocks is for dealing with resource management, not actual exceptions in program state. Given exceptions should be used to expression 'exceptional' program states, that is a significant downside to code readability.

Syntactic sugar like using/yield/with blocks improve the signal to noise ratio of try block usage but still rely on programmer acceptance of that idiom. Ideally, the responsibility of cleanup would be moved entirely to the class implementation rather than the consumer. C++ did this with destructors. In a managed world where maybe you don't always want an eager dispose, rather than syntactic sugar in the caller, move it to the signature of the dispose. Something along the lines of

public scoped void Dispose() { .... }

Alternatively, @Scoped or <Scoped> if you don't want more keywords. The topic is partly to blame but RAII is orthogonal to whether a language is garbage collected or not. It's sad that in an age where PLs are undergoing a sort of renaissance period, mention of C++ causes everyone to circle their respective wagons.

<comment><USER17> And RAII in C++ relies on programmer acceptance of that idiom.

<comment><USER18> Arguably it relies on the acceptance of fewer programmers, the library writers.

</comment></comment></comment></comment></comment><comment><USER19> _if PHP gets something right before your language does, you should reassess your life goals_

:)

</comment><comment><USER20> I am not super familiar with all the details of Java inner classes, but why can't you get most of the way there by doing something like:

      DB.open(new Runnable() {
        public void run() {
          // ... do stuff here ...
        }
      });

You can even design your resource layers such that they can only be used this way (or are easiest to use this way).

Basically, I'm just stealing the JavaScript-y way of doing this that uses closures:

      DB.open(function() {
        ...
      });

<comment><USER20> Answer: the inner class can only access constant locals :(. So you have to put any mutable state in members.

Blech. This might work for some cases, but would be a huge pain in the ass in others.

</comment></comment><comment><USER21> Also, Go gets this right with "defer", and with mostly deterministic error handling (panicking is not the normal way to signal an error, returning a status is).

<comment><USER11> That just pushes the problem around. You don't have to worry about forgetting to catch an exception, you have to worry about ignoring an error code.

<comment><USER21> Go's multiple return at least makes that simpler than C, you don't have to remember to check a global error code, and there are no magic return codes multiplexed with the expected response.

But the fundamental difference is that if you have code that does

        a()
        b()
        c()

then you can guarantee that a() will be executed, then b(), then c(). And if there are any branches in case of errors, they will be explicit. Exceptions surround every statement with the possibility of an unannounced exit.

</comment></comment></comment><comment><USER22> High-performant, world-class C++ is fairly well understood (afaik) to only use a very limited subset of C++'s features (e.g., see the JSF Coding Standard or Google Style Guide or go work for a hedge fund where low latency and high reliability is important).

The same for Java. I honor all the exceptions in the standard/platform libraries. But I see past the hype for my own interfaces. Imho, 9/10 exception classes clutter the interface. 9/10 (again for high reliability, high quality code that you want to work reliably but also be flexible enough to extend), what you want to return is a boolean (and log) for stateful methods. Meanwhile prefer stateless methods wherever possible. And generally speaking treating the JVM and Java as basically a really really high performant scripting engine (i.e., closer to JS than C; though the syntax is somewhere in between). Imho, if you can't do RAII, and you're not deterministic, you are basically a scripting language (or are in the GC family of languages, if you don't like the term 'scripting' -- I think it's cool...).

Anyway, that's how I approach it. But I don't buy into the hype of exceptions most of the time (though of course I honor whatever contract other libraries use).

<comment><USER23> _Imho, 9/10 exception classes clutter the interface._

Thats why checked exceptions are such a bad idea... Personally, I really like Go's defer, panic, recover mechanism[1] for handling exceptional circumstances.

[1] <http://blog.golang.org/2010/08/defer-panic-and-recover.html>

</comment></comment><comment><USER24> What you really want is something along the lines of:

        void myMethod()
        {
            disposable File myFile = new File(somePath);

            // ... do stuff with the file

            // "disposable" modifier causes myFile to be
            // forcibly destroyed upon leaving scope for any
            // reason (except if the disposable object itself
            // is returned from the method).
        }

An idiom designed specifically for the purpose of resource management would make for a far cleaner implementation than shoehorning an existing mechanism.

You'd probably also need to add checking for references to the object by still-living objects (i.e. objects not eligible for gc). If any live object has a reference to the disposable object, its "disposable" status gets removed. Similarly, returning the disposable object from the method also strips its "disposable" status. It would add extra processing at the end of the scope level, but generally methods that create/use resources don't need to be lightning fast anyway.

You could even add the "disposable" modifier to class definitions, making all instances of that class disposable by default (and thus destroyed unless referenced or returned).

<comment><USER25> It's not so easy because what happens if you have code like this:

      static File globalFile;

      void register_file(File aFile)
      {
          globalFile = aFile;
      }

      void myMethod()
      {
          disposable File myFile = new File(somePath);

          register_file(myFile);
      }

If you answer, "add referencing counting", reference counting isn't perfect because you can create cyclic references.

The only reason RAII works in C++ is because you can refer to an object by value and separately by reference. You can create stack-based objects that have a defined scope.

You really can't have this in a language that always treats objects only by reference.

<comment><USER24> My answer would be to create a shortcut in the existing reference system of the gc. Invoke a subset of the gc which checks a reduced list of object references made from that scope or deeper.

Reference counted systems only work if you don't create cyclic (strong) references, so that argument is moot. In fact, reference counted systems can deal with resource objects easily so long as the compiler/interpreter ensures that pending autoreleases are executed when unwinding the stack during an exception.

</comment></comment></comment><comment><USER21> I think you can avoid nesting finally thus:

        X x = null;
        Y y = null;
        try{
          x = foo();
          y = bar();
          yadda(x,y);
        } finally {
          if (x!=null) x.dispose();
          if (y!=null) y.dispose();
        }

<comment><USER19> what happens if x.dispose() throws an exception?

if (x != null) try { x.dipose(); } catch (Exception){} }

it's why the using keyword is so nice. Still, this is all hoops languages force us to deal with when they shouldn't (which is the OPs point)

<comment><USER21> You're lucky Java is checked at compile time. Ruby would eat that "no such method dipose" and silently leak x.

<comment><USER6> _You're lucky Java is checked at compile time._

Not lucky enough, because x.dispose() could throw an unchecked exception.

</comment></comment></comment></comment><comment><USER26> The problem with this whole argument is that the author assumes that deterministic memory performance is completely necessary. It's certainly nice, but there are so many times when it just doesn't matter.

While I agree that Java sucks because it makes certain very common things require extreme verbosity, worrying about garbage collection isn't all that important except in systems-level programming (which isn't done in Java really), and large GUI that need tons of memory and still need responsiveness. But many people wouldn't even think to use Java in those cases anyways, so I'm not really sure what this guy's point is.

<comment><USER27> Read the slides again. The author isn't concerned about deterministic memory performance. He's concerned about the fact that that you can't do RAII in Java and therefore any method that allocates resources, performs an action that could throw an exception and then deallocates the resources must wrap the action in a try...finally block. This is overly verbose and the compiler won't tell you if you forget to do it.

</comment></comment><comment><USER28> Non-slideshare link:

[http://docs.google.com/viewer?url=https%3A%2F%2Fs3.amazonaws...](http://docs.google.com/viewer?url=https%3A%2F%2Fs3.amazonaws.com%2Fppt- download%2Fraii-110506011720-phpapp01.pptx%3Fresponse-content- disposition%3Dattachment%26Signature%3D5lrdrqUoc6rD0E2fjI06%2FOHz4%2Fs%3D%26Expires%3D1304722818%26AWSAccessKeyId%3DAKIAJLJT267DEGKZDHEQ)

Edit: Warning. Actually seems to cut off some of the slides.

</comment><comment><USER29> This fact has lead to the popularity of the springframework in Java. They use the template design pattern to hide all of the resource acquisition and release. This makes it much easier to code as you don't have to "remember" to close your db connections. The remember argument is somewhat weak because you still need to remember to write your destructor. I do buy that it's easier to remember it in one place than all over the code.

</comment><comment><USER30> In the Java example with three try/finally's, he calls 'dispose()' on a File. I've never seen this before, what does it do? Or did he just hallucinate that to make the example look more dramatic?</comment>