Ask HN: If you were Edward Snowden where would you have gone? - <AUTHOR>

Just curious from this crowd, if you were Snowden and knew you were going to go on the run, where would you go?  The list of countries without extradition treaties to the US isn't exactly a list of places I'd want to spend the rest of my life. <comment><USER2> Brazil - Glenn Greenwald, your primary reporter you're working with is based there, big country, cost-effective when you're on a budget, and Greenwald would have a local network of people who could help hide you, _and_ Brazil doesn't extradite political prisoners.

Not to mention, borders on a ton of other countries with fairly porous borders, so you have the possibility of moving from one country to another.

I'm sure there's a lot more options that would crop up depending on a variety of factors. But if you're Snowden you want:

\- A network of friends and associates you can trust to help support you, emotionally, physically, and fiscally

\- To be in a country where the information you're in possession of might be valuable to that country, and could be used as a bargaining tool

\- A country with good, but not great, relationships with the US (so no UK, Canada, EU is probably out).

\- A country with a huge bureaucracy and judicial system - you want it to take years to extradite you

Hong Kong makes little sense on most of those, other than the judicial system.

<comment><AUTHOR> You make some really good points, but why do you say "a country with good, but not great, relationships with the US?"

<comment><USER2> This is hard to define in quantifiable terms, but you don't want a country that's besties with the US, or too heavily dependent on them, because they'll be too willing to jump through hoops to avoid making them angry.

But you also don't want a country that is enemies or has strained relations with the US - they're very likely to take advantage of you/snowden for their own gain. Or arrest you and torture you for the information you have.

You want a country where they like the US, have normal diplomatic relations, but don't necessarily want to seem like a puppet of the americans. They should have a strong belief in protecting individual freedoms.

Also, when you try to get asylum/protection in a country like Brazil or Ecuador or Iceland, etc. - no one can stand up and say, "He's helping our enemies".

</comment></comment></comment><comment><USER3> Russia. It is a big place with lots of choices of interesting places to live. And there is no way that the USA could ever get you out, even with rendition teams, except possibly in the capital Moscow. In fact, In Russia it is easy to disappear completely so that even the Russian state no longer knows where you are. Find a girl, go off an build a cabin in the woods, and live out your life off the grid. There are countless Russian doing just that all over the country because it is just so vast. Even Canadians, who pack themselves in a narrow strip along the US border, have no idea how vast Russia is. Snowden has done his job, leaked the info and demonstrated the incompetence of the US intelligence establishment in protecting its classified data. Other who desire to do similar data collection and leaking now have a roadmap as to how to proceed. Of course there are other countries where you can disappear like Brazil, New Guinea, Parts of Indonesia, but nowhere would give you the government shield that Russia can give. Time to learn Russian. You could be fluent in 3 years and then just disappear. Actually you could likely also disappear in some relatively urban areas once you become fluent, as long as you can keep moving.

</comment><comment><USER4> List of countries: [http://wiki.answers.com/Q/Which_countries_have_no_extraditio...](http://wiki.answers.com/Q/Which_countries_have_no_extradition_treaties_with_the_United_States)

<comment><USER5> from that page: The reality is that the US can request extradition through diplomatic contacts from any country even if no treaty already exists.

<comment><AUTHOR> I agree. From what I've read about other famous fugitives, it seems you're much better off if the country wanting to find you doesn't know where you are in the first place. A country where you can remain hidden is better than one where you can't, even if the latter has no extradition treaty.

</comment></comment></comment><comment><USER6> Hong Kong, remained there fighting extradition until the leaks were exhausted, then showed up for court in the US, ideally in late 2014. Ideally, find a fairly libertarian member of congress of either party (or a coalition) to request me to testify in open congress, and be brought back escorted by congresspeople to do so.

</comment><comment><USER7> To jail, because I'm really naive.

</comment><comment><USER8> I suppose it depends on whether the objective is to go to ground or fight it out in court.

Looking at pmtarantio's list, I'd have to go with the Maldives. At least life on the beach would be nice until I got rendered by SEALs coming up out of the surf.

</comment><comment><USER9> If the USA really want him, they will pretend to let him go into the wild and sometime before the end of his life a black-bag team will grab him. There simply is no such thing as safe anymore.

</comment><comment><USER10> Bolivia. Move to Bulo Bulo o Guayaramerin, you will _never_ be found. Buy some land, some cattle, stay low and live a peaceful life in a quite town in the jungle.

</comment><comment><USER11> I would have gone to New York, grown a long hair and lived low profile. I would create a fake profile on Elance if I had to earn money.</comment>


Tell HN: Steal my ideas - <AUTHOR> I've got a few ideas and I'm not sure if they'll ever see the light of day. I'm happy to share them with HN in the hopes that you work on them or they help give you other ideas. Some may already exist, and if so, I apologize!
Idea #1) A scholarship service/site that doesn't suck
You'd think finding scholarships wouldn't be that hard, but you're in for a surprise. My wife is fixing to start graduate studies and I've been pouring over scholarship/fellowship sites for her. I've spent countless hours just looking for ones for her to apply to, and I've visited 20+ scholarship search engines.
They're filled to the brim with scam/"you could win $100,000! sweepstakes" type scholarships. They also have tons of extra offers from paid for profit universities. Lastly, they display scholarships that she isn't even qualified for, despite narrowing the filters to ones that she is supposed to be qualified for.
I've found different scholarships on each site, so there's not even a single site that has all of the same scholarships on it. I'm starting to wish at this point that there was a paid service that someone could just pay $X for. They'd research for you and send you back a huge list of scholarships that were tailored just for you.
For that matter, you'd think there would be a better service out there that would research anything like that. Kind of like Google Answers/MTurk, only for in depth things. For example, maybe I'm interested in opening a bakery and I want someone to do the research for me for all the competitors in the area, what they charge, what they have on the menu, the size of their bakeries, the available properties in the area, the legal requirements of opening a bakery and getting licensed in the city, etc.
Idea #2) An expat job site that actually helps you immigrate, aka overseas recruiters
I've flirted with the idea of immigrating elsewhere for a while now. But the sheer volume of things you'd have to do just to immigrate is mind boggling, not to mention different for every country. Some professions can help you get a green card in X country, but not Y, etc. I wish there was a site that would be designed for hopeful expats that would connect them with jobs from employers in other countries that hire foreign workers. The site could also guide you through the immigration process, kind of like Legalzoom does for creating a company.
Idea #3) Sortfolio for X
Sortfolio is a neat tool because it's a great way to browse web designers visually. There's lots of other things that could benefit from having this, like what about Web/Mobile app developers? Videographers? What about a way to browse local/regional bands for weddings/gigs?
Idea #4) SponsorMe
How many hours in a given week do you spend on Youtube? What about your friends? Tons of Youtube members easily have 10,000+ subscribers. It's true that they can choose to display ads on their videos, but what about cutting youtube out of the equation? If someone has a video series where they review phones, wouldn't it be neat to be able to reach out to the content creators directly and have them mention your app in their video, or wear your company TShirt? American Idol for instance does this with Coke cups drank by the judges (or at least they used to). Think about how much time they get of their product being on screen.
The site could basically be a marketplace that lists both youtube members who are willing to take on sponsorships and possibly their rates, as well as companies looking to advertise their products. You could browse by category to find the best people to partner with. The site doesn't have to stop at youtube, as there are also traditional bloggers out there that might be interested.
Idea #5) "Beat Mine" restaurant, aka the reddit restaurant
A brick and mortar concept for a restaurant. The restaurants menu is driven by the patrons. For example, let's say the restaurant offers a chocolate cake. You try it but you know your homemade chocolate cake is better. You submit the recipe and the restaurant offers it temporarily. If enough patrons vote for it, that chocolate cake takes the place as their chocolate cake. You could offer a tiny percentage of sales of that dish as commission to the recipe submitter. This would provide constant incentive to keep trying to top that item. But who knows, maybe people (and/or the kitchen staff) demand familiarity when they go to restaurants and this would be a horrible failure. <comment><USER3> My free idea: when using different analytics services, I'm sick of having to add the tracking code and then reconfigure the same users and events for every new service.

So my idea is a third-party site that only collects your data once, and then serves it to other products. Kinda like Twilio for analytics, if you will.

As an added benefit, new analytics startups wouldn't have to build the "collect data in real time" brick. So that might help them focus more on what to do with your data, instead of on how to collect it.

<comment><USER4> This is probably one of the most powerful ideas I have read in a long time. It could be applied to your website data, as well as email data, lifestyle data, financial, etc...

<comment><USER3> Glad you like the idea! It does seem a bit like one of those all-encompassing "boil the ocean" ideas, but PG's last post made me think maybe those ideas are worth considering after all!

<comment><USER5> We've built a product for publishers called "MediaAdapt"

Dynamic vendor agnostic tags for analytics, adserving and targeting. You can mix n match, add / modify providers easily. <http://www.adinfinity.com.au>

</comment></comment></comment></comment><comment><USER6> Idea #2: Great idea, but many of the hurdles you have to jump over in order to immigrate are always served on a case-by-case basis, and are difficult to standardize.

For example, in most EU countries in order to get a work visa you have to display a reason why employer X should hire you over a citizen of their own country, i.e. what skill puts you over the rest of the populace who already pay taxes.

A counter-example is Cyprus, which will give you residency in 4-6 months if you buy property there. So, the only hurdle is $$$.

A more measured, focused version of this idea would be to start with a recruiter, a lawyer and a site: JobsInCountryX.com. As soon as that is moderately profitable, move on to country Y, Z, etc and cover the planet.

</comment><comment><USER7> Regarding #1: I just saw alltuition.com at the LAUNCH conference, they have a really nice UI, and seem to address more or less the pain you are describing.

Regarding #2: that sounds like a really tiny market to go after. People who want to change country. What about a site that tells you where you should live, based on what you want your life to be. It wouldn't focus on international only, think of people moving across states to find jobs, sunshine, or what have you.

</comment><comment><USER8> "For that matter, you'd think there would be a better service out there that would research anything like that."

You're asking for the Semantic Web.

No, really: if everyone's data were available as data, so you didn't have to scrape human-readable representations, this would be approximately trivial (at least, it'd be trivial for Google, because they already have this kind of raw computational horsepower, and experience with embarrassingly parallel programming).

</comment><comment><USER9> As a student, I can say you're spot on with the first one. A huge challenge, to be sure because applications are scattered across the internet as PDF's, docs and outdated online forms. Still - if you could get even 50% of the legitimate scholarships out there and categorize them in useful ways (undergrad, grad, high school, by interest, etc) - I know I would pay for access to a curated list for me.

</comment><comment><USER10> Me too: <http://ideashower.posterous.com>

</comment><comment><USER11> Here's my free idea:

An email service provider (ESP) that caters specifically to B2B and B2C newsletters (I'm thinking 100k to 10mil+ messages a month). It's crazy that this doesn't exist.

MailChimp and similar have pricing that does not scale up. Meanwhile MailGun and similar do not have the analytics or list management that publishers need. They are geared towards transactional messages, not newsletters. Lyris/EmailLabs and Silverpop cater to this market, but their products are not very cheap and not very good. (For examples, their APIs are terrible.)

I think there's a huge opportunity to simply layer a bunch of analytics and list management code on top of Amazon SES.

<comment><USER12> I guess we need to do a better job on our messaging because Mailgun does have Mailing Lists[1] and recipient<>event level analytics[2] that you can aggregate by just tagging messages. We are working on improving the GUI in the control panel for marketing folk, but for now developers can enjoy these for 0.1x cost of typical email marketing services now through our APIs.

[1] <http://documentation.mailgun.net/api-mailinglists.html> [2] <http://documentation.mailgun.net/api-campaigns.html>

<comment><USER11> I would be glad to take another look at Mailgun. Can you easily do segmenting (i.e. Only send this message to people where Job Title == 'CEO')? I think that may have been the dealbreaker when I last looked. Exposing the user's mail agent in analytics would also be nice.

And although I wish I could say all I need is a kickass API, I actually will need a GUI suitable for marketing folks too. Happy to followup privately since my requirements may be slightly unique.

</comment></comment></comment><comment><USER13> Livestream for writers.

A writing block in the top right rectangle on the page.

A chat block on the bottom right.

A menu on the top left.

An ad on the bottom left.

Make the panes able to be resized, or completely hid, by clicking and dragging on the intersection. Any time the menu or chat is visible, the ad must be as well.

Give the writer the power to control thing, like: can users copy and paste? Can users scroll around freely, or are they stuck with author view? Can the file be read when not streaming?

Eventually take it further, become a storefront. Let people sell their written wares.

Ideally? I'd like to work on it.

</comment><comment><USER14> please steal this ideas, too:

google analytics with out the new google analytics (the old google analytics interface using the google analytics API) .. as soon as google sunsets the old version (what they wanted to do last jan) there will be a lot frustration (as the new GA - currently - sucks, hard)

huge market (there will be millions and millions of frustrated users) - <USER2> easily be a premium market (5$ to 25% per user?) - i would be the first to sign up.

<comment><USER15> What's wrong with the new analytics program?

<comment><USER16> One thing all my clients are screaming about is "Where did the email report as pdf option go?"

That's been on the "coming soon" list ever since the new interface launched - no sign of it yet…

<comment><USER17> Shameless self-plug:

www.getmetricmail.com :D

</comment></comment></comment></comment><comment><USER18> Idea #1 <http://www.alltuition.com>

They presented at the Launch Festival this week, and won the "Best Overall" award.

</comment><comment><USER19> Idea #4:

<http://www.tadcast.com/> <https://mashable.com/2009/01/12/tadcast/>

(Also <http://www.brandfame.com/> and <http://videosponsorhouse.com/>)

There are some other startups that focus on placing background music in online videos.

</comment><comment><USER20> Idea #3:

<http://theymakeapps.com>

<http://scoutzie.com>

</comment><comment><USER21> Idea #1:

<http://www.academicworks.com/>

I interviewed with them last winter. Nice guys.

</comment><comment><USER22> These are all really good. Great to see so many giving ideas away.

I've put a few on my blog over recent months in case anyone's interested:

<http://willgrant.org/category/idea-dump/>

I know one (Wavetees) is being turned into an actual product.

<comment><USER23> Thar be some good ideas here mate, thanks for sharing.

</comment></comment><comment><USER24> A site that lets people crowd-source commercial products, like mobile or web apps. I think the hard part would be figuring out the value he person contributes to the product.

</comment><comment> saiko-chriskun I might be willing to do the coding for #2 if someone else has experience in the area and can help with the design/direction of the app :)

<comment><USER25> I like idea 2 and have years of experience both as being an expat and an employer who immigrates (Oil & Gas professionals). The revenue is drive from the recruiters side. Simple interface. 'I want to work in....' 'I am good at....' 'My family situation is...' etc. Pre sorted meta data and resume to recruiters who can immigrate the best talent in each sector, pre selected to those who actually want to go to that country/region. Rather than now when you start with a list of people who may not want to move to move to USA when they would like to go to Aus or Singapore etc. I'd love to do something like this. I can't code worth a damn but I am a relative expert in this area.

</comment></comment><comment><USER26> The #2 problem is served by a large, established industry called relocation services (<http://en.wikipedia.org/wiki/Relocation_service>). Combining this with a job board doesn't really make sense - the reason people are moving to the US for jobs and not vice-versa is because there are a lot of jobs in the US and not in the places where people are moving from.

</comment><comment><USER27> #3 - if you do one for bands, or want to discuss, get in touch: bas _AT_ versastudio.com</comment>


Ask HN: Will Mick Jagger face the music for taking advantage of his position? - <AUTHOR> And all the other rockstars who have used their position of power for exploitative personal gain? <comment><USER2> If getting groupies and having women throwing themselves at you because your a rock star is now considered a moral crime, then the American Dream and probably Western civilization is dead.

However, I think it's more likely that neither is dead and Mick Jagger nor any other musician needs to "face the music" for living wild and free, and you're just one of many obnoxious liberal/progressive agitators on their latest witch hunt.</comment>


Atomic Weights of 10 Elements on Periodic Table to Change - <AUTHOR> http://www.scientificcomputing.com/news-DS-Atomic-Weights-of-10-Elements-on-Periodic-Table-to-Change-122110.aspx <comment><USER2> The article has error or at least it is misleading.

Short version:

* ~1815-~1960 they use the H=1 or O=16 scales. They are two different scales, some people preferred one and other people preferred the otter one. In one of them H has "weight" 1 and in the other O has "weight" 16.

* From ~1960 they use the C_12=12 scale. This is another scale, where the isotope 12 of carbon has "weight" 12.

* There are a lot of technical modifications and, corrections during these 200 ~years. This a simplification of the history.

Also, from 1951 the atomic weights of some elements have uncertainties.

      Based on a report by Marble 98 , a range was finally
      added to the atomic weight value of sulfur for the first
      time in the 1951 report 99 . In the 1961 report 65 ,
      ranges were listed for six elements due to the natural
      variation in their isotopic composition and experimental
      uncertainties were added for five other elements
      following a systematic review by Cameron and Wichers.

So in the last 100 years there has been a lot of changes, a los of codifications and a atomic weight had uncertainties. Apparently this will only be a new way to show the uncertainties.

Looong version: <http://www.iupac.org/publications/ci/2004/2601/1_holden.html></comment>


Iterator patterns in Go - <AUTHOR> http://ewencp.org/blog/golang-iterators/

<comment><USER2> The iterator pattern I have in [https://github.com/ryszard/goskiplist](https://github.com/ryszard/goskiplist) uses an interface similar to

      type Iterator interface {
          // Next returns true if the iterator contains subsequent elements
          // and advances its state to the next element if that is possible.
          Next() (ok bool)
          // Value returns the current value.
          Value() interface{}
      }

which you then use like this:

      iter := s.Iterator()
      for iter.Next() {
          fmt.Printf("%s\n", iter.Value())
      }

I think this is a pretty good pattern: it's concise, looks less ugly than the callback and closure based iterators, and it's not using anything heavyweight like channels, so there should be no significant performance degradation.

Out of curiosity, I added this pattern to OP's test code as StatefulIterator ([https://github.com/ewencp/golang-iterators- benchmark/pull/1](https://github.com/ewencp/golang-iterators- benchmark/pull/1)), in 2 versions: one in which the iterator is a struct, and one in which the iterator is an interface. The results look like this (the 4 last rows are my additions):

      BenchmarkIntsCallbackIterator	         500	   3478962 ns/op
      BenchmarkDataCallbackIterator	         500	   4437885 ns/op
      BenchmarkIntsChannelIterator	          10	 186095017 ns/op
      BenchmarkDataChannelIterator	          10	 188627451 ns/op
      BenchmarkIntsBufferedChannelIterator	  20	  90941766 ns/op
      BenchmarkDataBufferedChannelIterator	  20	  90175550 ns/op
      BenchmarkIntsClosureIterator	         500	   5580257 ns/op
      BenchmarkDataClosureIterator	         500	   6183472 ns/op
      BenchmarkIntStatefulIterator	        1000	   2653265 ns/op
      BenchmarkDataStatefulIterator	         500	   3582051 ns/op
      BenchmarkIntStatefulIteratorInterface	 200	   7516778 ns/op
      BenchmarkDataStatefulIteratorInterface 200	   8250702 ns/op

      ok  	_/Users/ryszard/Projects/golang-iterators-benchmark	33.717s

As you can see, the struct version is the fastest of the lot: 2653265 ns for ints and 3582051 ns structs (versus the callback version with 3478962 ns and 4437885 ns, respectively). The interface version is slower, but still in the same ballpark as the callback and closure based ones, while being much more readable (but that's only my personal opinion). The not-so-stellar performance of interfaces is a bit disappointing, but that is a known issue.

</comment><comment><USER3> Not a single solution has error handling. There actually exists a very good iterator pattern in the Mongo driver mgo. The idea is that you have some function Next, and Next takes a pointer. You pass a pointer into Next, and the iterator fills that address with some data, returning a boolean indicating success. Then you just put that in a for loop to loop over the whole thing. The whole thing, with error handling, looks like this:

        var v someType
        for iter.Next(&v) {
            // do something with v here
        }

        if err := iter.Err(); err != nil {
            // the iterator had an error, handle that here.
        }

[http://godoc.org/labix.org/v2/mgo#Iter.Next](http://godoc.org/labix.org/v2/mgo#Iter.Next)

<comment><USER4> For the vast majority of cases, I would expect panic/recover to work for iteration over in-memory data structures. For something like a database iterator where the possible errors are more varied and likely, I agree an explicit iterator object is better. I probably should have defined the scope of problems I was thinking about better.

</comment></comment><comment><USER5> Iterators should really disappear and only be used when they are really needed. Just take a look at all the examples in the article and you will see that the iterators are noise and unnecessary. Most of the time, all you want is getting all the values in a collection, why would you even need to read the word "iterator" in that code?

Modern languages should all support some form of foreach, e.g. Java:

        for (Customer c : customers) { ... } // no iterator

C#, Scala and many others get this right as well. Go doesn't.

And, this:

       close(ch) // Remember to close or the loop never ends!

Seriously?

<comment><USER4> You need them because the examples are intentionally simplified. Even a data structure as simple as a dictionary has a useful variety of iterators: over keys, over values, and in some languages, over (key,value) tuples. Explicit iterators are really only noise for the "natural" iterator, i.e. in order iteration over an array.

I agree that having it hidden by a language feature is nice, but somewhere there is an iterator -- the class that supports that iteration must at least specify how it's accomplished. I would prefer if there were an easy way to integrate with the range keyword in Go.

EDIT: Adding to reply to some added comments. The close() one in particular really threw me. It makes sense in terms of how channels work, but is really unfortunate. When I first saw the channel-based approach, I thought it was a neat solution. But then I found all the problems with it (including the best example I could find of it online missing that close(), which is why I pointed it out!).

I think Go is close to getting it right if they would do what I mention at the end of the article: provide a way to hook into the range keyword.

<comment><USER5> > Explicit iterators are really only noise for the "natural" iterator, i.e. in > order iteration over an array.

Not really, they are really noise in a lot of situations. Right now, I can only think of one case where they are necessary: lazy traversal. Either the collection is huge or each element is expensive to materialize, so you want to do that one at a time. Iterators are perfect for this.

They are unnecessary in all other cases. For example, for your (key, value) example:

        for (Entry<String, String> entry: map.entrySet()) { ... }

Go exposes too many implementation details to my taste.

<comment><USER4> Fair enough. My day-to-day coding with Go right now involves large data sets where materializing something like that would be expensive. I'll admit my view of the issue is strongly biased by my very real need for iterators or something equivalent that can avoid that cost!

<comment><USER6> in the callback approach, you can pass in the current item and a Breaker or maybe a RewindBreaker that you can easily _ when you don't care about it.

</comment></comment></comment></comment></comment><comment><USER7> It's very important when looking at the channel method to realise that goroutines are NOT garbage collected. If there is any chance of the loop calling break or panicking, there is a chance of leaking goroutines. Since you might not know how your code is going to be used, this is an issue. A possible solution is to use two channels, the items channel and a fail channel. Whenever your iterator sends, it needs to use a select which either sends the item on the channel, or receives from a fail channel (in which case it exits the function.) I think while the channel method looks nice because of Go's special treatment of it's basic types (for better or worse,) it's not practically the best answer you should be using in your code.

<comment><USER4> I mentioned this pitfall, but didn't show how to solve it. I haven't seen a complete example yet and didn't take the time to work out the details yet. I'm less concerned about complexity in the iterator implementation, but handling this correctly _also_ seemed to require changing the caller code since it needs to send something on the fail channel. Then the onus is on the caller to remember to do so, which is just as bad as having to remember not to call break.

Of course, whether this is a real issue or not also depends on whether you're writing internal or external APIs. There are lots of other ways to generate uncollectible garbage too...

<comment><USER8> Use "defer close(ch)". If there is a break or a panic, the channel will be closed.

<comment><USER7> If there is a break or panic in the iterator, not the loop using the iterator. If the loop using the iterator closes the channel, the program will crash.

<comment><USER8> The sender is supposed to close the channel to signify to the receiver that there is no more data to be sent. The receiver is not supposed to close the channel. (You could hack around this by recovering from the panic, but this is bad style.)

[https://groups.google.com/forum/#!topic/golang- nuts/RmfHSHE9...](https://groups.google.com/forum/#!topic/golang- nuts/RmfHSHE9e30)

Note that there is no requirement that you close channels-- they aren't like file descriptors. They will be garbage collected after they're no longer needed.

goroutines, on the other hand, will stick around unless you clean them up. goroutines aren't iterators, and you shouldn't use them as iterators. They're more analogous to threads.

</comment></comment></comment></comment></comment><comment><USER9> The most obvious pattern, a simple for loop and a separate iterator type, is imho missing. Something like "for iter.Next() { fmt.Println(iter.Value()) }" is commonly used in Go and doesn't look that bad either...

<comment><USER10> A notable use of this pattern is bufio.Scanner: [http://golang.org/pkg/bufio/#Scanner](http://golang.org/pkg/bufio/#Scanner)

An example, scanning lines from standard input:

        s := bufio.NewScanner(os.Stdin)
        for s.Scan() {
            fmt.Println(s.Text())
        }
        if err := s.Err(); err != nil {
            fmt.Fprintln(os.Stderr, "reading standard input:", err)
        }

</comment></comment><comment><USER11> Seriously? Using a green thread is a pattern for iteration over an array? Or that creating a new function object per iteration is efficient? The "patterns" 2 & 3 listed in the article are grossly inefficient to be considered suitable to implement fixed or dynamic iterators.

<comment><USER12> Sometimes raw performance is not really called for. A lot of programmers are looking for ways to, for example, iterate over lots of different kinds of things that all provide the interface to do so, regardless of their actual types or the details of their allocation.

Sure, if you're about to iterate over a terabyte of double-precision height map data or something like that, please use an array.

<comment><USER11> Without such advice, that article is dangerous. A "lot of programmers" are going to read that and assume these patterns differ between them only in terms of "performance" which equates to "ns/op".

Also, I wouldn't use an array to iterate over a terabyte of double-precision height map -- have you tried that? I have, kind of. In a genome sequence visualization application. Try it sometime. It's fun.

</comment></comment></comment><comment><USER12> Only a minor point of the article, but clearly the equivalent of Pythonic for Go would be Gothic, not "Go-ish".

<comment><USER13> That's good. I was going to say "gauche", but that may be sending the wrong message.

</comment></comment><comment><USER14> Does Go have generator functions? Yield?

I'm curious because that's what makes python the best language for me in a lot of cases.

Iterators that don't load 100,000,000 rows at a time for a result set are... useful. And that's what you get with the simple (iterator/generator func)/db cursor pattern in python.

Something similar in Go would go a long way in helping me get over the fixed braces position go enforces. :)

</comment><comment><USER15> "I wrote two versions of each. One directly iterates over a []int, the other introduces a struct and uses a []*struct which it needs to extract the data from. The goal was to hopefully avoid benefits from cache coherence"

Can someone explain to me that last sentence? What's cache coherence?

<comment><USER16> Cache coherence is when data that you need close in time is physically close in memory, and therefore loading the first piece of data loads the second into cache so that it will be quick to load. The performance difference between fetching from CPU cache and main memory is about a factor of 10, so this is a significant effect.

When you're writing performance critical code this is a good thing to have happen, and it can be worth a lot of effort to make sure that you benefit as often as possible. However general purpose code usually does not wind up with data that is optimally organized in memory. But in a benchmark the usage patterns are simple enough that it is trivial to get well-organized data in memory without even intending to. Whether this is likely to be predictive of real world performance depends on how carefully coded the real world program is.

<comment><USER17> Cache coherence can also be a problem for performance, leading to what is called _false sharing_.

When reading some value in RAM, values in the same "cache line" (that are right next to it) get cached. However, if another thread has to modify those values that just got cached, then the cache needs to be invalidated. This often happens in producer/consumer implementations.

If this is discovered to be a problem, it's often solved with what is called _cache padding_. I.e. if you've got variables A and B that are right next to each other and they are modified from different threads, then you add fake variables (padding) between them that's the size of a cache-line (which is between 32 bytes and 256 bytes, depending on architecture).

</comment></comment></comment><comment><USER18> What's wrong with returning a populated slice? It's basically the same operation as returning a pre-sized, pre-filled buffered channel. Then you can "range" on the returned value.

The only downside is that you can't defer computation of values until they are asked for.

<comment><USER19> For one thing, that will use much more memory and take more time to compute.

<comment><USER18> Don't underestimate the time cost of coroutining (literally goroutining, and using a channel, or to-and-fro with HasNext and Next). And the unfinished generator is using memory, too. Code runs fastest when it can sit in cache, so creating a slice in a tight loop and returning it is probably optimal if the actual data you just materialized is small.

<comment><USER19> Sure, it's better than the goroutine approach, but that doesn't say much. It becomes quite suboptimal if you have a large amount of data. I also think that you're likely underestimating the cost of the additional memory allocations.

</comment></comment></comment></comment><comment><USER20> If you like/use iterators, you should read about ranges [0].

[0] [http://www.informit.com/articles/printerfriendly.aspx?p=1407...](http://www.informit.com/articles/printerfriendly.aspx?p=1407357&rll=1)

</comment><comment><USER21> overengineering at its finest.

</comment><comment><USER8> Iterator callbacks, generators, or functors feel very un-Go-like. It's trying to force a Python or OCaml idiom on to Go. Basically, what you want is to implement a HasNext and a Next function and write a "for" loop. All you need is this:

      for ; iter.HasNext(); val = iter.Next() {
         // do stuff
      }

There's no reason to look down on the humble for loop. Complexity is a bad thing, usually.

Channels and goroutines are also a very Go-like way to process data. But APIs that return channels assume that the caller wants concurrency, so be sure that that's true.

<comment><USER22> Right, but you have to consider the complexity of the iterator implementation as well. Every time I implement iterators for non-trivial data structures in languages without generators I want to hit myself in the face for using that language.

</comment></comment><comment><USER23> You gosters are planning on writing a lot of for loops, huh?

Y'all can't be just plain ignorant about what you can do in a language that has the features to support a proper collection library... So what's up with that? You like them for loops? Or does everything that's so awesome about go make it worth the apparently complete crap state of collections?

I suspect all this has to do with a choice of greater type safety over expressiveness, but I'm not sure. I know there's this big generics discussion in the go community. The thing about generics is you sprinkle butt-ugly and cross-eyed syntax on top of expressive and you get...expressive ugly cross eyed butt syntax collections.

Help me out here -- I read these rave go reviews and then I see this kind of thing and I think "well, it'd be better than Java -- maybe way better -- but it feels like Java redux all over again reheated."

<comment><USER4> I'm just learning Go, I'm certainly no evangelist. One huge difference for me, however, doesn't have to do with the language. It's deployment. It's _really_ nice for deployment to be scp rather than a bunch of package installs, making sure your classpaths are right, etc.

That said, one of the language features that drew me in is structural typing. I'd yet to see a well supported statically typed language that used structural typing, and it seemed like it would make software maintenance a lot easier. Of course, tools are often a better solution than language features, so maybe that's a bad reason to use a language.</comment></comment>


Erlang: The Movie - <AUTHOR> http://www.youtube.com/watch?v=uKfKtXYLG78

<comment><USER2> And, after you've watched the original, check out "Erlang The Movie II: The Sequel", by Garrett Smith (aka gar1t): [http://www.youtube.com/watch?v=rRbY3TMUcgQ](http://www.youtube.com/watch?v=rRbY3TMUcgQ)

(You are likely familiar with one of gar1t's earlier videos, the classic "Mongo DB is Web Scale":

[http://www.youtube.com/watch?v=b2F-DItXtZs](http://www.youtube.com/watch?v=b2F-DItXtZs)

And he's got more on his YouTube channel: [http://www.youtube.com/user/gar1t](http://www.youtube.com/user/gar1t) )</comment>


Twitter doesn't scale (for conversations) - <AUTHOR> http://senko.net/en/twitter-doesnt-scale-for-conversations/

<comment><USER2> So I'm the only person who goes to the profile in question and checks the @replies for that user to see if I'm repeating a response?

You can easily see the responses to a tweet assuming you use a client that isn't terrible. In TweetBot for Mac or iOS, it's literally just double- clicking the tweet or swiping to the side.

If it's the kind of tweet that users will reply to without hitting the reply button, you can see those responses by going to the user's profile and looking at their @ timeline.</comment>


Stable coin's token? - <AUTHOR> https://bit-media.org/cryptocurrency/sale-for-algorithmic-stablecoin-project-launches/ <comment><AUTHOR> I really don't know so much about the stable coin and its mining system, and can't understand with my poor English , but it looks a little interesting to me.</comment>


On the Importance of the Studley Tool Chest - <AUTHOR> https://blog.lostartpress.com/2014/10/16/on-the-importance-of-the-studley-tool-chest/ <comment><USER2> 2014; but still a lovely thing to see.</comment>


Show HN: Stock Option Trading Application in Racket - <AUTHOR> https://github.com/evdubs/renegade-way <comment><USER2> How do you get up to date security pricing info though? That was what I got stuck on when trying to build something like this. Finding stock prices without fifteen minute delays was a barrier I never got past.

<comment><AUTHOR> For live security prices, there are a couple that are commonly mentioned:

* IEX Cloud - [https://iexcloud.io/docs/api/#deep](https://iexcloud.io/docs/api/#deep) \- Live order book data straight from IEX. This is free and I don't think you even need an account at iexcloud.io to use it.

* AlphaVantage - [https://www.alphavantage.co/documentation/](https://www.alphavantage.co/documentation/) \- I think this is request/reply, but there is no 15 minute delay from what I can tell.

I don't use IEX's DEEP endpoint, but I do use IEX for daily historical prices, among other things. Here's the project that the option trading application uses for daily prices: [https://github.com/evdubs/iex- stocks](https://github.com/evdubs/iex-stocks).

With respect to the option trading application, it doesn't use live prices. Analysis is done offline and, upon order submission, a stock entry price is set so that the option orders don't activate until the live stock price has risen/fallen to the conditional entry price. This is one mechanism that allows the application to be careful and not be filled for an order when the stock has already moved against us. So, there is reliance that the broker (IBKR in this application) is properly handling our order and its special parameters.

If you care to take a look again at algo trading, I think you might find it useful to investigate more "offline" strategies that don't require you to be constantly plugged into ever-changing market data. You might even find that it's easier to find an "edge" as a retail investor by doing this rather than being on the lower-latency side of things.

<comment><USER2> Thanks for the links, I'll check that out carefully!

</comment></comment></comment><comment><USER3> this is pretty cool. i got distracted looking at the ib client repo, does it send strategies as a combo order or legs individually?

<comment><AUTHOR> It sends strategies as a combo order. You can see that in action at [https://github.com/evdubs/renegade- way/blob/master/position-...](https://github.com/evdubs/renegade- way/blob/master/position-order-manager.rkt#L241) Price conditions are sent along too to keep the order deactivated unless the stock is trading above/below the specified entry price.</comment></comment>


Ask HN: How do you relax? - <AUTHOR> A fairly straight forward question. The second part of it is, most of my relaxation during weekdays seems to involve being glued to some sort of screen. My iPad if I'm reading, my PS3+TV if I'm gaming or my laptop+hulu if I'm watching TV Shows / general talks.<p>I enjoy all of these, but is there no way (please don't say exercise) to wind down without having to look at a screen? <comment><USER2> Grabbing a piece of graph paper and hand-drawing some "pixel art" is quite relaxing due to its simplicity yet gradual complexity. Check out "Zentangles" for other interesting simple->complex doodles.

You can also try listening to a talk radio (CBC Radio 1 is great), or some podcasts. Podcasts will be pretty simple to stick to a routine, since there are some that come out weekly (or even daily).

Good luck!

</comment><comment><USER3> Get back to the nature. Whether it's hiking, jungle trekking, swimming in the ocean or running on the beach, it's totally reinvigorating. While you are doing it, breathe deeply and enjoy the sights and sound of the surrounding - you will come back a renewed man.

P.S: I'm very fortunate to live in Penang island (Malaysia), where all those things I mentioned just 20 minutes away from my house.

<comment><USER4> +1. I am very fortunate to live in Sydney, where ditto.

</comment></comment><comment><USER5> I read on my Kindle which is not like looking at a standard screen or you could read real books. I also find manual drafting relaxing, but other hobbies like drawing, knitting, or crocheting can be relaxing non-screen things to do.

</comment><comment><USER6> I personally can't relax unless my mind is being stimulated in some way, so I make stuff. If your purpose is solely to relax (as it is for me), it doesn't even have to be useful. K'NEX and Lego are personal favorites if I'm mentally out of steam (you can never be too old for Lego!). If I'm looking for something more stimulating I'll get out my breadboard or something similar.

<comment><AUTHOR> I know, I try to come back from work, switch off for sometime and then put in a few more hours at night building something interesting, so I don't really want to think at all if that's even possible.

Legos are an interesting idea.

</comment></comment><comment><USER7> Avoid digital rectangles. Begin to notice your breathing. Begin to pay attention to how your body feels, what goes around you (peripheral) and in front of you (3 point of awareness), explore hypnosis tapes and soothing music, reduce stimulus overload, return to nature.

</comment><comment><USER8> Go to the local park and do some sprints on the grass. There's nothing more invigorating than running as fast as you can.

After the sprints, fall on your back and do some sky gazing.

The sprints clear your mind, the sky gazing relaxes you and lets your mind wander ;-)

</comment><comment><USER9> I'm currently trying Vipassana meditation. I first heard about it from the "pragmatic thinking and learning" book. It's really simple to get started and it can really affect your concentration in a positive way.

</comment><comment><USER10> Explosions in the sky (It's a band) either on my Ipod, or on our stereo.

This is the only band that paints a soundscape(picture with sounds, like a landscape) and I will listen.

Im sure the same effect would occur with classical music as well.

</comment><comment><USER11> I go to see my girlfriend, play DoTA (sorry, computers again!), or just pick up a book and read a bit.

</comment><comment><USER12> How about exercising in a stimulating way? Ie. Learning muay thai, rock climbing, etc.

</comment><comment><USER4> Running for 2 hours at 160 bpm.

</comment><comment><USER13> What's wrong with exercising?

<comment><AUTHOR> Nothing at all, just that I've tried and failed multiple times to stick to a routine.

<comment><USER4> Only do as much as you feel good doing. Most people when they start out do too much or expect exercise to give a bad feeling, I know I did 2 years ago. Hell, I was even famous for hating exercise in a show called Nerds FC. But recently I have started running reallly really long distances at an "easy" pace, and it is the most enjoyable, meaningless thing to do! When you enjoy it, you won't need a "routine", you will just let yourself indulge.

</comment></comment></comment><comment><USER14> bit101bit@ubuntu:~$ shutdown now

</comment><comment><USER15> A walk?

</comment><comment><USER16> Lifting barbells.</comment>


Amazon to sell used ebooks - <AUTHOR> http://www.cnet.com.au/amazon-to-sell-used-ebooks-339343238.htm

<comment><USER2> The article doesn't confirm that Amazon is actually planning to sell used ebooks, only that they were awarded a patent to do so. I hope that they do facilitate this someday — the lack of resale value with digital goods is concerning — but how could it be in their interests to do so? Anyone care to play devil's advocate and explain how this could lead to increased revenue over only selling new ebooks (which presumably they get a significant cut of)? I want to believe.</comment>


New IDEs make working in COBOL as easy as C#, VB or Ruby. - nerds-central http://knol.google.com/k/alex-turner/visual-studio-cobol/2246polgkyjfl/8#

<comment><AUTHOR> That title ("Visual Studio COBOL") reminded me of the less-serious "Cobol on Cogs" site: <http://www.coboloncogs.org/INDEX.HTM>

<comment> nerds-central I love that site. They way it flickers and has screen burn effects are so kitch :)

</comment></comment><comment><USER2> Here's a word i haven't heard in a long time... In those days we chose to learn Clipper over Cobol, each CL would take 2-3 minutes to compile on a 8086 processor. Now it takes less than 1 sec to do it, lol

<comment> nerds-central How is Clipper doing these days? COBOL is making a resurgence as people realise it works!

</comment></comment><comment><USER3> While this might make the actual process of typing in the code easier, it doesn't make the language any better. I still can't imagine choosing to use COBOL over using Ruby or even C#.

<comment> nerds-central The point is that there is a lot of COBOL already out there, so someone has to maintained it and add to it. What is more, C# is not a perfect language for business its self, neither is Ruby. With good tooling the difference are small. Actually, in my case I would never recommend using Ruby for a commercial project - but that is another discussion for another time :)

<comment><USER3> There's been a lot of ruby code written on commercial projects, I think the developers (and customers) would disagree with that.

I also think you're way off on the amount of difference between C# and COBOL. The fact that COBOL _requires_ good tooling to be usable is telling in and of itself.

</comment></comment></comment><comment><USER4> How much COBOL is there still out there?

<comment> nerds-central Billions of lines of COBOL will 10s or even 100s of millions of lines written every year. Each time someone makes a mobile phone call, uses a credit card, books an airline ticket - 99% chance COBOL will handle part of that transaction.

</comment></comment><comment><USER5> It would be good if Micro Focus released an Eclipse plugin too.

<comment> nerds-central They do... Hopefully there should be a community knol on that as well in the near future.</comment></comment>