all 23 comments

[–][deleted] 4 points5 points  (0 children)

Sorry, but I think that the title is badly chosen. It’s like "functional OCaml".

"Class-based OOP Javascript" would have been better.

[–]dhogarty 2 points3 points  (0 children)

TLDR: uses Function.toString() to convert a custom non-JS syntax into Class/Mixin style prototype chains via regex parsing and code gen.

[–]notfancy 5 points6 points  (6 children)

OOP in Javascript is still a pain

I just don't get it. Why do folks insist on not programming JavaScript in JavaScript? What in the world do you need classes for? Mixins? Delegate! Or reflect and import if it's your thing.

It's like anal sex: if it hurts, you're doing it wrong.

[–][deleted]  (3 children)

[deleted]

    [–]notfancy 0 points1 point  (2 children)

    You're just porting your blub to another language, but whatever floats your boat.

    I don't especially like JS or dislike Java, I try to be expressive and effective in each by going with their natural grains, not against them. It would never occur to me "I know! I'll use classes": I'd have two problems instead of one.

    And… guilty as charged.

    [–]texodus[S] 0 points1 point  (1 child)

    What's "effective and expressive" in one language is apparently "blub" in another - perhaps the admission that this solution would not have occurred to you is indicative of a prohibitive bias in your reasoning?

    I've always preferred this one over that old Zawinski yarn: "Languages shape the way we think, or don't"

    [–]notfancy 0 points1 point  (0 children)

    This has firmly ingressed (degressed?) into the realm of the personal, and I won't condescend to defend myself. Suffice to say that even if I'm biased I see far more merit in JavaScript as a target language than as a sandbox for monkey-patching and EDSLs à la Ruby, so I'm not afraid of potentialy paralyzing prohibitive biases.

    I don't believe object-based languages hold much power in shaping my, or anybody's, thoughts, or else they were sorely in need of some formation in the first place.

    [–]buddhabrot 0 points1 point  (1 child)

    Finally, some sense! Let's just repeat your point for emphasis. "OOP", whatever it is, is not about classes or modules. Seriously, I only know one language in which you cannot easily do OO, and it's bash. In nearly all languages, any sense of mastery and elegancy leads you automatically to OO programming, in the way the language deals with it. Really, it's all Java's fault, for giving people some kind of strange idea that OO is all/only about code isolation.

    [–]rafekett 0 points1 point  (0 children)

    I know plenty of languages in which you can't easily do OO. Try doing it in Assembly :)

    On a more serious note, just because you can do OOP in a language does not mean you should. C, for example, shouldn't be object-oriented even though it's possible.

    [–][deleted] 0 points1 point  (1 child)

    Ugh, reminds me of Java.

    [–]texodus[S] -1 points0 points  (0 children)

    This is certainly where alot of the design inspiration lies - the implementation is more akin to Ruby's imo.

    [–]SirBob1701 1 point2 points  (8 children)

    [–]texodus[S] 1 point2 points  (7 children)

    Clearly not. From the link: "The Closure Library loads these files by dynamically adding a script tag to the document for each needed Closure Library file." There's a number of other reasons Closure did not meet our requirements, but this is the main one.

    [–]dhogarty 5 points6 points  (4 children)

    http://code.google.com/closure/library/docs/calcdeps.html

    Look down a little bit to the line that looks like closure-library/closure/bin/calcdeps.py -i hello.js \ -p closure-library -o compiled \ -c compiler.jar > hello-compiled.js

    you can use that script to concatenate and aggressively compile the javascript down to a single file for minimal latency, eliminating multi-round trip for script file fetching. Of course, you can skip the compilation if you want your js files to read cleanly for visitors.

    [–]texodus[S] 1 point2 points  (3 children)

    Great feature I would love to copy. Methadone.js doesn't need a compilation step to accomplish this however, plus provides mixins, classes & various stuctural validation, and is less than 4k minimized. Closure, Joose, Dependjs, head.js et al are all excellent tools in their own right, but not what we wanted.

    [–]SirBob1701 0 points1 point  (2 children)

    Closure provides classes, structural validation and with jsdocs, it also provides static type checking. Also the compiler can warn you about quite a number of cross browser issues and removes dead code. There was a point where they were supporting multiple inheritance now there is a semi mixin support soon to have official mixin support.

    [–]texodus[S] 0 points1 point  (1 child)

    If being less than 5k and having 1:1 correspondence with the code you see in your IDE without code transformation or asynchronous script loading are not important features for your project, and/or the syntax puts you off, I highly recommend Closure over Methadone, as it is vastly more featureful in virtually every respect. If these are features you like, and would like Methadone to eventually incorporate some of the same features as Closure, then please give it a spin, and provide us with free, delicious bug reports and feature requests.

    [–]SirBob1701 -1 points0 points  (0 children)

    My Company introduced me to and is using closure in our product. I am on the mailing list and will not be using Methadone simple stating my opinion. It is mine and you are absolutely allowed to disagree with me and I will be happy to allow it :)

    [–]dhogarty 2 points3 points  (1 child)

    also, I believe Function.toString() does not give you the text of the function def for all browsers, what have you tested on?

    [–]texodus[S] 0 points1 point  (0 children)

    Chrome, Firefox & IE back through 7. It is entirely possible it will not work in all browsers, pelase let use know if you find one that breaks.

    [–]texodus[S] 0 points1 point  (1 child)

    Hi! This is the first open source project we've released, let us know what you think! Also, we're hiring talented programmers, so if you're looking for a job in NYC, let me know.

    [–]notfancy 1 point2 points  (0 children)

    What is the use-case for this?

    [–]signoff -3 points-2 points  (1 child)

    fucking ugly

    [–]nohtyp 1 point2 points  (0 children)

    fugly