News for hackers. Stuff that matters.

chrisdotcode

Re:JavaScript in 2015 on Wednesday January 07, 2015 @01:50PM (#8852412)
Right - What I'm saying is that the above former code does handle the error, in the exact same way as the latter code.

For clarification, the error is handled implicitly (but you'd know what kind of error it was due to the type signature), but you can always handle it in manner you choose to at any point.

Re:JavaScript in 2015 on Wednesday January 07, 2015 @01:17PM (#8852169)
That's the magic of monads: the errors are all handled for you (in an encapsulated, lossless way), and you can deal with them (if you choose) at the end of the chain, just the same as promises (because promises are a monad).
Re:JavaScript in 2015 on Wednesday January 07, 2015 @11:10AM (#8851305)
This:

    images <- get "http://example.com/images.json"
is objectively easier to reason about than:

    var images;
    get("http://example.com/images.json", (err, resp) =>
        if err throw err;
        images = resp;
even though the former might be internally implemented as the latter.

In addition, the former doesn't give the programmer the 'opportunity' to cause a race-condition, and encapsulates the failure entirely for you (automatically and defaultly); If `images` ends up erroring, and you use it again, then it'll short-circuit without crash, very similar to `then()`.

Re:JavaScript in 2015 on Wednesday January 07, 2015 @10:08AM (#8850842)
What's interesting is that all of the 'niceness' seen is the result of a switch to the functional style.

Excluding the singleton class (which could have been a single function itself), you've got your map/filters in the gif processing, and encapsulation of async activities[0] through monads via promises.

Seems like JavaScript got good when it started embracing what functional programmers have been drowned out saying for years.

Looking good indeed.

[0] Async actions as a language-level construct, as opposed to a syntactic abstraction have always been A Bad Idea. Promises should have always been the default, and manually writing callbacks should have never been a thing.

Re:Announcing Internet Explorer Developer Channel on Monday June 16, 2014 @02:32PM (#7900651)
Correct me if I'm wrong, but isn't all of this openness a result of Microsoft realizing it's loosing, and trying to win back market share by niceing up to OSS developers?
Re:Downloading Software Safely Is Nearly Impossible on Monday March 03, 2014 @01:58PM (#7335615)
Is there actually a legitimate reason that the MIT PGP server doesn't have HTTPS?
Re:Ask PG: Is HN Expired Link Eventual Fix Planned? on Monday January 13, 2014 @12:27AM (#7049086)
If it's that trivial, a lot of us would be happy for such a fix; is there any particular limitation as to why it hasn't been done?
Re:Join the Compiler Creation Club on Monday November 25, 2013 @02:43PM (#6796397)
Thank you for the recommendation!
Re:Join the Compiler Creation Club on Monday November 25, 2013 @02:07PM (#6796157)
Most "tutorials" I've seen as of late (including this one) seem to walk through creating the grammar, and then just hand wave the actual creation of the AST (and the rest of the steps) to "yacc magic" or some other friends.

I would not call that building a compiler.

Are there any modern tutorials/references of hand-generating the grammar, hand-coding the parser, and hand-coding whatever comes next (because I have no idea, thanks to these new-age tutorials) - without a toolchain, so that the entire process can be seen from start to finish?

Re:JSFuck – Write any JavaScript with 6 Characters: []()!+ on Friday September 13, 2013 @01:20PM (#6381786)
Here's an article [0] explaining more about how this works from the author of Hieroglyphy.

[0] - http://patriciopalladino.com/blog/2012/08/09/non-alphanumeri...

Re:Unix Commands I Wish I’d Discovered Years Earlier on Tuesday September 10, 2013 @12:34PM (#6361129)
`mdfind' in non-Mac UNIXs is spelled `locate' (and the corresponding `updatedb' updates the indexing db, obviously (although you don't have to do this often, as it runs as a cron job)).
Re:What Makes Employees Work Harder: Punishment or Pampering? on Tuesday August 27, 2013 @03:39PM (#6285727)
This was Felixge - former core Node.js developer - with his pull request hack [0].

[0] http://felixge.de/2013/03/11/the-pull-request-hack.html

Re:Python quirks on Friday July 12, 2013 @01:16PM (#6033759)
Rather the dict is bound during "compile" time, and not at each individual invocation (which would be much better, IMO). And during each invocation, it doesn't get re-bound.
Re:Turing tarpit on Saturday May 18, 2013 @12:33PM (#5729462)
Could it be something like brainfuck[0]?

[0] - http://esolangs.org/wiki/brainfuck

Re:Obfuscated C Code Contest 2006. Please explain sykes2.c on Wednesday April 10, 2013 @12:11PM (#5526030)
What really irks me is that this question [1], asking word-for-word the same question for a different year entry, that was posted two days later was closed as "too localized" and has -10 points, while this one has +452.

Stackoverflow has serious problems.

[1] http://stackoverflow.com/questions/15429479/obfuscated-c-cod...

Re:Vim Creep on Thursday July 12, 2012 @03:07PM (#4236130)
Also feels good to have vim bindings inside of emacs using evil (http://www.emacswiki.org/emacs/Evil).