Better HN
topnewbestaskshowjobs
Log inSign up

codecurve

1,560 karma · joined Jan 18, 2012 (14y ago) · 220 submissions

[ my public key: https://keybase.io/danprince; my proof: https://keybase.io/danprince/sigs/8AYDk4-RDKmDfqhI3Zvr4m2aPQy1DeZ86fGOs6WbGLU ]
Submissions

comment 10y ago · link · parent

It feels like the author made the jump straight from PHP to Go without spending much time actually using Node or Ruby and he's subsequently shocked at how much better modern languages are when contrasted to PHP.

Many of these "solved problems" have also been solved with the other languages, albeit not always at the surface level. For Node specifically:

WebSockets -> SockJS, Socket/Engine.io

Concurrency -> Generator Functions

Testing -> import assert from 'assert' and npm test

Syntax -> Some great improvements with ES6 and solid styleguides (airbnb, standard) + eslint as an autoformatter

The major win here for Go is that as a new platform it was designed with simplicity in mind. These features are probably easier to pick up in Go than any of the alternatives, which is great. However, don't make the mistake of thinking that Go is the first language to solve these problems.

92.

Features JavaScript Can Steal from Clojure(lispcast.com ↗)

2 points · by codecurve · 11y ago · discuss

93.

Clojure's Protocol-Based Polymorphism for JavaScript(github.com ↗)

1 points · by codecurve · 11y ago · discuss

94.

IO Monad for JavaScript(cwmyers.github.io ↗)

7 points · by codecurve · 11y ago · discuss

comment 11y ago · link · parent

For all the gripes surrounding the lack of TCO on the JVM, Clojure really does provide a great set of tools to deal with iteration in a functional way. It's a rare thing when I need to fall back to using loop & recur.

comment 11y ago · link · parent

Haha, that's a pretty clear case for them not being distracting!

comment 11y ago · link · parent

Author here, would be interested to hear people's take on the addition of illustrations (illustration is being generous, I know). Do you find them distracting or do they help break up the text?

98.

Lisp in Your Language(danthedev.com ↗)

215 points · by codecurve · 11y ago · 76 comments

comment 11y ago · link · parent

You'll be able to achieve that behaviour when node also supports destructuring.

    import { readFile, writeFile } from 'fs';
    import { clone } from 'lodash';

comment 11y ago · link · parent

Probably for the same reasons you can't write

    var function diameter() {}
It's definitely a shame that the only way to achieve consistent behaviour between variables and named functions requires you to write the name twice.

    const diameter = function diameter() {};
If it wasn't for the usefulness of named functions for debugging and hoisting, I would just use:

    const diameter = function() {};

comment 11y ago · link · parent

Totally agree, it is much more important to be able to reason about mutability.

I would disagree that it's super-easy to reason about var, despite being lexically scoped. It still causes an enormous amount of confusion when loops and callbacks are used together.

The PI example only really works because we all know what PI should look like. If you were using someone else's constant value and it accidentally got rebound it would be much harder to know.

comment 11y ago · link · parent

I think that completely depends on the flavour of code you write. If you mostly use imperative styles, then the large proportion of your declarations will be `var` and `let`. It definitely makes refactoring harder in the direction you mentioned.

Alternatively, for a functional style, you have to have a fairly good reason for using `var` or `let`. I find myself treating them like I'd treat atoms in Clojure. They end up being the mechanism you use to make controlled side-effects.

I'll concede that `const` does have a complexity to understand...initially. However once you understand the distinction between assignment and value (you only have to understand it once), then you're back to a level playing field between both.

From then on, `const` gives you a guarantee about the assignment. Objectively, this guarantee eliminates complexity, you can look at a variable anywhere in a scope and know that it has the same value as at time of declaration (same TDZ exceptions apply). I don't see how this could be seen as backwards.

comment 11y ago · link · parent

Why not use `const` as default? I would argue that using `let` instead is a premature optimization of readability.

It's easier to reason about a variable if you know it will always be one value—even if the value may be mutated (which is unfortunate).

`const` is a simpler construct. It has less rules and I would always suggest that using `let` will introduce complexity that only needs to be there when you can identify a genuine need to re-assign a value to your variable.

That said, I enjoyed the post. It's a good read!

104.

Zurb Analyse Google's New Logo(zurb.com ↗)

1 points · by codecurve · 11y ago · discuss

105.

Transducers in JavaScript(jlongster.com ↗)

1 points · by codecurve · 11y ago · discuss

106.

Architects Want to Build Minas Tirith in the UK(indiegogo.com ↗)

2 points · by codecurve · 11y ago · discuss

107.

Immutable.js to seamless-immutable(noredinktech.tumblr.com ↗)

2 points · by codecurve · 11y ago · discuss

comment 11y ago · link · parent

You can use the Chrome dev tools to run an audit. One of the performance metrics it tracks is the number of unused CSS rules.

comment 11y ago · link · parent

Sure, the underlying storage mechanisms are different and it doesn't support as many types, but I didn't say it was a good polyfill.

comment 11y ago · link · parent

That's good to hear, I wasn't aware of Typed Objects. I guess the library linked at the end of the post is basically a very non-specific polyfill already? Well, using it like that is one way to get around bitwise littering.

comment 11y ago · link · parent

Author here. There were a lot of ends that I tried to tie up that started to be difficult to find hard evidence for. Some of the string/object storage stuff is discussed casually in mailing lists, but there aren't great places I could point to and say: _this_ is the definitive answer. If you would point me in the right direction for some of these resources, I'd be happy to amend the article. Thanks for reading all the same.

112.

Binary in JavaScript(danthedev.com ↗)

128 points · by codecurve · 11y ago · 29 comments

113.

Calling an array of functions in JavaScript (2013)(zpao.com ↗)

9 points · by codecurve · 11y ago · 1 comment

114.

Mostly Adequate Guide to Functional Programming in JavaScript(github.com ↗)

114 points · by codecurve · 11y ago · 64 comments

comment 11y ago · link · parent

(function double() { return this * 2; }).call(2) === 4

I didn't have to box anything to pass a primitive as this. Maybe some other versions are different, but this works in Chrome 40 and Firefox 33.

116.

Airbnb ES6 Styleguide(github.com ↗)

2 points · by codecurve · 11y ago · discuss

117.

Pure CSS Logic Gates(codepen.io ↗)

1 points · by codecurve · 11y ago · discuss

118.

I Was Wrong About JavaScript (2013)(simpleprogrammer.com ↗)

2 points · by codecurve · 11y ago · discuss

12345
8