The Blockchain Problem Space – When to Use Blockchain? - <AUTHOR> https://blog.ironbay.digital/the-blockchain-problem-space-bd94d2babb51 <comment><USER2> All: We've banned this site and this account for using a spam service to buy upvotes. Obviously that is a capital offense on HN. There's no issue on which the community feels more strongly.

I wish everyone would realize that when they do this, they leave obvious trails in the data and so it is not worth the risk.

</comment><comment><USER3> The other major issue with Blockchain is that "all nodes can see everything". This is theoretically a problem with distributed databases as well. However, in the case of distributed databases, the database nodes that can "see everything" are not the end user, whereas, in Blockchain because the nodes are untrusted, one must assume that the end user can see the entire Blockchain state.

This limits the number of use-cases tremendously to those where "everyone-can- see-everything" is an acceptable tradeoff.

There are several ways around this.

1) Zero Knowledge Proofs. But these are highly specialized and resource intensive. To my knowledge we don't have these for generalized Smart Contracts.

2) Split the overall state into Channels, Subledgers etc. with narrower "viewing rights". But again this typically involves an application compromise.

3) Encrypt or cryptographically hash portions of the state. But by definition, this portion of the state cannot be acted upon by smart contracts.

4) Use frameworks like Microsoft's recently released CoCo Framework which relies on Hardware Trusted Execution Environments (TEE). The issue here is that a compromise of a single TEE negates the whole scheme.

In my opinion the privacy characteristics of Blockchain are a critical factor that needs to be taken into account while deciding on the suitability of Blockchai for an application.

<comment><USER4> Can you clarify the disadvantages of the application compromises required for option 2?

I'm currently looking at Hyperledger Fabric and it falls into that category.

<comment><USER3> Sure. Hyperledger Fabric 1.0 has the option of "Channels" to limit viewership rights. In particular it restricts rights to a subset of the community. For example, you may have a 1000 parties in the community, but a particular channel may have only three (say A, B and C).

Now, if one takes a Supply Chain example (a domain I'm quite familiar with), most transactions cannot be restricted to just parties A, B and C. Some will involve A, B and D and some will involve B, C and F etc. So, it is difficult to come up with a suitable Channel membership model.

Even if the transaction is between A, B and C often the view rights are not symmetric. For example in a drop ship case where A is the Buyer, B is the seller and C is the fulfiller, the price attribute may need to be visible between A and B but not C. This is not possible with the Channel approach.

So this particular type of hard partitioning only works for the simplest Supply Chain examples.

Another type of hard partition is to partition by Transaction. But this involves issues such as synchronization between transactions. This becomes an off-chain concern with major consistency issues.

Hope this helps.

<comment><USER4> Thank you that was a very helpful answer

</comment></comment></comment></comment><comment><USER5> You know what is a great database with all those properties?

Your folder with git. There is nothing that you cant do with git that you can do with blockchains as a database.

About the BFT part, it fails the mention the very important part that it doesnt work without proof-of-work.

\---

So then when should we use p-o-w blockchains?

When you want to decentralize control - both, distribution & conflict resolution.

<comment><USER6> Git has a history and UTXO does not store history only keeps with the latest commit

<comment><USER7> git has shallow clones `--depth N`

</comment></comment></comment><comment><USER8> TL/DR: "If Byzantine Fault Tolerance [0] does not create a huge advantage for your use-case, it is unlikely blockchain makes sense to consider over a traditional database."

[0] [https://en.wikipedia.org/wiki/Byzantine_fault_tolerance](https://en.wikipedia.org/wiki/Byzantine_fault_tolerance)

<comment><USER9> Though many new "blockchain" systems do achieve BFT (perhaps most notably Tendermint, which seems to be passing aphyr's Jepsen tests with flying colors), it's important to keep in mind Bitcoin falls short of achieving it:

[https://eprint.iacr.org/2014/765.pdf](https://eprint.iacr.org/2014/765.pdf)

"Regarding BA, we observe that Nakamoto's suggestion falls short of solving it, and present a simple alternative which works assuming that the adversary's hashing power is bounded by 1/3."

One important difference between how a truly BFT system behaves versus Bitcoin is how Bitcoin handles network partitions, or rather, how it doesn't handle them.

Specifically, when Bitcoin goes split-brain, i.e. in the event of a network partition, Bitcoin will "reorg" into two new chains, both of which will happily accept writes from both sides. When the partition is healed, one chain will win, and the writes to the other chain will be clobbered. Ideally these transactions will wind up in the mempool again and be accepted into the new chain, but that isn't a guarantee, more of a band-aid, and doesn't change the fact the system ostensibly acknowledged a write it then lost.

On the CAP triangle, Bitcoin has chosen to sacrifice partition tolerance (i.e. Bitcoin is NOT partition tolerant), and this is bad: [https://codahale.com/you-cant-sacrifice-partition- tolerance/](https://codahale.com/you-cant-sacrifice-partition-tolerance/)

There are ways to turn Bitcoin into a truly BFT system. The main one I like is decoupling proof-of-work from transaction processing, turning it into a leader election system for a more traditional BFT algorithm, such as ByzCoin:

[https://arxiv.org/abs/1602.06997](https://arxiv.org/abs/1602.06997)

With ByzCoin, if you can't reach quorum, you can't make progress, so in the event of a network partition the system will simply stop accepting writes if it can't reach quorum, as opposed to accepting writes which will go on to be clobbered by a future reorg.

<comment><USER10> Not a bandaid at all. Unconfirmed transactions in the "lost" chain are bringing fees with them, so it is the exact same incentive of every other transaction.

Besides , how many times in history a continental network partition of the internet has happened?

And it would only take a single node connected to both sides (land and satellite?), to undo all the work of the would be attacker.

<comment><USER11> > how many times in history a continental network partition of the internet > has happened?

Continental? No. Country-wide? Many, many times.

Imagine being in Egypt during the Arab Spring revolution when the government shut off Internet access. Imagine selling product to people for Bitcoin, seeing your client software accept the transaction because "enough time has passed", and then a few days/weeks later, when Internet access is restored, seeing your wallet balance get clobbered by the much-longer global chain.

/shudder

</comment></comment></comment></comment><comment><USER12> That's...surprisingly simple. As it happens I was just today lamenting to a colleague that for all the blockchain hype, I have yet to hear about any other relevant use case than those which have an ideological agenda to require decentralization at their very core.

Reading this it seems like the author comes pretty much to the same conclusion.

Is it really that simple? I feel like I must be missing something, because the hype is so real.

</comment><comment><USER13> > Blockchain, however, handles conflict resolution in quite a different way. > If there is a net-split between Europe and the USA and two versions of the > database emerge, it simply decides on re-connection to keep the entirety of > the version that has received more traffic during the disruption (aka the > longer chain). This means if the USA version wins, all of the modifications > in the European version, even if there aren't conflicts, are discarded. To > reiterate, this means even if most of the interactions in Europe were just > with other users in Europe and not in conflict with the USA version, all of > those writes are thrown away regardless.

Is this really possible? I can't see why not. If so could a DoS on a specific region of nodes that's large enough to sustain it's own sub chain for a short period be possible? This would be extremely dangerous if transactions were confirmed by the network on a chain that is eventually ignored.

<comment><USER14> I think it's unlikely you'd have a fully split chain, although this is actually an interesting attack against bitcoin, considering China could theoretically cause a China / rest of the world blockchain partition.

</comment></comment><comment><USER15> Simple economics dictates when to use space on the Bitcoin blockchain: When your use case can afford it. This is because transactions require a fee to get confirmed in Bitcoin. And the fees are currently low enough that it supports most use cases; pretty much everything except microtransaction payments. With Lightning Network coming, even that may become economically feasible.

</comment><comment><USER16> Is "blockchain" singular, plural, or some kind of lowercase Proper Noun?

> Blockchains fall

Okay, blockchain is singular, so it always refers to a single object.

There is a universe U of objects, and "Blockchain" is a predicate on U. So for any given x in U, "Blockchain(x)" is a proposition. In other words, we can ask whether something is a blockchain or not.

> Step one is to figure out a framework for analyzing blockchain

Here it's being used as a plural, like you might study a herd of blockchain. That's okay in principle - some words are their own plurals, like "sheep" or "fish". But above, it had an "s" at the end, so it can't be plural.

Another possibility is that "blockchain" is the name of some specific object. "Fred went to the store" -> "I asked blockchain for some money".

That's no problem: Your name can be "Archer" and you can study Archery.

There is a constant c in U such that Blockchain(c). Something somewhere is named "blockchain".

> blockchain does not have the capability to support

> For everything Blockchain does worse than other databases

More evidence that he's talking about some specific blockchain. Christians capitalize God in every sentence to show reverence, while Atheists tend to leave it as a lowercase god.

Is something similar happening here? Which blockchain are people even talking about?

<comment><USER17> Blockchain should be singular - "blockchains" should be used when referring to the technology in general. Getting this wrong is the #1 indicator that an article on blockchains isn't worth reading.

<comment><AUTHOR> I'm not sure if it should be plural when referring to the technology in general. "Powered by blockchains technology" doesn't seem correct to me.

I do hope you'll read the article regardless!

<comment><USER18> The word "blockchain" works just like the word "computer". You can have a blockchain or multiple blockchains, just as you can have a computer or multiple computers. And you'd refer to "blockchain technology" just as you'd refer to "computer technology."

</comment></comment></comment></comment><comment><USER19> I think Steem is pretty interesting from a developer perspective. Since all data lives on the blockchain it's like having unlimited and unrestricted API access. It's very different from having to submit to whatever restrictions and rules centralised social networks usually put on their APIs, if they have one at all.

</comment><comment><USER20> You really need a blockchain for ONE THING:

To timestamp transactions in a distributed way.

Transactions can be signed, proving authorship.

At signing time, you can prove the transaction happened AFTER something else.

The only thing missing is PROVING THE TRANSACTION HAPPENED BEFORE SOMETHING ELSE.

For that, you need an incentive structure to keep each transaction be accepted by someone, somewhere, in a growing merkle tree.

That's the blockchain.

However we don't need proof of work to elect the next miner for every block. It leads to an incredibly wasteful arms race.

In fact we don't even need _every_ transaction to be verified by a miner. Only the merkle tree that happened before the block signing time.

<comment><USER10> Proof of work does not elect the next miner.

Proof of work means that the lucky random miner has invested energy on a previous valid block, and is lucky enough to find another valid block.

If you take that away, you could as well use a database and a trusted timestamp server.

<comment><USER20> No, that's a false dichotomy. And also the "lucky" is relative to the whole scheme. The value _to the miner_ of finding a hash to make another block has gone down and will continue to go down, that's partly why transaction fees are so high.

In any case, that's like saying someone is "lucky" to win a video game in Dave and Buster's. That's not the only way to incentivize validators to timestamp transactions. All you really need is a consensus protocol.

Ripple for example has a consensus protocol that can be run by an entire LOCAL community and can fund itself and the resources it uses. Without requiring a global blockchain. And Bitcoin validation is effectively centralized in the hands of a few miners.

<comment><USER10> Who defines the LOCAL community?

<comment><USER20> People who deal in that local currency.

</comment></comment></comment></comment></comment><comment><USER21> I have a use case for a new blockchain/cryptocurrency that I think is cool. Feel free to take the idea from me and implement it for an ICO :)

I propose "whatcoin", a cryptocurrency designed to create a market for peer to peer media sharing based on the upload/download ratio model used by what.cd and other private torrent trackers to incentive seeding and penalize leeching.

The whatcoin "blockchain" has a catalogue of all currently available music on the platform, so it doubles as the tracker and transaction ledger. The catalogue can have multiple copies of albums sorted by the specific release and the quality (lossless FLAC, lossy 320kbps, etc).

So let's say you want to download a FLAC formatted 1988 MFSL release of Pink Floyd's Dark Side of the Moon album. You'll pay a specific amount of whatcoin from your own wallet based on the size of the files being downloaded, which will be distributed to the seeders you peer with. You'll also pay a network transaction cost.

The network transaction costs fund the "miners", or those who upload new, verified releases that are not on the whatcoin network yet. Those who upload the music are also strongly incentivized to continue seeding it, because they will be paid whatcoin _inversely proportional_ to the number of other available seeders for the same files whenever someone chooses to download them. So the more exclusive the media is, the more lucrative it will be to host it.

Seeders will be paid for uploading media and leechers will pay for downloading media; leechers can then earn more whatcoin by continuing to seed the media they've just downloaded. Each upload/download transaction is recorded on the whatcoin network, and the greatest economic opportunity is available to those who can upload popular new media and then seed it very early on.

This proposal is similar to Filecoin, but you're paying to download new media instead of to store your own and retrieve it later. It also adds the extremely high fidelity media cataloguing that some private trackers have achieved. You could market it to the MPAA or RIAA as an "enterprise blockchain" the way banks are currently investigating it. The studios would be paid for new media they bring onto the platform, and indie artists could be paid for bringing their media onto the network instead of, say, SoundCloud or Bandcamp. If the media is popular enough then the original uploaders are heavily compensated and their hosting costs decrease over time, because there will be other seeders to maintain the media.

If large media firms didn't go for this immediately, you could try and take this concept and ICO with it. Then start competing with Bandcamp and SoundCloud to capture the indie market. With the ICO funding and notoriety in that space, try to take on the RIAA.

<comment><USER22> I has similar idea around 3 months ago. The problem is that to participate in this network you need to pay and in normal networks today you don't need to pay anything.

There are a lot of technical problems in this what you wrote, it's only good in theory. You write that each upload/download transaction is recorded but you don't define what is a upload/download transaction. If you will use protocol like bittorrent you have chunks that are downloaded from many peers that are divided into blocks, having all those transactions in blockchain will not scale, it's just too much data. Another problem, How can you ensure that someone will not cheat in network? I can spoof that I have certain data, you will send me coins and I will not send you the data or if you confirm in source it's even more easy to cheat I will just send information that I got corrupted data even it's ok. There is a lot more other problems with this idea.

</comment></comment><comment><USER20> Agreed. But also, it's become _very_ hard to get anything to get noticed organically.

It is not about quality. The same exact story submitted by different people or at different times may get 1 upvote and gets buried, or hits over 100 points on the front page. See this for example!

[https://news.ycombinator.com/item?id=14929067](https://news.ycombinator.com/item?id=14929067)

I suspect most frontpage people ask their friends to upvote a story in the first few minutes.

Check out my own list of submissions for some examples. The vast majority is 1-2 points. Including SHOW HN stuff I worked hard on such as this:

[https://news.ycombinator.com/item?id=13474714](https://news.ycombinator.com/item?id=13474714)

Ironically, I got more upvotes on a comment I made, regarding this phenomenon.

<comment><USER2> You've posted several of these off-topic complaints in off-topic places, but doing it in response to a comment about people buying spam upvotes on HN takes the cake.

There's no right to "get anything to get noticed" on HN. There is, however, a duty not to defraud the community. If people defraud the community then obviously we're going to ban them many times over.

We detached this subthread from [https://news.ycombinator.com/item?id=15010431](https://news.ycombinator.com/item?id=15010431) and marked it off-topic.

<comment><USER20> I posted it a couple times since I have no idea if you saw it. If you responded (as you did) I would not post it again. HN is not like Facebook, no one gets notified of follow-up comments, so I don't know if someone actually saw my comment in response to theirs.

I _totally_ agree that the community should protect itself from being defrauded. I actually support the measures you are taking on that front. I just wanted to bring to your attention, as a pretty active and interested user of HN, that it has changed and the _system_ pushes people to do this kind of stuff. It's fostering competition to do it, because that's what it takes to get to the front page. I suspect that this happens in _most_ cases. Look, I could be wrong - you have way more data than me - but using just what's available to me suggests that "asking friends to give you a couple upvotes in the crucial first few minutes" happens a lot. Heck, I did it in the past once or twice and it worked. The problem is that this mentality causes the element to become _necessary_. That, or clickbait.

We don't want this in the community, I agree, but it's like punishing X in individual cases while the system almost requires X to get to the front page in the first place. _It is not about a "right" to get anything noticed on HN. It's about the incentive structure that develops over time as the system grows and changes._

Bitcoin started out to be decentralized and now is in the hands of several miners, and fees have gone up. Saying that there is "no right to have a transaction be recorded in the ledger" doesn't mean there isn't an incentive problem with a root. The root of _that_ problem is the escalating proof-of- work arms race.

Authorities in the drug war thought if only they got low level dealers to rat out their suppliers there would be no more drugs on the street, but the incentive structure of money to be made on drugs caused a problem. The root of _that_ problem is an escalating arms race between the feds and the cartels caused the drug gangs become more ruthless and publicly execute the families of those who ratted people out, greatly increasing violence.

The root of _this_ problem is an escalating arms race to get noticed as HN has grown. But perhaps there is no problem. If there is, however, this is _NOT OFF-TOPIC_. The topic _is_ gaming the system. And I am saying this as someone who wants to see less of it, but recognizes that the system _now_ encourages it more than in the past.

<comment><USER20> Ok since you detached the threas I'm going to guess the downvote is yours, with no response so you think there is no problem. And this is off-topic.

Well, I've brought it to your attention, no reason to mention it anymore. Good day sir! :-)

<comment><USER23> If you want to talk to the mods, you can just email them instead of posting your complaint repeatedly in random threads and hoping someone notices.</comment></comment></comment></comment></comment>


A curious phishing attempt - <AUTHOR> https://htbr.nl/2020/03/30/a-curious-phishing-attempt/ <comment><USER2> Good reminder that ad blockers provide security against this sort of thing. Yet another example of ad networks not checking content.

Does anyone know if this also impacts duckduckgo, which uses keyword based ads from Microsoft Advertising?

<comment><USER3> Not ads-based, but I'd imagine their "I'm feeling ducky" re-director feature could be abused for phishing links quite easily. duckduckgo.com/?q=!ducky+hxxp://badguydomain.com. Google's I'm feeling lucky re-director was already caught being used for phishing re-direction (and patched with a click-through). [https://www.microsoft.com/security/blog/2019/12/11/the- quiet...](https://www.microsoft.com/security/blog/2019/12/11/the-quiet- evolution-of-phishing/)

</comment></comment><comment><USER4> Bunq or any financial services company is in a perfect position to trace these criminals. If they would create some actual Bunq login accounts and actual Bunq ATM card numbers, with zero balance or low $5 balance, they could feed some of these account numbers to the malware site before shutting it down, and later monitor where those account numbers end up getting used.

Does anyone know if banks, MasterCard, Visa, etc., are already doing this? It seems obvious and straightforward, but maybe banks are averse to giving out actual credentials (no matter how limited the account) in case something goes wrong.</comment>


Ask HN: Next generation of responsive templates, interaction with webcams? - <AUTHOR>

Nowadays, we can see big changes in responsive templates and new requests to completing that, more smart and fast.
Well, now, we have good support of webcam API(s) in browser and JavaScript, so I think the next generation of responsive templates will have interaction with webcams. For example detecting the brightness of the environment and then change the background and text colors to something better to improve the readability of the page.
What you think? <comment><USER2> From a technical standpoint, the idea of basing a design on interactions with webcams is quite fascinating. You could even try and do facial recognition through that and see how far away somebody is from the monitor to adjust text- size for instance.

But it's hard to see that idea taking off for general usage.

The second somebody visits your website and sees "This website is requesting permission to access your webcam" they're going to be a bit freaked out about that and might be hesitant to interact with that site further.

<comment><AUTHOR> Absolutely correct. I think the big problem with webcams would be the browser permissions for using webcams and also the message that mentioned by you before.

</comment></comment><comment><USER3> Like this? [http://webdesign.maratz.com/lab/responsivetypography/realtim...](http://webdesign.maratz.com/lab/responsivetypography/realtime/)</comment>


Is your JavaScript function actually pure? - <AUTHOR> http://staltz.com/is-your-javascript-function-actually-pure.html <comment><USER2> If we want to be pedantic, there is no such thing as a pure JavaScript function. If the stack is full, the invocation of ANY function will overflow the stack. That's a side effect to the outside world. Pure functions exist under Plato's Theory of the Form conception of the world, but not on a fixed and finite physical computer. [http://www.johndcook.com/blog/2010/05/18/pure- functions-have...](http://www.johndcook.com/blog/2010/05/18/pure-functions- have-side-effects/)

If we don't want to pedantic, then a fraction of the 74% of who took the function as 'pure' probably took this to mean being equivalent to referential transparency. That's good enough, and I believe the author would agree.

 _I hope we can start shifting our discussions from 'is this pure?' to 'Does this function behave like a Mathematical Function in all the situations I will encounter in my code?'_

It's a good exercise to think about assumptions, but we shouldn't be _so_ paranoid as to check if native JS methods, namely Array.isArray, have been overridden (unless security is a concern). When we speak about the Fibonacci sequence, it's nonsensical to talk about f("pie"). The domain being integers is implied in the semantics of the function. In the veins of "keep an open mind but not so open that your brain falls out", I propose "keep writing code with pure functions, but not so pure that your code becomes cluttered."

<comment><USER3> I ran into this article a little while ago and I had a similar sentiment. I get the point staltz is making but it felt pedantic and heavy handed, hell you can ignore JavaScript entirely and the same is true for just about every programming language. Seems that there is a trend towards ideology in the JavaScript community lately that bothers me. People obsess over pure functions and FRP and talk so highly about these things like mutation and non-FRP are the worst things on the planet when it comes to code.

<comment><USER4> The trouble with trying to apply words like "community" to millions upon millions of people with basically nothing but a surface connection (like they all have used javascript, for instance) is explained nicely in Vonnegut's "Cat's Cradle"

<comment><USER5> "The JavaScript community" need not include everyone who has used javascript. Why do you assume GP was intending it to do so?

<comment><USER4> I made only one assumption - that "the JavaScript community" is a granfalloon. Any further assumptions you assume I made are not valid.

</comment></comment></comment></comment></comment><comment><USER6> Reposted from [https://news.ycombinator.com/item?id=12530652](https://news.ycombinator.com/item?id=12530652)

I disagree with some of the claims, as I think these sorts of edge-cases mostly serve to highlight how imprecise the given pure/impure distinction is, and how we can't always take a semantic concept from one language (e.g. Haskell) and apply it in another (JS).

For example, if you always get "TypeError" when calling "sum()", you can replace "sum()" with its result ("throw TypeError") and get the same behaviour; it doesn't break referential transparency, so is it "pure"? What do we even mean by "result" in a language with exception handling? Do thrown exceptions count, or only return values?

Similarly, using "valueOf" doesn't show that the sum function is impure, it shows that the sum function is higher-order. If we mapped 'Math.random' over an array, does that make 'map' impure? What does it mean to be pure/impure when any variable can be replaced by a 'valueOf' function/procedure?

If two expressions call the same procedures, the same number of times, in the same order, and return the same pure function of their outputs, are those two expressions the same? Would replacing one with the other maintain referential transparency, and does that imply "purity"?

I think the answer is that such examples need more fine-grained notions than just "pure"/"impure". Otherwise it's just arguing over the semantics of English, rather than semantics of programs.

<comment><USER7> Rather than talking in terms of "purity", it's better to talk in terms of "effects". Raising an exception is an effect. Returning different results when passed the same arguments twice is an effect. I/O is an effect. Looping forever (also known as "divergence" in some circles) is an effect. What you call "purity" is just the absence of effects.

From the point of view of programming language semantics, what all effects have in common is that they reduce the extent to which equational reasoning is applicable to our programs. For example,

        f(x) == f(x)

doesn't always hold if `f` is a non-deterministic procedure, and

        function foo_bar() {
            var x = foo();
            var y = bar();
            return (x, y);
        }

isn't the same as

        function bar_foo() {
            var y = bar();
            var x = foo();
            return (x, y);
        }

if `foo` and `bar` have effects that don't commute.

\---

Higher-order functions also give us an interesting possibility: effect polymorphism. Let's consider the humble `map` function, operating on lists:

        map _ [] = []
        map f (x :: xs) = f x :: map f xs

Intuitively, it's clear that `map f` is an effectful procedure if and only if `f` is an effectful procedure. This notion can be formalized by giving `map` the following type signature:

        forall (a b : Type) (f : Effect). (a -f-> b) -> (List a -f-> List b)

Where `Foo -Bar-> Qux` means "procedure with argument type Foo, effect Bar, and return type Qux", and `Foo -> Bar` is sugar for `Foo -Pure-> Bar`.

<comment><USER6> Algebraic effects are a way to make well-behaved languages (Haskell, Idris, etc.) more intuitive/generic/terse/etc. to write; I'm not sure how useful they are for reasoning about an arbitrary snippet of JS taken from the wild.

One problem stated in the article is we can't even rely on things like variable substitution to be effect-free, due to mechanisms like "valueOf". For example, in your "map" definition, the value of "f" called at the head of the list may differ from the value of "f" passed to the recursive call.

With this level of monkey-patching possible, it becomes quite hard to say anything about a piece of code other than "it's return type is Any, it might throw an exception, and it could perform arbitrary effects" :(

<comment><USER7> > I'm not sure how useful they are for reasoning about an arbitrary snippet of > JS taken from the wild.

Probably not much, indeed.

> One problem stated in the article is we can't even rely on things like > variable substitution to be effect-free

I have no idea how to make sense of this. The presence or absence of effects is an object language notion. Variable substitution is an operation on the syntax of this object language, and syntax necessarily lives in a metalanguage (e.g., the language in which a compiler or interpreter is written).

EDIT: Forgot about explicit substitutions, which make substitution an explicit reduction step in the object language. Even then, I don't see how substitution can be effectful by itself.

> For example, in your "map" definition, the value of "f" called at the head > of the list may differ from the value of "f" passed to the recursive call.

At least in a call-by-value language, this is should never the case. Funny things can happen if lexical environments are first-class objects, of course.

<comment><USER6> > I have no idea how to make sense of this.

Maybe I should have used a different phrase. I meant that an expression consisting of a variable (e.g. "x") may be evaluated as if it were a dynamically-dispatched function call (e.g. "x.valueOf()"), so even the most innocent-looking expression may contain hooks to which someone may have attached an effect.

Even though JS is call-by-value, implicitly-called methods like "valueOf" allow values in normal form to act like thunks with arbitrary side-effects, which causes a dependence on evaluation order even for such innocent-looking expressions as "x".

<comment><USER7> Wow, this is terrible. I already knew I didn't know JavaScript. But I didn't know the extent to which I don't know JavaScript.

</comment></comment></comment></comment></comment></comment><comment><USER8> The author uses the definition that a pure function must return identical outputs on identical inputs. I actually think a better definition is that the output of a function cannot depend on anything but it's inputs. If we use that definition then the first example he gives where the `sum` function violates pureness is actually not a violation. This is also justified by interpreting a `.valueOf = Math.random` field as a random variable, making the procedure `sum` a map from a random variable to a random variable.

<comment><USER9> The definition of a pure function is pretty well defined [https://en.wikipedia.org/wiki/Pure_function](https://en.wikipedia.org/wiki/Pure_function). Math.random depends on hidden state, so (generally) any function using it isn't pure. This doesn't matter much in a language like Javascript, but other languages depend upon this definition (like the lazy function evaluation in Haskell).

<comment><USER10> Is that definition of pure closer to mthq's definition or the one in the article? I'm not sure.

It says "same argument value(s)", but how does that apply when the argument is a function? The article seems to be saying that if the same argument is passed in every time, then the function is only pure if it returns the same value every time, regardless of whether the argument is a pure function or not.

<comment><USER11> A pure function can't call a non pure function. So you can pass in a non pure function so long as you don't call it.

</comment></comment></comment></comment><comment><USER12> The assumption in this article is that as long as a line of code as the same characters, its output will be the same. But this makes no sense. Consider:

        var arr = [0,1,2]
        sum(arr);
        arr = [1,2,3];
        sum(arr);

The two sums will have different results. What the article does is in essence calling

        sum([Math.Random(), Math.Random(), Math.Random()]);
        sum([Math.Random(), Math.Random(), Math.Random()]);

I don't see why one would expect the output of such a call to be always the same, if you are in all effect changing the input. Even if the characters you typed are the same, if the values that are passed around change the result of a function call will change. "Pure" is a property with regards to the values passed to a function, not to the characters typed to call it.

<comment><USER13> I believe as well that the article is imprecise, since it elaborates on a trick question and tries to just inform about the term "pure" being hard to define, especially in a dynamic language.

To be referencing an exact quote of the article to make it very clear:

      var arr = [{}, {}, {}];
      arr[0].valueOf = arr[1].valueOf = arr[2].valueOf = Math.random;

Obviously this relies on multiple function calls, so the output of the original function `sum` is still predictable. I think predictability and the absence of side effects is still a much better definition for pure functions.

It's also a necessary definition in JS. Saying that 'the same call of the function with similar enough arguments will always yield the same output' is not a sufficient definition and way too simplified.

</comment></comment><comment><USER14> Dear god this article is annoying. I could spend an hour nitpicking the bs-ey wonk that André is spewing here, but that would be pointless, so I'd like to make a more macro point: Can we please get away from pedantism and trivial analysis as a display of intelligence?

</comment><comment><USER15> Sorry... in Haskell there is performUnsafeIO. Nothing in Haskell is therefore guaranteed to be pure!

Hello Downvoter: I know it is silly but the article is talking about equally silly JS by overriding valueOf.

<comment><USER16> The question is asked providing the entire implementation of the respective sum functions in terms of primitives. There's no room for unsafePerformIO in the Haskell code (assuming prelude's `(+)` and `foldl`).

There _could_ be if the Haskell version was typed on `Num a`, but it's typed on `Int`, which is a standard type with a known pure Num instance.

<comment><USER15> Ok sure but I was meaning in general.

Anyway pass in (repeat 0) and you get a side effect. :-)

<comment><USER17> Haskell is well-known not to be pure in supporting non-terminating computation.

</comment></comment></comment></comment><comment><USER18>
        sum(); // TypeError: Cannot read property 'length' of undefined

That doesn't mean it's not pure.

        var arr = [{}, {}, {}];
        arr[0].valueOf = arr[1].valueOf = arr[2].valueOf = Math.random;
        sum(arr); // 2.393660612848899
        sum(arr); // 2.3418339292845998
        sum(arr); // 2.15048094452324

Oh come on. By that logic there are no pure functions in C, because you can play with #define. Definitions are meant to be useful.

</comment><comment><USER19> If we're being nitpicky about type checking...

        function f() { return Math.random() < 0.5; }
        f.toString = function () { return 'function toArray() { [native code] }' }
        Array.isArray = f;

What, use Function.prototype.toString instead? What if someone tampered with that too?

</comment><comment><USER20> Don't pure functions come with the disclaimer that no one does anything stupid like overriding the Date constructor or valueOf?

Otherwise, we have to either come up with a different name for pure functions with a modified meaning, or write a bunch of absolutely ridiculous defensive code in every single function we want to truly be pure.

</comment><comment><USER21> Throwing an error doesn't make a function impure. If the calculation is erroneous then the expression sum() _has no value which could replace it_. I.e. the definition of pure being that we can replace sum(a) by its value without changing the behavior of the program, simply doesn't apply. The exception is effectively equivalent to the situation of there not being a value.

As for this:

      var a = {}; a.valueOf = Math.random;
      var fn = x => x * 10;
      fn(a); // 5.107926817373938
      fn(a); // 3.4100775757245416
      fn(a); // 5.1903831613695095
      // Same input, different outputs!

Calling that "same input" just because it has the same syntax "a" is just ... plain silly. It's obviously "a" that is impure not the "fn" multiplication function. "a" is behaving like a macro which denotes the retrieval of a pseudo-random number.

It's simply not reasonable extend the definition of a functions' purity to include *the behavior of the expression(s) which are evaluated to provide its arguments.

(I would say that it's still not reasonable even under non-strict evaluation.)

</comment><comment><USER22>
      > Well, in an actual functional programming language like PureScript or Haskell we can:
      >
      > sum :: [Int] -> Int
      > sum = foldl (+) 0
      >
      > The list cannot be undefined, cannot be null.

Yes it can?

      main = putStr "The result is: " >> print (sum undefined)

      The result is:
      Program error: Prelude.undefined

So by the same logic Haskell doesn't have pure functions, either?

</comment><comment><USER23> Defining what a pure function in JavaScript _is_ seems to be the difficult problem here.

Maybe we should call a function pure if "given identical, _pure_ arguments, it returns identical, _pure_ results". You would also need to define when an object is pure. That's already difficult, as the semantics of JavaScript objects are so weird. It's quite likely that we would have to replace "identical" by some weaker notion of relatedness which is merely preserved by "pure" functions...

Anyway, this might be useful as a static analysis for a JavaScript vm. It depends on how much wild JavaScript code is actually "pure" in any reasonable sense of the word. Let's just sum this up and say that JavaScript is really not a nice language to analyze.

</comment><comment><USER24> Along the same lines as worrying about someone redefining `Array.isArray`, someone could compile your Haskell with its own prelude, including their own definition for `Int`.

There's a point at which the pursuit of purity becomes the pursuit of sanctity, in the sense of Haidt's moral foundations ([https://en.wikipedia.org/wiki/Moral_foundations_theory](https://en.wikipedia.org/wiki/Moral_foundations_theory)). It's not about a rational tradeoff at that point, it's about easing an anxiety and sense of uncleanliness. I say this because I'm prone to doing it too, and I've noticed that I can spend a lot more time and energy than is worthwhile "cleaning" code.

</comment><comment><USER13> Obviously due to JavaScript being a scripting language and dynamically typed, we have to make certain assumptions so that we can even consider calling any function "pure".

It's nice that André wants to warn us here about the fact that the term "pure" is more or less accurate depending on the language.

In JS it can depend heavily on previous assumptions and the context, but I'd argue that this is often only due to the arguments that are being passed to a function. A non-safe function that isn't type will always be impure in some contexts. But for sanity reasons we must be able to make assumptions about the arguments.

</comment><comment><USER25> Good article. Yes, the idea of purity becomes less useful in OO languages. That's not specific to JavaScript or even to dynamic typing. Try summing the elements of a Collection<Integer> in Java and your code will also be impure, because Collection is an interface whose implementation can do anything. I agree that JS goes too far in allowing you to impersonate numbers, but most real-world code uses interfaces in some way, so you can't make it pure without changing your language into Haskell.

</comment><comment><USER26> I'm too stupid to see how this is either practical or relevant in a loosely typed language. The example was making assumptions that it is an array with integers. It was also making an assumption a hacker is not hijacking your code to put strange values into your array etc. This reminds of John Resig's super complicated tricky JavaScript examples only a very small number of people would even care to try to understand but slightly less purposeful. Probably good for that type of crowd.

</comment><comment><USER27> I bet you can still break that last code block by having an isArray accessor that returns the "proper" function the first time and a broken one the second time. :-)

</comment><comment><USER28> If you compare Haskell with JavaScript, all JavaScript functions would run in the `IO` monad because you can always (even implicitly as in the article) run an impure action even if everything else seems pure. In Haskell, if your function is not monadic, you can't "run" the monadic action. On the other hand, you don't see exceptions in Haskell's type signatures and you can throw them in pure code. Hm! ;-)

</comment><comment><USER29> I would also use some `demand` function or argument-validator in JavaScript to validate that, thats a good practice in anyway, like: `function sum(arr) { goodArrayOfNumbers(arr); ... }`.

I think that; in JavaScript you NEED to validate your arguments with something like that, you really cant assume nothing. ("Dont assume it, prove it!").

</comment><comment><USER30> Trivia: assuming the input to `sum` below is guaranteed to always be a non- trickery array of numbers, so it always returns the same result for the same input, is the function 'pure'?

        var x = 0;

        function sum(arr) {
            x += 1;

            return arr.reduce(function(a, b) { return a + b; }, 0);
        }

<comment><USER31> I don't understand how this is ambiguous. `sum` is changing state outside its scope (a side-effect). There is no definition of "pure" I'm aware of that would include this implementation.

</comment></comment><comment><USER32> I would use my dynamic type checker/enforcer to make it pure:

      var types= require( 'types.js' );

      function sum(arr) {

        arr = types.forceArray( arr );
        var z = 0;
        for (var i = 0; i < arr.length; i++) {
          z += types.forceNumber( arr[i], 0 );
        }
        return z;
      }

</comment><comment><USER33> If you're using valueOf like that then you already did something wrong. Reevaluate your life choices.

</comment><comment><USER7> Is this function pure?

        function make_pair(x, y) {
            return { former: x, latter: y };
        }

</comment><comment><USER34> Given the emerging importance of separating "pure" code from "side-effecting" code, what frontend JS techs actually enforce this division, as opposed to just leaving it up to the fastidious developer? Elm? Haskell/Haste?

</comment><comment><USER35> For those of you that write in JS (and not TypeScript), do you use "void 0" instead of "undefined"? I use undefined and would hate to switch to void 0, since it's less clear and unnecessary thanks to tools like JSHint.

<comment><USER36> `undefined` is a variable that can (could? It may have changed with strict mode or ES6) be set globally to arbitrary values.

You can use `undefined` safely with an IIFE wrapper:

        (function(undefined) {
            // you're safe here
        }());

</comment></comment><comment><USER37> Premise is interesting, but by the end, JS fails the author's standard of purity not really because of its function implementation (or any variant thereof) but because of its dynamic-weak type system.

</comment><comment><USER38> I mean what happens when someone does

        Array.isArray = () => true;
        Array.isArray.toString  = () => 'function isArray() { [native code] }';

:/

</comment><comment><USER39> Should have been titled:

"Is Your JavaScript Function Actually Pure? An impractical guide to Pedantic JavaScript."

</comment><comment><USER40> No

        (map println [1 2 3])

Map is RT even when println is not

</comment><comment><USER41> so var sum=(...a) => a.reduce((x,y)=>x+y) is pure?</comment>


Ask HN: Best distributed job processing system in 2019? - <AUTHOR> I have around 10 million network I/O related jobs that I would like to do in a short period.
So I hope to use a job queue to run it distributed on several servers.
I have used celery in the past but it is not quite reliable.
Features most important to me are multiple retries, restarting workers that are not responding, ability to monitor status of the queue and workers. Nice to have features - cron scheduling, task chaining, high throughput.
Which is the most stable, reliable job queue out there? It would be preferable to support workers in multiple languages. The ones I would prefer are Python and Go.
I have used celery in the past, but workers often hang <comment><USER2> Workers hanging is a thing that happens everywhere. (You might not have enough resources if it's happening often, though.)

You should design the workers so that what needs to happen still happens in the event of expected failures, or so that it at least fails gracefully and with a useful paper trail. Failures happen, good engineering anticipates and plans around them.

For example, you could schedule up to three attempts spaced at least five minutes apart, set a timeout on jobs so they don't stay open indefinitely (appearing to hang), have jobs that still fail get routed to a dead queue, and make sure worker code behaves appropriately in response to internal errors and improper input data (such as getting an HTTP error or unexpected MIME type) while logging any unexpected states for later review. Most of the point of a library like Celery is that it makes common strategies like these easier to implement.

You mentioned in a reply that the jobs are requests to external websites. The rate of errors from that is going to be like a thousand times all other sources of jobs not completing as expected unless something is hella weird with your setup.

<comment><AUTHOR> Thank you for taking the time to respond. That is only part of the problem. I am quite aware of that there are quite a number of external issues that can affect a job. Data extraction is something I have been working in for more than a decade.

I have a few other pet peeves with Celery. I run scheduled tasks using CeleryBeat but those tasks cannot be tracked from flower. Signals don't work. I also would like something language agnostic so I can write memory/processing intensive tasks in something more performant (Go or Rust).

</comment></comment><comment><USER3> Personally, I've cobbled something together using this: [https://www.2ndquadrant.com/en/blog/what-is-select-skip- lock...](https://www.2ndquadrant.com/en/blog/what-is-select-skip-locked-for- in-postgresql-9-5/)

Storing the queue state and task results in postgres makes it easy to integrate with workers in different languages, but you need to write the library code to query and lock a free task to process.

I'm not sure how well this would scale for 10 million tasks in "a short period". It works fine for me running the database and multiple workers on a single machine with around 100k tasks that are scheduled and processed every week or two.

> Features most important to me are multiple retries, restarting workers that > are not responding, ability to monitor status of the queue and workers.

Some of these concerns might not be the responsibility of the job processing system: you might just need to set up some monitoring and health checks to restart services or machines if they stop responding

</comment><comment><USER4> I've been using Qless for a client recently.

The core logic itself is Lua that runs in Redis itself, but each language generally needs a client to interface between the native expected norms and the Lua. I can't comment on the availability or quality of Python or Go client libraries.

It's not perfect, but it's workable.

</comment><comment><USER5> Interesting - I have had good experience with Celery, so interested to hear more about the problems you encounter. In particular Celery provides all the features that you are looking for so it would be great to know more about your specific issues.

Can you elaborate on your set-up?

</comment><comment><USER3> Some ideas from prior hn discussion: [https://news.ycombinator.com/item?id=15985103](https://news.ycombinator.com/item?id=15985103)

</comment><comment><USER6> Unfortunately queue doesn't always mean FIFO, as you might expect. Are you submitting them all at once? Does response order matter?

<comment><AUTHOR> No response order does not matter. These are individual requests to separate websites. For me queue is just a way to distribute work among workers.

</comment></comment><comment><USER7> SLURM is pretty solid, and designed to scale to supercomputer sized workloads.

</comment><comment><USER8> BEAM - The Erlang Virtual Machine

</comment><comment><USER9> Have you looked into actor frameworks?

</comment><comment><USER10> kubernetes.

<comment><USER3> Can you go into more detail? I understand k8s might be a fairly reasonable way to start and supervise a large number of services, and I've seen it used to execute one-shot batch jobs.

But I can't quite join the dots to see how you could have a distributed job processing system with just k8s.

Would you need to use some other system (perhaps also running in k8s) to track the queue of tasks and store task status & task results? Or can you get k8s itself to act as the task queue?

<comment><USER11> Have a look at Argo if you are interested in leveraging k8s infrastructure [https://github.com/argoproj/argo/blob/master/README.md#what-...](https://github.com/argoproj/argo/blob/master/README.md#what- is-argo-workflows).

For us, we settled with Netflix Conductor as it scaled pretty well and allowed us to have pretty complex workflows and error paths and retry logic. Also is an independent and standalone tech.</comment></comment></comment>


Courtroom AI system claims almost 90 percent accuracy in detecting lies - <AUTHOR> https://motherboard.vice.com/en_us/article/zmqv7x/ai-system-detects-deception-in-courtroom-videos <comment><USER2> I will be utterly astounded if this "study" is replicated. I will not be remotely surprised if they sell it the gullible fools in public service who don't treat lie detectors with the utter contempt they deserve.

What are currently the best tech buzzwords that might convince people you have magic pixie dust for sale?

<comment><USER3> There's plenty of science behind micro-expressions and detection of deception.

Paul Ekman [0] is "ranked 59th out of the 100 most cited psychologists of the twentieth century" and I thought the TV show based on his research [1] was very entertaining. (I am surprised that the article used the phrase "micro- expression" without any reference to Ekman's work.)

[0] [https://en.wikipedia.org/wiki/Paul_Ekman](https://en.wikipedia.org/wiki/Paul_Ekman) [1] [https://en.wikipedia.org/wiki/Lie_to_Me](https://en.wikipedia.org/wiki/Lie_to_Me)

<comment><USER4> Do you know what science actually is?

<comment><USER5> Your question seems to be inconsistent with HN guidelines: comments should be constructive.

Specifically, comments should encourage discussion and allow for multiple perspectives on topic. It appears to me that your comment is borderline name calling and is anything but constructive.

<comment><USER4> Thanks for your concern, but I disagree. Science means something, and really don't confuse word count with value.

<comment><USER5> I fail to see how asking someone if they know what science is would help with a constructive discussion. Did you mean to imply that the micro-expression related work the the GP cited is not scientific in your opinion? Or are you questioning the GPs knowledge about science?

<comment><USER4> It seemed like a legitimate question to ask someone referring to the content of those links as "plenty of science..."

<comment><USER6> Do you know what "constructive" actually means?

<comment><USER4> See? Brevity can work.

<comment><USER5> I think you missed the point - it wasn't about brevity but about being constructive.

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER7> Title is very misleading. These are "pretend" courtrooms. No data from actual legal proceedings.

From the article: _This was based on evaluations of 104 mock courtroom videos featuring actors instructed to be either deceptive or truthful._

<comment><USER5> This is interesting! The ground truth for the study couldn't have been far removed from the "ground truth". I am afraid this appears to me as a pattern where any dataset whatsoever is thrown at ML algorithms and the results are heralded as the new way of analyzing data. There is no regard to the source of the data, it's deficiencies and utter disregard to its applicability to the problem at hand. See the question generation related deep learning papers based on SQUAD dataset.

</comment></comment><comment><USER8> alphaalpha101's now dead comment is reasonable: Denying justice in one out of ten cases is unacceptably high.

<comment><USER9> You're extrapolating a lot here: this is a demonstration in a mock environment. There's no indication that this is going to be rolled out as-is and used as the final arbiter of justice. Yes, denying justice 10% of the time is unacceptable. But that's not what's being presented here.

As an aside, the comment you're referring to was dead on arrival. It looks like that account has been banned.

</comment></comment><comment><USER10> I tried for a while to think of a good retort to this article, I couldn't. So instead:

This is fucking retarded.

They should institute a law that if you are using machine learning to make major decisions about people's lives then you need to take a test about basic ML (test sets, validation sets, etc.)

<comment><USER5> Perhaps one could insist for an explanation and reasonable defense of the outcome by these ML algorithms. Would that be a feasible retort?

</comment></comment><comment><USER11> I would have liked to read the actual paper, but the arXiv link leads to something completely unrelated: [https://arxiv.org/abs/1712.05526](https://arxiv.org/abs/1712.05526)

Does anyone have a correct link?

<comment><USER12> They meant [https://arxiv.org/abs/1712.04415](https://arxiv.org/abs/1712.04415) (based on a full text arxiv search of the text mentioned in article)

<comment><USER13> The project is known as DARE. Interesting classifier but not really that great. Try it out, it is open source so far. Just like many proof of concept it starts to rapidly fail when trained on too much data and otherwise generalize only so so.

This is essentially some feature engineering thrown at an SVM / GNN. What makes the results even tougher to reproduce is that the training set is not provided, only resulting matrices.

It is telling when different classifiers work best for supervised and auto cases...

</comment></comment></comment><comment><USER14> Alternate headline: Best Courtroom AI wrongly accuses 1 in 10 people of lying.

<comment><USER15> But what is the Jury's alternative (unassisted) effectiveness?

</comment></comment><comment><USER16> Even if they can, anyone who understands Bayes' theorem will tell you that the false positive rate would be way too high for this to be used in real life.

</comment><comment><USER17> I'm reminded of the scene is "Ex Machina". If you've seen it you'll know what I mean. If you haven't, I won't spoil it for you. But it's (semi-)relevant.

</comment><comment><USER18> Not designed by sociologists.

More rubbish out of the polygraph playbook. AI is the modern Mechanical Turk when applied to the complex nonlinearities of human behavior.

</comment><comment><USER19> it's the 10% i'm worried about - what's the false positive rate? priors or it didn't happen...

</comment><comment><USER20> Wouldn't this violate the Fifth Amendment (self incrimination clause) if actually used?

<comment><USER5> Interesting point though I am not sure how the 5th amendment would apply here. Specifically, I thought that 5th amendment allows you to _not_ answer a question or _not_ testify. After you say something, it looks like using it to make a case against you is a fair game.

</comment></comment><comment><USER21> What's accuracy of lie detector machines?

<comment><USER22> Terrible (50%?). They're so bad their results haven't been admissible in court for years.

<comment><USER18> Exactly, and the statistic of 50% doesn't portray the actual reality.

The better fact is to cite that a monkey is as accurate as a polygraph machine.

Remember that 50% numerical accuracy is _because it cannot be any lower_. If it could, it would be inversely utilized for accuracy.

</comment></comment></comment><comment><USER23> What about half truths?</comment>


How craig constructed the message that he signed - <AUTHOR> https://www.reddit.com/r/Bitcoin/comments/4hhreq/how_craig_constructed_the_message_that_he_signed/ <comment><USER2> I still don't understand why those who believed this guy didn't just ask him to move a single satoshi from one of the early accounts known to be associated with Satoshi. No elaborate crypto required for that... just a publicly- verifiable display of ownership. This could turn out to be quite embarrassing for Andresen.</comment>


Show HN: Losing an argument online? Respond with fire - <AUTHOR> https://github.com/victorqribeiro/fireEffect <comment><AUTHOR> Jokes apart, the original article describing the algorithm is an excellent reading, you should take a look.

[https://web.archive.org/web/20160418004150/http://freespace....](https://web.archive.org/web/20160418004150/http://freespace.virgin.net/hugo.elias/models/m_fire.htm)</comment>


Marketing advice from Deadmau5 - <AUTHOR> http://deadmau5.tumblr.com/post/23238420396/some-advice-on-rollercoasters-and-shit

<comment><USER2> Ha, I would never have thought deadmau5 had such awful writing skills.</comment>


Early Stage Startups Don't Need Money, They Need Customers - <AUTHOR> http://startupnorth.ca/2012/03/27/early-stage-companies-dont-need-money-they-need-customers/?__lsa=32115409

<comment><USER2> It baffles me to no end that the Canadian government is not leaping on the startup trend. It's an observable fact that a lot of Canadian talent heads south for more money and opportunities, but no-one seems to care enough to do anything about it. Meanwhile, the US passes the JOBS act to allow even more early-stage startup funding.

I lived in and around Vancouver for two years and absolutely loved it, but my visa expired and I had to leave. These days I live in NYC and, well, I love it here too, but my visa in the US is very restrictive- I can't start my own company, for example. The US seems to have an endless, protracted debate about immigration that has next to nothing to do with economic or political reality. Canada doesn't, and has a _huge_ opportunity to attract international entrepreneurs that want to do business in North America. But I have absolutely no immigration routes back into the country, and there's no change on the horizon. So I won't be heading over the border any time soon.

<comment><USER3> Manitoba is trying. <http://www.innovatemanitoba.com/> is a government sponsored body trying to increase entrepreneurship in the province.

I was on one of their programs last year where they brought in some prominent angels and VCs, and ran a 3 day course on how to define your business and pitch it. It was an amazing time.

This year they're increasing the number of programs and trying to get banks, universities/colleges, and some industry to come on board to provide mentorship and advice to would be entrepreneurs.

<comment><USER4> Interesting, I had not heard about this program, thanks. I grew up in Brandon, where there is not much of a tech culture to be found (moved to and currently work in Calgary). Is there a tech community in Winnipeg?

<comment><USER5> Small and growing. It's a bit fractured at the moment and there are many places to focus one's attention, but that's better than the alternative of nothing at all.

I see things improving for us over the next few years.

</comment></comment></comment></comment><comment><USER6> While it is not as sexy, it's worth noting that "funding" from customers is generally cheaper than funding from investors. Plus, once you have revenue, you generally become more interesting to investors and have more leverage in those conversations because you may not need the money to survive the way you do early in your company's life.

We're a "revenue-backed" startup so I'd say that if you can do it, it is a great way to control your destiny. The challenge with this method is that growth comes after revenue, i.e. you spend generally after you have sold the product which means growth is slower while fundraising allows you to spend ahead of revenue.

Nevertheless, good to see this advice on HN.

<comment><USER7> Revenue also opens the door for loans which can be a great if dangerous source of funding as you don't give up equity and can still scale slightly ahead of your growth curve.

<comment><USER6> Great point albeit unexplored by us. Are you talking about loans from traditional banks?

I've perhaps unfairly assumed traditional banks won't fund SaaS companies because of unfamiliarity with non-asset intensive businesses. Or that they'd require me to put up my house, wife and child as a personal guarantee?

<comment><USER7> Yep, traditional banks. As long as the revenue is stable enough you don't need a personal guarantee from a traditional bank. They can be just as intrusive as other investors and even require thinks like the company take out life insurance on key employees. But it is a real option you may want to look into.

Another option many small companies don't consider is net 30 - 60 day payments from key suppliers. You generally get a grace period after an initial bill and can often work out a deal where you either have say 45 days to pay while still being considered current OR get a discount if you pay within a week of getting a bill.

One company I worked with had the equivalent of a 60k loan from CDW due to the rate they where buying equipment plus the grace period.

</comment></comment></comment></comment><comment><AUTHOR> I think there aren't enough resources for Canadian startups but at the same time, I agree with this post that once you can show some traction, then funding is not as hard to come by. The trick is figuring out how to get to that point and pay the rent.

</comment><comment><USER8> In reality, the problem ("what founders fail to do") is far more pernicious because it always _seems_ like you already know the problem you're solving and what your target customers want. But then you go out and talk to people who are deeply interested, but who don't buy for _some reason_. And you wave your hands and explain why they aren't an exact fit, assuring yourself that the faceless others you know to exist are your real targets. But there are no faceless others, just more people who all have their own bizarre edge cases that don't quite fit how you genericized your vision before you had any customers.

<comment><USER9> It seems like you are trying to say something, but it's not clear exactly what it is. Are you speaking from personal experience? Or guessing at the mindset of others?

It seems pretty obvious that if people are not willing to pay, then there is some sort of problem. Either your business plan isn't quite right, or perhaps the market you thought exists doesn't, or maybe your salesmanship is just very poor.

Part of doing a startup is figuring out which of these is the case. Try asking people for that _"some reason"_. Try changing the price. Try changing your sales pitch. Get feedback and advice from others. Focus on getting answers.

<comment><USER8> To understand my comment you must refer to the section of the article I have cited.

<comment><USER9> If reading that section helped, I would not have needed to ask for clarification.

As near as I can tell, you are trying to say one of two things: either that the tasks laid out in the article are hard, which is true, or that founders typically _think_ that they are doing those things, but are really not.

</comment></comment></comment></comment><comment><USER10> Depends on what early-stage means. If that means no funding money, then this statement is simply not true in many cases. Suppose you're tring to sell software and support. How are you going to sell a 1-year support contract if the customer can tell there's no guarantee you'll be around in 3 months? I'm speaking from personal experience. OTOH I'm sure the situation is better for web startups that are selling a service on a monthly basis.

</comment><comment><USER11> The chart still shows that startups raised $227k on average in the discovery phase.

The problem is in Canada there's noone willing to invest at this stage, at all. The angels here are known to only invest in later stage startups.

Although I agree the focus early on be on customers... its still hard to be 100% focused on customers if you're also constantly concerned with how you'll pay rent.

<comment><USER12> Traditionally this is from savings, family and friends, borrowing against your home, etc. And it feels like there is more opportunity to this capital in other places, i.e., anecdotal evidence that lots of folks in other places will put up $5-20k to invest in a friends startup. This doesn't happen as much in Canada (tight accredited investor definitions, higher taxes, higher real estate prices and home borrowing).

<comment><USER11> Indeed, the valley has the benefit of having lots of successful tech entrepreneurs reinvesting back into the community whereas most other cities depend on more old school angels or gov financing who only focus on safer bets.

This is not to knock on angels in canada, but an important to note when comparing SV with anywhere else... its not just about having VCs with big funds.

</comment></comment></comment><comment><USER13> Woohoo gets the karma on my post! Unfair ;)

<comment><AUTHOR> Ah the world isn't fair is it? Oh yeah and you're welcome ;-)</comment></comment>


Firefox OS Building Blocks find a new home, and get more streamlined - <AUTHOR> https://hacks.mozilla.org/2013/07/firefox-os-building-blocks-find-a-new-home-and-get-more-streamlined/

<comment><USER2> > We wanted to know if it was possible to use Building Blocks not only for its > main purpose, that's creating phone applications, but also as a base to > create a standard web site.

While I've known that the "phone" has been the primary target so far of FF OS, but still I'm a little sad that I'm reading it.

iOS and Android are built for tablets as well as phones. iOS is going to be expanding by allowing more devices to connect in their next version. When I first heard about FF OS, I thought: "Awesome! Now I can start writing HTML5 apps for my phone, my tablet, my desktop, etc." But, then I found out that the goal was just to be a phone. I not only spend a lot more of my day on a laptop/desktop than a phone, but I'd like to live in a future where the software can be written once for desktop, laptop, tablet, phone, "watch", car, or other device, and new hardware can easily be integrated with it (such as a keyboard, printer, car electronics/computer, stereo, etc.).

I think it is awesome that FF OS apps will be easier to develop, but I wish there was something fun to develop in HTML5 and JS that I couldn't do already in Android or iOS. To do this, FF OS has to stop being afraid to really dig into Gonk and make it as easily extensible on the hardware side as it is to develop and share HTML5 apps in FF OS.

<comment><USER3> There are definitely visions and plans to be more than phones. Did you ever see this announcement? - [http://blog.mozilla.org/ligong/2013/06/03/foxconn- joins-the-...](http://blog.mozilla.org/ligong/2013/06/03/foxconn-joins-the- firefox-os-eco-system/)

Edit: Disclaimer, I work for Mozilla

<comment><USER2> Awesome! Looking forward to being able to use FF OS on my laptop!

</comment></comment></comment><comment><USER4> Has there been any progess towards being able to dual-boot OS on a phone? It would be great if you could run stock android on say a Nexus 4, but boot into other OS's to try them out

</comment><comment><USER5> For those wanting to take FF OS for a spin, load up Firefox and search the add-ons directory for "Firefox OS Simulator".

</comment><comment><USER6> I haven't been following Firefox OS that closely, but one question comes to mind: why didn't Mozilla fork Palm's excellent WebOS?

<comment><USER7> One reason is that Firefox OS uses the Android kernel. This means that Mozilla doesn't have to beg device manufacturers for hardware support. If a device runs Android, it should be able to run Firefox OS with little software modification. Another reason is that Firefox OS uses Gecko as the UI. So the two major components, the kernel and userland are taken care of; there is no benefit from forking WebOS.

<comment><USER2> > One reason is that Firefox OS uses the Android kernel.

It uses parts of Android in HAL, but Gonk isn't Android.</comment></comment></comment>