-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
We are breaking up. I'm sorry, it's not you, it's me. I really like you, but I feel like now is that time in my life where I grow up and face some big challenges and decisions. The first time I saw you, I couldn't take my eyes off of your beautiful list comprehensions. Your arrow functions were amazing. I bet you remember all the special moments we had together. It was pretty fantastic. It was love at first sight. You remind me of my parents, Mr. Python and Mrs. Ruby, who taught me great things in life. But now, I can make my own decisions independently of my parents. As I said, there's nothing really wrong with you. It's just that I need to go dangerous, I need to live that adventure that every man is called to. To take my backpack and just go, discover the world out there. With you, I don't have my freedom to name my own functions. I can't make classes the way I want to. You don't let me do that. And I know your intentions are the best, please don't get offended here. I know you are trying to save me against evil code and odd bugs. But I have grown up and those aren't issues anymore. Also, in the end of the day, your generated JavaScript is just about 5% more verbose than actual CoffeeScript code, so I don't see real benefit. I think I'll survive. This time, I actually believe I can JavaScript. I don't particularly like it, I miss you sometimes, my dear. But I got courage. This will be tough, but it's my destiny. It's what I'm called to do. Sorry.
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* App entry-point. | ||
*/ | ||
var Package = require('package.json'); | ||
var binder = require('rxmarbles/binder'); | ||
var Sandbox = require('rxmarbles/views/sandbox'); | ||
var OperatorsMenuModel = require('rxmarbles/models/operators-menu'); | ||
var OperatorsMenuView = require('rxmarbles/views/operators-menu'); | ||
var OperatorsMenuInterpreter = require('rxmarbles/interpreters/operators-menu'); | ||
var DOMDelegator = require('dom-delegator'); | ||
var Utils = require('rxmarbles/views/utils'); | ||
|
||
var domDelegator = DOMDelegator(); | ||
|
||
var sandboxContainer = document.querySelector(".js-sandboxContainer"); | ||
sandboxContainer.innerHTML = ""; | ||
sandboxContainer.appendChild(Sandbox.render()); | ||
|
||
binder(OperatorsMenuModel, OperatorsMenuView, OperatorsMenuInterpreter); | ||
// binder(SandboxModel, SandboxView, SandboxInterpreter); | ||
|
||
Utils.renderVTreeStream(OperatorsMenuView.vtree$, ".js-operatorsMenuContainer"); | ||
|
||
var versionElement = document.querySelector("a.js-appVersion"); | ||
versionElement.textContent = "v" + Package.version; | ||
versionElement.href = "https://github.com/staltz/rxmarbles/releases/tag/v" + Package.version; | ||
|
||
var rxVersion = Package.dependencies.rx.replace(/(~|\^|\.\+)*/g, ""); | ||
var rxElement = document.querySelector("a.js-rxjsVersion"); | ||
rxElement.textContent = "RxJS v" + rxVersion; | ||
rxElement.href = "https://github.com/Reactive-Extensions/RxJS/tree/v" + rxVersion; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Important Model-View-Interpreter binding function. | ||
*/ | ||
module.exports = function(model, view, interpreter) { | ||
view.observe(model); | ||
interpreter.observe(view); | ||
model.observe(interpreter); | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var Rx = require('rx'); | ||
|
||
module.exports = { | ||
"all": { | ||
"label": "all(x => x < 10)", | ||
"inputs": [ | ||
[{t:5, d:1}, {t:15, d:2}, {t:25, d:3}, {t:35, d:4}, {t:65, d:5}, 80] | ||
], | ||
"apply": function(inputs) { | ||
return inputs[0].all(function(x) { return x.content < 10; }); | ||
} | ||
}, | ||
|
||
"any": { | ||
"label": "any(x => x > 10)", | ||
"inputs": [ | ||
[{t:5, d:2}, {t:15, d:30}, {t:25, d:22}, {t:35, d:5}, {t:45, d:60}, {t:55, d:1}] | ||
], | ||
"apply": function(inputs) { | ||
return inputs[0].any(function(x) { return x.content > 10; }); | ||
} | ||
}, | ||
|
||
"contains": { | ||
"label": "contains(22)", | ||
"inputs": [ | ||
[{t:5, d:2}, {t:15, d:30}, {t:25, d:22}, {t:35, d:5}, {t:45, d:60}, {t:55, d:1}] | ||
], | ||
"apply": function(inputs) { | ||
return inputs[0].contains({ content: 22 }, function(x, y) { | ||
return x.content === y.content; | ||
}); | ||
} | ||
}, | ||
|
||
"sequenceEqual": { | ||
"label": "sequenceEqual", | ||
"inputs": [ | ||
[{t:5, d:1}, {t:15, d:2}, {t:25, d:3}, {t:35, d:4}, {t:65, d:5}, 85], | ||
[{t:2, d:1}, {t:20, d:2}, {t:40, d:3}, {t:70, d:4}, {t:77, d:5}, 85] | ||
], | ||
"apply": function(inputs) { | ||
return inputs[0].sequenceEqual(inputs[1], function(x, y) { | ||
return x.content === y.content; | ||
}); | ||
} | ||
} | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
var Rx = require('rx'); | ||
|
||
module.exports = { | ||
"combineLatest": { | ||
"label": "combineLatest((x, y) => \"\" + x + y)", | ||
"inputs": [ | ||
[{t:0, d:1}, {t:20, d:2}, {t:65, d:3}, {t:75, d:4}, {t:92, d:5}], | ||
[{t:10, d:"A"}, {t:25, d:"B"}, {t:50, d:"C"}, {t:57, d:"D"}] | ||
], | ||
"apply": function(inputs) { | ||
return Rx.Observable.combineLatest(inputs[0], inputs[1], function(x, y) { | ||
return "" + x.content + y.content; | ||
}); | ||
} | ||
}, | ||
|
||
"concat": { | ||
"label": "concat", | ||
"inputs": [ | ||
[{t:0, d:1}, {t:15, d:1}, {t:50, d:1}, 57], | ||
[{t:0, d:2}, {t:8, d:2}, 12] | ||
], | ||
"apply": function(inputs) { | ||
return Rx.Observable.concat(inputs); | ||
} | ||
}, | ||
|
||
"merge": { | ||
"label": "merge", | ||
"inputs": [ | ||
[{t:0, d:20}, {t:15, d:40}, {t:30, d:60}, {t:45, d:80}, {t:60, d:100}], | ||
[{t:37, d:1}, {t:68, d:1}] | ||
], | ||
"apply": function(inputs) { | ||
return Rx.Observable.merge(inputs); | ||
} | ||
}, | ||
|
||
"sample": { | ||
"label": "sample", | ||
"inputs": [ | ||
[{t:0, d:1}, {t:20, d:2}, {t:40, d:3}, {t:60, d:4}, {t:80, d:5}], | ||
[{t:10, d:"A"}, {t:25, d:"B"}, {t:33, d:"C"}, {t:70, d:"D"}, 90] | ||
], | ||
"apply": function(inputs) { | ||
return inputs[0].sample(inputs[1]); | ||
} | ||
}, | ||
|
||
"startWith": { | ||
"label": "startWith(1)", | ||
"inputs": [ | ||
[{t:30, d:2}, {t:40, d:3}] | ||
], | ||
"apply": function(inputs, scheduler) { | ||
return inputs[0].startWith(scheduler, 1); | ||
} | ||
}, | ||
|
||
"zip": { | ||
"label": "zip", | ||
"inputs": [ | ||
[{t:0, d:1}, {t:20, d:2}, {t:65, d:3}, {t:75, d:4}, {t:92, d:5}], | ||
[{t:10, d:"A"}, {t:25, d:"B"}, {t:50, d:"C"}, {t:57, d:"D"}] | ||
], | ||
"apply": function(inputs) { | ||
return Rx.Observable.zip(inputs[0], inputs[1], function(x, y) { | ||
return "" + x.content + y.content; | ||
}); | ||
} | ||
} | ||
}; |
27 comments
on commit 57e37f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loved it! 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats, though https://github.com/staltz/rxmarbles/blob/master/README.md still says that the project is CoffeeScript. A very minor oversight given the size of this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point. Thanks. @buro9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good decision indeed, cheers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best decision (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello!
With you, I don't have my freedom to name my own functions. I can't
make classes the way I want to. You don't let me do that.
Could you please explain this? I'm interested in it 👂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain this? I'm interested in it
foo = (x) -> 2*x
console.log foo(5)
Gets compiled to
// Generated by CoffeeScript 1.7.1
(function() {
var foo;
foo = function(x) { // I want `foo = function foo(x) {`
return 2 * x;
};
console.log(foo(5));
}).call(this);
For debugging purposes, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can have your foo: http://coffeescript.org/#lexical-scope
Properly written CoffeeScript has everything you mentioned there in your complaints.
And it's sad -- you're drawing your own conclusions without even learning the topic in interest. CoffeeScript will never be an advantage when not used properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can have your foo: http://coffeescript.org/#lexical-scope
Exactly where? I didn't find it even with the browser's search.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➜ Desktop node_modules/.bin/coffee -p test.coffee
(function() {
var foo;
foo = function(x) {
return 2 * x;
};
}).call(this);
➜ Desktop node_modules/.bin/coffee -b -p test.coffee
var foo;
foo = function(x) {
return 2 * x;
};
➜ Desktop
Notice the -b
switch -- it would solve this particular issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is completely not what I'm talking about. Notice the comment here in the middle of the code:
// Generated by CoffeeScript 1.7.1
(function() {
var foo;
foo = function(x) { // I want `foo = function foo(x) {`
return 2 * x;
};
console.log(foo(5));
}).call(this);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue jashkenas/coffeescript#15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed pardon me. But, Note that there is a solution to the scoping issue, and it is employed for class constructors, primarily for reflection purposes, but the resulting code is too verbose to use for every function.
. The answer is use classes. How it technically is supposed to be in OOP. But since you're using Rx, the compiled code would most probably be an overkill. Thus, a proper solution -- sourcemaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bstst no, the proper solution is dropping the toy language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I wouldn't use classes. That would be a hackaround for such an obvious feature that needs to be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] your generated JavaScript is just about 5% more verbose than
actual CoffeeScript code, so I don't see real benefit [...]
Other pros/cons aside, the point of CS isn't to minimize the generated JS, and I'm almost positive you know that--I don't understand why you brought that up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A hackaround is the var foo = function foo
notation. It's just wrong. Don't blame CS or MS for this. Blame JS itself.
@mvasilkov, unless you're doing functional programming, CS is quite awesome. I've been on your side of the opinion for quite a long time. CS is not intended to fix all JS issues. It's just a perfect OOP JS wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the point of CS isn't to minimize the generated JS, and I'm almost positive you know that
Well, in my mind one of the points of CS is really to make JS less verbose. I wouldn't say "minimize", but less verbosity. It's a point for me, yes. I appreciated it to some extent (and lots of other people appreciate it too, under the argument of readability).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A hackaround is the var foo = function foo notation. It's just wrong. Don't blame CS or MS for this. Blame JS itself.
I'm 100% convinced that JavaScript sucks. I said, I like CoffeeScript, but JavaScript exists, and we can't deny that. It exists and some things you just have to do it the JavaScript way. You can't have any other language on the browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one of the points of CS is really to make JS less verbose
@staltz Right, it makes JS less verbose by not being JS. The point is to write your code in CS, which is less verbose than JS, and not worry about the generated JS. (The reality is that you occasionally need to look at the generated JS, but that's a separate issue.) 5% is essentially nothing, and gets minimized anyway.
An argument against CS because it generates marginally more JS than hand-written JS, to me, doesn't make sense: when using CS, CS is the artifact you deal with (delta the occasional caveat mentioned above).
I'm ambivalent on the CS v. JS thing myself, but I can't get behind this particular reason, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davelnewton I like to compare this with C vs Assembly. C is in many ways Assembly in disguise, but if you take a C artifact, it is probably 40%~60% (statistics from my mind) the size of the corresponding hand-written Assembly or generated Assembly.
In Javascript vs CoffeeScript, the CS artifact is just about 95% the size of the corresponding JS artifact. And you can see that clearly on this commit. Check for instance these two files operators-menu.*
57e37f1#diff-be22ef9a6ad6adba18c1392e56f085d8L1 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because of all the unnecessary parentheses, commas and braces in your CS! ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comma/parentheses strip tease is the most useless feature (and often confusing) that I've found in CS, and I'm no way obliged to use it, so I've never used it.
PS: also, that would only affect the length of lines, not the number of lines. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@staltz Agreed, in this short, simple example, there isn't much benefit, although I personally find less braces etc. easier on the eyes--but that is almost completely non-technical and opinionated. I would have written that CS slightly differently, but largely agree.
I don't think the benefits of CS are readily apparent in small, isolated examples, though.
Like I said, overall I'm ambivalent :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, I still like CoffeeScript! I just couldn't let it get in my way this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good decision, one day Javascript will rule !!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's right move!
Best decision (: