132 comments

[ 9.8 ms ] story [ 204 ms ] thread
Make sure you scroll down and read the mandatory disclaimer before commenting on the merits of this approach.
(comment deleted)
This is the Internet of Things for code. This is wonderful.

This is also probably a snarky shot at npm [1], for those who lack context.

[1] https://news.ycombinator.com/item?id=11340510

My goal was for it to be entertaining and educational[1]. I love npm (which made this possible to begin with!)

[1] ES6 features (arg defaults, destructuring, modules, template literals, String.prototype.repeat), babel configuration and runtime compilation, async / await

I feel like require-from-twitter really helps enforce the Unix philosophy. It's hard to write modules with multiple responsibilities in 140 characters.
I wonder how large a system could be created using nested tweets of js. Needs versioning though.
This does need a warning, but PDF isn't the reason.
What does the link do?
It opens your mind until your brain falls out.
It's just a PDF.

It's a funny PDF, though.

Actually, there are several immutable FS-over-tinyURL projects. I have created some of them too. A real problem with Twitter is that you can get banned quickly for doing this.
Careful what you wish for - someone is bound to try to prove you wrong now.
There will be a fork that allows concatenation of multiple tweets.
Hey, nice one! But reading the code I didn't see any arg defaults or destructuring. Saw the other stuff though! Which is pretty darn cool.
I was considering the source tweet as well :D
Except the problem isn't editing, but deletions.

Twitter allows deletions and explicitly requires you to process and honor deletion events in their TOS. They have even blocked API access to programs that don't honor deletions.

So, just as bad (or, maybe worse, in that you can't even keep around committed code that comes through this process, if the originating tweet was deleted) as npm.

On the other hand, no one can reclaim a tweet after it's been yanked. So, `require from tweet` is a safer system for your production systems.
Twitter API clients are required to delete all copies of tweet contents when a tweet is yanked, or Twitter will revoke API access, which might bring your production systems to a deserved halt.
Yes but they won't accidentally pull a malicious version of the tweet pretending to be the original. They'll just stop working
That is an unacceptable outcome for production systems.
Reading the NPM blog today - that's not really a problem in NPM.

Reclaiming a module name requires a breaking version for any new code, so it shouldn't be an issue there.

It's still an issue for any developers who use '>' instead of '~' or 'x'. That's quite a few.
You have left out a very crucial fact which completely destroys your argument: Twitter has no verification process that the tweet was deleted because you're NOT ADVERTISING THE TWEETS. You're using them as source code. So the public is NOT privy to what you're doing with the tweets! So Twitter would have to get a search warrant to determine that you aren't deleting tweets! Of course they don't care; they care about what you're revealing to the public.
Twitter doesn't need a search warrant to query their own servers.
Your computer has to download the tweet before it runs the tweet. It will be cached on your computer. Compliance with twitter TOS means you have to clear your cache when twitter says the tweet was deleted. Since you're using the tweet to run code, it doesn't hurt anything if you ignore the "deleted tweet" advisory.
I put my code on Github. Twitter could monitor my repos if they wanted.

Writing a monitor for all of Github would even be possible.

> Twitter would have to get a search warrant to determine that you aren't deleting tweets

Search warrants are incident to criminal activity in the United States of America. Twitter is a private company, not a law enforcement agency.

I'm surprised no one has mentioned IPFS as a solution to the deleting.
I would say it is an equally snarky shot at all those who choose to depend on a third party module for something that can be written in 140 chars.
this would actually be an interesting coding challenge and experiment to see if something could be built worthwhile in modules limited to no larger than 140 characters.
Not a good constraint. Just make each tweet module export a string, and concatenate them and eval().
well, that could be easily solved by prohibiting eval?
Concatenate them and then run them through Babel...
Are the tweet modules allowed to requireFromTwitter other tweet modules?
Pretty comical. I bet folks would actually use this to some extent, without realizing that Tweets can also be deleted.
But the point is they cannot be edited or replaced.
Neither can npm module versions without direct assistance from the company (which, if you were able to gain favor, you might be able to get Twitter to do the same).

The only difference is someone can't take over a tweet should the original tweet author delete their account.

To solve that problem we need require from bitcoin blockchain transaction.
> without realizing that Tweets can also be deleted.

Yep, just like NPM modules.

the next version should have a require from #hashtag, so that it can be fault tolerant, and would last longer when lawyers request a takedown!

    >   "dependencies": {
    >    "babel-preset-stage-0": "6.5.0",
    >    "babel-preset-es2015": "6.6.0",
    >    "babel-runtime": "6.6.1",
    >    "babel-plugin-transform-runtime": "6.6.0",
    >    "babel-cli": "6.6.5",
    >    "babel-core": "6.7.4",
    >    "twit": "2.2.3",
    >    "entities": "1.1.1"
    >    },
The problem right here. Just to run a script you now need to import a whole third party language runtime ? what other language does pull this kind of stunt ? Javascript is madness.
Most of that is so people can use the slightly nicer syntax of the newer version of JavaScript in a more supported way as it's transpired. Honestly I'm not a fan because, as you can see, it's a big ass bucket of extra complexity for some extra, albeit nice, syntax updates.

I'm waiting for wide support of ECMAScript 6 before I start using it widely. Though I feel I'm a bit in the minority here I just don't want to deal with all of the transpiling complexities if I don't need to.

I've started using ES6 sans 'transpiler' for web development on Chrome. There's still the build step for release to other browsers, but so far I haven't bothered.

(I think your decision is completely reasonable; only pointing out that since just this month, with Chrome 49 out, you can develop without any build step.)

Yup. I'm working on a Polymer project in ES6. I develop in Chrome with it pointing directly at my source, so I get a full debugger and quick reloads by hitting the F5 button. Then I use crisper/babel/vulcanise via a ninja build script to generate an ES5 deployment package for the other browsers. It works really well.

(ES6 is so, so much nicer than ES5. It's almost like a real language now!)

Is there anything you can share of that ninja script? I've been looking at it as a replacement for environments where grunt doesn't work too well.
Sure --- it's a mess, though.

https://github.com/davidgiven/gruntle/blob/gruntle/build.nin...

https://github.com/davidgiven/gruntle/blob/gruntle/build

build is a tiny Lua preprocessor which expands templates in build.ninja.

It needs a cleanup but it works, it's way faster than gulp, and is much easier to debug. Haven't touched grunt so I don't know how it compares there.

Thanks. Could I get away without the Lua?
Yes, but you'd need to expand the source file rules inline --- I added the Lua because I was fed up with doing it by hand. (Ninja doesn't have implicit rules.)
(comment deleted)
Note that other browsers (specifically Firefox and Edge) generally have better ES6 support than Chrome does, so a "build step" is not needed for them unless you happen to be using one of the very few things that Chrome supports and they do not.
Babel is run on the tweet, presumably to allow more terse code and thus more useful 140 character libraries.
clojure? I think the language is one just another jar to install. Makes it easier to pin stuff to the language version.
Javascript is in fact special because it's one of the few languages where the developer can't choose the version of the language to use. It's dictated by users with 4 year old browsers.
Execpt for server-side languages that's nearly always the case
Where? Java has such short maintainable cycles that Java 7 was dropped before Java 8 became used, and compiled languages (think C, C++, Haskell) always work.

Are there any other languages relevant for non-server usage?

You can quite easily choose your version. There are virtual hosts out there supporting any version of anything. This problem is largely solved.
That's nearly never the case, unless you are running uncompiled scripts downloaded from the internet with no version manifest, in which case that's also horrible.
For scripting languages, sure. For compiled languages, you can choose whatever version you want, since the end user gets a binary blob instead of source code (and even if they're building from source, their package manager should be able to download the required build dependencies for them).
This is just to let non-JS programmers program JavaScript. Asynchronous programming, or programming without global/imports is too hard it seems.
I don't think it's the amount of code that is a problem here (we all depend on million lines of codes for a simple hello world program in C). The problem is the number of sources that one should trust to run it, which should be minimal.
It's part of the joke that makes this post funny.
First of all, whoosh, and second, no other language has the same platform/delivery mechanism as web client javascript. Any "transpiled" language is going to have to include it's own dependencies somehow.
Well this is meant to be a bad example, really all the babel stuff would be dev dependencies and ideally you'd have some watch task to compile and auto-reload.

In production you'd only have a bundled/minified version transpiled JS so there's no need for a runtime.

Ultimately with web assembly this gets even better.

(comment deleted)
If you can get a good toolkit for writing a GLR parser, then people will write their own tokenizers, BNF formal grammars, and plug it into your parser. It would take a single person about two to six weeks to get something thoroughly polished in JavaScript along the lines of what is described. However I think that without some form of centralization, (perhaps a subreddit? idk) it will be difficult for the standardization and namespace organization process to take place. If it is just one person, there is no question of standardization; if it is multiple people, the question of who is in charge of the namespace becomes relevant. Who is in charge of the namespace in this particular experiment?
Umm isn't babel-runtime an actual third party language runtime dependency (like polyfills and shared code for stuff like async) ?
Indeed, it is the only post-build babel dependency required if you want things like you say: async/await. The rest are the babel dependencies are build tools.
I wouldn't really call it a dependency since it gets inlined with the shipped code.
npm over twitter? A site populated by trolls and spammers. What could possibly go wrong?
A developer gets upset at unilateral actions by NPM resulting in a project being renamed or taken down unnecessarily (potentially breaking builds). So this dev decides to take down all their projects, as a sort of protest. This breaks a lot of builds. The JavaScript community thinks a clever solution is utilizing Twitter as part of the build process? Because then everything would be dependent on Twitter not adding an "edit tweet" button...
Lol they are so far ahead of you. It's a jab at the situation.
> The JavaScript community thinks a clever solution is utilizing Twitter as part of the build process?

The JavaScript community thinks a hilarious, tongue-in-cheek solution is utilizing Twitter as part of the build process.

FTFY

Oops. I retract my comment and denounce myself.
...and then someone on Hacker News implies that the playing around of a single individual represents what "the JavaScript community thinks"...
Why is this not a npm module yet? Name suggestion: kik2
(comment deleted)
Not enough Twitter, can't you tell that's the problem here
For everyone who doesn't know it, there's a project called http://140byt.es/ compiling many code snippets that fit in a tweet (;

There was also a clever trick to compress/uncompress ascii text by using base[huge number] or something like that (full unicode) so it could be uploaded to twitter, but I don't remember the exact number

Standardized modules like this are exactly what the node.js-stack bot herding community has needed!

On the plus side: if you saw this dependency in a module you were looking at you would know to think twice.

Standardized modules like this are exactly what the node.js-stack bot herders need!

On the plus side: if you saw this dependency in a module you were looking at you would know to think twice.

can someone explain what is this ? I really have no idea
> // ES6 leftPad

and he even had space for a comment in there....

I think it was important to him since otherwise leftPad probably wouldn't fit in a tweet so nicely..
There's still another eight days until April first.
(comment deleted)