There is no pass by reference in Go - <AUTHOR> https://dave.cheney.net/2017/04/29/there-is-no-pass-by-reference-in-go <comment><USER2> An extended explanation missing from Dave Cheney's answer is that the "reference" etymology has at least 2 meanings. This is why his explanation is virtually the same as the one 20 years ago in the C Language FAQ[1] compiled by Steve Summit.

\- "reference" definition 1: an alias that cannot be null which is what a "reference type" is in Pascal and C++. This might be thought of as a stricter "computer-science" definition. The C and Go languages don't have this type of "reference".

\- "reference" definition 2: a pointer variable that lets programmers change the _" thing pointed to"_ instead of the pointer variable itself to avoid copying unnecessary bytes. This is the colloquial usage. It also doesn't help that we call the star operator the "de-REFERENCING" operator[2] instead of the "de-POINTERIZING" operator. (What are we "derefencing" if it's not a "reference"?!?)

Cheney is talking about definition 1.

[1] [http://www.di-srv.unisa.it/~vitsca/LAB/C-faq.html](http://www.di- srv.unisa.it/~vitsca/LAB/C-faq.html) excerpt:

      4.11:	Does C even have "pass by reference"?

      A:	Not really.  Strictly speaking, C always uses pass by value.
    	You can simulate pass by reference yourself, by defining
    	functions which accept pointers and then using the & operator
    	when calling, and the compiler will essentially simulate it for
    	you when you pass an array to a function (by passing a pointer
    	instead, see question 6.4 et al.).  However, C has nothing truly
    	equivalent to formal pass by reference or C++ reference
    	parameters.  (On the other hand, function-like preprocessor
    	macros can provide a form of "pass by name".)

[2] [https://en.wikipedia.org/wiki/Dereference_operator](https://en.wikipedia.org/wiki/Dereference_operator)

<comment><USER3> Indeed. Definition 2 is broadly in line with what "reference" means in general usage, while definition 1 is a term of art in the vocabulary of certain languages.

Before languages had reference types or pointers, the distinction between pass-by-reference and pass-by-value (or also pass-by-name in Lisp and Algol) told you important things about the semantics of the language, such as whether a function you called could modify the objects you gave as arguments, or incorporate them by reference into some other object, and how arguments that are expressions are handled. Some of those distinctions become blurred when pointers or references are passed by value; the distinction on _how_ you pass them now becomes a distinction on _what_ you pass. In practice, is there any language that passes pointers or references by reference?

<comment><USER4> It may be what reference means, but just because a language has references doesn't mean that it is passing-by-reference. There are plenty of languages that allow actual pass-by-ref, like C++. The usual litmus test is writing a function that takes two ints (not int refs!) and they're swapped at the end. In C++, you can tell because of "int&" in the signature of the function you're calling; as opposed to plain int.

In languages with macros, you get to cheat a little, and write something that looks like the above without _really_ having those semantics. However, in languages like Lisps where your macro language is extremely powerful, you might not really miss it so much.

There is a lot of convenience in _not_ having pass-by-ref! Sometimes I feel like the ardent opposition just doesn't want to admit their favorite language is missing a feature ;-) If I call a function f(a, b), I know that a, b are still pointing at the same object in e.g. Python. That is not the case in C++ (pass-by-ref) or Lisp (arbitrary macros). Predictable language semantics make code easier to reason about. That's a good thing, and it's quite plausible that the added complexity and confusion of supporting pass-by-ref isn't worth the expressiveness.

I appreciate that the term is confusing, but it does mean something. I submit that making it mean two things would be even more confusing. If it's confusing, just say "passing (an argument) _as a reference_" which is unambiguously about what you're passing, and not how you're passing it.

<comment><USER5> _" If I call a function f(a, b), I know that a, b are still pointing at the same object in e.g. Python."_

      def f(x):
        global a
        a = "No, you don't"

      a = "I know"
      f(a)
      print a

This counterexample may be far-sought, but it is a minimal version of what can easily happen in larger programs that have shared mutable state.

But yes, call by reference can be confusing. It also can be very useful, though. That's why many modern languages have call by reference, but also require callers to specify it at each call site. I think that gives you the best of both worlds.

</comment></comment></comment></comment><comment><USER6> "Maps and channels are not references."

But then refer to the Go team's article on maps:

      Map types are reference types, like pointers or slices, and so the value of m above is nil; it doesn't point to an initialized map. A nil map behaves like an empty map when reading, but attempts to write to a nil map will cause a runtime panic; don't do that. To initialize a map, use the built in make function:

      m = make(map[string]int)

      The make function allocates and initializes a hash map data structure and returns a map value that points to it. The specifics of that data structure are an implementation detail of the runtime and are not specified by the language itself. In this article we will focus on the use of maps, not their implementation.

Saying maps are not passed by reference is a bit deceiving. The map's _pointer_ location is not passed by reference.

Source: [https://blog.golang.org/go-maps-in- action](https://blog.golang.org/go-maps-in-action)

<comment><USER7> IMHO saying they are is misleading as this article correctly points out nothing is, and Rob Pike himself has pointed out the same on many occasions. They are referred to as "reference types" because they contain pointers to the underlying data structure. However the thing stored in the variable is more than just a pointer, and it is passed by value.

Knowing the difference can have important ramifications; particularly in the case of a slice which has its header copied when passed to a function.

</comment></comment><comment><USER8> It's a question of semantics and the poorly chosen word "reference".

The roots come from C, where pretty much every book on the subject talked about the difference between passing a huge, expensive value to a function vs passing a cheap pointer "reference" to it.

And while the semantic purists will scream and holler, the fact remains that, colloquially, a pointer is a reference to something, not the something itself. And so this annoying debate rears its ugly head a few times a year and makes it into HN or Slashdot or whatever.

<comment><USER4> Nobody is debating what the word "reference" means. The debate is that "pass- by-reference" is already a different thing from passing something __as__ a reference.

I appreciate that it's confusing to someone who isn't familiar with the term, but so's most of CS. We had a term and it referred to a thing, and having it refer to two different things is worse.

<comment><USER8> And yet this is the reality we live in. No matter how much talk of "should", the reality stares you implacably in the face. This is a UX problem.

Practically speaking, the most important concept is that of cost, which the naive answer covers. The distinction only matters in a language that actually differentiates the two. Otherwise it's little more than trivia, and certainly nothing to get worked up over.

<comment><USER9> The difference between pass-as-reference and pass-by-reference is more than trivia - if you were ignorant of it in a language, you might find trouble in the future when a function decides to alter its argument values in a way that negatively affects the caller. Part of the reason we should work to clarify the language is to avoid misconceptions about behaviour based on what kind of "reference" is meant.

<comment><USER10> A language with pointers also allows a function to alter its _logical_ (not syntactical) argument values in a way that negatively affects the caller.

There isn't much practical difference between using

        // void c_func_alters_deref_pfoo(Foo * pfoo)
        Foo foo = { ... };
        c_func_alters_deref_pfoo(&foo);

and

        // void cpp_func_alters_foo(Foo & foo)
        Foo foo = { ... };
        cpp_func_alters_foo(foo);

besides the ability to pass null or otherwise invalid pointers in the C-style version, which can (depending on situation) either simplify your API or be a source of bugs.

<comment><USER9> >A language with pointers also allows a function to alter its logical (not syntactical) argument values

What's the difference between a logical and syntactical argument?

</comment></comment></comment></comment></comment></comment><comment><USER11> Minor nit...

> It is not possible to create a Go program where two variables share the same > storage location in memory.

It is possible to do so, because the empty struct occupies no space. For example:

        s := []struct{}{
            struct{}{},
            struct{}{},
        }
        fmt.Printf("%p %p\n", &s[0], &s[1])

        > 0x176f44 0x176f44

But that's kind of a fringe case, and I suppose one might argue that the two variables occupy no space so in a sense they don't share that space. Either way it doesn't detract from the original point of the post :)

</comment><comment><USER8> Often, I'll deliberately give the naive "pointers are references" answer in a job interview, just to gauge the interviewer's response.

It's actually a good proxy to determining company culture. If he starts to patiently explain the difference, I'll stop him and talk about the practical implications of the concept, and we'll have a good laugh.

If he gets annoyed or stiffens and things become tense, I'll have a good proxy for what to expect should I make the mistake of working there.

<comment><USER3> Then there are those interviewers who silently cross you off the list and move on. They are probably type II people, however, so no harm done from either point of view.

</comment></comment><comment><USER12> By this obtuse definition of 'pass by reference', Nothing with a C-like function call stack will 'pass by reference'. Programming languages that approximate 'pass by reference' will actually pass a pointer to the called function that points to a value in the callee's stack frame. The pointer in the called function is a local variable, so changing the value of that has no effect in the callee's scope. Changing the contents of the thing pointed to is the only _meaningful_ 'pass by reference', and practically most languages have that. (including Go)

</comment><comment><USER13> Interestingly, the term "reference type" has been removed from the Go spec in 2013: [https://github.com/golang/go/commit/b34f0551387fcf043d65cd7d...](https://github.com/golang/go/commit/b34f0551387fcf043d65cd7d96a0214956578f94)

Yet some semi-official sources (like The Go Programming Language book) _do_ refer to channels as "reference types".

TBH, I find cheney's post not fully useful without explaining what _does_ happen behind the scenes in maps so that passing them by value doesn't incur large copies.

<comment><USER14> A map is a tiny struct containing a pointer to the bucket storage. It's always cheap to pass a map value.

<comment><USER13> Right.

I'm saying the linked blog post can be improved significantly by spending a paragraph on explaining this. Otherwise it just sounds like magic.

</comment></comment></comment><comment><USER15> C# has a name for Go's object semantics: Marshal By Reference. This means that when an object features in a call, the GC pointer aka reference is passed (by value) rather than the object value itself. This reference is fundamentally different from the reference concept in C++. So the term reference is semantically overloaded and means different things in different programming languages. However, the phrase "pass by reference" is language independent and the author is correct, it doesn't have those semantics.

</comment><comment><USER16> When teaching, rather than using a special name like "pointer", wouldn't it be better to simply explain that it's a variable that holds a memory address? Once a student (e.g. who only knows a high-level language) understands that they now have to think about memory explicitly, then the behavior of such a variable will become obvious. AFAIU there are only two special features of pointers: the dereference operation and the additive arithmetic which increments in strides according to their type.

</comment><comment><USER17> C++:

      void f(map<int, int> m)
      {
      	m[0] = 0;
      }

      int main() {
      	map<int, int> t;
      	t[0] = 1;
      	f(t);
      	cout << t[0] << endl;
      	return 0;
      }

prints 1.

Go:

      func f(m map[int]int) {
      	m[0] = 0
      }

      func main(){
      	var t = make(map[int]int)
      	t[0] = 1
      	f(t)
      	fmt.Println(t[0])
      }

Prints 0.

So in C++ maps are passed by value. In Go they are passed by, hmm, "not value".

Go could have made maps similar to C++ maps and then people could use a pointer to a map when they wanted that. As it stands maps are "different" which is not a big deal once you're used to it but still makes things a little weird if you're coming from C++.

</comment><comment><USER18> Go lacks the C++ reference operator. You can't write:

        func fn(m &map[int]int) {
            m = make(map[int]int)
        }
        ...
        fn(m)

You have to write:

        func fn(m *map[int]int) {
            *m = make(map[int]int)
        }
        ...
        fn(&m)

It's very C. The caller is forced to use different syntax to pass something as a pointer/reference. In C++ and Rust, you can't see from the call whether you're passing a pointer or a reference.

<comment><USER19> The difference is in C++ rvalues coerce to const&, while in Rust they do not.

E.x. this works

        int square(const int & num) {
            return num * num;
        }

        int main() {
            square(5);
        }

this does not

        fn takes_ref(a: &i32) -> i32 {
            *a
        }

        fn main() {
            takes_ref(64);
        }

There are still cases where you won't be able to tell if you're using a ref or not, though:

        let x = returns_a_ref();
        takes_ref(x);

</comment></comment><comment><USER20> However, Go has pointers (just not pointer arithmetic):

[https://tour.golang.org/moretypes/1](https://tour.golang.org/moretypes/1)

Does anyone know of an imperative language doesn't have references, but also doesn't have pointers? Perhaps using something like copy-on-write to pass variables to functions.

</comment><comment><USER21> I haven't used Go before; is there a common conception that you can pass by reference in Go?

<comment><USER22> I guess in every language with pointers, people often confuse passing the pointer as a value with passing the object as a reference.

<comment><USER23> I'm still confused and I've been working in various languages for 15 years.

If I pass a java object to a function, I'm passing a (probably) 8-byte pointer to some memory with a class tag, fields, whatever. It goes on the stack just like an 8 byte long.

In languages that support pointers more directly, I'm doing the same thing, maybe minus the class tag in the pointed-to memory. Address is in an 8 byte type, put it on the stack and access the pointed-to struct in your new frame.

Yet I've seen interview questions about whether you're "passing by reference" or "passing a reference by value" like there's some big meaningful difference and one answer is wrong.

I don't get it. Is this just one of those nerd arguments where we're debating semantics for the sake of it?

<comment><USER4> In all of those cases, you're probably passing a reference by value, semantically. ("Probably", because you didn't specify which languages, so I'm making an educated guess.)

The usual litmus test is having two objects (or ints or whatever), write a fn `swap(a, b)` where the two are swapped after the call is over. Can't do that in Java or Go or Python or C; but you can in e.g. C++ and you sorta-can in Lisp. In C++, you'd see int& (or whatever) show up in the arguments of swap().

<comment><USER23> Ok, yeah, I saw upthread about C++ and Pascal having a more formal reference type.

But in C and Go you can pass pointers to pointers, in Java and Python objects with mutable object references..

It seems like the whole article could have been "Go does not have the C++ reference type, so it's not really in the mix when calling functions".

<comment><USER4> Yep. "Reference type" is a confused and overloaded term, so I prefer to say "pass-by-reference" when I meant int& and "pass-as-reference" (or the, in my opinion confused and confusing, pass-by-object, if that's helpful to the listener).

</comment></comment></comment></comment></comment></comment><comment><USER24> Doesn't the post stumble over right in the second section? "It is not possible to create a Go program where two variables share the same storage location in memory". So what? The C example didn't show that either.

<comment><USER4> You are correct that C also does not have pass-by-reference. However, the second listing is a C++ program, not a C program, and C++ very much has pass- by-reference. The C++ program demonstrates true aliases, as you can tell from the output of the printf (see comment on same line).

<comment><USER24> I have always found that is conflating the semantics of _using_ with the method of _passing_. Even with/out aliases you are still _passing_ a reference.

<comment><USER4> I don't think that's accurate. I can pass something locally declared as int to a fn that takes int& according to it's signature. It seems that's precisely what the confusion is about :)</comment></comment></comment></comment>


AMA Book: A Book by Reddit with Best AMAs - <AUTHOR> http://askmeanythingbook.com/ <comment><USER2> It just shows how they only care about generating money. Don't be sheep and buy this.</comment>


Distelli Rest API - An API for your Builds and Deployments - <AUTHOR> https://www.distelli.com/blog/product-update-introducing-the-distelli-api <comment><AUTHOR> I'm the founder and I'm happy to answer any questions.</comment>


Firefox does not have a well-designed privsep model - <AUTHOR> https://marc.info/?l=openbsd-misc&m=152872551609819&w=2 <comment><USER2> > I doubt firefox will ever focus on security. The security mechanisms we are > talking about require breaking compatibility or performance. This isn't the > stuff one rearranges deck chairs for.

They seem to be willing to break compatibility as illustrated by them ditching their massive library of legacy extensions.

He seems to somewhat contradict himself by saying Mozilla won't do things to improve security then describes a security feature they have implemented for JIT that Chrome has yet to provide.

<comment><USER3> W^X is simply the idea that code segments are either writable or executable, never both simultaneously. It does limit some attack surface area. That being said, while it'd be a welcome addition to V8, it almost definitely would come with some performance cost and a complexity increase, whereas Chrome has focused on sandboxing the JIT in such a way that gaining access to the JIT would not get you very far. So, while layered security is almost never a bad thing, I think that it's possible this trade-off is not a terrible one for Chrome security.

<comment><USER2> His email starts off with this claim:

> In a browser, there are 2 main security components you want: The main > security advantage is privsep. The other is W^X jit. Other security effects > will follow from those design choices, especially if you have privsep. For > instance, the chrome privsep is nicely refined and pledge enforcements could > be added.

EDIT: Just to be clear I'm not arguing against DEP/W^X but simply appears he is contradicting himself.

<comment><USER3> To be more particular, though:

\- W^X defends against a subset of attacks that privsep defends against.

\- Privsep is a bigger architectural impact than W^X. The entire app, almost everything, is impacted by privsep. Only the JIT is impacted by W^X.

So while it is nice that Firefox has been doing W^X, it doesn't mean they're closer to huge steps like Chrome-level privsep of processes. I hope they are, though.

</comment></comment></comment></comment><comment><USER4> Privsep is useful but I'm not sure I buy the argument that Firefox needs to go all in on it to be secure. Despite Chrome's engineering approach people still managed to privilege escalate all the way from their webassembly decoder (insecure C++) all the way to persistent root on Chromebooks, due to fundamental security engineering failures (multiple) that no amount of privilege separation could stop.

More precisely limited capabilities for content processes, etc, are good but you also just need to write more secure, more stable code and Rust is a great investment towards that. I don't think Firefox needs to go all the way to Chrome's horribly slow 37-million-process-types model. The Chrome approach has significant downsides - any use of the GPU has measurable overhead which turns into higher battery usage (this is the main reason Edge uses less battery on Windows for things like video playback), and their privilege isolation turns cache hits for web content loads from <1ms to 20-60ms because of the multiple RPC trips and context switches necessary to load things out of the cache Because Security. Every decision made in Chrome probably had a reasonable security motivation but I don't think that necessarily justifies turning a page load from 0.5s to 2.0s just to protect against a hypothetical attack.

DISCLAIMER: I got paid to work on Firefox and Chrome, so I have some sort of bias here

</comment><comment><USER3> Moving a lot of critical code to a memory safe language will be a cool advantage for Firefox, performance benefits aside. That being said, I think it's easy enough to see why Chrome may have a lead given that it indeed was designed to be secure from the get-go. I hope Theo is wrong here, and that things _are_ getting closer, but I guess time will tell.

<comment><USER5> Yes, I think rewriting Firefox core components in Rust should give Firefox an edge in some areas, but I still think Mozilla made was wrong to go with its "hybrid" approach for its multi-process architecture.

Perhaps it's a win in the short-term, a win that maybe Firefox desperately needed to catch-up in performance, but they need to slowly transition away from that to a more secure model, as they start fixing other performance issues and fine-tune the browser more.

<comment><USER6> I don't know why you're getting downvoted since that's literally their roadmap. [https://bugzilla.mozilla.org/show_bug.cgi?id=1432593](https://bugzilla.mozilla.org/show_bug.cgi?id=1432593) In addition to separating sites, they're breaking services out into their own processes, like moving all network access to a separate process [https://bugzilla.mozilla.org/show_bug.cgi?id=1322426](https://bugzilla.mozilla.org/show_bug.cgi?id=1322426)

</comment></comment></comment><comment><USER7> As the oxidize projects continue to land this email will become more and more obsolete. There's simply no way for C++ to compete with Rust, and while there will be continued utility pledge() is pretty quaint versus memory safety.

<comment><USER8> Doesn't every email explaining the current state of <insert item here> become more and more obsolete over time?

<comment><USER9> Not if <inserted item>'s state stops changing. :)

<comment><USER8> A good point

</comment></comment></comment></comment><comment><USER10> We, the consumers, have to make trade-offs.

For example, Chrome sends your browsing habits back to Google who uses that data to "personalize" other services. I think of ads when I see this.

I wouldn't be surprised if using chrome caused google to get data on unreleased projects, corporate networks, and other bits leaked to them. I wonder how they use it.

In any case, you trade one risk for another. Different people are going to evaluate those differently.

I do like more disclosure to help people decide all around.

<comment><USER11> Consumers are not in a position to make informed choices about the security implications of the way a browser is implemented.

<comment><USER12> Frankly the idea of consumers making informed choice is hogwash from end to end. Either we do so on whims, or we pick whatever is in front of us because we can't go another day without. Neither allows for "informed" decisions in the sense the economics textbooks present.

<comment><USER13> Even if we study: I can only devote X hours per product while your average company has one or several full time company that know the market much better than I do and are also probably working on way to trick me, one way or another.

It's not a fair fight.

</comment></comment></comment></comment><comment><USER14> Would love to see an official response. Mozilla has worked hard at adding multi-process, and improving security all over the place, such as at the level of internet protocols and infrastructure.

His focus on memory security is just his personal bias as a systems engineer writing in C, and this focus alone does not provide a comprehensive comparison.

<comment><USER15> privsep isn't "memory security".

</comment></comment><comment><USER16> Firefox team has been making tons of effort for prolonged periods of time. I'd be extremely fond of them focusing on having a proper privsep model now.

</comment><comment><USER17> privsep? W^X? Can someone post a link or two? :)

<comment><USER18> [https://en.wikipedia.org/wiki/W%5EX](https://en.wikipedia.org/wiki/W%5EX):

>W^X ("Write XOR Execute"; spoken as W xor X) is a security feature in operating systems and virtual machines. It is a memory protection policy whereby every page in a process's or kernel's address space may be either writable or executable, but not both.

"privsep" stands for "privilege separation", which is fairly self-explanatory. See [https://en.wikipedia.org/wiki/Privilege_separation](https://en.wikipedia.org/wiki/Privilege_separation).

</comment></comment><comment><USER19> Oof, this is just drama-mongering, made worse by cherrypicking the grumpiest thing from the email to put in the title. Not much point bringing that drama for a re-warming here.

<comment><USER20> We've updated the title from 'Theo de Raadt on Firefox security: "all I see is lipstick on a pig"'. We'd rather use a representative phrase from the message, if someone can suggest one.

</comment></comment><comment><USER21> Famously outspoken developer is mildly outspoken? I am shocked!

</comment><comment><USER22> Chromium is an open source project, and we should treat it like one. Google paid for most of its development, but were able to pay many open source developers less because they were excited about working on an open source project (see the thread about compensation on today's Ask HN post about working for startups). Ditto for Android. Nobody should be shy about forking these projects. We don't owe Google for them, beyond what the license says. Fair is fair.

If we can treat Chromium like an open source project, maybe we can retire Firefox.

<comment><USER23> Some of us love Firefox and do not want webkit hegemony, even if it is open source.

<comment><USER12> IF that was true, then perhaps more effort should be directed towards making Gecko a drop in engine?

The big "benefit" of webkit is that it is a engine without the whole "browser" thing tagging along.

But the last time i poked at getting gecko to stand on its own, albeit some time ago, it involved grabbing Firefox and giving it some configure (or whatever that python thing that is masking as configure that Mozilla is using these days) options to have it barf out only Gecko.

<comment><USER24> I think they're working on servo for that. It'll be able to be dropped in place of Chromium: it'll support the same API.

Or so I remember.</comment></comment></comment></comment>


NASA - 2012: Beginning of the End or Why the World Won't End? - <AUTHOR> http://www.nasa.gov/topics/earth/features/2012.html <comment><USER2> No worries guys. It's like the problem with the LHC: our stream of consciousness will simply flow unhindered into the reality in which we all don't get killed by a rogue planet.</comment>


JQuery google api and other google hosted javascript libraries. - <AUTHOR> http://scriptsrc.net/

<comment><USER2> When using this CDN for versioned libraries like jQuery, be sure to avoid using the "latest version" references[1][2].

In order for the "latest version" feature to be reliable, they have to avoid users having stale local copies for very long. Thus, they serve those with a much closer expires header, which defeats one of the shared CDN's biggest benefits.

When you reference the full version explicitly[3], it's served with a +1 year expires header.

// Not cached for long.

[1] <http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js>

[2] [http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.j...](http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js)

// Cached for up to a year.

[3] [http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min...](http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js)

<comment><USER3> Good point. Another reason to do this is that jQuery and other libraries are not always backwards compatible between point releases, so you can end up with broken code in the wild without your knowledge.

</comment></comment><comment><USER4> Exactly necessary was it to implement this site in Flash? It's quite a bit of overkill for such a simple app.

<comment><USER5> I believe getting copy/paste to work across browsers requires a Flash include.

<comment><USER6> Copy and paste work _just fine_ in all of my browsers without Flash. You show me some text, I select it and copy it. You can even use fancy Javascript to select all of the text if I click anywhere on the text you think I want to copy. Just in case I don't want to press "Command-A."

I don't get the need to gratuitously replicate functionality that's already dead simple. It's a personal project, so I suppose it's as much art as engineering. But of this were a business, I would be very interested in some A/B testing to measure whether you are losing users by not having a one-click way to copy the script code.

</comment></comment></comment><comment><USER7> While the advantage of referencing the google api files is that your browser can take advantage of cached copies, Google Webmaster Tools recommends reducing the number of DNS lookups if you do so. I recently worked through all the PageSpeed and YSlow flags and saw a decent bump in traffic afterward. It could be coincidence, but I had a long history of stable traffic, so the timing seemed too coincidental.

<comment><USER2> ajax.googleapis.com is being referenced on so many sites now that many, if not most, visitors will have the DNS resolution cached.

<comment><USER8> Not that I doubt that, but how would you even go about measuring such a thing? Obviously, there's a cost to using google version too (DNS lookup + one more point of failure). It would be nice to have real numbers for what percentage of visitors actually have the libraries cached. Remember, that the files are versioned and they're also serving less popular libraries than jquery. My guess is that it would be slower to use the google version for some library/version combos. The question is which ones.

<comment><USER2> I ran a crawler on the Alexa top 200,000 a couple months ago, measuring how many sites referenced jQuery and how many used a CDN. I haven't published the results yet, but will be sure to submit that post here when I write it.

Keep in mind that the version fracturing doesn't increase the likelihood of a DNS lookup.

</comment></comment></comment></comment><comment><USER9> I find this page more convenient: [http://code.google.com/apis/ajaxlibs/documentation/index.htm...](http://code.google.com/apis/ajaxlibs/documentation/index.html)

<comment><USER10> this page tells you how to use googles javascript to load the library, instead of providing links directly to the library's.

<comment><USER9> It provides the url for each library.</comment></comment></comment>


Ketamine May Relieve Depression by Repairing Damaged Brain Circuits - <AUTHOR> https://www.npr.org/sections/health-shots/2019/04/11/712295937/ketamine-may-relieve-depression-by-repairing-damaged-brain-circuits <comment><USER2> So does Ketamine have any other ways of action besides neurogenesis?

There are compounds like NSI-189 that are going towards this path, but they come up short in trails.

</comment><comment><USER3> What do they mean at the end by you need to maintain the new connections?

<comment><USER4> If I've read this correctly, the theory states that depression heralds from damaged connections between synapses in a brain region regulating mood. Fixing these connections can be induced by stimulating the synapses in that area in a specific way, which Ketamine does. The effect appears to be transient, which means the damage returns after a while, requiring additional treatments. If there was a way to stop the disruption of connections in that brain region permanently, you would not need repeat Ketamine treatments.

<comment><USER3> Ah so ketamine then isn't solving the problem, but rather is just repairing the damage which will come back? Kind of like road maintanence?</comment></comment></comment>


Named pipes, process substitution and tee - <AUTHOR> https://kaushikghose.wordpress.com/2016/10/27/named-pipes-process-substitution-and-tee/ <comment><AUTHOR> _So we have here, again, a subtle way in which Darwin's BASH shell differs from Linux's and lurks, waiting, to screw you up and waste your time. It's a pity that the Mac has taken off for developers (myself included) because it's clear Darwin will never be a proper -nix but the adoption of Macs by developers probably takes some energy away from getting Linux on laptops._</comment>


Webhosting Talk Hacked - All Data Deleted Save for Oct 08 Offline Backup - <AUTHOR> http://blog.raamdev.com/2009/03/26/the-importance-of-offline-backups

<comment><USER2> This is insane:( I think WHT is the oldest community I've been a member of. Joined when I was 11, makes it 10 years!

This would make for a great case study though. It sounds like it has to be an inside job considering the hacker was so totally aware of all the backup infrastructure. WHT doesn't have tonnes of employees so it shouldn't be too hard to figure out if it was from the inside.</comment>


Ask HN: Should we use C++ instead of C? Which version of C++? - <AUTHOR>

For a new data service I'm building at work, I'm seriously evaluating using C++ instead of C (I can't use Java/Scala due to memory footprint). I'm confident our team can cope with either so I don't see that as an issue.
Advantages of C++ over C, as I see it:
- Slightly easier memory management
- Better standard library: strings, STL, Boost etc
- Access to modern libraries open-sourced by Google
(http://stackoverflow.com/questions/4721824/what-libraries-has-google-released-for-c),
  Facebook (https://www.facebook.com/notes/facebook-engineering/folly-the-facebook-open-source-library/10150864656793920) et al.
Cons:
- The language is more complex; should choose the right subset
- More chance for library/version incompatibilities?
I'm not too aware of the state of C++ nowadays. Does anyone have any recommendations for which version of C++ to go for, which style guidelines to follow etc? (All our environments are Linux) <comment><USER2> Have you considered using a mix of languages? For instance Python with C in areas that are performance critical. I'm seeing this used increasingly on scientific projects and I have heard no complaints.

The reason I suggest a mix of languages is that, as you probably already know, writing in C slows development time and writing in C++ is like walking through a minefield where seemingly simple things explode in complexity. In my experience/opinion C codebases are more maintainable although the code probably took longer to write.

<comment><AUTHOR> Hm, I haven't given that serious thought. I'm used to doing cross language calls on the JVM but not to native code.

In our use case we need to load a lot of data and serve it. The client library could be written in Python. I'm trying to decide on the language to use for the lower level.

</comment></comment><comment><AUTHOR> I must add that I've looked at this recent HN thread on the same (<http://news.ycombinator.com/item?id=3953434>) by the author of 0MQ. But I felt the question is still valuable enough to stand on its own.</comment>


FCC fines Swarm $900k for unauthorized smallsat launch (2018) - <AUTHOR> https://spacenews.com/fcc-fines-swarm-900000-for-unauthorized-smallsat-launch/ <comment><USER2> I really wish cities and other regulatory bodies were equally as zealous in their slapdowns of startup behavior. Airbnb, Uber, and the slew of scooter companies come to mind as doing the equivalent of Swarm's behavior in their respective markets.

<comment><USER3> Hmm... Uber and AirBnB were 'first wave' where there wasn't even any precedence to charge or regulate them. Now we see a ton of regulations in specific cities for both of those companies.

As for the scooters, maybe you just live somewhere else, but where I am in, it was a fucking NIMBY nightmare. They were throwing them in front of tech / private transportation buses and into the water. They were all banned for about 6 months until legislation came out.

</comment></comment><comment><USER4> Kurzgesagt[1] convinced me that space debris will become a real problem if we're not careful. A "Swarm" of fist-sized cubesats whizzing around our planet at a few thousand km/h sounds like a nightmare.

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

<comment><USER5> Possibly stupid question, but I've been wondering about this for a while:

Could space debris also make ICBM launches infeasible? If so, I honestly wonder whether the trade-off could be worthwhile.

<comment><USER6> Probably not, ICBMs don't need to attain a full useful LEO, they only need to stay in an orbital path for 1-2 orbits as current warhead delivery vehicles are configured. That would allow them to use an orbital path lower than any orbit that could be sustainable for debris.

Even if the current crop of ICBMs can't be configured to use such an orbit, development of such wouldn't take more than a few months.

</comment></comment></comment><comment><USER7> Not enogh, they willfully ignored the FCC. They should be bared from launching anything in the future and the CEO should be fired.

<comment><USER8> That won't do any good, sadly, which is the system working as designed.

The violation is associated with the company, which can disincorporate, sell off all assets to a holding company, then reincorporate as a shiny new corporation pure as driven snow.

Criminal charges can only be applied to specific individuals; and each of those individuals you can bet are engineering their organizational structure to provide plausible deniability.

Our justice system is ill equipped to handle poor behavior by corporate actors compared with human ones. You can't jail a Corporation, and while you can kill one via revocation of charter, there is nothing to keep the same people from gathering together to do it again under a new corporate identity.</comment></comment>


Google Wallet Co-Founding Engineer Departs Google for Square  - <AUTHOR> http://www.nfctimes.com/news/google-wallet-co-founding-engineer-departs-google-square

<comment><USER2> I was really excited for Google Wallet, so much so that I bought a Galaxy Nexus.

Guess what? Verizon blocks it. If Google doesn't want to fight for their product, why should their co-founding engineer stick around? Happy he is off to Square. (I'm not so much grumpy at losing a specific payment option I'm grumpy at one of the few companies with enough force to lean on Verizon capitulating. New tech gets slowed and I get sad.)

<comment><USER3> I did the exact same thing and have the exact same resentment. Now I am stuck with a GIANT phone for 2 years.

<comment><USER4> Didn't y'all know that Google Wallet was blocked before you bought the phone?

<comment><USER5> Nobody really advertises, "capable of Google Wallet, but we won't let you have it". That's the problem with letting the carrier own the phone.

The Galaxy Nexus is a pretty nice phone, Wallet or not, and I'm not sure if anything else would have been as good anyway. Verizon's 4G network is better than Sprint's, anyway. A reasonable tradeoff for what amounts to a novelty. (I will need to carry my physical wallet until every store on Earth has an NFC reader anyway.)

</comment></comment></comment></comment><comment><USER6> Meanwhile, Osama Bedier is still a VP at Google and now an advisor to Mezz [1] a startup which, if he signed the same employment agreement the regular folks sign, means he probably will be moving on from Google shortly. (My personal experience is that Google pretty much considers any outside work a conflict of interest)

[1] <http://www.crunchbase.com/company/mezz>

</comment><comment><USER7> Why wouldn't Square want to work to make their payment platform accessible through multiple channels (NFC, their dongle, mobile-to-mobile, etc.)? Just as they should develop for many of the big software platforms, they will probably need to have product offerings that allow payments in multiple ways.

<comment><USER8> You can already just pay with the app, which I think really is the best way since it doesn't require any special hardware for the customer.

Of course only problem is the penetration of Square registers.

<comment><USER9> I don't have any insider knowledge of Square specific to this, but it's not that hard to make a shim for a PoS to do all sorts of stuff. I contracted for a company in 2003 which did NFC/RFID readers with a little magnetic shim for existing magstripe card readers. You can also integrate at a deeper level directly into the PoS -- there is some customization needed, but a lot of it is generic.

</comment></comment></comment><comment><USER10> Why isn't Google buying Square anyway? They really need a popular payments platform to integrate with Android. I realize they might not want to sell now, but maybe they want to sell it for a good price.

</comment><comment><USER11> Just part of the normal turn over when you have more than 32,000 employees.

<comment><USER12> Doubtful. I've been in the same spot myself and eventually also left that employer - it's incredibly painful to be enthusiastically dedicated to a project and see it go nowhere. Worse yet, it goes nowhere because upper management is unwilling to throw their weight into it.

Eventually you get fed up and leave for a company that has a track record of actually pushing hard in the field you're interested in.

<comment><USER5> Is Google Wallet really not going anywhere? Who else lets you make NFC payments in the US today?

</comment></comment></comment><comment><USER13> Slow news day.

</comment><comment><USER14> Congrats to Jim

<comment><USER14> (McKelvey)</comment></comment>


Is Google Drive worse for privacy than iCloud, Skydrive, and Dropbox? - <AUTHOR> http://www.theverge.com/2012/4/25/2973849/google-drive-terms-privacy-data-skydrive-dropbox-icloud <comment><USER2> If:

 _"Google is giving itself all the permissions it could possibly need"_

Then

 _"We will ask for your consent before using information for a purpose other than those that are set out in this Privacy Policy."_

Doesn't mean much, irrespective of the policies of any other business.

</comment><comment><USER3> The short answer is 'no'.

<comment><USER4> The 50% longer answer is 'yes':

Google - "giving itself all permissions it could possibly need" including creating derivative works of any kind.

Dropbox - "solely to provide the Services"

Skydrive - "solely to the extent necessary to provide the service"

iCloud - "solely for the purpose for which such Content was submitted"

Basically Google can do anything they want with your data, but the others can only use the data for what you would expect (storing/syncing your data).

<comment><USER5> "create derivative works (such as those resulting from translations, adaptations or other changes we make so that your content works better with our Services)"

Seems reasonable enough to me. Seems like you're taking the wording to the logical extreme and rolling with it.</comment></comment></comment>


Cheezburger CEO's Tweet Gets a Response From Reddit's Co-Founder - <AUTHOR> http://mashable.com/2010/08/28/reddit-cheezburger-response/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Mashable+%28Mashable%29 <comment><USER2> Does anyone know how much Cheezburger/Pet Holdings is worth? Can they afford to buy Reddit? I'm not sure how much Reddit is worth (I heard $12 million to $65 million back when it sold, presumably more now). Pet Holdings didn't seem to be a moneybags kind of company (<http://www.crunchbase.com/company/pet- holdings-inc>).</comment>


An Interview with Rich Hickey about Clojure (A-Z series) - <AUTHOR> http://www.computerworld.com.au/article/313989/-z_programming_languages_clojure

<comment><USER2> Bonus: Plenty of _other_ great interviews linked to from the first paragraph of the article. I am reading an interview of Simin Peyton Jones. [http://www.computerworld.com.au/article/261007/-z_programmin...](http://www.computerworld.com.au/article/261007/-z_programming_languages_haskell?fp=&fpid=&pf=1)

The complete list is at [http://www.computerworld.com.au/tag/a-z%20of%20programming%2...](http://www.computerworld.com.au/tag/a-z%20of%20programming%20languages)

very informative and enjoyable! There goes the day. I'll be reading these all day!

</comment><comment><USER3> Did anyone else notice that he's started mentioning the CLR a lot more in this article? I know that there has been some recent work on getting Clojure running on the CLR and Clojure-in-Clojure; but I thought it was interesting that it's starting to return to Rich's conversations as well.

<comment><USER4> Yeah, which makes some sense. I think Clojure's strength is that it makes inroads with Java developers (as opposed to Common Lisp guys jumping over). If he can get the same excitement out of some .NET'ers it could double his user base.

</comment></comment><comment><USER5> "Right now we're in the early adopter phase, with startups and ISVs using Clojure as a secret weapon and power tool."

Are any YC start-ups using Clojure?

<comment><USER6> Well it wouldn't be a "secret weapon" then, would it?

</comment></comment><comment><USER7> Nice! I've been waiting for the Clojure A-Z serious interview for while.

</comment><comment><USER8> So:

Clojure was born as a hybrid of FP and CL for the JVM, as that seemed perfect to the authors personal experience...

Sorry, but I'll not abandon my own way for such a personal preference style (if I only could remember where I already saw this pattern... hm [...]).

I'm perfectly OK with my chosen Lisp system (no, I won't tell you, no war fan I am).

<comment><USER9> "The author prefers it" is suddenly a problem with a language? Have a look at Clojure; it's a very nice language on its own merits. (I particularly like the combination of software transactional memory with by-default immutable data structures.)</comment></comment>


Ethiopian Multiplication - <AUTHOR> http://threesixty360.wordpress.com/2009/06/09/ethiopian-multiplication/

<comment><USER2> This has been attributed to so many places. I actually spent some time coming up with an algebraic proof that it worked when I was in college. It turns out that it is perfectly clear what is happening if you write both numbers in binary as another poster has pointed out.

However for historical purposes, the question is why? I think there is a very simple reason. Before you have based number systems, most number systems are usually derived from tally sticks. This makes some functional sense, and once you think about it from a tally stick, roman numerals make perfect sense. For example consider the number XXIV. It represents a position on a tally stick:

IIIIVIIIIXIIIIVIIIIXIIIIVIIIIXIIIIVIIIIXIIIIVIIIIL

Count to the second X and then one before the V. IXL is the same. Count backwards one X and then one I from the L. So while our system of numbers today is based on position of digits, many earlier systems were based on visualized markings on tally sticks. So you have numbers without a base system. This divide and add approach works very well when you don't have a number system. You can take your tally stick, figure out the number, and the same on the other side. I cannot think of another way to do multiplication on a tally stick.

Interestingly tally sticks of a slightly different sort were in use up until the early 19th century in Britain as tax receipts and in 1836 the attempt of the British government to get rid of these humble staves leveled both houses of parliament. Before you have widespread numeracy, tally sticks are how you track amounts for everything from debts to receipts. It isn't surprising that this would be a widespread method.

<comment><USER3> The interesting part is that Romans wouldn't have written 24 as XXIV. They'd have written it as XXIIII, which makes it much simpler because you only ever go left to right..

<comment><USER2> the Romans, IIRC were extremely inconsistent. Sometimes, for example, you see IIXX for 18. However either way it represents a place on a tally stick.

</comment></comment></comment><comment><USER4> To multiply 14 and 12 in my head, I break it down like this:

        14 * 12 = (14 * 10) + (14 * 2) = 168

Anyone else do that?

<comment><USER5> Similar here, but based on memorization. Since I know twelve squared ((12 * 12) = 144) by rote, the rest is easy.

      14 * 12 = (12^2) + (12*2) = 168

<comment><USER6> I tend to use the tens as well, but in this case I would have used the 12*12 + 24 trick. I also use some of the others listed here, so it makes me happy to know there are people like me out there.

</comment></comment></comment><comment><USER7> Since dividing by two (ignoring remainders) is just a left shift, and multiplying by two is just a right shift, this means you can do multiplication with just <<, >>>, and +.

Of course, here's another, er, related algorithm. Take your two numbers A and B. Make a variable called C, initially set to 0. Iteratively decrease A by 1, and increase C by B. Do this until A = 0. Then C is your answer. Everyone knows this technique, it's obvious. But it means that you can do multiplication with just + and --.

I wonder what other ways you can do multiplication with a limited set of mathematical operators.

<comment><USER8> The other interesting property to the first algorithm is that you don't need to calculate a conditional for each bit in one of those factors. You can just AND each bit in one factor by all the bits in the other factor (ANDing is equivalent to multiplying in binary), before the shifts and the adds. Because ANDs, shifts, and adders are extremely simple to implement in hardware, most (all?) binary multiplication circuits are based off of the peasant multiplication algorithm, with modifications that trade off expense of manufacturing (more gates) for quicker computation (less gate delay due to exploiting parallelism in the algorithm).

</comment></comment><comment><USER9> I've heard this referred to as the "Peasant's algorithm," though I don't know why. Interesting fact: In binary, the peasant and traditional multiplication algorithms are actually step-for-step identical.

</comment><comment><USER10> Some folks have pointed out the relationship to binary multiplication. Here's a TED talk that discusses the long history of binary math in ancient Africa. <http://www.ted.com/talks/ron_eglash_on_african_fractals.html> Spoiler: Boole got the idea from Africa by way of the Middle East!

</comment><comment><USER11> My dad wrote a short article on this in the 1980s:

<http://darrow.faithweb.com/peasantmultiply.htm>

</comment><comment><USER12> In Ruby:

      # Ethiopian Multiplication
      # usage: ruby em.rb 673 7
      m, n = ARGV.map(&:to_i)
      product = 0
      while m >= 1
        puts "%4d : %4d %s" % [m, n, m.even? ? "Ignore" : ""]
        product += n unless m.even?
        m = m / 2
        n = n * 2
      end
      puts "Product: #{product}"

<https://gist.github.com/3660240>

</comment><comment><USER13> My son was taught this method at school as THE way to do multiplication. Imagine my confusion when he brought homework back and I started doing multiplication the way we were all taught, only to be told "DADDY, you don't know anything!".

<comment><USER14> Do you live in the UK? I read an article some time ago about a new methods of multiplication and division that was being taught at UK elementary schools. Parents had trouble with it because they were not taught that way.

While the new simple methods got the job done, I still think the old methods are worth teaching because they're required when doing some advanced math later on.

The difficult method of long division, for example. After elementary school arithmetic, I've had to re-learn the method several times. In grade school it was doing divisions of numbers but later the same method was used for division of polynomials, then doing binary and again when learning how to compute crc checksums and hassling with polynomial fields in crypto class.

Math education is not necessarily supposed to be about learning how to get shit done (if it were, it would be obsolete because of calculators), but rather learning methods to deal with numbers, polynomials and other algebraic beings.

</comment></comment><comment><USER15> Made me think of the Trachtenberg Speed System: <http://mathforum.org/dr.math/faq/faq.trachten.html>

</comment><comment><USER16> I don't know; I feel like this would get complicated far more quickly than the FOIL method...

<comment><USER16> As soon as I walked away for some more water, I realized I had missed the point ;-)</comment></comment>


Light Phone - <AUTHOR> https://www.thelightphone.com/home <comment><USER2> Turn off images, visit this site, and see what happens.</comment>


Screenie - Fancy Screenshot Tool - <AUTHOR> http://code.google.com/p/screenie/ <comment><USER2> I use Jing on Windows (also has an OSX client) www.jingproject.com. Works great and it is free.

</comment><comment><USER3> Looks cool. When will there be some windows binaries?</comment>


How to Build a Data-Driven Startup - <AUTHOR> http://davidcancel.com/data-driven-startups/ <comment><USER2> "Does anyone give a shit about your dumb idea?" should be a bumper sticker/everyday growl reminder/alarm sound/first question of the YC app.

The graphic from the homepage of www.ABtest.com is also pretty self- explanatory about A/B.

<comment><USER3> _"Does anyone give a shit about your dumb idea?" should be a bumper sticker_

I dislike this style of communicating a point. There has been an epidemic of it on the web over the last year or two (that and its close cousin, the "X Reasons Why Your Y Sucks" post). Apart from being crude and overused, I think it sends the wrong microsignals. Many good ideas seem dumb at first. To me it indicates a deep misunderstanding of the creative process to blast anything in the delicate, incipient stage with this kind of harsh language. The most consistently creative people I know don't do it.

This may be a merely stylistic point, a matter of taste, but I suspect it's more. The way one puts things has effects. In particular, it affects what ideas and possibilities open up next.

<comment><USER4> I actually think it gives exactly the right signals. The people you'll have to sell to (customers, investors, future hires) will probably not be very understanding of the creative process. They'll think your idea is dumb, and they'll say "no thanks," or just hit the back button, without a second thought. The presentation is about convincing them otherwise, so it makes sense to put the problem statement front and center.

</comment></comment></comment><comment><USER5> David does a great job of pointing out a mistake people make when interpreting the Lean Startup philosophy. It isn't about optimization, its about validating basic assumptions.

</comment><comment><USER6> This presentation can basically be summed up as a verbal kick up the ass - "JFDI". For that, it's useful - beyond that, I feel it's much too shallow for the HN audience (we know this stuff... we've read Steve Blank, we're looking for more nitty gritty details).

</comment><comment><USER7> I have a question does the churn rate he talks about (less than .8% of users stay more than a year) apply to startups aimed at business critical applications like inventory control etc.?

I do know that most business "software" is horrendously underused, but does anyone know the actual churn rates? Also does it vary for desktop applications? If so what types and why?

</comment><comment><USER8> Could anyone at the talk explain the three charts on slide 62? What are they representing?

<comment><AUTHOR> Hi,

Those 3 chart types are the only data visualizations I recommend using. I should have left out the pie chart, since I don't use those.

I wasted many years of my life at Compete obsessed about "data visualizations" only to learn that no one except me and my statistical team cared about them. Please don't waste as much time as I did playing with exotic visualizations.

;dc

<comment><USER9> He asked if you could explain them, specifically what they are about I think.

<comment><AUTHOR> Sorry not sure what you mean.

Do you mean explain what a line, bar & pie chart are good for?

<comment><USER9> Ohh I am sorry I thought you were emphasising the data the charts were measuring rather than the actual types of chart themselves!

If you only mean that we should use only line, bar or pie charts, then I would say that scatter graphs at time have a good use of showing outliers, such as some guy who spends say ten minutes on the site, or visually able to show for example how many people spend ten minutes and how many 3. Communicate in other words much more information than a line, bar or pie chart can at times. I mean, people did not invent these other charts for no reason :)

</comment></comment></comment></comment></comment><comment><USER10> Nice presentation, keeps it very simple. Oddly enough I signed up for his other startup performable the other day, seems his whole startup is oriented around helping you do this lol.

<comment><AUTHOR> Thanks for the kind words and for giving Performable a try. Let me know if I can be helpful.

;dc

</comment></comment><comment><USER11> This is such a great presentation. Thank you, David!

</comment><comment><USER12> is there a video link to the presentation?

</comment><comment><USER13> This is a seriously awesome deck!

</comment><comment><USER9> I should have stopped reading the presentation when he said reading is useless!</comment>


Give HN: Startup Idea 404ed.biz and bubb.ly - <AUTHOR>

A new bubble is forming around institutional investors in web startups. See latest posts of Fred Wilson, Mark Suster, Paul Kedrosky et all other prominent VCs about.
In response a good idea would be to showcase both  sides of the table: bubb.ly (availability not checked) a site showing which startups will likely to bubble and most importantly why.
And 404ed.biz (available) alias notfounded.biz a site presenting successful companies and products doing on their own without venture capital investment <comment><AUTHOR> Business model? Think Mashable, RWW and co.

These sites would meta-filter startup news and present the most interesting cases worth analysing by a community</comment>


Samsung Will Eventually Provide Samsung Pay as a Service - <AUTHOR> http://arc.applause.com/2015/08/13/samsung-pay-as-a-service/

<comment><USER2> I see two challenges for Samsung: first, as far as I know, they've never tried to resell software like this to other smart phone manufactures. Second, if EMV/chip-on-a-card takes hold (with the shift in liability that card issuers are going to do to force their hand in adopting chip readers by Oct 1st), where does that leave Samsung Pay's only advantage over Apple and Android Pay?

</comment><comment><AUTHOR> So, this is what happened to LoopPay after Samsung bought it.</comment>


Why does the government let a company like Herbalife stay in business? - <AUTHOR> https://www.latimes.com/business/story/2020-08-28/herbalife-lawbreaking-companies <comment><USER2> I have no idea how you're supposed to find this organically; Here's the PDF that tells the tale:

[https://opportunity.herbalife.com/Content/en- US/pdf/business...](https://opportunity.herbalife.com/Content/en- US/pdf/business-opportunity/StatementAverageCompensation2011EN.pdf)

In 2011, in the US ~351,000 people were on the roles as individual sellers. The pdf even acknowledges "Single-level Distributors benefit from buying Herbalife products at a preferred price for their consumption and that of their families, and for many this is the only benefit they seek."

Those 351,000 people are the product for the "Supervisors"

Here's another one for 2013: [https://opportunity.herbalife.com/Content/en- US/pdf/business...](https://opportunity.herbalife.com/Content/en- US/pdf/business-opportunity/statement_average_gross_usen.pdf)

400,000 people who earned nothing at all from herbalife as individual sellers (they could potentially profit from selling product, but that's quite rare, it looks like 50,000 people bought more than the minimum [see footnote in pdf]).

Next, 43,000 people who could potentially earn money from their downline (see the 400,000 chumps above); but only 2,300 actually did earn anything at all.

Next, the actual winners in the pyramid: 73,000 people at the top. But wait, 18 percent earned $0 and another 56% earned $250 on average. So how many people in the pyramid earn above minimum wage? Something like 2,600 people.

<comment><USER3> This is reassuring, if anything. Those numbers make it sound like it's mostly just a business with an unusual sales and marketing mechanism. The vast majority of the customers aren't taking part in the "pyramid scheme" part of the enterprise. They're just buying herbal supplements because they make them feel better or maybe their neighbour pressured then into it. All slightly skeezy but no worse than most retail businesses selling discretionary items.

It would be much worse for society if most of the "individual sellers" were buying large quantities of the useless product, intending to sell it on but never being able to.

What proportion of people in the distribution/consumption pyramid for Coke earn above minimum wage from distributing or consuming Coke? Surely a lot fewer.

<comment><USER4> >The vast majority of the customers aren't taking part in the "pyramid scheme" part of the enterprise. They're just buying herbal supplements because they make them feel better or maybe their neighbour pressured then into it. All slightly skeezy but no worse than most retail businesses selling discretionary items.

That's one interpretation. The other interpretation is that herbalife has reached a saturation point where there aren't any suckers to sign up anymore, and all the "customers aren't taking part in the 'pyramid scheme'" are just the bag holders.

</comment></comment></comment><comment><USER5> Our own government perpetuates the greatest of all frauds, the lottery, over the poor and uneducated to the tune of tens of billions a year. I've tried all my life to get my mother to stop buying tickets and she simply won't despite being a complete dependent of her children (and she's never won decades later!). It's a sickness.

Herbalife (and Casinos) for that matter feed off that sickness as well. It's hard to rationalize banning one and not ban the others and from my ignorant perspective, American society is not in a place where it can collectively come to a consensus to end industries that feed off of the intellectual, emotional and psychological deficiencies of people. The machine is just too big.

<comment><USER6> It's pretty common for not poor people to buy lottery tickets. When the NY lottery was really big about 3 years ago, everyone at my old firm put in a $100 (so like 7k total) to buy tickets. Ended up winning $200, so we bought some champagne.

I noticed other firms doing the same thing, with the convenience store guy telling me that the building in total spent over 100k on lottery tickets within a week or so.

Moreover, the lottery isn't a fraud. The mechanisms and payouts are all known, much like roulette or blackjack. We have a word for it, and it's called gambling (not fraud).

<comment><USER7> I've worked at a couple of places that better than average paid folks pooled some money to buy Powerball tickets. Its low grade gambling and a little bit of team building. I do remember the big one in the late 90's we won our money back which actually was much more difficult than just losing.

I was asked to buy $120 worth of tickets in 94ish and not one damn winning number showed up on any of the tickets. It was requested I never buy for the group again.

<comment><USER8> I think the people buying scratch offs every week are gambling. The people who buy a Powerball or Mega Millions a few times a year, when it gets huge, are just doing it just for entertainment's sake and have no serious expectation of winning.

It's still problematic, but the real argument for keeping the lottery is that without it, organized crime would start running more of their own numbers games again.

<comment><USER9> Agreed. It definitely makes sense from a harm reduction standpoint, keeping people from turning to more predatory options.

At the same time, it's pretty sickening to see the normalization of dangling a pipedream in front of people trapped in lives of 'quiet desperation.'

It's a 60% best solution, where the next best solution is 20% best.

</comment></comment></comment></comment></comment><comment><USER10> For a harrowing, tragic, and hilarious MLM story, read Elle Beau's blog, it's a treasure: [https://ellebeaublog.com/poonique/](https://ellebeaublog.com/poonique/)

People tip-toe around calling MLM what it is, specifically a scam using psychological tactics of a cult. For example, Dave Ramsey (host of a highly popular financial radio show and podcast) condemns credit cards in fiery rants, but uses carefully measured terms when talking about MLM. "Most people lose money, but a few can be very successful..."

Something about MLM gets people scared to tell the truth. I think that everyone knows a friend or family member in MLM, and don't want to risk that relationship. Of course that's what MLM preys on.

<comment><USER9> I mean, Dave's not wrong. If you had a few beers with folks in an MLM who kind of know the deal, what percentage would admit to hoping to be one of the 'got in early and made some money' folks without being too terribly concerned about those at the bottom of the pyramid getting fleeced.

</comment></comment><comment><USER6> Bill Ackman of Pershing Square tried really hard to publicize their shittiness for his massive short bet on Herbalife. There's even a documentary about it. Never seemed to work. Not sure how much he lost in the trade, but a tidy sum, to say the least.

Of course it didn't help that Carl Icahn was on the other side of the trade. Herbalife's stock has done really well for a company that sells no real product and has no real value.

<comment><USER11> [https://en.wikipedia.org/wiki/Betting_on_Zero](https://en.wikipedia.org/wiki/Betting_on_Zero)

</comment></comment><comment><USER12> See this link (previously at [https://news.ycombinator.com/item?id=9714417](https://news.ycombinator.com/item?id=9714417) on HN) for a different take on Herbalife (by a short seller who went long on Herbalife and made quite a bit of money).

[http://brontecapital.blogspot.com/2015/06/herbalife-very- lon...](http://brontecapital.blogspot.com/2015/06/herbalife-very-long- post.html)

<comment><USER13> That was a great read, thanks!

</comment></comment><comment><USER14> Because there is loud grumbling about a "nanny state" when government prevents people from making probably-stupid business decisions. Multi-level marketing, initial coin offerings, allowing people without much money to invest in startups, and casino gambling all lead to most people losing their money.

<comment><USER15> I think the "nanny state" concept is poorly calibrated. If you allow entities to profit from causing harm, or conveniently shift the cost of negative externalities onto other people, day to day life will eventually become so adversarial that it is unliveable. This seems to be happening already, as we are inundated with scam texts, emails and phone calls; children are under siege from social media, the fast food industry, Juul; whole regions are routed by the opioid crisis; tobacco related diseases are still one of the top causes of death; the fossil fuel industry keeps edging us closer to varying degrees of annihilation.

</comment></comment><comment><USER16> Well I think it's pretty simple - MLM companies contribute more in political funding, than than the perceived detrimental aspects of their business hurt the electoral prospects of our elected representatives.

As a token example - [https://en.wikipedia.org/wiki/Betsy_DeVos](https://en.wikipedia.org/wiki/Betsy_DeVos)

</comment><comment><USER17> A lot of it simply comes down to how much you want government to police behavior. There is only so much irrationality that can be reined in.

There are also legitimate home based businesses. Government regulations tend to not be very good at telling the difference between legitimate operations and those which are sketchy, but not outright fraud.

<comment><USER18> >A lot of it simply comes down to how much you want government to police behavior.

Individual behavior: As little as is demonstrably necessary.

Corporate behavior: Every bit that shapes capitalism into being benign & overtly beneficial - including police intervention for those on the receiving end of law-changing campaign donations.

</comment></comment><comment><USER19> I don't know why Herbalife, Amway, Primerica and all the MLM pyramid schemes are technically legal and allowed to exist.

<comment><USER9> To play devil's advocate, with people tied up in legal pyramid schemes there's some degree of oversight and public scrutiny. The companies can't egregiously screw too many people too bad. Anybody who does a little homework can see that it's a scam because there's a small number of the schemes around, and Coffezilla has talked about them all ad-nauseum. Vs. if those people were tied up in illegal/underground pyramid schemes, those schemes might be 1,000x more predatory and exploitative.

Like payday loans. They're horrible and predatory, but they'll only take your car, not break your kneecaps if you can't pay.

Addressing market failure in the United States is more damage control and harm reduction than anything. Our Chesterton's fences are in the form of duct tape on top of duct tape.

</comment></comment><comment><USER20> Season 1 of The Dream podcast is an easy and informative look at mlm. [https://www.stitcher.com/podcast/stitcher/the- dream](https://www.stitcher.com/podcast/stitcher/the-dream)

</comment><comment><USER21> Can you say reg-u-la-tory cap—ture

</comment><comment><USER22> We're not in the nutritional supplements business. We're in the empire business.

</comment><comment><USER23> Paywall: [https://archive.is/ya5D9](https://archive.is/ya5D9)

</comment><comment><USER24> A recent conversation on reddit exposed me to somebody who feels its ok to say card fees are for chumps and fund his no fee high return points wins. I think predating on ill informed poorer people who incur credit card debt and fees is wrong personally. Some people think it's OK.

Herbalife is in this spectrum of product: the government is mostly financially a-moral not moral or imorral and so prostitution income is not untaxable even if prostitution is. Herbalife has to get closer to the ponzi end of the spectrum to fall afoul of the law. Right now, it's only appealing to greed.

If herbalife and flyer miles points cards predate willful stupidity then the government needs a strong drive to legislate because in the end it too is conflicted.

Its a long bow libertarian position I dont agree with BTW, I think the role of government is to protect the innocent dupes. But there are thin-end-of-the- wedge arguments a-plenty here.

If I were king, I'd ban herbalife. If I needed a kings tax income I might not.

<comment><USER4> >who feels its ok to say card fees are for chumps and fund his no fee high return points wins. I think predating on ill informed poorer people who incur credit card debt and fees is wrong personally.

Are you talking about interest for carrying a balance, or the various fees you get hit with if you screw up (eg. late fees, returned payment fees)?

<comment><USER24> I wasn't that specific. I am pretty sure the general principle here is that any fee you can avoid by rigorous use of the card sensibly, within your limit, he feels its acceptable to "share" as a benefit the fee free element, where the profit for the card company is in the late paying, over extended customer.

Carrying a balance and paying card interest rate when secured and unsecured loan rates are several if not ten or more percentage points lower (card interest was 20-23% in 2019 when bank loans were under 10% in my economy) provides the profits which allow richer card holders to avoid costs. This still feels like predatory behaviour to me.

His "i got the points be like me" is herbalife marketing of the gilt edged lifestyle which attracts the chumps who pay the cost of his fee free rewards. Its not implicit, it is explicitly why they offer him and his income bracket the deal.

<comment><USER25> This depends on the card. For subprime cards, it's true that late fees and interest charges make up most of credit card companies' revenue. But in the premium market segment that he's talking about, ~90% of revenue comes from annual fees and merchant fees. Even customers that never pay a dime of interest or a single nuisance fee are profitable.

As one case in point, most of American Express' flagship products don't even allow you to carry a balance (and thus pay interest).

Source: work in the industry

<comment><USER24> What's the cut off for premium above? I was on the Amex lower tiers for work related stuff and the no max thing was seriously useful for international travel. Also frightening.

<comment><USER25> It's a bit nebulous, but as a rule high-annual-fee/interest rate rewards cards are built around this model; the higher the annual fee, the less interest income a bank expects to earn.

Issuers tend to specialize, too. For instance, banks like Barclays, Chase and Amex only (intentionally) target prime customers. Chase has been known to fire customers that suddenly start carrying significant balances on their cards, for instance.

On the other hand, banks like Capital One and Credit One explicitly target subprime customers and make the vast majority of their income from interest. Whereas Amex makes 90% of their card income from annual fees/interchange, for C1 it's more like 90% interest/10% interchange. Chase is like 65/35 Interchange/interest, for comparison.

For Amex, the simplest rule is that any card named after a color (Amex Gold, Amex Green, Amex Platinum etc) doesn't charge interest.

Oh - and the Amex charge cards don't actually have no limit. They do have a line, it's just hidden (and somewhat larger than most credit limits). Amex actually has a 'check my spending power' tool on their website where you can plug in a hypothetical purchase and it'll tell you if they would (hypothetically) approve it.

</comment></comment></comment></comment></comment></comment><comment><USER26> The premise is exactly backwards. Why should the government be able to put a company like Herbalife out of business? Adults should be able to decide for themselves whether to buy products. If they make mistakes by our judgement, which is always very imperfect, that is their business.

<comment><USER27> Because Herbalife is not a legitimate business, it's a pyramid scheme with just enough details tweaked to not quite count as one under existing legislation.

Do you think people should be able to buy in to Ponzi schemes, or give money to people running three card monte games on the roadside too?

<comment><USER28> Ponzi schemes require deception and fraud. Unless Herbalife is defrauding people, which MLM's typically do not, there is no comparison.

They are an inefficient allocation of resources for the person investing their time and money, but the same could be said of many, many other endeavors.

I'd rather resource be spent to teach people how to properly calculate ROI and IRR.

</comment></comment></comment><comment><USER29> > Nevertheless, Herbalife recruiting materials were festooned with "images of > expensive cars and opulent mansions."

Why does it stay in business? Because there is nothing wrong with a company that exploits the greed of individuals. Yes, some people are compelled due to desperate situations. But the solution here is raising the education level high enough to not succumb to their inner greed. The solution isn't reactively outlawing knives that cut more people than others.

<comment><USER30> > _Why does it stay in business? Because there is nothing wrong with a company > that exploits the greed of individuals._

There's certainly plenty wrong with it; perhaps you meant to say it's not illegal.

<comment><USER6> I mean, morality is an opinion, so it doesn't really make sense to try and correct someone about it.

<comment><USER31> This is an incredibly glib dismissal of an entire area of philosophy.

It may seem intuitively obvious to you that there are not moral facts (it seemed intuitively obvious that the opposite was true to people even as recently as 150 years ago) but the debate is hardly settled by any intervening scientific or cultural or philosophical advancement.

I guess read J.L. Mackie's "Ethics" for an introduction to the subject.</comment></comment></comment></comment>


LiteCLI – A user-friendly command-line client for SQLite database - <AUTHOR> https://www.pgcli.com/launching-litecli.html <comment><USER2> Slightly off topic - one of the authors, Amjith Ramanujam who is active here, gave a great talk at Pycon 2017: [https://www.youtube.com/watch?v=hJhZhLg3obk](https://www.youtube.com/watch?v=hJhZhLg3obk)

It covers the powerful features of the prompt-toolkit library that is used to make this client.

<comment><USER3> Thank you for the kind words. It's always nice to hear from happy customers .

</comment></comment><comment><USER4> Neat, this is much nicer than the stock sqlite3 CLI client! The pager behavior is a bit annoying, actually, since if my SELECT has more columns than can fit on screen, the pager switches to an alternate screen and when I quit, my results are hidden from me. Is it possible to turn this behavior off?

[append] Off for a specific query, I mean. I think I'd prefer to leave it on by default.

<comment><USER5> Doesn't seem to support sqlite3 dot commands such as .mode/.separator/.import/.output/.headers... (these are really implemented in sqlite3 CLI and not part of the sqlite library). These are, at least for me, among the main reasons to use the CLI in conjunction with SQLite. (The SQLite CLI is very good for massaging CSV data into the correct shape; as far as I know there is no canonical file extension for CLI scripts, I use .sqs, and the CLI has no parameter to run scripts directly, so you have to start the CLI manually and do .read foo.sqs).

<comment><USER6> >and the CLI has no parameter to run scripts directly, so you have to start the CLI manually and do .read foo.sqs).

It does work, but only sort of. Just did:

$ sqlite3 -init select_contact.sql test_sqlite.db

\-- Loading resources from select_contact.sql

Alan|Acre|50|Male|100.0

Betty|Smith|20|Female|200.0

Charlie|Copenhagen|30|Male|400.0

Dorothy|Delhi|80|Female|400.0

Edwin|Bombay|40|Male|100.0

Edwin|Pune|55|Female|110.0

SQLite version 3.8.11 2015-07-27 13:49:41

Enter ".help" for usage hints.

sqlite>

where select_contact.sql contains "select * from contact;"

So it can run a script given as a parameter.

But it leaves you in the CLI instead of cleanly exiting. And prints those extra headers, etc. Not very Unix-philosophy-adherent, it seems.

Edit: formatting

</comment></comment></comment><comment><USER7> Missed opportunity to call it CLite? :)

<comment><USER3> Damn it! :)

<comment><USER8> Would you consider changing pip to pip3 in your command? Lead the way with good practice?

<comment><USER9> I'm not sure how that is good practice?

<comment><USER10> Its a Python3 script, shouldn't it use pip3 ?

      I installed it with: $ sudo pip3 install litecli

      (seemed to work)

<comment><USER11> Dont use sudo pip, it can break your system.

</comment></comment></comment></comment></comment></comment><comment><USER12> I see that this is based off of pgcli and the link above is from pgcli's blog page; presumably ownership is same between these two projects. What is the difference between LiteCLI and pgcli? I could not find it in the blog post nor the web page

<comment><USER3> DBCLI ([https://www.dbcli.com/](https://www.dbcli.com/)) is an open source org that made pgcli, mycli, mssql-cli etc.

LiteCLI is part of that org. So you can think of it as a clone of mycli that happens to work with SQLite.

The code base is largely similar between mycli and litecli. The changes are to support the SQLite backend and to support the dot commands (like .tables, .mode etc).

So the feature set should be same.

The DBCLI tools are not created by a single individual (anymore). We have a team of core devs and the lead maintainer for pgcli, mycli and litecli are all different people.

</comment></comment><comment><USER13> I have been using pgcli itself for many years and it is a fantastic piece of software. If you're a terminal user that deals with Postgresql, I highly recommend you try out pgcli!

</comment><comment><USER14> This is fantastic - really pleasant to use, and a very obvious upgrade to the default client.

<comment><USER3> Thank you, Simon. That means a lot coming from the author of datasette. I love your work.

</comment></comment><comment><USER15> Very cool. I tried it on Windows 8.1 and it works with some issues. For instance, I downloaded the SQLite sample DB ([http://www.sqlitetutorial.net/sqlite-sample- database/](http://www.sqlitetutorial.net/sqlite-sample-database/)). For some tables (albums, artists), doing a select * from table results in :

 _' charmap' codec can't encode character u'\xe3' in position 2052: character maps to <undefined>_

Feature request: allow for snippet expansion. For instance, when I type 'ssf' \+ tab, it should expand to Select * From and show the table dropdown.

</comment><comment><USER16> Looks like nice, will definitely use this.

Without knowing either program very well, how does it compare feature-wise to "DB Browser for SQLite" (apart from the GUI) ?

</comment><comment><USER17> This is awesome! I use pgcli everyday and love it so much. This is gonna be a great addition to my SQLite toolbelt!

</comment><comment><USER18> Personally I like to use ptipython (think a better version of the CLI for ipython) and SQLAlchemy whenever I'm debugging my SQLite databases. It's light, can install most places, and has my JEDI autocomplete.

</comment><comment><USER19> «Lit»+Tab will now be one of my most used commands on Ubuntu. Thank you!

</comment><comment><USER20> Looks great!

What would be neccessary if someone would like to integrate it with osqueryi?

</comment><comment><USER21> Ah, this is very nice! Also a great tool to teach people SQL :)

</comment><comment><USER22> Awesome I wanted to create something similar when I saw pgcli but it seems you beat me to the punch!

</comment><comment><USER23> Interesting. I love SQLite and this looks awesome :) Hopefully I'll report back later with some criticism.

</comment><comment><USER24> Awesome! Very clean design :)

</comment><comment><USER25> Going to start using this every time I work with a sqlite database now!

</comment><comment><USER26> Does this go through the same ridged testing as SQLite?

<comment><USER3> Haha. No.

We have a large set of tests, but the coverage is no where close to the level that SQLite has.

<comment><USER5> AFAIK the CLI has tests but not to the depth and detail the main library is tested. Makes sense, since the CLI is often not shipped in applications.

</comment></comment></comment><comment><USER27> Thanks for building this!</comment>


Tweetdeck sells for 30m I really should have finished this side project... - <AUTHOR> http://vimeo.com/1087907

<comment><AUTHOR> UI needed work, but it was integrated fairly well with Twitter, Facebook, FriendFeed, YouTube and GMail.</comment>


Invention: Rolling (bladeless) fluid turbine - <AUTHOR> http://www.epo.org/learning-events/european-inventor/finalists/2016/sedlacek.html <comment><AUTHOR> Disclaimer: I am the son of the inventor.

</comment><comment><USER2> Very cool. I see one of the companies that sprouted is near me(West Palm Beach). I want to play with this!

<comment><AUTHOR> Glue a straw to a ping-pong ball and suspend it in the bathtub's drain ;)</comment></comment>


Python Is Not C: Take Two - <AUTHOR> https://www.ibm.com/developerworks/community/blogs/jfp/entry/Python_Is_Not_C_Take_Two <comment><USER2> This is a useful walk through optimization in python.

> The lesson is clear: do not write Python code as you would do in C. Use > numpy array operations rather than iterate on arrays. For me it meant a > mental shift.

I think the lesson is that "performance critical software requires attention to very many specific details." Using a garbage collected language that allocates objects on the heap by default means that you'll have to take special steps to change the default behavior of the system. You will see very similar behavior with C++, Java, etc.

> I didn't use Pypy so far because it only supports part of Numpy, and not > Pandas, Scipy, and Sklearn. It may be that Pypy supports enough of Numpy to > run my closest distance code though. If that's the case, then I'll blog > about it soon.

I'll confess, I was eagerly waiting the pypy results. IMO using pypy means I get the best of both worlds: more code that can be naively python with python idioms and still yield sufficient performance. For critical algorithms where I can't hit sufficient performance, it's appropriate to use cffi or something to optimize.

<comment><USER3> Sure, but what if my work depends on a library that uses C extensions that isn't supported by pypy? Any of the scikits, for example.

<comment><USER2> Unfortunately I have no answer for those. For now scikit and pypy seem mutually exclusive.

</comment></comment></comment><comment><USER4> I like Numba, but it's sometimes jarring writing C-like code in a language which almost explicitly advises against it. Once you get into the habit of "FOR LOOP BAD" it's difficult to get out of!

It's interesting seeing what the effect of Big-O is. Once you introduce a logarithmic solution, it doesn't really matter that you're using Python because it's asymptotically so much better than the n^2 brute force approach. Nearest neighbour is a particularly nice demonstration of this, because it's an algorithm which is frequently used in realtime and obviously you don't want a performance hit of 2 seconds for every query!

Note Numpy has a builtin np.radians() which is a little cleaner than a one value look up table.

In [2]: %timeit np.random.random((10000))*3.14 1000 loops, best of 3: 245 µs per loop

In [3]: %timeit np.radians(np.random.random((10000))) 1000 loops, best of 3: 262 µs per loop

<comment><USER5> Yeah I've started using Haskell a lot lately, which doesn't really do for loops per se. It was pretty natural to use `map` though because I was plenty used to Numpy style (ok really it's originally APL style but Numpy is where I picked it up).

Numba is pretty nifty for things that are unnatural in this style, where an algorithm is better expressed in an index-dependent style, like e.g. a numerical ODE solver. Sometimes you can get around it with tricks like convolution, but not always.

</comment></comment><comment><USER6> I guess it's kind of beside the point of the article, but I wonder if the author considered using a library like Shapely[1].

[1] [http://toblerity.org/shapely/manual.html](http://toblerity.org/shapely/manual.html)

<comment><USER7> Thank you for the suggestion.

At first glance, it does not seem to provide an object for dealing with a finite set of points. Using it would require first to transform the track into a continuous line, via interpolate(), then project() each waypoint to find the nearest point on that line. Issue is that this will not give me one of the original points of the track, which is what I needed.

But I may be wrong.

<comment><USER8> I'm curious about why that was? From the graph showing the raam datapoints, there's a region with large gaps between points, and it would choose a track point that's well away from the original?

I've written some code to deal with this before (in my case, I wrote a distributed timer for cycle races, predicting current rider locations and gaps from sparse user reports). For me, finding nearest point on the segments of the polyline worked, but choosing only vertices would have made the time estimates terrible. Were the points somehow more fixed than that, eg towns/motels on the route?

<comment><USER7> The waypoints are not distributed regularly, but the track points are.

Here is why performance mattered in my case.

I needed to predict future positions of the cyclist (see [https://www.ibm.com/developerworks/community/blogs/jfp/entry...](https://www.ibm.com/developerworks/community/blogs/jfp/entry/Predicting_Cyclist_Trajectory?lang=en)). The computation relied mostly on weather forecasts provided for each track points.

I then needed to know where to start my computation, i.e. find the track point closest to the current location of the cyclist.

</comment></comment></comment></comment><comment><USER4> An alternative solution that I discovered a year ago. My problem was that I had a list of 2D points lying in an image. I wanted to calculate the distance to the nearest point for every pixel - somewhat similar to a Voronoi diagram except I needed the distances as well as the cells.

When I asked Stackoverflow, having tried Kdtree, someone suggested a simple brute force solution in OpenCL (using the pyopencl library):

[https://stackoverflow.com/questions/24020409/producing-a- nea...](https://stackoverflow.com/questions/24020409/producing-a-nearest- neighbour-distance-map-for-a-set-of-points)

Scipy's KDtree took around 30 seconds per 1MP image. The OpenCL solution took 50ms (at the expense of my screen locking up)!

As the response said: "And the improvement was quite good.", no kidding.

<comment><USER7> Thanks a lot. I'll have a look at using OpenCL in my case too.

</comment></comment><comment><USER9> Does everyone at IBM still use a 1024*768 monitor? Come on, guys, we've moved on from 12px sized fonts.

Edit: BTW, irony intentional.

<comment><USER7> No, I am not ;)

More seriously, are you unhappy with the default layout of developerWorks blogs? What change do you suggest? Not that I am in any way responsible for it, but I can certainly pipe your suggestions to the power that be.

<comment><USER2> This is a good example of Sayre's Law [1], which I only learned about from another HN post the other day. ;)

[1] [https://en.wikipedia.org/wiki/Sayre%27s_law](https://en.wikipedia.org/wiki/Sayre%27s_law)

<comment><USER7> Lol and thanks. I'll reuse that one for sure!

</comment></comment></comment></comment><comment><USER10> TL;DR if you want fast code: write Python but execute C.

<comment><USER7> Exactly.

Note that you execute C code anyway when you use Python standard implementation (CPython). Point is to use the best C code you can get with limited effort.

</comment></comment><comment><USER11> > The lesson is clear: do not write Python code as you would do in C. Use > numpy array operations rather than iterate on arrays. For me it meant a > mental shift.

This was actually one of the main motivators for me to learn Julia. No need to vectorize loops. Looping through things is idiomatic Julia code that the compiler knows what to do with.</comment>


Comcast adjusts way it manages internet traffic after reports of blocking BitTorrent - <AUTHOR> http://www.nytimes.com/2008/03/28/technology/28comcast.html

<comment><USER2> It took pressure from the FCC to get them to stop.

Their new plan does seem a nice one though. At the busier times of web traffic those using the most bandwidth will be throttled, not just the bittorrenters.</comment>