Hacker Newsnew | past | comments | ask | show | jobs | submit | Theyeard's commentslogin

Very nice! It reminds me of these two loader experiments: https://curiosity-driven.org/amd-loader-with-promises https://curiosity-driven.org/minimal-loader

But for production builds I highly recommend Almond: https://github.com/jrburke/almond


There's also https://github.com/systemjs/systemjs which aims to implement the ES6 Module Loader.


One interesting use-case is having an Atom feed and HTML page at the same time. See source code here: https://curiosity-driven.org/


I'd rather see technical details too plus maybe a comparison between require.js/almond and define.js. Currently it's not clear what are the advantages of define.js.

N.b. another AMD loader (30 lines of JS): https://curiosity-driven.org/amd-loader-with-promises


Wow, great idea. I wish this was available as a npm package.

A couple of things, sometimes the service doesn't work and returns "YUI Compressor : 0bytes (100%)" or "JSMin : 886bytes (0%)". A typo: succees.

The references section could be expanded with resources about writing JS code in a way that enables optimizations:

http://toddmotto.com/what-function-window-document-undefined...

https://curiosity-driven.org/minimal-loader


Thanks for the feedback, I really appreciate it! I will do my best to fix this ASAP, and I was planning on adding more references anyways.


Kaleidoscope - LLVM Tutorial [0] is an excellent resource with code samples in C++ and OCaml.

[0] http://llvm.org/docs/tutorial/index.html


Agreed, it's an excellent resource. One of the best PL tutorials I've ever read.

But if you use the OCaml version with a recent version of OCaml, you'll run into a few issues. I sent in a patch with a few simple updates to the path mailing list earlier this year, but last I checked it wasn't merged.

Patch is here (it's a text file, despite the "bin" extension):

http://permalink.gmane.org/gmane.comp.compilers.llvm.cvs/183...

I also pasted the patch here:

http://pastebin.com/YvzB71nJ


Parsing, evaluating, continuations and CPS... it seems similar to this language: https://curiosity-driven.org/continuations#interpreter but the syntax is clearly different. Also, that interpreter is implemented in ~320 lines of JS.


Excellent point, added as annotation, thanks!


Yes, you're right, numbers treatment is not exactly the same as in Bitcoin Core. The script interpreter supports only basics and it was implemented to show how Bitcoin Script works in general for another article [0].

But it was not clear from this text whether it's a complete implementation or not so it looks like a bug. I've added the annotation [1] and will update the interpreter in the future.

Of course if one wanted to use Bitcoin in real projects I'd rather recommend Bitcoin.js [2] but that's another topic.

Thanks for comment!

[0]: https://curiosity-driven.org/bitcoin-contracts

[1]: https://curiosity-driven.org/low-level-bitcoin#operators

[2]: http://bitcoinjs.org/


No problem - I wasn't sure if this is something you're currently working on or just a demonstration. The script interpreter is a tricky beast that looks easy but has a lot of edge cases. If one client behaves slightly different, a blockchain fork could happen: https://bitcoin.org/en/alert/2013-03-11-chain-fork


Yes, exactly. And there are a lot of tricky corner cases like SIGHASH_SINGLE when number of inputs != number of outputs with hash 0x01 [0]. Actually the entire implementation (Bitcoin Core) is the specification :) It's interesting from the software design point of view - an extreme case of backwards compatibility. It's hard even within Bitcoin Core as some changes already caused forks [1].

The article is just a demonstration but it won't hurt if it was as accurate as possible (while still being readable) :)

[0] https://en.bitcoin.it/wiki/OP_CHECKSIG#Procedure_for_Hashtyp...

[1] http://bitcoinmagazine.com/3668/bitcoin-network-shaken-by-bl...



So what happens if someone puts CP into the block chain and publishes the instructions to retrieve after two months?


On related note, you can think of a JPEG image as an instruction to retrieve CP from your CPU and LED screen if you will. When it comes to law, there's no logic since all laws are written and interpreted by faulty humans with some weird ideas in their heads (like "lets beat the shit out of people who disobey").


Nothing. The way arbitrary data is stored in the blockchain is encoding it in the financial transactional data.

For example, you could use a similar method to "store" data using Paypal: use the amount of cents in each transaction to encode a byte of data (e.g. $1.17 means 0x75 etc.) and make transfers to random people until enough bytes have been transferred. That's it, your copyrighted data or CP is now forever "stored" on Paypal servers.

I don't think this accusation will hold up in any reasonable court. Taking into account the cost of storing data (20 bytes in a single output of minimum 5400 satoshi + fees) your hypothetical instructions and code to retrieve the images would be of comparable size to any images you can reasonably store.


There is no minimum output size. Outputs can be zero-valued.


The standard client and by extension most miners will reject outputs smaller than a certain value ("dust")

You are correct that the protocol itself doesn't have a minimum output size, so if you mine a block yourself you can include dust reliably.


The same thing that happens to every other data put in transactions - if they're included in blocks every node (full verifying node [0]) downloads it and stores it locally forever.

[0]: https://code.google.com/p/bitcoinj/wiki/FullVerification


So a lawless space? What if a judge wants the data to be removed?


If the judge is really determined to put you in jail he will find CP, cocaine and unpaid taxes everywhere in your life. Law operates beyond logic and reason: only authoritative opinions and scripture interpretations matter. Ask that question to those who will put handcuffs on you, not to fellow peaceful citizens.


Then they'd need some very powerful mining equipment! Bitcoin uses merkel trees to ensure transactions in blocks never change.


An unregulated/unregulatable space. Might as well try to regulate math - "PI is 3"


How is that related? If someone puts CP intentionally into the block chain that has nothing to do with math. The spread of child pornography is a criminal offense and they could just force every miner to split the chain or charge them for spread of CP.


> By that logic you could make anything illegal, legal.

I'm not a lawyer but from a technical point of view it's almost impossible to remove any kind of data from a truly distributed network. Be it Bitcoin's Blockchain, BitTorrent or the internet itself. That's just a fact, no judge order will change it, sorry.

And as M4v3R said it'd be very expensive to add a big file like a picture to Blockchain anyway.


Its pissing into the wind to try to regulate some things. Like trying to teach a pig to sing? Doesn't work, and annoys the pig.


You probably have it on your computer already, if someone publishes interesting enough instructions for "retrieving" it.


Pi is a number. A picture is also a number (a very long one, just like any other file), including CP.


By that logic you could make anything illegal, legal.


It is perfectly possible to do so, but it would be quite expensive to do so. It is easy to embed ASCII data (some 40-80 bytes) in one transaction, but that's it. To embed an image, requiring at least few kilobytes of binary data, you would need to pay a significant amount of fees.


Exactly - scripts are pure functions. Reasoning behind this is explained by Satoshi himself at Bitcoin Talk [0]. Contracts page at Bitcoin wiki has an example of defining a will using Bitcoin and an oracle [1].

[0] https://bitcointalk.org/index.php?topic=195.msg1611#msg1611

[1] https://en.bitcoin.it/wiki/Contracts#Example_4:_Using_extern...


Yup. The concept of a blockchain is fundamentally incompatible with external inputs. That's because at any given moment you need two things: - everyone to agree that the new block is valid (and you can't really do that if blocks contained functions that had to be verified with external/changeable outputs) - everyone has to agree that all the past blocks were valid, which is even harder, because if blocks referenced external outputs, the sites/sources they relied on may have changed

That's why not only Bitcoin, but also Ethereum and all the other blockchain-based currencies need oracles for passing external inputs in.

By the way, here's our repo, if anyone's interested in the whole concept: https://github.com/orisi/orisi -- there are tutorials there explaining how to set up an example oracle, and an example client sending stuff to oracles to sign.

There's also one of the core devs explaining this stuff: gavintech.blogspot.com/2014/06/bit-thereum.html


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: