Better HN
topnewbestaskshowjobs
Log inSign up

chrisdotcode

928 karma · joined Jul 12, 2012 (14y ago) · 116 submissions

Director of lambda functions.
Submissions

comment 11y ago · link · parent

But that's the thing. It's far easier to 'program' a static HTML than any other dynamic alternative.

What people seem to not understand is that the exact same template that they are using on the client renders exactly the same on the server.

comment 11y ago · link · parent

I'm not bashing the article - I'm referring to the mindset necessary for the fact that this article even needed to be created. Server-side rendering should have always been first-class.

comment 11y ago · link · parent

I agree. This is the progressive enhancement I've talked about earlier.

Present a long, full form for JS-less users, and present it all nice-ified for those with, and send it off for server processing when you're done.

comment 11y ago · link · parent

> Progressive enhancement (beyond very small apps) is a challenge to maintain, since UI state needs to be shared between a server runtime and client runtime.

It does? Why? The server is handling the data to be rendered either way, and as I say in response to another comment, rendering the data is as simple as:

    res.end(render(template, data))
> And your comments about shitty execution of web pages and apps could apply to any shitty app. They have nothing to do with client-side JavaScript applications. I expect a better argument than "I once saw a webpage that sucked".

The argument is "you are VC-funded, and taking a 1mil+ dollars to build the Next Big (S|P)aaS. You are spending tons of money on A/B testing, designers, mockups, UI specialists, and your page does not even load for the lowest common denominator - and easiest to manage (static HTML) users of the web?"

The web was built for content-first, not flash.

comment 11y ago · link · parent

As I've said,

> The solution is very simple: render all the data on the server, and progressively enhance subsets of your app with JS, by overriding the defaults of the rendered page. It's literally like we're discovering DHTML all over again.

Client.js, rendered on the client:

render(template, data)

Server.js, rendered on the server:

render(template, data)

---

They're exactly the same. You use a templating engine library for either JS, or your server language to process the same data. What client.js should do is change things dynamically, progressively.

comment 11y ago · link · parent

There's an option for the basic HTML layout available if you have JS disabled.

That's the second-best approach. The first is using a JS-redirect to the flashy AJAX page, or just overriding all the default handlers necessary with JavaScript (remember, at this point, your content was already (supposed to be) properly rendered for you by the server).

comment 11y ago · link · parent

EDIT: Lots of downvotes for saying that there are other ways to program apps besides doing everything on the client. Render content on the server, enhance content presentation on the client.

---

I don't get it. Is this 1996? Why are people just now 'discovering' that you don't need to throw JS at an application to have it completely usable?

> All modern websites, even server-rendered ones, need JavaScript. There is just a lot of dynamic stuff you need to do that can only be done in JavaScript.

Really? Look at Linode, Amazon, or even Google (including GMail, and probably others). All of which are big names that can and do work ENTIRELY without JavaScript.

> Client-side JavaScript applications are damn fast.

Another (AJAX) HTTP request + rendering the returned data on a tiny mobile phone is faster than one HTTP request for the entire webpage and having dedicated machinery pre-render the content for you? I don't think so. He does talk about this point later on, but which is it? Client-rendered JS apps are, or aren't fast?

---

JS Hipsters offloading rendering everything to the client for absolutely no reason is the 'everything-looks-like-a-nail' or the 'everyone surfs the web like I surf the web and has my specs' problem. Worst of all, in doing so, they completely neglect actual content. You don't know how many million-dollar VC-funded company webpages I've visited that don't even have a damn tagline visible on their landing page without JavaScript enabled. <h1>s with actual content inside of them are too complicated now?

The solution is very simple: render all the data on the server, and progressively enhance subsets of your app with JS, by overriding the defaults of the rendered page. It's literally like we're discovering DHTML all over again.

98.

A complete rewrite of wiki as a single page application(c2.com ↗)

161 points · by chrisdotcode · 11y ago · 119 comments

comment 11y ago · link · parent

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.

comment 11y ago · link · parent

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).

comment 11y ago · link · parent

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()`.

comment 11y ago · link · parent

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.

comment 12y ago · link · parent

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?

comment 12y ago · link · parent

Is there actually a legitimate reason that the MIT PGP server doesn't have HTTPS?

comment 12y ago · link · parent

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?

comment 13y ago · link · parent

Thank you for the recommendation!

comment 13y ago · link · parent

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?

comment 13y ago · link · parent

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...

comment 13y ago · link · parent

`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)).

comment 13y ago · link · parent

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

comment 13y ago · link · parent

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.

112.

All Megaupload Data Has Been Deleted(theverge.com ↗)

3 points · by chrisdotcode · 13y ago · 1 comment

113.

Massive Number of Vulnerabilities Found in X.Org(lists.x.org ↗)

197 points · by chrisdotcode · 13y ago · 107 comments

comment 13y ago · link · parent

Could it be something like brainfuck[0]?

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

comment 13y ago · link · parent

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...

comment 14y ago · link · parent

Also feels good to have vim bindings inside of emacs using evil (http://www.emacswiki.org/emacs/Evil).
1234