HNHacker News
TopNewBestAskShowJobs

ahoge

1,026 karma · joined December 11, 2011

submissionscomments
ahoge··on Ruining the diversity of JavaScript community with a coding style guide
Yes, a style guide "ruins" diversity. That's the whole point.
ahoge··on It's the Umami – Why the Truth About MSG is So Easy to Swallow
> Would you use these crystals in your kitchen if they were called “super delicious umami crystals?”

I use those crystals in my kitchen and they are labelled "monosodium glutamate" (Ajinomoto). A pound of that easily lasts me 2 years. You only need a dash here and there (and only if it isn't umami on its own).

I also eat/use Parmesan, Dashi, tomatoes, and so forth.

ahoge··on It's the Umami – Why the Truth About MSG is So Easy to Swallow
You only need a tiny dash of MSG. If you got a pound of that stuff, it will last you ages.
ahoge··on It's the Umami – Why the Truth About MSG is So Easy to Swallow
> If you think MSG is fine, try eating a tablespoon of it with nothing else.

If you think salt is fine, try eating 10 tablespoons of it with nothing else.

ahoge··on Google Apps drop support for IE9
> I wonder if Google will ever end up in legal trouble for such a policy.

Why would they? On what basis? Also, even Microsoft doesn't want anyone to support old versions of IE. Microsoft wants to sell Windows licenses, remember?

ahoge··on Angular Announces AngularDart
> Sadly, this is the nature of so-called "Open Source" at Google.

What's up with those scare quotes? Angular is open source (MIT), not "open source".

ahoge··on Angular Announces AngularDart
> It's being designed as a javascript replacement.

Yes, it is. But I'm not sure why you're viewing that as something negative.

It addresses the kind of problems everyone encounters when they try to write bigger applications in JavaScript.

GWT and the Closure Compiler also did this kind of thing. Dart does the same, but in a far more elegant manner. It's terser and the workflow is far more streamlined.

Having proper tooling is really great. Also, thanks to the type annotations you'll need fewer tests, you get better documentation, and it also acts as a safety net for refactoring/maintenance work.

It will enable more people (myself included) to write larger high-quality web applications.

ahoge··on Angular Announces AngularDart
> browsers that don't support Dart in the browser (which is all of them except Chrome)

All but Dartium. Even Chrome doesn't support it natively yet.

> Dart's type system is basically just the Closure JsDoc system used by the Closure compiler.

Yes, it's basically something like that. The difference is that it's terser and far more convenient to use. Since it's baked into the language, it's standardized and properly supported by all tools.

Another difference is that you immediately benefit from putting those annotations at the boundaries. You get the checks and call-tips right off the bat.

> Dart is really just another Coffeescript

No, Dart and TypeScript offer proper tooling. CS doesn't.

Dart also offers much nicer semantics.

> One of the benefits of development in JavaScript is you can simply refresh your browser and it just works.

Same with Dart. You just use Dartium during development.

ahoge··on Firefox Developer Tools, Part 2: Scratchpad and Style Editor
> Ctrl+Shift+i

Try Ctrl+Shift+C. It jumps straight into select/inspect mode.

Prior to Firefox 25 this would open Firebug. Now it opens Firefox's dev tools (also select/inspect mode).

I rebound Firebug's shortcut to Ctrl+Shift+X. This way I can still use it if I want.

ahoge··on Ask HN: PHP vs. Node.js vs. Go for a new startup?
If it must be one of those 3 options, I'd probably go with TypeScript running in Node.

Scala is another option you might want to look into.

For scaling, see: http://12factor.net/

ahoge··on Web Framework Benchmarks Round 7
> Why mandate how the benchmark is implemented?

Otherwise you won't be able to compare the results.

For example, the Benchmarks Game [1] specifies how the algorithms in those benchmarks should work. For some of the benchmarks, there are faster algorithms. However, it's not about comparing algorithms, it's about comparing language implementations.

[1] http://benchmarksgame.alioth.debian.org/

ahoge··on Java Virtual Machine in pure Node.js
Java 6.0 comes with JSR 223 ("scripting for the Java platform"). It's a framework for hosting scripting engines. 6.0+ is shipped with a JavaScript engine based on Mozilla's Rhino.

http://en.wikipedia.org/wiki/Rhino_%28JavaScript_engine%29

ahoge··on Java Virtual Machine in pure Node.js
> [1999's] slow Java

Java 1.2 (1998) used a JIT and a generational collector. It was probably faster than today's Ruby, Python, or PHP.

What was slow was start up. Applets in particular were really horrible since they completely froze the browser for several seconds.

If I remember correctly, this was finally fixed many years later with some version of Java 6.0.

ahoge··on Firefox 25 is released
Of course there is some variation. There are always some bigger features which take their sweet time. However, there is always a constant stream of smaller fixes and improvements.

Also, if there are ~86 releases per decade, those features and improvements are of course far more evenly spread compared to some product which only released 4 versions in the same time span. (IE6 was released in 2001 and IE9 in 2011.)

ahoge··on Firefox 25 is released
I know you tried to be funny, but this "150" actually means something very specific. It's +125 of those steps.

That's way more meaningful than +7 major releases. Just look at other software. Sometimes it takes 1 year. Sometimes 6 or even longer. Sometimes the changes are very minor or purely cosmetic. Sometimes the changes are very drastic. Sometimes it's even a complete rewrite.

I don't see how that's any better. Basically, it just means that someone thought it would be a good idea to increase the major number by one.

ahoge··on Firefox 25 is released
You know that there is a point to it, right? Now there are always 4 versions: fresh nightly builds, dev, beta, and stable. Every ~6 weeks dev becomes beta and beta becomes the new stable version. This way you get a higher degree of parallelization. There is no global feature or whatever freeze. New stuff is added all the time.

The version number is now basically just a step counter.

ahoge··on Things that suck in AngularJS
> Then there's Dart, which is kind of their version of CoffeeScript/TypeScript/etc.

From my point of view, it's just the next logical step after GWT and Closure. The annotations are baked into the language's syntax, you get the usual JS-like development cycle (save -> F5), and Java/C#-like tooling.

TS is somewhat similar. CS, however, isn't. CS doesn't offer any tooling advantages over JS.

> looks strikingly like Angular at times

Heh. There is also a Dart version of Angular:

https://github.com/angular/angular.dart

ahoge··on Php.net detected as a malware host by Google Safe Browsing
Favicion caching is extremely aggressive in Firefox. In the past, visiting the URL of the favicon and pressing Ctrl+F5 was enough. Nowadays, you have clear your cache [1] and then restart your browser.

[1] Tools -> Options -> Advanced -> Network -> Cached Web Content -> Clear Now

ahoge··on The genius and folly of MongoDB
I'm only interested in cross platform stuff. Whichever part of the stack it is, it must work on Windows, Mac, and Linux.
ahoge··on Fructose: The Poison Index
> many more

That's not the same as several times more. If I remember correctly, it was something along the lines of 500% more. It's a crazy amount of fructose. And there usually is very little fiber (which you'd get with fruits) to slow down the absorption rate.

HFCS isn't that different from sugar. The only real problem is that it's even cheaper than sugar.

Theoretically, you could use a bit less because it's a little bit sweeter than sugar, but no one seems to do that.

HFCS is a very cheap way to make your crappy product taste like something. That's why it's everywhere.

ahoge··on Fructose: The Poison Index
>Their problem is that they regularly eat thousands of extra calories.

Which is so much easier with fructose. It gets in the way of feeling full and it has lots of kcal.

Nowadays, we consume several times more fructose than we did 100 years ago. Our bodies still handle it very poorly.

If you want to lose weight, watching your fructose intake will make it a lot easier.

ahoge··on Cargo Cult CSS
> If your intention is to create reusable components [...]

This isn't like Bootstrap, mind you. It's a set of building blocks for one particular website.

> Also, there's the obvious anti-pattern of using # as the href, instead of an actual URL.

It's about the structure of the markup. "#" is used as no-op href for dummy links. "data:," is used as no-op src for dummy images.

ahoge··on Cargo Cult CSS
Subtree root node, descendent, modifier, and not CSS.

A modifier changes one or several aspects to make it more suitable for a different purpose.

You can stick subtrees into the leafs of other substrees. There is no overlap or interweaving.

So, if you look at some node, you just travel the tree up until you hit the first UpperCaseCamelCase class. That's the structure this node belongs to. It's also the name of the partial.

E.g. this is the "bricks/_Pagination.scss" partial:

  /// Simple pagination for search results and similar things.
  ///
  /// <div class="Pagination">
  ///     <a href="#" class="active">1</a>
  ///     <a href="#">2</a>
  ///     <a href="#">3</a>
  ///     <a href="#">4</a>
  /// </div>

  .Pagination {
  	@include TopMargin;
  	text-align: center;
  	font-size: 0;
  	& > a {
  		background: lighten($lightBlue, 12.5%);
  		color: #fff;
  		display: inline-block;
  		width: $gap;
  		padding: $gapTiny 0;
  		text-decoration: none;
  		margin-left: $gapTiny;
  		font-size: $rootFontSize;
  		&.active {
  			background: $lightBlue;
  			cursor: default;
  		}
  		&:hover {
  			background: $lightBlue;
  		}
  		&:first-child {
  			margin-left: 0;
  		}
  	}
  }
The generated docs: http://i.imgur.com/YFbhWjj.png

If there are any modifiers, a preview (with one line description) will be generated for each of them.

Apart from the reset/normalization and base styles, everything looks like that.

ahoge··on Cargo Cult CSS
Right, so what's the problem if it looks fine?

The only problem is that you used an ID.

>"do not reuse"

Why not? If someone wants to reuse something, they probably have a good reason. Why would you get in their way? You won't gain anything from doing that.

ahoge··on Cargo Cult CSS
> But that's based on your own system, which may be non-obvious to other developers.

Yes, conventions are like that. You have to read the docs.

> [...] this kind of naming convention isn't a native part of CSS.

That's true for naming conventions in general.

Well, this stuff was added for a reason. If you know the rules, the SCSS and markup becomes way easier to navigate. Additionally, there are now many properties which can be automatically verified.

It adds structure which wouldn't be there otherwise.

ahoge··on Cargo Cult CSS
>The fact that [IDs] cannot be reused in a single page is what makes IDs so useful.

This isn't enforced by browsers. They will happily render all elements with the same ID and apply the same styles to all of them.

This kind of thing really isn't useful. If you accidentally put the logo twice on the page, it will be clearly visible. It virtually never happens and when it does it isn't hard to track down.

This "just once" property of IDs really doesn't add anything useful.

>Unlike a class, an ID informs me with 100% certainty that if modified, it will not affect other instances on the page, because there are none.

If I modify one of my building blocks, I know that every instance of it will now look like this.

Consistency is awesome.

ahoge··on Cargo Cult CSS
Preprocessors help with organization. I have one partial for each of my legos, for example.

They also allow you to do things like cache busting or sprite sheet generation.

Personally, I think it's totally worth it.

ahoge··on Cargo Cult CSS
>Reuse of what, exactly? Selectors? Properties?

Building blocks or legos. You create a library of these and then you just use them.

Soon, you reach a point where implementing new features/views doesn't require any new CSS. You just use what's already there.

As a result, the total number of rules is kept at a minimum, which helps with performance and also with maintenance.

>If you're building components that could end up on any page entirely outside of your control, I agree.

Well, I don't write every template/view/whatever.

>How does the developer benefit from writing the classname like this?

If you change the JS, you can freely add/remove those "js-" classes.

If you change the structure of the markup, those classes will warn you ahead of time of potential issues. They will also give you something for grepping.

Also, using those classes on the CSS side can be easily identified by tools.

Basically, it's just a naming convention which tells you something about the purpose of this particular class. In languages like Java, C#, etc. you also use naming conventions to communicate something useful. In CSS, I do the same thing. There is UpperCaseCamelCase, lowerCaseCamelCase, _withLeadingUnderscore, and x-prefixed. All of these things mean something specific.

Apart from reset/normalization and base styles, everything is written in the same mechanical style. This makes the code really easy to navigate. It's very organized.

ahoge··on Cargo Cult CSS
Well, that's the definition of a cargo cult. Following some rules without actually knowing why.

If you use IDs because some person on the internet said "Use IDs, for the love of God", you're cargo-culting.

Thing is, I know why I follow these rules. I'm the one who wrote them and refined them over the course of several years. I made informed decisions based on 13+ years of experience of which I spent the last 4 writing ecommerce related frontend code for dozens of websites.

This stuff is never done. It's always based on my current knowledge/experience and the limitations of the current boat-anchor version of IE.

Nowadays, my code is more maintainable, I can actually do some sort of "refactoring", and the total amount of selectors is very close to the optimum.

Anyhow, not using IDs makes writing CSS easier. Even if you don't understand the reasons/mechanics behind it.

ahoge··on Cargo Cult CSS
> Some CSS framework methodologists suggest that using IDs is a bad idea. The reasoning behind this is that IDs carry such a higher specificity [...]

No, the primary reason is that IDs prevent reuse.

If you want to build a library of reusable components, IDs are obviously not what you want.

As the person who writes these components, you do not care how often one of these components is used. From your point of view, it only matters if it's used at least once. If it isn't, you can throw it away.

Secondly, if you use IDs which were added for JavaScript or fragment links, you'll introduce some coupling which really shouldn't be there.

Same thing with JavaScript. If you need a class, you should add a prefixed one (e.g. "js-foo"). Obviously, classes like that should never appear in your stylesheet.

Nothing of this has anything to do with cargo cults. There is an actual reason behind every rule.

← PreviousPage 10 of 16Next →