Show HN: Extract it – Because nobody can remember tar commands - <AUTHOR> http://extractit.mawalabs.de/ <comment><USER3> It's a nice web gadget. However, I just go by this handy table, which is on a yellow stickie on my monitor:

      NAME             MODERN GNU TAR COMMAND
      file.tar.gz      tar xf file.tar.gz
      file.tar.bz      tar xf file.tar.bz
      file.tar.bz2     tar xf file.tar.bz2
      file.tar         tar xf file.tar
      file.tgz         tar xf file.tgz (missing from web gadget!)
      file.abcdef      tar xv file.abcdf (*)
      ---
      * If file.abcdf is actually any of the preceding formats;
        i.e. GNU Tar doesn't just go by the suffix!

Nobody memorizes these, and I wouldn't want to turn into a nobody, right?

By the way, if you actually do need a command which performs a pattern match on a file name and dispatches some other command, why would you go through a web browser? You'd want this in your shell as a function:

      $ dtrt x.blorch.zonk.bloop # "do the right thing"

Hello, we have "case"

      case "$file" in
      -* | --* ) echo "oops, $file looks like an option!" ;;
      *.zip ) unzip "$file" ;;
      *.rar ) ... ;;
      *.tar.* | *.tgz | *.tar ) tar xf "$file" ;;
      ...
      esac

</comment><comment><USER4> Just add this to your .bashrc/.zshrc.

      extract ()
      {
        if [ -f $1 ] ; then
            case $1 in
                *.tar.bz2) tar xjf $1 ;;
                *.tar.gz) tar xzf $1 ;;
                *.bz2) bunzip2 $1 ;;
                *.rar) unrar x $1 ;;
                *.gz) gunzip $1 ;;
                *.tar) tar xf $1 ;;
                *.tbz2) tar xjf $1 ;;
                *.tgz) tar xzf $1 ;;
                *.zip) unzip $1 ;;
                *.Z) uncompress $1;;
                *.7z) 7z x $1 ;;
                *) echo "'$1' cannot be extracted via ex()" ;;
           esac
        else
            echo "'$1' is not a valid file"
        fi
      }

<comment><USER5> all the $1 here should be quoted as "$1", just in case if it gets a file with space in the name.

</comment></comment><comment><USER6> Why not just learn what the flags mean? If you're cargo culting it, and not learning the point of the "xfvz" (it means eXtract, from the specified File, with a Visual dump of the extraction, from a gZipped archived tarball) -- you'll never remember it.

<comment><USER7> "tar xvzf" is already a part of my muscle memory. Occasionally I need to change the "z" to a "j" for bzip2 archives. And the "x" becomes a "c" if I'm Creating an archive rather than eXtracting.

Also this site doesn't show the command for files with ".tgz" extensions.

<comment><USER8> > tar xvzf" is already a part of my muscle memory. Occasionally I need to > change the "z" to a "j" for bzip2 archives

With modern tar, just don't include the z at all. "tar -xf" knows how to extract various kinds of compressed tar files automatically.

<comment><USER9> Today I learned. I've been doing zxvf for quite a while and I always got annoyed with bz2 files.

</comment></comment></comment></comment><comment><USER10> For GNU tar at least it's not necessary to specify the compression program when extracting--it will auto-detect it. Additionally when creating tar files it has -a, --auto-compress to use the file extension to determine the compression program to use.

[http://www.gnu.org/software/tar/manual/html_node/gzip.html#a...](http://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompress)

<comment><USER11> Recent versions of BSD tar will also detect the compression algorithm for extracting. No such luck with the -a, --auto-compress option though.

<comment><USER12> Bsdtar definitely supports -a. I'm on a phone so I can't help too much but its the first option after you Ctrl+f for getopt on [https://github.com/libarchive/libarchive/blob/master/tar/bsd...](https://github.com/libarchive/libarchive/blob/master/tar/bsdtar.c)

</comment></comment></comment><comment><USER13> I have good memory but I always try to convert information into mental cards so I can draw associations, that is how I have learned all commands you can imagine. I deactivated the system file manager of my operation system long time ago because I got used to the terminal, and that is how I do everything in my personal computer.

For extraction of archives I am able to remember the commands like this. For files with "tar" extension I use "tar xf" (where "x" means eXtract and "f" file, I think so). Now, if the extension is "tar.bz2" add a "j", and "z" for "tar.gz". For "zip" files use "unzip" and start adding a prefix like "b" or "g" for "bz2" and "gz" files respectively:

      file.tar     -> tar xf
      file.tar.gz  -> tar xfz
      file.tar.bz2 -> tar xfj
      file.zip     ->  unzip
      file.bz2     -> bunzip2
      file.gz      -> gunzip

[https://github.com/xvoland/Extract](https://github.com/xvoland/Extract)

</comment><comment><USER14> Does not recognise .xz? It's the first thing I tried, ffs.

It looks like it does not recognise other usual things such as .gz alone or .tgz: [https://github.com/Mawalu/extract-it/blob/gh- pages/main.js](https://github.com/Mawalu/extract-it/blob/gh-pages/main.js)

<comment><USER15>
        var input = document.querySelector('#leInput'),
        commands = {
          '.tar': 'tar xfv',
          '.zip': 'unzip',
          '.tar.bz2': 'tar jxvf',
          '.tar.gz': 'tar xfvz',
          '.tar.bz': 'tar xjf',
        };

I don't think the difference between .bz2 and .bz makes any sense. Am I wrong, or is it just that bz2 extracts verbosely and bz doesn't? I'd guess these flags were copied from some random sources without the author realizing they are nearly equivalent.

I know difficulty with tar is a meme[1], but once you get over that "j" means bz2, why is it hard to remember V for Verbose, Z for gZip, X for eXtract, F for File (which you'll almost always be passing)? I ask this both rhetorically because it shouldn't be hard, but also because I am sometimes oddly hesitant when forming tar commands. But not enough to reach for a web page.

[1] [https://xkcd.com/1168/](https://xkcd.com/1168/)

<comment><USER14> It's not hard at all. I personally memorised "zxvf", and change z accordingly, or remove v if it's a shitload of files and it floods my terminal.

</comment></comment></comment><comment><USER16> Or, add this to your .bashrc (ensure that it's sourced.. some distributions don't do this automatically):

         alias untar="tar xvf"

Then, open a new terminal window, and from then on it's just:

         untar filename.tar.gz

<comment><USER17> Don't you need the z flag as well since filename is gzipped?

<comment><USER16> Not anymore! GNU tar now figures it out automagically :)

<comment><USER18> BSD tar also has this functionality. "tar -xf <filename>" works for archives compressed with gzip, bzip2, or xz.

</comment></comment></comment></comment><comment><USER19> Does not work if I don't use a dot at the beginning of the extension.

        .tar -> enter -> works
        tar  -> enter -> nothing happens

I use an extract() function on my shell initialization files. It deals with most formats for me.

Anyway nice to see it implemented on a web interface, the source code is really brief :-)

Right now it supports tar, tar.gz, tar.bz, tar.bz2 and zip. If you want to deal with more formats, you have plenty of places to look for the 'ext => cmd' relation:

         https://github.com/search?q=extract

<comment><USER20> >Does not work if I don't use a dot at the beginning of the extension.

Maybe because you're expected to type the full filename, for example crash34_master.tar.gz

</comment></comment><comment><USER21> I can remember tar commands.

</comment><comment><USER22> Maybe I just use tar a lot, but I actually can remember all the flags I typically use and wouldn't use this :) still nice work though.

co workers have sent this to me multiple times

[https://xkcd.com/1168/](https://xkcd.com/1168/)

it helps the characters name is also mine!

</comment><comment><USER23> I use atool ([http://www.nongnu.org/atool/](http://www.nongnu.org/atool/)) You can just do "aunpack file" or "atool -x file", same goes for packing..

<comment><USER24> I've used this for years, not because I can't remember tar, gunzip, unzip, unrar, 7z, etc commands (although it takes a second to recall which flags to use for a particular archive format), but because it prevents tarbombs/zipbombs from filling my current working directory. It first extracts the archive to a temporary folder, and if it notices only one file in the folder, it moves it back one directory. One minor complaint is that "aunpack" is awkward to type, so I've aliased it to `a`.

</comment></comment><comment><USER20> Why hasn't anyone made (afaik) an all in one extractor that depends on all the popular compression tools and uses the appropriate one depending on the extension. That would be useful.

<comment><USER25> bsdtar does this, except by looking at the file format rather than looking at the extension. It supports tar, pax, cpio, zip, xar, lha, ar, cab, mtree, rar, and ISO images, compressed using gzip, bzip2, lzip, xz, lzma, or compress.

</comment></comment><comment><USER26> Gee, I've been using a handrolled program that a) figures out what other program to delegate to as well as what options to pass and b) makes sure unpacking whatever results in exactly one new entry in the current directory, that is, unpacks into a newly created directory if there's more than one thing top-level in the archive. Maybe I should have been posting it on the internet!

</comment><comment><USER27> You basically need to know three options for tar:

-x EXTRACT -c CREATE -f - USE STDIN/OUT

to create a tar file of the current directory:

tar -cf - . | gzip > /tmp/foo.tar.gz

to extract:

gzip < /tmp/foo.tar.gz | tar -xf -

why tar has all the options was someone's idea they were helping you out -- they weren't

Create is -c --- remember that eXtract is -x - remember that -f - <USER2> stdout/stdin depending on your need -- remember that

pipes are your friend.

</comment><comment><USER28> I use a little mnemonic phrase... tar dash eXtract Zee Files (tar -xzf)

and

tar dash Compress Zee Files (tar -czf)

Yes, the z does nothing when extracting. But it helps me remember.

</comment><comment><USER29> This makes total sense as a web service.

In all seriousness... why? This would be an awesome unix tool.

<comment><USER30> One such unix tool is "dtrx", which has been around for ages.

[http://freecode.com/projects/dtrx](http://freecode.com/projects/dtrx)

<comment><USER18> I use p7zip, which has also been around for ages. Whether you have a .tgz, .txz, .rar, .zip, or whatever, you can extract it with "7z x <filename>".

</comment></comment></comment><comment><USER31> Every time I need to extract some kind of tar file i just do tar -xf filename.tar.<whatever> and it works fine. This would be nice for compressing, but seems pointless.

</comment><comment><USER32> Wait, is this seriously a problem for people, or an xkcd joke?

</comment><comment><USER33> In all seriousness, who would actually use this?

</comment><comment><USER34> I'm not using this until it handles SGI bru. Remember bru? No? Consider yourself lucky.

</comment><comment><USER35> what other tar commands/options do people use when extracting? lately with tar it doesn't even seem you need z/J/... to pick the compression format, just tar xvf archive.tar.whatever and it figures it out itself</comment>


Ask HN: What is up with all the sextortion emails? - <AUTHOR> I received two emails with actual, although old passwords claiming to have been extracted from porn websites with malware and, in doing so, the scammer claimed to have recorded me doing "dirty stuff" in split screen, asking for 1800 dollars in a bitcoin wallet.
I was talking to coworkers and many have claimed to have received these emails as well.
We were all cool with it, but I can see people actually freaking out about it.
It has been covered on krebsonsecurity in 2018, but these seem to have resurfaced: https://krebsonsecurity.com/2018/07/sextortion-scam-uses-recipients-hacked-passwords/
Has anybody received those emails recently? What can we do to protect those close to us against these attacks? <comment><USER2> Sure. Google the opening claim to find a website where ppl are registering them, and notice another hit where it's debunked. Try this: study the message's source and google the IP address. Mine originated in Mexico.

<comment><AUTHOR> hmm, doesn't it look like mexico could be a proxy for masking the email origin?</comment></comment>


HomeControl: HomeKit bridge written in Go - <AUTHOR> http://selfcoded.com/homecontrol/index.html

<comment><USER2> Great idea, given that LIFX themselves haven't added support for HomeKit to their own app, I hope that your's gets approved soon! However I fear that this might be the sort of thing that falls afoul of App Store review rules... and not IMHO for any particular valid reason unfortunately.

Is there anything available in the App Store that actually uses HomeKit yet?

<comment><AUTHOR> As far as I know, there is no app on the App Store which uses HomeKit. Probably because there is no HomeKit hardware on the market yet.

</comment></comment><comment><USER3> No code, no gist :/

<comment><USER4> There's this:

[https://github.com/brutella/gouvr](https://github.com/brutella/gouvr)

Which seems to fulfil the claim:

> I've already implemented HomeKit bridges for the UVR1611, LIFX and olp425. > Each of those example implementations are written in less than 200 lines of > code.

And relates to hardware like this: [http://www.ta.co.at/en/products/uvr1611/](http://www.ta.co.at/en/products/uvr1611/)

The author is active on Twitter, you could follow him for updates: [https://twitter.com/brutella](https://twitter.com/brutella)</comment></comment>


Github for 3d models and 2d plans - <AUTHOR>

Just something I was wondering in bed last night. Since Github is mainly aimed at code, it'd be cool to see an equivelant for 3d models and 2d plans. Couldn't find anything while doing a quick search. Might be a hole in the market, or maybe just a plain bad idea. What are your thoughts? <comment><USER2> use <http://www.thingiverse.com/></comment>


Brief Thoughts on Angel List - <AUTHOR> http://500hats.typepad.com/500blogs/2011/02/brief-thoughts-on-angel-list.html

<comment><USER2> I'm not really sure how Angel List works. I listed my startup a couple of weeks ago and it's had just 3 views. We don't have any "Social Proof" since we have been bootstrapping to this point. It feels as though Angel List has no utility unless you already have taken some money or a have a well known advisor. I also have not listed Price & Terms, which I have a feeling is also hurting the profile, as I'm not yet sure how much I should be raising and would like to discuss that with a potential investor first. So, if I have no "Social Proof", how likely are investors to find my company's profile on Angel List?

Edit: I guess there is also the possibility that my company will not be the next Facebook nor does it even aspire to be and because of that, I guess it might not be interesting to investors.

<comment><USER3> best way to start on angel list is: 1) get at least one notable angel to introduce it / submit it 2) ideally have them introduce you to a few others (privately) 3) once you have some visibility / traction with a few folks, then set your listing public and open it up to the rest (if you want)

this should probably be a separate thread here or on Quora to discuss best techniques for marketing a deal on Angel List. i'll try and write a blog post on this or a Quora question in the future. it's worth diving into more.

<comment><USER2> That does make sense, and if that is the way it works, that's the way it works. The name AngelList, at least from an entrepreneur's stand point, might be misleading then. It seems to me that AngelList is more of a list of potential start-ups for angels than it is a list of potential angels for start-ups. While it can be used either way, to me it seems that the benefit is more for the angel than the start-up looking for funding. Maybe it should be called StartupList?

<comment><USER4> It worked this way long before angellist. You need some combination of amazing team, traction, or social proof. AngelList features a huge bunch of angels which is a HUGE benefit to the startup. Finding angels is hard. But just because they are all in one "room" doesn't mean that you don't have to impress them in the same way that startups have always needed to impress.

The good news is that once you DO get get something eye-popping (an amazing prototype, a great advisor, a brilliant growth curve), AngelList can be like gasoline on a match-- you close faster and with better terms (at least that's what I've heard from multiple sources).

</comment></comment></comment></comment><comment><USER5> Dave strikes me as rude, obnoxious, and difficult to read. But more importantly, he strikes me as correct. The vast majority of VC's do a terrible job at investing. He's bold enough to try a new way - the index fund of the startup world.

As they say, those who say it can't be done shouldn't interrupt those who are doing it.

Who knows if it will work, but I'm eager to see the results.

Edit: when I say Dave, I mean his writing style - I've never met the guy.

<comment><USER6> I think I may be the only person on HN (besides Dave himself) who actually enjoys his writing style. Then again, I grew up on the East coast playing poker and basketball everyday, so smack talk is second nature to me.

Most people in the Bay Area seem to be in a competition to see who can be the most modest, which has never been my style.

<comment><USER7> I like it too (east coast as well). I just see it as straightforward, though I've also been accused of having an offensive or off-putting tone when I thought I was being straightforward as well.

<comment><USER8> I don't see it as straightforward. I agree with a lot of what he says, but trash talk of pretty much any kind tends to distract of the issue at hand.

Like in sports or gaming, I always prefer the person who plays silently and speaks with purpose than someone who tends to trash talk while playing. But neither form of etiquette effects who is the better player.

</comment></comment></comment></comment><comment><USER9> Oh wow, I'd describe that writing style as "stream of semi-consciousness". I couldn't read all of it.

<comment><USER10> I would describe his entire writing style as annoying and abrasive which makes it so I can read barely any of it. But I suppose some people like it or the ideas as his writings seem to do well here.

<comment><USER3> that is my writing style. i was also in a hurry because i needed to get my kid to basketball practice at 10am, and i started at 7am.

usually it takes me about 5-6 hours to include the "full insanity" version with fonts, pictures, etc.

(anyway, i'm obviously an acquired taste... i won't be offended if you think i'm offensive.)

<comment><USER10> I've never met you so I can't possibly think you are offensive but I do find your writing style a bit harsh to read, some people obviously like it though.

</comment></comment></comment></comment><comment><USER11> Dave makes it pretty clear that though VC's years ago praised the theories of the Wisdom of Crowds, they felt it applied to other industries, and not theirs.

Seems most 'experts' feel that way.

</comment><comment><USER12> Dave nails the often unspoken truth: traditional VC's have been terrible on average. Suspect the savvy LPs will pour more and more into 500hat-esque vehicles...

</comment><comment><USER13> Dave is spot on when he says that "value-added" investing comes more and more from domain experts. We have lately had discussion with a few investors. The quality of feedback AND connections from those that have been hands-on entrepreneurs, especially in our field (gaming) is in a totally different level compared to others.

</comment><comment><USER14> I wonder when this Silicon valley school yard soap opera is finally over.

</comment><comment><USER15> Just in time for my compilation (bit.ly bundle) of interesting reads in tech controversies: <http://bit.ly/openletters>

</comment><comment><USER16> Reading him is like reading James Joyce Finnegans Wake. For those who haven't read the book: <http://en.wikipedia.org/wiki/Finnegans_Wake>

</comment><comment><USER17> This blog seems like a parody of western civilization.

</comment><comment><USER18> I don't like how he points at the negative 10 year VC return numbers as implied proof his strategy is superior. On the other hand I don't know why I'm arguing against someones alter ego.

<comment><USER19> I think he's acknowledging that there is still risk in his strategy, but that's it's not as risky as critics like to say.

<comment><USER18> That's overly charitable of you. Why would he bring up the last 10 years of VC returns unless his argument was, "look how bad traditional investor schools of thought are, anything else that kinda seems to make sense must be as good or better". But that doesn't follow.

The past 10 years returns of VC's investment strategy says nothing about his strategies relative performance.

<comment><USER3> i didn't say "anything else must be as good or better".

what i meant was that blind trust in traditional VC strategy doesn't make any sense, since on average they suck.

my strategy is still new (<12 months old), so there's no historical performance to compare, outside my investing at Founders Fund (which looks pretty good so far) and my own angel investing (which also looks pretty good).

sorry i can't share #'s here on those, but as a personal investor i was in early on Mint, SlideShare, Simply Hired, & Mashery. as a professional investor at Founders Fund i was in early on Twilio, CrowdFlower, CreditKarma, Bitly, and several others which are doing pretty well.

still, it's too early to say whether i'm any good or not.

my point was simply that arguing status quo doesn't make sense when status quo is sucking pretty hard.

<comment><USER18> Look, I like your investment strategy and want to see how it plays out.

That said, your post does imply that the weak returns of the VCs last decade lend your approach merit when you point out their weak returns and then say:

"to be more specific: if we look at the #'s, on average it's more likely that high-volume, spray & pray investing -- which i will going forward refer to as "a quantitative investment strategy" -- is likely to be successful than a "focused, low-volume" investing strategy."

(Of course I assume you measure success by expected value, not the chance of being in the black after a small number of investments)

<comment><USER3> yeah, guess i'm intentionally taking on the "spray & pray" haters, but to me more specific -- i'm combining that strategy with other filters, domain- specific expertise, selective follow-on investment. the combination of all of these is more like an index fund for initial selection, then active management and time-weighted averaging of future funds into the winners.

little bit complex to describe, adn we're still developing it so even i'm not final on which parts add most value.

but we are trying some new shit. some of it hopefully works ;)

<comment><USER20> One has to believe that with the variety of startups coming out that seed- level spray and pray, coupled with selective follow-on will likely get you in on big things.

Worst case, you have an existing relationship with a large number of startups, a percentage of which will undoubtedly go on to bigger things or exits -- the trick is of course in how big that percentage is.

This is evidenced somewhat by the increasingly large number of teams getting accepted by YC.

</comment></comment></comment></comment></comment></comment></comment><comment> clark-kent I appreciate the entertainment, investing would have been so boring.

"Angel List is like Dangerous Sex with Super Models for Virgin Nerds.

yeah that's it -- imagine if you're Urkel and all of a sudden you get to find out who the newest Sports Illustrated hotties are, who they're screwing, and then SOMEHOW you discover an opportunity to SCREW THEM YOURSELF TOO! (omg, where do i sign?!?) ok, so you get the picture. this is probably why Bryce left the party."

<comment> clark-kent The above quote is direct from the blog post. Not my words.</comment></comment>


CentOS Administrator Reappears - <AUTHOR> http://www.centos.org/modules/news/article.php?storyid=381

<comment><USER2> I already panicked and started the move of one of our servers over to Ubuntu Hardy.

I'm worried for CentOS, continuing this saga with an open letter and a picture of a possibly stubborn leader is going to hurt. I think it's time to go tight lipped, have a conference call, hash it out and make things right.

Then make an announcement about all the GREAT things that came out of the call and how CentOS is on the verge of greatness with its new found community guidelines.

But programmers are not PR or Marketing guys usually, we're quite sensitive about our work, so I'm leery this will just turn into a public mud slinging battle.

<comment><USER3> Really? You really migrated servers over to another distro within a few days of hearing the the project manager had gone AWOL?

You do realise that you can stick with the same distro forever and just patch all of your packages manually, don't you?

<comment><USER2> A few hours actually. It was just 1 server. I'm sorry if it looked like I said more. I do patch manually already.

If there are two ships going out to sea, and the ship where I've already loaded my luggage all of a sudden has crew members running around screaming "where's the captain, where's the captain, he's been gone for months." You know.... I'm just going to take my bags and put them on the other ship and not worry about it anymore. I don't need any more stress in my life, there's already PLENTY of that.

</comment></comment></comment><comment><USER4> Where are the details!?! I want to know why he went AWOL for so long, and what kind of agreements were reached regarding the centos funds and domain. =P

<comment><USER5> this isn't a soap opera. It's their business, even if they decided to make part of the thing public.

<comment><USER6> And my business is my business. We used to use CentOS and now we switched to another open build of RHEL.

I have nothing against them, they all seem to be great guys, I would have a beer with them. But the image of the project as a whole has suffered, and because of a lack of perceived stability and reliability we decided to switch.

<comment><USER7> that's the risk you take for using a community (ish) / volunteer developed OS.

I always recommend Fedora - because they have Red Hat upstream so it's enterprisey but still the same sort of community :)

<comment><USER5> Red Hat is actually downstream from Fedora. Red Hat takes a Fedora release once every two years and makes it into a RHEL.

<comment><USER7> yeh sorry I realised this after posting. thanks for the correction (I think my point still stands, I dont know).

</comment></comment></comment></comment></comment></comment><comment><USER8> question. does the CentOS admin make any money?

<comment><USER9> This post tells a bit about it.

Basically that all the donation and ad revenue are unaccounted for. I certainly wont donate a cent (pun highly intended) until this is cleared up.

[http://dag.wieers.com/blog/the-burden-of-keeping-things- priv...](http://dag.wieers.com/blog/the-burden-of-keeping-things-private)

<comment><USER10> Wow. That should have come out a long time ago. A good time for all open source projects out there to become accountable about their donations. And to stop donating to those that are not accountable.</comment></comment></comment>


Intuit (remember them?) releases Turbo, latest attempt at PFM - <AUTHOR> http://www.zdnet.com/article/intuit-unveils-new-finance-platform-turbo/ <comment><USER2> I would rather not give any business to a company that lobbies for inefficiency in tax collection to preserve it's own products and profits.</comment>


More Rust compared to C++ - <AUTHOR> https://rnestler.github.io/more-rust-compared-to-c.html <comment><USER2> I'm bored of all the Rust vs. C++ comparisons, when the C++ code is something you simply don't write with modern and idiomatic C++11 and C++14. Not that you could not write it, but seeing this would not pass me reviewing the code.

The add_one example, as simple as it is, is a horrible example.

Why not embrace value semantics and write it like:

        int add_one(int x) { return x + 1; }

There is simply no need for pointers or references. Write simple code first. To the heap allocation example:

        auto x = std::make_unique<int>(5);

Even if this is a silly example, just say no to unnecessary heap allocation. Why not:

        int x{5};

Now to the lifted example:

        void add_one(std::unique_ptr<int> num) {
            * num += 1;
        }

This mixes operations with lifetime management. The add_one function does not need to care about ownership. And it does not need to take ownership of its argument. Instead on the call site do:

        int add_one(int); // from above

        auto p = make_unique(5);
        auto six = add_one(*p); // <-

There are valid points in the blog post and I know that most snippets are meant as examples. But as someone writing C++14 you can't win me with those kinds of posts, even though I'm having a fun time playing with Rust in my spare time.

For more about modern practices see: [http://klmr.me/slides/modern- cpp/](http://klmr.me/slides/modern-cpp/)

Also see Howard Hinnant's unique_ptr tutorial: [http://howardhinnant.github.io/unique_ptr03.html](http://howardhinnant.github.io/unique_ptr03.html)

<comment><USER3> You seem to be pretty fundamentally missing the point of using those examples.

All of your examples look almost identical in Rust and C++. That's not a positive, nor is it a demonstration of similarity - it's a useless set of examples for a post _demonstrating the differences_ between the two. :P

It's worth looking at each of the examples in the article and thinking about them in the context of the more complex practical problem that do _require_ mutable/heap state.

Again, think of the examples as 'C-Reduce'd[1] ones - just enough for an experienced programmer to 'get' the differences and infer its relevance to real world cases.

To give at least one motivating example: for your first case (functional add one) - that's entirely passable for the (tiny) int, but quite useless for the larger case of BigInteger. That's where Rust's default move semantics would really shine, but using BigInteger as an example would introduce lots of irrelevant semantics, making the example bigger but scarcely more informative.

[1]: [http://embed.cs.utah.edu/creduce/](http://embed.cs.utah.edu/creduce/)

<comment><USER2> I'm not missing the point of those examples. They showcase Rust vs. ridiculous C++.

See my point with making the add_one function not taking a unique_ptr. This is valid criticism and valid in more complex practical examples, too.

<comment><USER3>
        BigInteger& add_one(BigInteger& num)

is an awful function (really no checks of any kind, such as multiple holders). You suggest that it's valid for more complex practical examples, but that's a simple example where you'd probably want:

        void add_one(std::unique_ptr<BigInteger> num)

BigInteger is a common example often written in fluent/mutable style or to take ownership of the argument in just this way.

<comment><USER2> Your second function still mixes ownership with resource management. Taking an unique_ptr<BigInteger> by value means, add_one takes the ownership of it. But it does not return anything, making it a useless function.

The though-process goes like this:

* Do you need read-only access to the argument, take a const T&

* Do you need to modify the argument, take a T (by value), letting the call site decide to either pass an rvalue (move it, no copy), or an lvalue (copy)

There simply is no need for unique_ptr<BigInteger>, as BigInteger already handles its resources internally (with move semantics). It's the same reason as to why an owning pointer to a vector is silly when a vector already handles ownership of its resources.

[http://klmr.me/slides/modern-cpp/#9](http://klmr.me/slides/modern-cpp/#9) is exactly about this.

<comment><USER3> Yup, I agree with you (and pjmlp, who I can't reply to) on all of this.

I can see where you're coming from in pushing for all-value semantics, taking advantage of the mechanisms built into the language to control how those semantics play out.

I think it's worth remembering through all of this that getting just the right semantics requires a little more effort and thought on the part of the callee, in C++-land, as well as which the relative lack of consistency (and opaqueness) in these semantics, at least in the absence of a full IDE or similar to jump to signatures.

Oh and briefly, the C++ may be unidiomatic, but it's perhaps useful as a C++ mimicry of the Rust code to show maximally similar semantics?

I think perhaps the dismissive nature of your GP post blinded me to exactly what standard you wanted the C++ to hold to (oh and also, swapping out heap allocation still seems to be missing the point, as there are definitely cases where that's the 'right' behaviour)

</comment></comment></comment></comment></comment></comment><comment><USER4> It's pretty amazing how detailed and helpful Rust's error messages are.

        rust_dangling.rs:6:5: 6:6 error: cannot borrow `v` as mutable because it is also borrowed as immutable
        rust_dangling.rs:6     v.push(6);
                               ^
        rust_dangling.rs:4:14: 4:15 note: previous borrow of `v` occurs here; the immutable borrow prevents subsequent moves or mutable borrows of `v` until the borrow ends
        rust_dangling.rs:4     let x = &v[0];
                                        ^
        rust_dangling.rs:8:2: 8:2 note: previous borrow ends here

<comment><USER5> you got that right, I wish all languages did that,and why not, even suggest modifications to the code in order for it to compile or run... Errors should be an opportunity for programmers to learn, it shouldn't feel like a punishment. But we'll get there eventually.

<comment><USER6> Obviously not so much for the kind of memory errors the GP is talking about, but clang/clang++ do provide similarly detailed error messages, including suggestions for name-related errors as to what you might have meant (either because a different variable provides the member you specified or becuase of a similarly spelled name).

<comment><USER7> clang was what I based the current Rust compiler's error messages on. Matching its quality was a design goal from the start, since I think that one of the biggest reasons for clang's success was the quality of its error messages. Diagnostics are the UX of a compiler, and so they're deserving of the exact same care that is put into mobile app or Web design.

<comment><USER6> Yes, absolutely. I have a theory that a big part of the reason clang leapfrogged g++ so quickly on these things is because it was (initially aiming to) dogfood itself, So getting better error messages than g++ could give was an early and high priority task to its first users.

</comment></comment></comment></comment></comment><comment><USER8> The author mentions that Rust's "Box type is an owning type" and compares Box to C++'s std::unique_ptr. Worth noting: Rust's most basic variable syntax provides unique_ptr-like behavior, so you usually don't need the Box type for this behavior. For example:

[https://gist.github.com/jarrett/fe3f24c301a586efd7c1](https://gist.github.com/jarrett/fe3f24c301a586efd7c1)

<comment><USER9> Are you sure your comments are right? It seems to me like the value would be memcpyed, when you pass by value. There is not one unit of memory that is "taken over," or if there was, then Rust would have a serious problem.

<comment><USER8> > It seems to me like the value would be memcpyed, when you pass by value.

As far as I know, the compiler should not copy in that instance. Rather, it should move.

> There is not one unit of memory that is "taken over," or if there was, then > Rust would have a serious problem.

Could you elaborate on that? Rust does have an ownership model, and ownership can be transferred as in the example. What sort of problems would you expect that to cause? If you're worried that it will invalidate existing pointers, the compiler checks that for you. Unless you deliberately circumvent the check, the compiler guarantees that your pointers are valid.

<comment><USER10> Semantically speaking, the only difference between a move and a copy is that you're allowed to use a copy type afterwards, and you're not allowed to use a move type afterwards. It's still a memcpy. Of course, these may be elided by optimization passes.

<comment><USER8> > Semantically speaking, the only difference between a move and a copy is that > you're allowed to use a copy type afterwards

Are you speaking about Rust specifically, or move in general? I had always understood that move was no more expensive than passing by reference. That is, I had thought the memory was on the heap and didn't need to be copied each time someone new took ownership of that heap space.

<comment><USER10> I mean in Rust.

> That is, I had thought the memory was on the heap

An example:

        let x = Box::new(5);
        let y = x;

While the 5 is allocated on the heap, when we move x to y, _the pointer itself_ is memcpy'd. That's why Box<T> isn't Copy; as you say, a simple memcpy won't actually duplicate the structure. Make sense?

(and in this case, I'd assume llvm's optimizations would realize the copy is superflous and just elide it, but semantically, that's what's up)

<comment><USER8> Oh, agreed. But how about this:

        let x = BigExpensiveStruct::new();
        some_function(x);

That won't trigger a big, expensive memcpy of the BigExpensiveStruct, will it? I'd thought that its memory was on the heap.

<comment><USER10> If that's just a struct, it's stack allocated. So it's not ok the heap in the first place. IIRC, LLVM may optimize passing it to the function by reference though.

<comment><USER8> Good to know. Thanks! So I guess the moral is, if you have a big, expensive struct, make sure the expensive part is in a sub-structure you _know_ is heap allocated, such as a Vec. E.g.:

        struct Expensive {
            cheap_value: u32,
            expensive_value: Vec<u32>
        }

Does that seem like a good maxim?

<comment><USER9> That is not a big expensive struct (to memcpy). (edit: I'm just bickering about what to call things, what you say is right.)

Your intuition about the performance of this sort of thing might be served by reading about how calling conventions work. You might not need to copy the struct from a local variable to where it belongs on the stack or in registers when calling a function, either because the calling convention says you put a pointer to the struct somewhere (depending on its size) or because you're (you being a compiler) clever enough to put it in the place that'll end up in the argument list later. The callee, however, has less flexibility, and if it needs to pass the value somewhere else, it'll probably have to copy the data. This is way better than allocating it on the heap -- stuff on the stack is in the L1 cache, you compute it's location statically instead of having to traverse data structures, but yeah if you found yourself copying around a 1000-byte struct you might want to box it or pass it by reference. I only know about C and C++ calling conventions though, so don't infer from my comment that Rust isn't doing anything "special" for big non-copyable structs -- I wouldn't know.

<comment><USER11> Rust (well, LLVM really) will automatically pass any "large" struct by reference, which in practice is going to be anything more than a few words (I think in the current implementation, it might actually be two). Unless the function call is inlined, of course, in which case LLVM can do pretty much whatever it wants.

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER12> Those trivial examples seem to be mostly to not scare off C++ programmers. It's more interesting, though, to see how far you can push single ownership. You can build a single-ownership tree. Rust lacks a "nil", but has discriminated variant records (called "enums") to handle has/doesn't have semantics. You can also grow a <Vec> of owning references, so you can have an array which owns a variable number of children. Using all those features together, you can build a tree. Take a look at the XML library for Rust to see how this all works.

But it can't have backpointers. That would violate single-ownership. Weak pointers for backpointers are available, but that's an unstable feature and introduces reference counting overhead. Rust needs some construct which includes a single-ownership forward pointer and a dependent back pointer, updated together so that they're always in sync.

<comment><USER13> > Rust lacks a "nil"

Rust has the concept of a possibly-null pointer; you just have to write it explicitly by wrapping something in the Option type. In particular, Rust has a guaranteed optimization that says if you have a type with a single zero- argument constructor and a one-argument constructor, and the one-argument constructor takes a type that can't be null, then the type with those two constructors will just use null to represent the zero-argument constructor. So Option on a pointer/reference type just represents a nullable pointer.

<comment><USER12> Rust's "Option" type is a generic enum. There is no explicit "nil".

<comment><USER14> That's what she said.

</comment></comment></comment></comment><comment><USER15> To me, C++ suffers a lot from the "spoonful of sewage syndrome". Yes, C++14 is a lot prettier than C++, but they preferred to be backward compatible with a rotting language. If people know that some things are bad, but prefer to retain them (for whatever reason), then they should not complain that at some point somebody comes along and just drops the insanity. (yes, C++ would be a lot better (or less worse) if they would correct mistakes from the past).

Anyway, Rust is simply a language with a lot less cruft, combined with a better tool chain (compare rust compiler errors to g++ compiler errors). That's not a surprise, considered C++'s age (30+ years). OTOH, without C++, Rust would have been impossible. OTOH2, Rust wanted to be somewhere between C++ and OCaml. I think they succeeded.

<comment><USER16> C++11/14 should have been a clearer break from legacy ANSI C++. Overloading of keywords just to avoid adding new keywords to the grammar (lexer/parser) - that's what makes C++ really ugly. Especially if one has to read through old third party code. The STL was so slow/bad that almost ever PC game shipped with their own implementation. (I heard STL implementations got better). Boost is too bloated, the compile time and executable increases and many avoid adding it to their project.

<comment><USER17> We all know how clean breaks work out....

<comment><USER16> Yes, we know.

But adding new keywords instead of reusing/overloading old ones for newer features would have been nice. Writing new code in C++11 isn't the problem, reading old ugly C++ code and trying to understand it is. I think the clean break is Rust and it already looks promising. Sure some of its syntax is influenced by non-C languages and looks a bit weird, but I can live with that.

<comment><USER17> I like a lot of C++ (since C++ARM days), but I also like safe systems programming more (Ada, Modula-2, Oberon, ...).

The question is if Rust will earn the hearts of an OS vendor and be available in their respective SDKs.

Right now I see Apple going Swift and Microsoft making .NET compile straight to native code.

<comment><USER16> Operating systems today are mainly C based (majority of kernel mode code) - WinNT/ReactOS, Unix/Linux/*BSD/OSX/Android. Also in the user mode side, C is heavily used in all above mentioned OS (WinAPI, DirectX, etc. are all in C). C++ is also heavily used (e.g. for GUI applications like Office and newer OS development). Most third party applications are written in C++ inclusive almost video games of the last 15 years. Apple bought Steve Jobs' NeXT Software and with it NeXTSTEP (now MacOSX) and Object-C.

I read somewhere that Microsoft is working on a Rust competitor and Swift with it's great syntax is refreshing. But with these closed languages, I hope that Rust has success.

Ada is great and heavily used in specific domains - only its syntax is not that great. Also VHDL is based on Ada and its syntax. I had a Professor who had worked on Modula&Oberon with Niklaus Wirth, though he later moved on to Sun Java.

<comment><USER17> > Operating systems today are mainly C based

Only if you are speaking about UNIX clones.

Genode, BeOS, Symbian and OS/400 are a few examples of OSes developed in C++.

> C is heavily used in all above mentioned OS (WinAPI, DirectX, etc. are all > in C)

DirectX is COM and most new WinAPI since Vista are also COM.

No one in his right mind uses COM from C instead of C++.

Windows is moving into straight C++ as of Windows 8, with the adoption of kernel support for C++ based drivers and the move into WinRT, a COM superset coupled with .NET metadata.

The upcoming Windows 10, embraces WinRT for its Universal API model and C style is considered legacy. Hence why Microsoft is not caring to update their C support beyond what is required by the ANSI C++ standard.

Good luck coding COM and WinRT applications with pure C.

Mac OS X drivers are written in a C++ subset, Embedded C++.

Now imagine, if it has taken this long for C++ to start replacing C in core OS development, how long it will take for Rust to fill in?

Rust is nice, but I am too long in this industry and have seen too many languages come and go in systems programming. The only ones that stayed around have had OS vendors support in their respective SDKs.

<comment><USER16> > Only if you are speaking about UNIX clones.

I wrote "operating systems today are mainly C based" and that's true. Also WinNT/ReactOS was inspired mainly by VMS and OS/2\. I am well aware that many other OS exist.

> DirectX is COM and most new WinAPI since Vista are also COM

Fundamentally DirectX and the (post Win95a) shell is COM-based API, and while COM may look on the surface as if it is C++ based, it's actually not - a COM interface isn't a class, it's a struct, and full C compatibility exists (COM as-designed is intended to be language-neutral). And major parts were coded in C. I suggest checking out the Wikipedia article on COM for further info. Coding against COM from C may not be as simple as from C++, but that doesn't matter. dotNet and their new WinRunTime are also COM-based. Sure, it's clear that MS is using C++ nowadays and nothing is wrong with that. The real question is what the future of C#? Will it be 'replaced' by a new language similar to Swift and Rust? Or maybe it will get a static compilation option similar to Go-lang that contains the GS and parts of the framework in the executable. Microsoft has little C# based software on the client side - due to the massive setback and fail of the original "Longhorn" where the new C# based Explorer and WinFS beta1 were way too slow. Nowadays C# based server side product development is mainly done by MS India (e.g. SharePoint). So as it seems they are back to native WinRT (COM based) and HTML5.

> Rust is nice, but [...] The only ones that stayed around have had OS vendors > support

Dogfooding is important and Rust is already used in the Mozilla Servo project, a new web engine. One can imagine that a future FirefoxOS will be based on it as well (replacing the C++ based Gecko engine), as it already uses no legacy XUL GUI code. And there are Rust based experimental operating systems like from "Julia Evans": [http://jvns.ca/blog/2014/03/12/the-rust-os- story/](http://jvns.ca/blog/2014/03/12/the-rust-os-story/)

<comment><USER17> > I suggest checking out the Wikipedia article on COM for further info.

I know COM since it was called OLE and promoted as an DDE evolution.

Developing software since 1986.

> Or maybe it will get a static compilation option similar to Go-lang that > contains the GS and parts of the framework in the executable.

It already has that since Singularity, via Bartok, which was adopted into Windows Phone 8 via MDIL, which produces native binaries with dynamic linking.

[http://channel9.msdn.com/Shows/Going+Deep/Mani-Ramaswamy- and...](http://channel9.msdn.com/Shows/Going+Deep/Mani-Ramaswamy-and-Peter- Sollich-Inside-Compiler-in-the-Cloud-and-MDIL)

Static linking Go style is coming with .NET Native.

[https://msdn.microsoft.com/en- us/vstudio/dotnetnative.aspx](https://msdn.microsoft.com/en- us/vstudio/dotnetnative.aspx)

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER18> Unfortunately most of the C++ vs Rust comparison posts are coming from people who aren't familiar with C++'s idioms and it's obvious that it's not their day to day / goto language.

</comment><comment><USER19> Is there anything that compares Rust's performance vs other languages?

<comment><USER10> Like all performance questions, the answer requires another question: "at what?"

There's been a number of different benchmarks, in a bunch of places. We generally end up in the same realm as C++, sometimes faster, sometimes slower.

Also, many benchmark authors seem to accidentally compile Rust code without optimizations. We're considering switching Cargo's defaults because of this.

<comment><USER19> I'd be interested in seeing Rust included in [https://www.techempower.com/benchmarks/](https://www.techempower.com/benchmarks/)

<comment><USER10> Yeah, it might be neat. It's still unclear how good Rust is going to be at website backends, though there's a lot of people putting hard work into it. Once it all matures, seems good.

<comment><USER19> I'm considering C++ for an NLP related project. Normally I use Java/Scala, but the memory usage when you have to store a lot of strings, is pretty high. (The Stanford NLP library recommends at least 3-4Gb of Ram)

I'm considering C++ for the lower memory requirements, but obviously the syntax, etc aren't ideal. Do you have any opinion on how Rust would perform in that scenario?

<comment><USER10> I'm not mega familliar with NLP as a field, but abandoning Java means you abandon Weka, right? While Rust the language might be good for this, there's basically zero libraries, so you'll be doing all that work from scratch.

</comment></comment></comment></comment></comment></comment><comment><USER20> More Rust compared to C++: [http://rosetta.alhur.es/compare/C++/Rust/#](http://rosetta.alhur.es/compare/C++/Rust/#)

<comment><USER10> This Rust code is very, very, very out of date. There's a project to update things to a more modern Rust: [https://github.com/Hoverbear/rust- rosetta](https://github.com/Hoverbear/rust-rosetta)

<comment><USER20> Why aren't these tasks being updated at RosettaCode?

<comment><USER10> I believe they were waiting for stability so that they wouldn't introduce churn. Unsure though, I don't really participate in that project.

</comment></comment></comment></comment><comment><USER21> Are there examples where borrow checker stands on your way? Like the mentioned (in comments) way of building a tree. I'm sure there should be really weird edge cases.

<comment><USER10> Newcomers to Rust often find that the borrow checker _always_ stands in their way, because they haven't internalized the rules yet. I've also spoken with a few frustrated ex-C++ers, who have some sort of pet pattern that works basically all the time, but the borrow checker doesn't like the 'basically.'

Another good example is that the borrow checker is currently based on lexical scope. See all the examples in [https://github.com/rust- lang/rust/issues/6393](https://github.com/rust-lang/rust/issues/6393) .

In general, any kind of analysis like the borrow checker will reject some valid programs, as it pays to be extra conservative. You then slowly expand the set of accepted programs, until hopefully, it matches the true set of valid programs, without accepting invalid ones.

<comment><USER13> > I've also spoken with a few frustrated ex-C++ers, who have some sort of pet > pattern that works basically all the time, but the borrow checker doesn't > like the 'basically.'

What kinds of pet patterns have you seen?

<comment><USER10> It's hard to remember specifics, as this is usually based off of someone jumping into IRC and asking a question about how a certain thing works. They're often very detailed things that require intimate knowledge of implementation details. Or threads like [http://www.reddit.com/r/rust/comments/31mgav/what_would_the_...](http://www.reddit.com/r/rust/comments/31mgav/what_would_the_rust_equivalent_of_this_c/) , which isn't really _wrong_, but unions are hard, and so people miss them.

This kind of thing happens any time you transition languages: when I started hacking on Rust, I was trying to figure out how to do the metaprogramming shenanigans that Ruby lets me do. Ironically, Rust's metaprogramming features are my biggest weakness as a Rust programmer, I don't really write my own macros.

</comment></comment></comment></comment><comment><USER22> Lately I have been thinking that we are getting the abstraction wrong in programming.

In real world, abstraction is a lossy process. From "white horse" to "horse", we lose the information about color. And this lossy nature of abstraction is important, as it become simpler. This should be differentiated from saying "horse" but actually meant "white horse", because in that situation, it is not abstraction but omission. The complexity is still there (or even more).

In programming, add types or mutability increase the complexity. In that regard, Rust is simply more complex. But that is not what I commenting on. I am commenting on the trend in programing to hide that complexity by omission (such as type inference) or make it implicit such as using key word 'let' and 'var'. They only make the user less aware of the complexity at surface.

Now I am not saying language designers are not doing the best they can do (earn both honest and popular credits); but I have been thinking what might be the ideal way to handle complexity, and I only can see how we are doing it with our natural language. In our day to day business, when we say horse, we do not care about its color, and any one who interprets the sentence (with horse) is fine to imagine either a white horse or black horse or any but need understand the color is not important. So in analogy, in high level abstraction, we should be allowed to say a number with no type but be understood by the compiler that any number will do, which may even include a byte. Then the language should allow us to declare specific type as well -- just like in real life we should be able to directly say "white horse" if the color is meant to be important. Which means we should be able to specify an integer with 64 bytes long (I don't think we ever really need arbitrary precision) if we deem critical. We should note that I am not referring a dynamic type, nor an optional type system. The type is always specific at very low level (cpu level). The compiler decides for us when we don't say and we don't say when it is not important any compiler decision is ok.

Of course this is not realistic and the reason is simple. The way we do daily business leads to imprecise implementation. I say horse, and it can be implemented either as a white horse or black horse or anything in between (hopefully a common one at least). It is tolerated in our daily life because the implementation is often cheap and can be directly verified at every level. E.g. I say get me a horse, I verify your facial to see if you heard, and verify you action to see if you are about to act, and I get in between gossips to get warnings of any surprises, ..., all the way until I actually have the horse. And along any of these steps, if I find I actually meant a white horse and you are not getting a white horse, I interrupt your implementation and make corrections. In programming, writing code is expensive (programmers are paid well, takes long time), and the typical only feedback is when the code completes and the user uses the software (at which point the user is getting the feedback, not programmer), and when things go wrong, user have no idea how to make correction, and this is even true for programmers, who have no idea what is inside their libraries and the nuances of the programming languages they are using.

TL;DR We are stuck.

To solve this scenario, I think the first step is to make every one be able to program, then the implementation can become cheap, and the feedbacks can become short and quick, and the compiler can become less rigorous, and then we may be able to program like we speak -- program the way we thinks.

<comment><USER16> We could write down our problems in simple English.

We then use do a natural language parsing (NLP), and transform the output to Prolog code. We execute the Prolog code and use a search engine to find the solution. Each result is used an input for another (second) search step. We score each result and _do something_ with it. That's more or less how IBM Watson works.

<comment><USER23> So, like [http://gkoberger.github.io/stacksort/](http://gkoberger.github.io/stacksort/)? ;]</comment></comment></comment>


Vator.tv - It's YouTube for Start-Ups - <AUTHOR> http://www.vator.tv <comment><USER2> Hmm.. Why not just post your business pitch on YouTube and reach a wider audience? Just curious how this site can bring anything unique to the already full YouTube table. There seems to be a lot of video posting/hosting sites that think success can be had by claiming support for a niche market when there is really little new functionality there to truly differentiate.

Best of luck to them though. The basic idea is great for the group here.

<comment><AUTHOR> Good question - the twist on Vator.tv, as I understand it, is that each quarter the top voted video has the opportunity for VC funding.

<comment><USER3> I think I'll pass on any investment that is based on an unrelated popularity contest. Popularity of my product ought to play a role here...but popularity of a video about it?

Anyway, I don't get it and won't visit again, though I think there's still plenty of room in the online video market for niche entries.</comment></comment></comment>


Why Doing Nothing Is One of the Most Important Things to Do – Time - <AUTHOR> http://time.com/5300633/doing-nothing-work-vacation-time-history-leisure/ <comment><USER2> I often forget to do nothing. I'm very action oriented.

Recently I've started taking a few short breaks during the day. If I'm at work I put my arms on my desk, rest my head in my arms, focus on my breathing and count ten exhalations. If I'm at home I do this laying down, usually counting thirty exhalations. The home practice turns in to multiple ten to thirty minute rest periods throughout the week.

When I'm in the habit of doing this my life is, self-reported, sample size of one, noticeably calmer and more enjoyable.

</comment><comment><AUTHOR> IMHO, being productive and creative are two almost incompatible things for us mere mortals:

\- Being productive requires focus and energy to get things done. Typically, the "obvious" decisions are being made and implemented;

\- Being creative, or even thinking out of the box, requires one to relax, get their mind wandering, wait patiently for that creative spurt to come...</comment>


California Considers $1,000 Fine for Waiters Offering Unsolicited Plastic Straws - <AUTHOR> http://reason.com/blog/2018/01/25/california-bill-would-criminalize-restau <comment><USER2> But why? Do lawmakers think that waiters set policy? I hope that this is a joke, because 6 months in jail/$1000 is truly insane.</comment>


a² + b² = c² - <AUTHOR> http://i.imgur.com/DrROq.gif

<comment><USER2> Cute... It reminds me of proofs my father designed into a barn he built years ago.

<http://waiveris.com/project/fractals/barnwindows/>

</comment><comment><USER3> I like that it's animated; nearly every static "visual proof" of the Pythagorean theorem is nearly incomprehensible to me without a lot of explanation---I'm a _huge_ fan of visual proofs but for most of them you really need a time dimension to make sense of them.

</comment><comment><USER4> Another cute way that's more obviously correct without translations is to consider a square with sides of length a+b. You get an interior square of area c^2 and 4 right triangles with legs of size a and b.

</comment><comment><USER5> Nice animation, but I think in the last step when c² is mentioned (after "a² + b²"), the c-square should be restored such that it is again visible as square.

</comment><comment><USER6> now let's do this for the rest of the education field!

</comment><comment><USER7> If you like this sort of thing, definitely check out this book: [http://www.amazon.com/Proofs-without-Words-Exercises- Classro...](http://www.amazon.com/Proofs-without-Words-Exercises- Classroom/dp/0883857006/)</comment>


Corporate profits continue to increase, while wages continue to languish - <AUTHOR> https://twitter.com/RBReich/status/1018239133578194944 <comment><USER2> If it was that easy, everyone would be creating their own companies...

</comment><comment><USER3> The concept of profit maximization rules most of the corporate sector.</comment>


The return of turtle.  Growing demand for Logo programmers - <AUTHOR> http://techcrunch.com/2015/01/09/disney-builds-an-adorable-robot-to-etch-massive-pictures-onto-the-beach/

<comment><AUTHOR> Turtle is back! [http://en.wikipedia.org/wiki/Turtle_(robot)](http://en.wikipedia.org/wiki/Turtle_\(robot\))

The professionalisation of drawing in the sand. I can't work if this is a good thing or a bad thing - aren't sand drawings meant to be done with a stick by children?

One thing for sure is that you'll need to sharpen your Logo [http://en.wikipedia.org/wiki/Logo_%28programming_language%29](http://en.wikipedia.org/wiki/Logo_%28programming_language%29) programming skills in future.

Here's some historical turtle robots: [http://images.google.com/search?tbm=isch&q=turtle+logo+robot](http://images.google.com/search?tbm=isch&q=turtle+logo+robot)</comment>


MIT's free online classes can lead to degree - <AUTHOR> http://m.sfgate.com/business/technology/article/For-1st-time-MIT-s-free-online-classes-can-carry-6556128.php <comment><USER2> That is nice and all, but it will still cost you $1500 for the 'MicroMaster' credential and then another $33K for the rest of the year long program. Still no chump change by any stretch.</comment>


Ask HN: Best way to listen to your own mp3s on your iPhone? - <AUTHOR> <comment><USER2> You can load them into iTunes if that's your thing. I personally don't like the UI, and have used foobar2000 for a good while (with a custom theme). You can load music onto it using iTunes, or from the files app on your phone. In foobar2000 you can also download from a upnp server, which is nice if you don't have iTunes (like me). If you have Plex, the Plexamp mobile app works pretty well. It supports your playlists, downloading, and a pretty good radio.

</comment><comment><USER3> Personally, I like to use Decoupled ([https://decoupled.app/](https://decoupled.app/)).

* Supported formats: FLAC, Ogg, Opus, Apple Lossless, MP3, AAC, WAV.

* Music sync through USB, via iTunes File Sharing or via FTP, WebDAV and a simple Web browser.

* Includes Dark mode.

</comment><comment><USER4> I use the VLC app (I'm on Android). I use the SanDisk Ultra Dual Drive Go USB Type-C Flash Drive which has both a Type-A and Type-C connector so it's easy to transfer files.

</comment><comment><USER5> I love Poweramp (i'm on android). Plex is second best but has stability problems.

</comment><comment><USER6> iMazing

Been using it for years and years. Currently on my iPhone SE with a headphone jack. Total win.

iTunes made me insane. I had hundreds of albums carefully ripped during the before times. Plus a radio show archive.

<comment><AUTHOR> Exactly what happened to me. Wasted several hours over the past two weeks trying to make sense of iTunes. So frustrating.

Thanks for the tip. I will try iMazing.

<comment><USER6> Cool. If you figure out the setting for gapless playback, post it here, per favore. It rarely bugs me, but there's In the Aeroplane Over the Sea, Lamb Lies Down on Broadway, and a few others where it pops up. Not 100% sure I'd change it though. I use those milliseconds to remind myself that it is still an option to thrive in the hedgerows.

<comment><AUTHOR> > Lamb Lies Down on Broadway

One of the best song and album ever.

<comment><USER6> Too bad it's so early in the world's day and this thread is sinking. I think you could and should have gotten some great comments.

I'd be interested in other related tech, plus the music recommendations of us pioneers, rebels, mutineers, and so forth. (Yes, a poke at Apple ;)

<comment><AUTHOR> HN should find a way to counter-balance that. Most successful threads are timezone friendly to the US.

Anyway, on your poke at Apple, you reminded me of the 1984 ad. Most people don't know the fine details of the story of it and its meaning. From Wikipedia [0]:

> "Let's see—an all-powerful entity blathering on about Unification of > Thoughts to an army of soulless drones, only to be brought down by a plucky, > Apple-esque underdog. So Big Brother, the villain from Apple's '1984' Mac > ad, represented IBM, right? According to the ad's creators, that's not > exactly the case. The original concept was to show the fight for the control > of computer technology as a struggle of the few against the many, says > TBWA/Chiat/Day's Lee Clow. Apple wanted the Mac to symbolize the idea of > empowerment, with the ad showcasing the Mac as a tool for combating > conformity and asserting originality. What better way to do that than have a > striking blonde athlete take a sledgehammer to the face of that ultimate > symbol of conformity, Big Brother?"

[0]: [https://en.wikipedia.org/wiki/1984_(advertisement)](https://en.wikipedia.org/wiki/1984_\(advertisement\))</comment></comment></comment></comment></comment></comment>


A Number Theorist Who Solves the Hardest Easy Problems - <AUTHOR> https://www.quantamagazine.org/james-maynard-solves-the-hardest-easy-math-problems-20200701/ <comment><USER2> Now I'm curious about that last result discussed, for bases less than 10 - "proving that there are infinitely many primes that don't have any 7s (or any other digit you might choose)". It sounds like Maynard decided to stop at proving the result for all bases 10 and above, but could it be true for the smaller bases too?

In the case of binary numbers, proving that there are infinitely many prime binary numbers without a 0 is the same as proving that there are infinitely many Mersenne primes, so the (non-trivial) binary case seems to still be a difficult open problem.

It would be fascinating if there's a cutoff in base expansions where this stops being true.

<comment><USER3> I suspect in that in any base b, and for any collection of base b digits such that the gcd of the whole set is 1, there are infinitely many primes which only use those digits. I also suspect the Mersenne case b=2, set={1}, is the hardest.

</comment></comment><comment><USER3> This left a bit of bad taste in my mouth: "It's easy to imagine an alternative timeline in which Zhang proved his result six months after Maynard instead of six months before."

I don't think even Maynard has claimed he would have gotten to bounded gaps without Zhang.

<comment><USER4> The article does call Maynard's approach "completely independent". So while Maynard himself might not want to make any such claim, clearly the impression left with the interviewer is that he would indeed have got there without Zhang.

</comment></comment><comment><USER5> Does this mean that for any given prime, there will always be a prime within 600 digits? Or that given a set of infinite numbers, you can also construct an infinite set of pairs of primes 600 digits apart?

<comment><USER6> > Does this mean that for any given prime, there will always be a prime within > 600 digits?

No. Euclid showed that the gap between consecutive primes can be arbitrarily large. In particular, n!+2, n!+3, ..., n!+n are all composite whenever n>1.

> Or that given a set of infinite numbers, you can also construct an infinite > set of pairs of primes 600 digits apart?

It means that there are infinitely many pairs of primes p and q such that 0 < |p - q| < 600.</comment></comment>


Debunking the Myth of the 10,000-Hours Rule - <AUTHOR> http://www.brainpickings.org/index.php/2014/01/22/daniel-goleman-focus-10000-hours-myth/

<comment><USER2> This is debunking a popular misinterpretation of the 10,000-hours rule by restating the actual rule. It's 10,000 hours of _deliberate practice_ , and it's only possible to sustain about 4 hours of this per day.

It's not debunking the actual rule.</comment>


Ask YC: Rate my news aggregator prototype - <AUTHOR>

First, if you want to skip my explanation and just see what I've built, http://startupurls.com/
For those with a bit more time, first, my problem:
I don't go to popurls.com because I don't like reading news about Brittney Spears or the latest rantings from Digg, but I really like the concept. I like looking through top news stories in an aggregator along with unique photographs and videos.
But I've never found anything like it that is focused around startups.
I have a couple of specific questions.
1. Is this a site you'd visit?
2. What other url's would you be interested in getting news from? (I looked at startups.alltop.com, but it seems that most of that is not very high quality -- it seems to be there simple because the blog has the word "startup" in it. There are a few exceptions).
I'd really like to see where you read about startups, which reminds me, I need to add killerstartups.com.
Plus, there are no pictures. Pictures break up the monotony of getting news from text, IMHO.
3. Are there any sites (or feeds) that show videos re: startups? Pictures?
Thanks! <comment><USER2> Seems like a site like this will live or die by the curation. Its not clear to me why I would visit your site versus Hacker News since the community here culls out the startup related posts from the sources you have listed on your site already.

Also, "startups" is a pretty broad topic and there are lots of sites which aggregate startup related content. It seems like you could be more successful by picking some aspect of startups and focusing on aggregating content related to that specific aspect.

As far as video, vator.tv has lots of startup video content. I am not sure about pictures, but sites like slideshare.com have interesting startup related presentations.

<comment><AUTHOR> Thanks for the tips.

What do you mean by "curation?"

<comment><USER2> Just the idea that you could bring a lot of value by only displaying content that is truly related to startups. For example, you are pulling in the straight TechCrunch feed, but in reality only a small percentage of TechCrunch stories are really relevant to startups. One potential way to improve on the sites that inspired your site is by creating some filtering system to only show the relevant stuff. I know Guy Kawasaki has said that AllTop is targeted to folks who don't know how to use feed readers (i.e. non-techies). But an audience for a startup related news is probably already grabbing the feeds for a lot of these sites. So, you could make the user experience better by filtering out some of the "other stuff" either programatically or by hand. Anyway, hope this is helpful.

<comment><AUTHOR> Good point. Thanks for the feedback.

</comment></comment></comment></comment><comment><USER3> A nice idea.

I like the concept. The execution is good too :D

Your right pictures would be nice if you can get them in.

Also I would push the content to the right and put a slim sidebar with some more info and links to stuff you can't syndicate (perhaps).

One killer feature (not sure how far you want to go with the site :D) might be to allow accounts and then for us to save our favourites or memorable content for future reference (like a personal search.yc).

+woot though :D

<comment><AUTHOR> Thanks for the feedback.

I'm not sure if this will take off or not, but it's something that I'll visit every day, and in the end that's all that matters (unless I was depending on this to feed the fam, which luckily I'm not).

I still can't believe there's so much open-source software that allows creations like this to be possible. I had it running in about 30 minutes.

</comment></comment><comment><USER4> Personally I would just subscribe to the blogs I'm interested in by RSS, but then again popurls does seem to be popular, so I'm sure there is some portion of people who prefer this.</comment>


Muon-catalyzed fusion - <AUTHOR> https://en.wikipedia.org/wiki/Muon-catalyzed_fusion <comment><USER2> Had a friend trying to raise money for a startup supposedly going to make energy using that. Turned out to be scammy.</comment>


Starting Up in a Down Economy - <AUTHOR> http://www.inc.com/magazine/20080501/starting-up-in-a-down-economy_pagen_3.html

<comment><AUTHOR> Sorry for posting page 3. This is a repost, but I think it's appropriate at the moment.

<comment><USER2> well, now we all know that at page 3 you thought we should all read it.

did you read past page 3?

<comment><AUTHOR> I posted page 3 because page 1 has already been previously posted, but didn't get modded up.

I'm reposting because I think it's a good read given the current situation.</comment></comment></comment>


Google Analytics problem - odd map of Florida - <AUTHOR> http://www.convertyourcds.com/blogs/district-media-works/1540142-google-analytics-map-problem-south-florida-underwater

<comment><USER2> Easter egg by Google I guess... Kind'a one the had - trip between Boston and London or so.</comment>