« first day (478 days earlier)      last day (4471 days later) » 

9:03 PM
(global.window || exports).Class = function a(b) {
    var c = "constructor", d = a[c], e = a.call, f, g = 0, h, i, j, k, l = function o() {
        f = this instanceof o, b instanceof d && (f ? b : e).apply(f ? this : b, arguments);
    }, m = l.prototype, n = l.$proto = {};
    m[c] = a;
    while (j = arguments[g++]) for (i in (k = j.prototype) && k[c] == a ? j = j.$proto : j) k = n[i] = j[i], h = i[0] == "$", l[i] = k instanceof d ? function(a, b) {
        return function() {
            return b.apply(a, arguments);
starting to look good
 
GGG
yeah i like that
@IvoWetzel my solution to exports is to have them in a separate file
in foo.js just have Class = function ...
and in foo.exports.js have exports.Class = Class
and then just glue them together at build time :)
 
hm
but this is smaller :P
 
GGG
true
assuming global is a thing
and window is a thing
i feel like separate files is more reuasble
i just started doing it so i'm not sure it's great yet but it seems great
 
want a shortcut for instanceof and arguments :(
 
GGG
m4_define(ARGS, arguments)
;p
 
9:06 PM
:(
GIEF MACROS
NAO
 
GGG
that will actually work if u just run it thru m4
i've done some dirty dirty things with m4
like CLASS
ftw
 
Does chrome's JS console do line-by-line debugging at all? Couldn't find a way to do it without inserting a billion break points.
 
press the stop button
 
Insert breakpoint -> F11?
 
(the thing that looks like something on a tape recorder) than step through the code
the arrow things to the right of the stop button
 
GGG
9:13 PM
or hit pause on the script tab
the thing that also looks like a button on a tape recorder
unless you have google analytics running on your dev copy
then it will break as soon as you move the mouse
it is really great how we have built in debuggers nowdays
js doesn't feel like a third class citizen anymore
 
Hmm, weird, I thought my script was running slow but the profiler says it's (program) using all the CPU, that's chrome right?
I get a full second pause when I click an input field but it's not running anything onclick or onfocus, tabbing through the inputs doesn't lag. No idea what's causing it and now it looks like it's not JS...
Neeevermind, it's recalculating styles that's slow. Should have checked the timeline not the JS
Chrome doesn't have a style profiler like Opera yet does it?
 
gosh got it under 400 bytes
 
Profiles tab?
 
@IvoWetzel @GGG thanks though, didn't know about the step through feature
@Zirak yeah
 
GGG
@BenBrocka nightlies have it
 
9:27 PM
Strangely the lag only happens in chrome, still trying to find what's up. The page is a giant form nightmare but shouldn't be that slow, and isn't in FF
 
You know what would be awesome? CSS position-x and position-y. So I could specify position-y: fixed and position-x: static.
 
GGG
chrome is really slow with css stuff
slower than firefox
 
<rumor start="true">I heard Google is trying to punish sites for using too much CSS</rumor>
 
(global.window || exports).Class = function a(b) {
    var c = "constructor", d = a[c], e = a.call, f, g, h = 0, i, j, k, l = function() {
        f = this != global, b[c] == d && (f ? b : e).apply(f ? this : b, arguments);
    }, m = l.prototype, n = l.$$ = {};
    m[c] = a;
    while (j = arguments[h++]) for (i in (k = j.prototype) && k[c] == a ? j = j.$$ : j) k = n[i] = j[i], i[0] == "$" ? g = 1 : m[i] = k, l[i] = k[c] == d ? function(a, b) {
        return function() {
            return b.apply(a, arguments);
oh god
 
@GGG Apparently...shouldnt' be doing anything though, except the default yellow glow on input fields
 
GGG
9:31 PM
that glow shit is slow
 
stripped out all the instanceof things :O
 
GGG
chrome is really slow with those gradients
 
@GGG Not 350ms slow...
I did notice FF was much better with gradients though
 
GGG
@IvoWetzel why are you using those impenetrable variable names :(
 
@GGG uglifyjs output
 
GGG
9:33 PM
ah
 
I've got a "readable" version too
/**
  * Copyright (c) 2012 Ivo Wetzel.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
  * in the Software without restriction, including without limitation the rights
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  * copies of the Software, and to permit persons to whom the Software is
  * furnished to do so, subject to the following conditions:
 
heh, got a 503 message, and in it: Additionally, a 503 Service Temporarily Unavailable error was encountered while trying to use an ErrorDocument to handle the request.
 
GGG
ok maybe i am just having a noob moment but what is global
i know it's something in node.js
 
a reference to the global object
 
GGG
but not in browsers right
 
9:34 PM
aka window
 
The global object. Another name for window
 
or the nodejs global thing
 
GGG
it doesn't work in my browser
ReferenceError: global is not defined
is it, like, something you shim
or a strict mode thing or something
 
huh...weird...that worked not so long ago
 
gnah, stupid FX
 
GGG
9:35 PM
i know i'm having a noob moment here but i really don't understand it :(
so global is supposed to work in browsers?
or it did or something?
 
It should reference the GO, I think
 
seems FX broke it
works in Chrome
 
GGG
not this ver
i have a slightly older version of chrome
because on an older version of ubuntu
probably not uncommon
i think i'd stay away from global
 
then, I'll fallback to the this thing
gnah
2 bytes more that is
 
GGG
the this thing is bad too
 
9:37 PM
Weird, it doesn't work in Chrome 16, but does in Chrome canary 19.0
 
GGG
well in production code
 
works in this case
just checking for the invocation of the Class constructor
easy way to figure out if it's called without context
or with new
 
GGG
isBase = this != global;
can you do that by sticking something in the prototype and checking that instead
or maybe that's longer
 
> The value of Infinity is +∞ (see 8.5). - es5.github.com/#x15.1.1.2
hehe
 
...RECURSIONS!
 
9:40 PM
There's also The value of NaN is NaN and The value of undefined is undefined
 
from philosophical point of view, you cannot implement undefined while adhering to its definition
Undefined cannot even exist
(in the real world)
It's always something, not undefined, so this means that either something is undefined, or undefined is something, in the either way, you've got to ask the same question again.
So it's obviously a trap, which kills of people with very high IQ (those have unlimited stack)
Pretty much halting them
OK, now I'm alone again :(
 
GGG
undefined can exist
 
There "is" nothing. We say that it's there, because our language is incapable of expressing nothingness
 
but then it's not undefined!
 
GGG
what is a Jabbafoobafabba?
 
9:45 PM
Unless you're talking quantum physics
 
The point of languages is to explain meaning, and nothing "is" meaningless, therefore languages cannot explain nothing. QED
In other news, language parsing is hard.
 
I guess we - as being pragmatic programmers - should solve this problem by defining that undefined = "kitten".
 
GGG
undefined = [][0]
 
@GGG e=undefined²
 
Obviously. Whenever you see a kitten, stepping on it won't matter, since it's undefined
 
9:48 PM
@IvoWetzel typeof NaN ==Number
 
GGG
stepping on undefined things could matter
PitOfSpikes
ReferenceError: PitOfSpikes is not defined
 
@BenBrocka That's old!
;)
 
catch ( e ) { /*I'm here just to mess with you*/ }
 
But NaN is a quantum thing
So....
what happens if you put a cat and a NaN into a box?
 
GGG
NaN = "kitten"
 
9:49 PM
@IvoWetzel But relevant :P
 
I should make a library, have it be enormously popular, then sneak in a line of code which wraps everything in a try...catch statement, where the catch is empty
 
I mean the NaN could become a Number and then all hell breaks loose onto the kitten :O
 
Reminds me of the discussion about NULL in the DBA chatroom, NULL is much more complicated than NaN...
 
Or maybe the kitten could become Cthulu, and then we're all screwed
 
@Zirak Dunno, I fear that there's a "catch" to using that library...
 
GGG
9:50 PM
you can actually set NaN to "kitten"
 
ahahahahah
 
Is Cthulu a number?
 
GGG
i'm surprised
 
catch(me){/*if you can */}
 
@IvoWetzel I tried to explain that to others, but this is just meaningless!
 
9:52 PM
@Zirak You mean it's undefined?
 
if ( you.get('action') ) {
    celebrate();
}
 
Or wait.. not that would imply
 
"use strict";
(function () { return this; }).call() === "kitten"
Assuming we use the Ivo Wetzel standard of ES5
 
"use nyan";
 
!!give Ivo Wetzel a lick
@Zirak Mmmm! Ivo Wetzel tastes just like raisin
 
GGG
9:57 PM
lol wtf
 
Uh that's dirty! Do you think so...
 
GGG
!!give Zirak's mom a lick
 
Well I better not show you how a lemonade is made
 
Now I've got that flash thing in my head all over again
 
GGG
hahah
 
9:58 PM
evil smile
 
1
Q: returning either an object or false in dynamic languages

SeanConsider this javascript: function Foo() { function getPreferences() { if ([there is an existing preferences object]) { return preferences; } return false; } } And calling code that looks like: var foo = new Foo(); var prefs = foo.getPreferences(); if (prefs) { // do s...

 
@Feeds null, and your code won't work
 
user1385191
> We made some targeted changes in this area in IE9. Our data suggests that making this quirks only would break a large number of web sites.
 
user1385191
this mindset really annoys me
 
user1385191
don't let users hang themselves just because they can
 
user1385191
...or perhaps this is Google being too clever for their own good again (referencing second comment from Microsoft employee)
 
How can it be a performance hit?
 
user1385191
10:30 PM
I'm assuming because adding it to the window means very easy access
 
user1385191
and applications utilizing it would have to interface with getElementById et al., which is slower
 
user1385191
particularly in regards to name fetching
 
oh, for the programs themselves...thought he was saying it was a performance hit for the engine.
And wow, that's a "not insignificant" thing?
 
user1385191
I recall reading somewhere that code speed was paramount for Google
 
user1385191
...so they'd ignore standards and reason whenever possible in favor of speed
 
user1385191
10:34 PM
I'll dig up the article
 
sigh @ Bateman's response to Zbarsky: "I think they usually end up going down different code paths based on other aspects of the page."
 
GGG
@IvoWetzel i just remembered 'self' ... you could use that instead of global or this :)
 
user1385191
I just use this
 
GGG
this doesn't seem portable
like you can't cut and paste it into a function property
i mean self is garbage too but whatever :p
anyone have a cross-browser getcomputedstyle function on hand
looks ok
defaultView looks sketchy
 
10:52 PM
The function ( id ) { var elem = document.getElementById( id ); doStuffToElem; } pattern always seemed strange to me...what if the element doesn't have an id, and why can't I just pass an already selected element?
 
That does kinda suck… where is it a pattern?
 
I see it lots of times. Not so much in recent code, probably because most "js programmers" do these stuff by jQuery( 'everything' )
The code example above? I also space out some parens. To be specific, the most outer enclosing parens.
 
Absolutely. It limits reusability.
 
( (like this()) )
 
user1385191
can't stand that pattern
 
GGG
10:56 PM
yeah
function getStyle (element, styleProp) {
  if (element.currentStyle) return  element.currentStyle[styleProp];
  var view = document.defaultView ? document.defaultView :
             document.getComputedStyle ? document :
             window.getComputedStyle ? window;
  return view.getComputedStyle(element, null).getPropertyValue(styleProp);
}
there's mine
i vaguely remember doing this before and getComputedStyle being somewhere else in some browser
chrome, actually, i think
this should work
 
It seemed kinda perverted to me at first as well, but then I tried and realized the extra clarity I suddenly get. I can't stand when people space out every parens, it kinda destroys the code intention, but I like my version.
 
GGG
space inside parens is weird
noobs do that
 
The Zend Studio formatter is a nightmare for that. It adds spaces everywhere. So function calls look like expressions.
 
GGG
yeah spaces before parens are for keywords
like each
 
Like this: foo ( bar );
 
10:59 PM
Great argument. "I don't like this, ergo n00bz do that"
oh, that just sucks
 
user1385191
@Zirak aka resig code
 
GGG
i've never seen a style guidline saying to put spaces in there
it's just something ppl do for no reason afaik
ergo, noobs do that
 
Resig spaces out everythng. ( ( like this() ) )
 
GGG
case in point
 
My style guideline says that
 
user1385191
11:00 PM
function dumb ( id ) { return this[ "document" ][ "getElementById" ]( id ); }
 
Well, it's his code ... unfortunately it's had a lot of influence.
 
And I do it because it makes it easier for me to see my code
I'm surprised nobody complained up-til now, I've been doing it for months
 
I don't even put spaces after keywords any more (e.g. if(foo) ...). I thought it would be harder to read until I looked at some Plan9 source code. Beautiful.
 
if I have a dom [div#sweepstakesToggle > div.title, div#contestsToggle > div.title]
$('.title', '#sweepstakesToggle') correctly get just the first div.title
$('#sweepstakesToggle .title') -- grabs all divs with .title
I thought jquery used CSS selectors and the second should select the first just the same, no?
 
GGG
@adscriven i keel you
 
user1385191
11:03 PM
I can see the case for spaces with blocks
 
GGG
gotta put a space after keywords
 
@GGG read some Plan9 src and then keel me!
 
user1385191
@Brombomb post HTML; get advice
 
GGG
i keel you now then read source
 
Src straddles the line between English and maths notation. It's a hard call.
@GGG hehe, that's okay too
 
11:05 PM
thanks @Matt
multiple id's all called the same
 
If everything were an expression then you'd definitely not want a space after an 'if'.
 
user1385191
wat
 
GGG
if if were a function
 
user1385191
 
copy pasta
 
GGG
11:05 PM
pretyy much everything in js is an expression
except, like, var declarations
 
That's how languages like lisp and smalltalk and io work. Just functions or method calls.
It's a shame JS isn't a bit more like that given it's lisp heritage.
 
GGG
so no keywords?
 
Ideally.
 
GGG
sounds like some symbol soup
 
Smalltalk has only six.
Or somthing like that.
 
GGG
11:07 PM
hmm that sounds kind of appealing
i imagine you need somethign for flow control
unless you want to do it with functions
ifthen(cond, test, doIfTrue, optionalDoIfFalse)
 
Do it with functions (or methods).
 
GGG
but that's ugly
 
Why?
 
GGG
because not as readable as "if (cond) { foo } else { bar }"
 
I think lisp is if(condition, consequent, alternative)
@GGG Isn't that just what you're used to?
 
11:10 PM
ternary operator, like (condition) ? consequent : alternative; no ?
 
Some people argue that lisp is not as readable as C, but some don't
 
GGG
@adscriven it's closer to what i'm used to in english
willing to bet it's closer to other languages as well
 
Lisp has macros though, so you can have all the syntactic sugar you like (more or less).
 
GGG
macros generally aren't great for defining block level stuff
like if, while, switch, et c
at least in my experience
maybe it's different in lisp
 
Then choose Ruby or VB. if cond then foo, or foo if cond else bar
 
11:13 PM
cond in lisp is a macro
 
way more English-like
 
Well it can be. It doesn't really matter if it is or isn't.
 
None of these silly ( and {
 
GGG
it's not that the keywords are english words, it's the order of the tokens
an if token, a condition, a code block.
an else token, a condition, a code block
it just makes sense
 
(s in lisp aren't silly. The syntax is a syntax tree. That's what gets you macros.
 
11:15 PM
In Ruby you can foo if cond else bar, which is also a valid English sentence
 
GGG
i don't care that it's english, i care about the order stuff is written in
 
on github how would I roll back a few commits, I pushed to the wrong branch.
 
GGG
this order makes sense
 
So does that one
 
posted on February 06, 2012 by Vasilis

A better Photoshop grid for responsive web design » Blog » Elliot Jay Stocks The main reason why not every new site is designed responsively is because visual designers don’t know how to design them. I would be struggling too if my tool of choice was photo editing software. The most important thing we should focus on in the next few months or so is to get designers to understand fluid g

 
GGG
11:16 PM
@rlemon checkout whichever version and push that
 
Englishness isn't as important as expressiveness.
Sense does this order make, young Jedi.
 
I'm on your side @adscriven, btw. Insert Ƨ at the end of all my previous sentences, if that wasn't obvious
 
GGG
m4 has a similar macro, ifelse. it's a pain in the balls once you nest more than one. Way less readable than if...else
to me anyway
 
@Zirak Well, I guess I'm having a dumb moment, because it still isn't! :-)
 
GGG
and how would you implement a switch as a function? I can't even imagine
my point has nothing to do with english my point is keywords help organize things
 
11:19 PM
oh, right...Ƨ signifies "treat what previously appeared as sarcasm, in case that wasn't obvious". At least, I use Ƨ to signify that
 
@GGG It's not a function: it's a macro. The syntax tree gets transformed (or can be transformed) into nested ifs.
 
GGG
ah, yeah that makes sense
 
@Zirak I love typographic witticisms!
 
GGG
but since macros are invoked like functions the syntax is limited
 
No, macros transform the syntax tree at compile time.
 
GGG
11:21 PM
yeah but i mean the calling notation
MACRO()
not for example MACRO(){}
i mean keyboards have like three or four different brackets on them, why not use different ones for different stuff
so the code doesn't all look the same
() for calling functions
{} for code block
[] for array access
makes sense visually
 
Well, you could write (MACRO (blah) { blah }) (I think). But why would you want braces?
Braces aren't necessary in lisp like .s aren't necessary in smalltalk to call methods.
 
GGG
just saying it's natural to have different symbols with different meanings, not try to squeeze all possible meanings into one set of symbols
 
@GGG Well, that's interesting. Lisp was never meant to have the syntax it does. It was meant to have infix notation like maths, and proper syntax and stuff. But (dylan aside) no one got round to implementing it because people just preferred to write literal syntax trees. Kinda like people like writing literal objects in JS.
That kind of uniformity gives you a power that you just can't have in other languages.
I know where you're coming from though. I like JS's syntax. I find Coffeescript very hard to read for example.
 
GGG
i guess i don't understand what the uniformity makes possible that you couldn't do otherwise
 
Macros.
You can treat code as data, and data as code.
 
GGG
11:29 PM
can i pass unparsed expressions around without them being functions?
 
Domain-specific languages become very easy.
 
GGG
that get evaluated later?
 
@GGG You can do whatever you like.
 
GGG
so i could pass an expression as an argument to a function and it would actually pass the whole expression, not the result
?
 
`quote` is a fundamental operation in lisp.
 
GGG
11:31 PM
how is this different than running C or C++ or javascript through a macro preprocessor
the macros are actually built in to the interpreter i guess?
 
C macros operate on text. Lisp macros operate on the syntax tree.
 
GGG
hmm yeah that is cool
 
The downside is that you have lots of (s and )s. But there's an upside too.
Good text editors help a lot.
 
GGG
hmm yeah i imagine so... i haven't looked at lisp in years
last time i did was for scripting the gimp... i think that was lisp
 
Smalltalk is very similar, but there's an extra layer of abstraction, the object. Lisp was a major influence on Smalltalk.
@GGG yeah, I'm pretty sure that the gimp uses a lisp.
 
GGG
11:35 PM
i wish i knew of more practical uses for stuff like that so i could have an excuse to mess with it
i have to say the gimp scripting was not fun and i quickly got lost in parentheses, but eventually i got whatever i was doing done
i don't remember what it even was anymore, i'd normally use imagemagick
 
The thing that I find so remarkable about lisp, is that it is ultimately so powerful, and yet it is probably easier to implement a lisp interpreter than for any other language. I love ideas like that.
 
0
Q: Javascript regex shorthand?

WalkerneoI'm trying to enjoy some of the awesome javascript code golf submissions on anarchy code golf, but I keep seeing things like: for(;s=readline();)print("h"+/t.*/(s)) ...which was the JS winner for: http://golf.shinh.org/p.rb?ttp I don't understand how that is correct javascript syntax, and I e...

 
Those are the ones worth pursuing.
 
GGG
hmm.. is there a lisp interpreter in javascript
that might be fun to make
 
I expect there are loads.
But don't google.
 
GGG
11:38 PM
lol why
 
Just read SICP and make your own.
Much more fun, and more instructive.
 
GGG
i could use that emscripten thing
to crank one out
 
Bah. Just read SICP. There are video lectures too. Greatest comp sci course eva! :-)
 
GGG
yeah there's loads
even a "Lisp interpreter in javascript with jQuery"
 
Hahahahaha!
 
GGG
11:40 PM
because obviously jQuery is key for interpreting lisp
 
Wtf? Ohgoddearjesuskillmenow.
 
GGG
this also looks cool - lambda-the-ultimate.org/node/892
 
Heh. LtU is a great site. Mostly over my head, which is why I love it.
The problem with that kind of thing is that it often descends into code golf.
SICP is more useful.
However, the fact that you can code-golf a lisp->JS compiler is telling in itself.
 
GGG
yeah that's pretty interesting
 
The only other language I've encountered that's similar is Forth.
 
11:45 PM
Isn't SICP Scheme?
 
Yep. But Scheme is a lisp in the broad sense.
Really Scheme is a simpler lisp.
I think it was Scheme that introduced lexical closures (but don't quote me on that).
Emacs Lisp predates Scheme, which I think is why it is dynamically scoped (and why people hate it!).
'Hate' is the wrong word, I hope you realise.
'Disappointment' is probably closer to the mark.
 
The main reason I, at least, hate elisp is because of lack of proper encapsulation
 
Isn't that a symptom of dynamic scoping? Or is there more to it?
 
Well, even with dynamic scoping, you can define a "namespace"
 
Okay, well that's 1up on JS already...
 
11:50 PM
Here, a great article on elisp's faults: steve-yegge.blogspot.com/2008/11/…
js is superbly awesome, because it combines awesomeness from Lisp and Self and some few more (I can't seem to remember where dynamic objects come from)
 
Well, I've got as far as Hallowe'en, ... typical Yegge ... still reading ...
Doesn't Self have dynamic objects? Smalltalk does.
 
Can't remember...haven't used either in a long time
 
AFAIK Ruby borrows much OO from Smalltalk.
 
Ruby borrows everything from Self. I'd call it Self mixed with VB mixed with COBOL
 
I don't know what Howl's Moving Castle is.
@Zirak Eh? Ruby has classes! It's Smalltalk/Perl.
 
11:56 PM
Doesn't VB have classes? Or was it VB.net?
 
VB has classes.
Heh, jscript.net has classes :-)
Oh. *Every* symbol in elisp is global?!
Even function parameters?
 
I don't think it goes that far
 
'Every symbol in Emacs-Lisp is in the global namespace.' Hmm. Well that's a pretty provocative statement then.
 

« first day (478 days earlier)      last day (4471 days later) »