HNHacker News
TopNewBestAskShowJobs

ahoge

1,026 karma · joined December 11, 2011

submissionscomments
ahoge··on Writ – Opinionated, classless styles for semantic HTML
Zen Garden is pretty much the opposite of what one should do nowadays. Someone wrote some markup and sprinkled a ton of CSS hooks on top and then someone else came along and wrote the CSS.

It uses these 12 IDs:

css-zen-garden, design-archives, design-selection, zen-benefits, zen-explanation, zen-intro, zen-participation, zen-preamble, zen-requirements, zen-resources, zen-summary, zen-supporting

And these 39 classes:

archives, benefits, css-resources, design-archives, design-name, design-selection, designer-name, explanation, extra1, extra2, extra3, extra4, extra5, extra6, indicator, intro, main, next, page-wrapper, participation, preamble, requirements, resources, select, sidebar, summary, supporting, view-css, viewall, wrapper, zen-accessibility, zen-faq, zen-github, zen-license, zen-resources, zen-submit, zen-translations, zen-validate-css, zen-validate-html

If you've ever wondered how some websites end up with a meg of CSS, that's exactly how that happens. Each view/page starts with some markup, then you sprinkle some one-off CSS hooks over it, and then you write some overly specific CSS rules which are impossible to reuse. Rinse and repeat.

It's more efficient to create a library of reusable building blocks and then build your views/pages out of these. All of the more organized approaches (BEM, SUIT, etc) work this way. You always use what's already there and you only extend a component or create a new one if it's absolutely necessary.

ahoge··on Coca-Cola Funds Scientists Who Shift Blame for Obesity Away from Bad Diets
The only problem with HFCS is that it's cheaper than dirt.
ahoge··on Toggle CSS bookmarklet
It does work, but you need a browser which supports all of the used ES6 features (even in sloppy mode). As far as I can tell, it should work in Microsoft Edge.

It will work in Firefox once they enable `let` without specifying the script version.

It will work in Chrome once they fix for-of and once they make `let` work outside of strict mode.

ahoge··on We don’t trust drinking fountains anymore, and that’s bad for our health
The one at my local university dispenses chilled water with light carbonation. I wish I had one of those at home. Tap water doesn't get any fancier than this.
ahoge··on What kind of Web Components do we need?
> But WebComponents aren't "new elements."

How so? What's the difference?

Just like native elements, Custom Elements work with any modern framework. You can just add them to the DOM and they will work fine. They have their own attributes and methods. They also can fire events and react to attribute changes.

> It's more like being able to call a function and return an XML subtree.

It's not like that. You just use your Custom Element like any other element. If you want a "video" element, you add a "video" element. If you want a "my-video" element, you add a "my-video" element.

You'd interact with this "my-video" element the same way as you would with a "video" element. All the DOM/event stuff works exactly the same.

ahoge··on ES6 Performance
Interesting data, poor presentation.

The tables need some formatting and colors would be nice, too. Instead of "slower" and "faster" it should be just a factor. So, 2x would mean that it takes twice as long and 0.5x would mean that it's twice as fast.

Also, what's the baseline? Where does that 1x come from?

ahoge··on Airbnb JavaScript Style Guide

  > new Array('a')
  ["a"]
  > new Array(2, 3)
  [2, 3]
  > new Array(2)
  [undefined, undefined]
  > new Array(2.3)
  RangeError: invalid array length
  > new Array(2.3, 4.5)
  [2.3, 4.5]
The Array constructor is really bogus. It switches to a different mode if a single number is passed.

ES6 added `Array.of` for this reason:

  > Array.of()
  []
  > Array.of(1)
  [1]
  > Array.of(1, 2)
  [1, 2]
I don't really think it's needed though. Spread and rest already take care of the common use cases.
ahoge··on Airbnb JavaScript Style Guide
It's not an issue since using a non-hoisted variable before it was declared is an error.

Your editor should immediately highlight this error with a squiggly line.

ahoge··on John Carmack working on Scheme as a VR scripting language
> You can only compare things meaningfully when you have comparable knowledge of both.

Lisp isn't the only language which allows you to nest things.

You can nest function calls, lists, objects, tuples, and whatever in any language.

  (a b (c d))

  a(b, c(d))
Impossible to imagine, eh?

> Why don't you answer my earlier posts, where I show how to make similar syntax in Lisp?

So, your solution to make Lisp usable is also to not write Lisp? And I'm supposed to take that as disagreement?

If you extend it with your own syntax, it becomes a different language.

ahoge··on John Carmack working on Scheme as a VR scripting language
> This is simply the case of getting used to something.

My point was that other languages provide more visual hooks. Lisp is just words and parens. Nothing sticks out. Everything is the same.

So, you can't learn this "visual vocabulary" because there simply isn't any. There is a thing at the beginning of each list and what follows are the parameters. That's it.

"(define x 5)", "(square x)", and "(+ x x)" are syntactically the same thing.

> Array programming may seem like an odd niche if the only thing one knows is web development

You make it sound like it's either web stuff or maths.

Array programming languages aren't used for scripting (e.g. games), are they?

ahoge··on John Carmack working on Scheme as a VR scripting language
> I have no idea what you mean here.

Nested lists are similar to nested function calls. Did you skip the rest of the paragraph?

> the "things" are sticking out in a variety of ways

No, they don't. Syntax-wise, everything is the same.

"Scheme's very simple syntax is based on s-expressions, parenthesized lists in which a prefix operator is followed by its arguments. Scheme programs thus consist of sequences of nested lists."

There shall be nested lists. That's all, folks!

In other languages, you have syntax for importing stuff, syntax for declaring a variable, syntax for different loop constructs, syntax for branching, syntax for classes/methods/functions...

Each building block comes with its own syntax.

This isn't as elegant as having one universal construct for everything, but it's easier to use (once you got used to it), because the syntax itself carries a lot of the information.

  (define (square x)
    (* x x))
I rather write something like:

  square(x) => x * x;
"bla(...)" is a bit of syntax for defining a function. "=>" is a bit of syntax for defining a lambda. "x * x" is a bit of syntax for using x's "star" operator.

> Again, I don't understand what you mean.

J and APL aren't popular languages. There are many unpopular languages with worse syntax. They are also both array programming languages which is a rather odd niche.

ahoge··on John Carmack working on Scheme as a VR scripting language
> How can you be disliking it from a practical point of view if you don't use it in practice?

I had plenty of exposure to deeply nested things. This is pretty much like nested function calls. "foo(a, b)" and "(foo a b)" isn't all that different, is it?

I prefer to have different bits of syntax for different things because it looks less uniform. I like it when different things stick out in different ways.

> Also, take a look at APL or J if you want to see "unreadable" language.

Both of these aren't even in the top 50. Can you think of a somewhat popular (non-legacy) language?

ahoge··on John Carmack working on Scheme as a VR scripting language
> Firstly, Racket is not a Scheme.

Did I talk about Racket anywhere?

> Does this look like S-expressions to you?

"MiniPacal implemented in Racket"

Are you really arguing that implementing some other language is the way to go?

https://github.com/eudoxia0/cmacro http://research.swtch.com/shmacro

Totally legit "C".

ahoge··on John Carmack working on Scheme as a VR scripting language
> [Scheme's syntax is] not that uniform, really.

"Scheme's very simple syntax is based on s-expressions, parenthesized lists in which a prefix operator is followed by its arguments. Scheme programs thus consist of sequences of nested lists."

That's as uniform as it gets. Everything is the same.

ahoge··on John Carmack working on Scheme as a VR scripting language
> You get to the end and all of a sudden the }();

With most code conventions, you wrap immediately invoked function expressions (IIFEs) in parens:

  var foo = (function () {
    ...
  }());
The only purpose of those extra parens is to act as marker.

Well, with block scope (`let` & `const`), IIFEs aren't really needed anymore.

ahoge··on John Carmack working on Scheme as a VR scripting language
Yes, I "dare" to have an opinion on that syntax.

I like it from a theoretical point of view. It's very uniform which is convenient for implementers. It's brilliant, really.

However, I dislike it from a practical point of view, because this uniform soup is hard to scan and also hard to write.

I pretty much like any other language's syntax better than this one. Even fairly cryptic ones like Erlang's.

ahoge··on John Carmack working on Scheme as a VR scripting language
"This stuff" was referring to the entry point.

I didn't complain about parenthesis. ASM's syntax is also extremely simple, but that doesn't make it easy to use, does it? If everything looks the same, it's hard to scan.

C-like languages provide more visual hooks than Lisp dialects.

ahoge··on John Carmack working on Scheme as a VR scripting language
https://en.wikipedia.org/wiki/Scheme_%28programming_language...
ahoge··on John Carmack working on Scheme as a VR scripting language
> Or assuming hello is a global in your dart example

The way it's written implies that it's somewhere inside some block, because "main()" is always the entry point. I wrote it like that because I couldn't be bothered to figure out how this stuff works in Scheme.

With entry point:

  main() => print('Hello World');
Alternatively:

  main() {
    print('Hello World');
  }
ahoge··on John Carmack working on Scheme as a VR scripting language
The example was taken from Wikipedia's Scheme article.

I do not know how to write Hello World in Scheme.

By the way, I really like how everyone's Hello World looks different.

ahoge··on John Carmack working on Scheme as a VR scripting language
Best? If we'd all agree on what "best" means, we wouldn't discuss anything ever.

Scheme and all the other Lisp variants look terrible to me. Having an excessively simple syntax doesn't mean that it's nice to use. They went too far.

This is probably the primary reason why Lisp dialects aren't more popular. Even the simplest code examples look like some sort of practical joke.

    (let ((hello0 (lambda() (display "Hello world") (newline))))
      (hello0))
[Edit: This example was taken from Wikipedia's Scheme article.]

Something like that in Dart:

    hello() => print('Hello world');
    hello();
Dart's syntax is way more complicated, but this is much easier to understand, isn't it?
ahoge··on A game whose source code fits in one tweet
They meant something like "var n = Date.now".

However, there is no guarantee that this will work since it assumes that `this` isn't used by that function.

E.g. if you want to do something like that with console.log or document.querySelector, you have to use bind:

  var log = console.log.bind(console);
  var qs = document.querySelector.bind(document);
ahoge··on Atom 1.0
Norwegian with Sámi has a lot of collisions. With the regular Norwegian layout, the only collision should be µ (M + AltGr).
ahoge··on Atom 1.0
AltGr is used by many layouts such as German, Turkish, French, Polish, and US International.

https://en.wikipedia.org/wiki/AltGr_key

Also, this was supposed to be fixed in 1.0. I don't know why they decided to release 1.0 prematurely.

ahoge··on Atom 1.0
Eh. Why is 1.0 out already? Keyboard layouts which use AltGr are still broken.

E.g. I can't type '@', '\', and 'µ'. Yes, I can't write metadata annotations or escape some characters.

ahoge··on Learn ECMAScript6 by doing it
Only a tiny percentage of websites uses a dark color scheme.

I have a small bookmarklet for nuking colors, which I can run via some shortcut (ShortcutKey2URL).

javascript:for(var e of document.querySelectorAll('*')){e.style.color=window.getDefaultComputedStyle(e).color;e.style.backgroundColor='#fff'}void(0)

Kinda crude but it works well enough.

ahoge··on Learn ECMAScript6 by doing it
If you are fine with bright text on dark backgrounds, sure.

I'm not. Looking at this for a few minutes will impact my vision and it will most likely also cause severe headaches. Migraine is fun like that.

Anyhow, the tddbin site uses a black on white color scheme. There is no reason for the index site to be inverted.

ahoge··on Dynamics.js, a JavaScript library to create physics-based animations
Since ES5, you can't use `with` in strict mode.

Well, you shouldn't use it anyways since it's confusing/ambiguous and it's also terrible for performance.

ahoge··on Favicon bug
Hard limits aren't much of an issue if updates are rolled out ever 6 weeks.
ahoge··on ES6 in Depth – Symbols
I should have used Object.freeze(this) in the c'tor.
← PreviousPage 2 of 16Next →