HNHacker News
TopNewBestAskShowJobs

grayrest

1,959 karma · joined May 10, 2009

front end guy
submissionscomments
grayrest··on Ask HN: Is jQuery still a thing?
I hope you don't take my comment as too much of an insult to your work. I consider the hallmarks of the current generation of frameworks to be component composition, framework based change synchronization (KVO, diffing, dirty checking), and the avoidance of DOM interaction (jsx, templates). Not being on the newest trend doesn't automatically make something bad and it's clear that you and your team put significant effort into your framework so I'll have to do a much more thorough investigation before I have a real opinion on it.
grayrest··on Ask HN: Is jQuery still a thing?
I'd never heard of this library and I spend a couple hours a day reading developer news so I wouldn't call this popular.

I'd also argue that this as a current generation framework. I only did a brief skim but the patterns remind me of a Knockout or Enyo codebase with data binding between components doing explicit dom manipulation. The contributors tab shows a 2014 start but I'd have guessed a 2010-2011 start from looking at the code.

grayrest··on Ask HN: Is jQuery still a thing?
The only use case for jQuery is if you want virtually all your logic and rendering to be server side and only want to use javascript for toggles, form checking, or other jQuery sprinkles. I wouldn't choose this but if someone did and picked jQuery I wouldn't question the jQuery part much.

If you're writing more than a couple hundred lines of javascript, the jQuery model of putting your application state in the DOM is inferior to pretty much any other application model. There's a reason everybody went to Backbone and then to the component libraries. Separating your model and rendering concerns and delegating the latter to your framework roughly halves the amount of code you need to write.

grayrest··on Ask HN: Is jQuery still a thing?
No popular current generation framework relies on jQuery. The most recent one I can come up with is Angular 1's reliance on their jQlite micro-library but would use the full jQuery if it was on the page.
grayrest··on Seven years of Go
> I also spend/waste a lot of time, probably the most time in total, tracking down complex issues that got past the type system and existing tests and code reviews

Nobody will argue against you on this. The static/dynamic debate, as I understand it, is about whether typing and design constraints typing impose are worth the reduction in simple issues. Reasonable people can choose both and my personal take is that I think types are worth it given a good type system for a long-maintained project. You get more people coming on board and I think types are most useful in that situation.

generics and sum types

> how does it square with people like the author of Clojure? Is he just a god-tier outlier?

I happened to be in a group Rich joined for lunch at the last Clojure Conj and we talked about typed functional languages. The short story is that he doesn't think types are worth the tradeoffs. At the time Clojure had just introduced transients and he mentioned the numerous typed functional language blog posts about the feature and that most were incorrectly typed. He gives specific examples at the end of Simple Made Easy and reiterated many of them those during the discussion.

I think we'd agree that, libraries and architecture matter more than language but I do think language influences the abstractions the library can provide. My post wasn't really meant to argue the superiority of types in all situations but rather a specific response to the sentiment of "why do people always bring up typos when I never run into them"?

grayrest··on Seven years of Go
> I understand but I can't really agree since things like typos and type fails pretty much never happen to me, at least in production.

The typos / type fail comments are shorthand for the real complaint, which is that a long-maintained large dynamic language codebase requires continuous vigilance. I've worked in dynamic languages for most of my career (Python, JS, Clojure) and typos/type-fails are pretty rare but if you haven't spent a half day tracking down a bug that turned out to be one of these at some point in your career, I'd be quite surprised. The breakdown comes when someone not familiar with the code makes a change without fully considering the consequences and it goes through something that nil-puns so the error isn't detected immediately.

My experience with people who are really against type systems is that they haven't run into a language with a good type system. I'm a fan of the gradually typed JS dialects (Flow more than Typescript) since you get the quick hacking at the beginning combined with compiler-enforced vigilance once you switch over to maintenance mode. Type-inferred languages are also nice, particularly fully type-inferred languages. I think F# [0] is both terse and accessible, for example.

[0] https://fsharpforfunandprofit.com/why-use-fsharp/

grayrest··on Seven years of Go
> Yes, the first couple of weeks were a bit rough while I was getting used to the ownership system, but since then I have been progressing at a relatively quick pace.

This is the very definition of "high barrier to entry". Clearly it wasn't too much of a barrier for you but I can see how it'd be an issue for people. I'm expecting editor support and wider adoption (differently constructed tutorials, SO answers) to lower this barrier. I think Rust has the potential to be very popular, particularly if the reputation shifts from "high barrier to entry" to "slightly harder to get started but fewer problems in production".

grayrest··on Elm is Wrong
> it got me to start thinking about what I wanted in a functional language that compiles into JS

I investigated Elm just after the 0.17 release, decided I was fine with it but didn't really love the language. I've since moved to investigating F# and the Fable compiler. While it's unlikely that someone who prefers Purescript would prefer an ML derivative, I feel I should mention it for other people reading the thread from the front page and prefer having imperative escape hatches.

The Ocaml to JS compilers (Bucklescript/js_of_ocaml) also produce nice js output but my background with Clojure has left me enjoying the benefits of being a functional language that's part of a larger ecosystem and I'm comfortable enough with .net core to be willing to treat F# as a viable language outside windows.

grayrest··on Rust Actor Library: First Assorted Thoughts
> The Rust ecosystem is so new that it feels a bit like we're in the Wild West.

This is pretty normal for an ecosystem at Rust's stage of development. Ecosystem development is always something of a monkeys-on-typewriters effect and if you continuously have major disruptions in the language, you wind up with Javascript Fatigue.

What I'm particularly impressed with in Rust is the core team's leadership. I'm looking forward to Tokio because I think it's likely to have Rails-like dominance over the ecosystem. This is exciting because it gets us monkeys all pointed in the same direction instead of writing another postgresql client because existing ones don't support the current flavor of event loop that I'm using. Getting to the point where we can snap a bunch of pieces together and have a network service is huge for office advocacy. I think it was a key factor in Ruby's wins over the more established Python web community when observing from the Python side.

I'm also pleased that the Rust core team is focused on my pet areas of improvement: editor support, impl Trait, and async network services.

grayrest··on TypeScript 2.1 RC: Better Inference, Async Functions, and More
Does the new inference allow incremental construction of objects?

    interface Color {
        isRed: boolean,
        name: string
    }

    function example(): Color {
        let x = {};
        x.isRed = false;
        x.name = "Cerulean";
        return x;
    }
Obviously you'd just build the object at once for something this simple, but for larger/more complex objects it becomes trickier.
grayrest··on Rust Actor Library: First Assorted Thoughts
> I've been looking at a bunch of the libraries that expand upon mio, but this is the first time I've heard of `rotor`.

The current state of affairs is somewhat up in the air because Alex Crichton (futures) and Carl Lerche (mio) are working on the Tokio project [0][1], which is likely to become the most favored way to do things on top of mio.

[0] https://github.com/tokio-rs/ [1] https://medium.com/@carllerche/announcing-tokio-df6bb4ddb34

grayrest··on Parsing JSON is a Minefield
It got supplanted by Transit [0] as an interchange format. Both are only really used within the Clojure community. I use Transit for internal-facing APIs.

[0] https://github.com/cognitect/transit-format

grayrest··on Ask HN: What cool development languages/tools changed your career?
> Are there any enormous advantages to using Vim vs. a Vim emulator?

There are lots of vim commands and most emulators do not implement the entire set. Macros, register recording, text objects, correct repeat, recursive keymappings, bookmarks/jump history, and ex mode are the most frequent casualties. Because everybody has a different subset of vim commands they use an emulator that works fine for one person will be unacceptable for others. I personally can't stand any of the VS Code vim plugins, which is a shame because I really would prefer to migrate from vim to vscode for the rest of the vscode ecosystem. The best emulator I've used is Evil (the emacs one, install spacemacs if you want to give it a go) and I find the InteilliJ and Atom emulators to be okay.

There's also plugins that are almost never carried over to emulators (though surround is in Evil):

EasyMotion [0] - Lets you jump around in complicated ways. I use the following config to be able to jump around in a minimal number of keystrokes:

    let g:EasyMotion_keys = 'jfkdlghtyuievnbsa'
    let g:EasyMotion_smartcase = 1

    nmap <space> <Plug>(easymotion-bd-W)
    nmap <S-space> <Plug>(easymotion-s)

Surround [1] - Lets you surround text objects and delete surrounding stuff easily. I use the following to save keystrokes, since I find `sw"` considerably easier to type than `ysiw"`.

    nmap s      ysi
    nmap S      ysa
    nmap s$     ys$
    nmap sv     gvs
[0] https://github.com/easymotion/vim-easymotion [1] https://github.com/tpope/vim-surround
grayrest··on Ask HN: What cool development languages/tools changed your career?
> I don't know exactly how fragile that magic is.

It's reasonably robust for the HTML/JS part. The majority of current generation Javascript frameworks are built on similar techniques and the main thing Elm adds is the type system and guaranteed purity.

For CSS, all bets are off. I expect Elm to put more effort into styling when scoped CSS becomes widely deployed enough to rely on.

grayrest··on Server APIs Project
Last time I messed with Swift, I was using a vim plugin based on SourceKitten[1] but it was a couple months ago over a weekend and I honestly can't remember how well it worked. If you were inclined, it seems like it'd get you most of the way to a language server.

[1] https://github.com/jpsim/SourceKitten

grayrest··on Ask HN: What cool development languages/tools changed your career?
Rust has been great. Not so much for the language itself but rather as a vehicle to explore the layers under the language runtimes I've been using for most of my career.

It hasn't really changed my perspective on programming. I haven't been doing it long enough to have it transform my career. As an answer to the OP, it's not a particularly good one for me.

grayrest··on Ask HN: What cool development languages/tools changed your career?
Different poster, but I have an opinion.

I think that if you're going to do React/Redux, your life would be easier in Elm.

I'm a full time Clojure/Clojurescript dev and from my perspective, the main thing Elm is lacking is Protocols (in Clojure/Swift, Traits in Rust). I know Evan has been pushing back on it because it adds complexity to learning the language and you can get by without them, but I miss them. I could quibble about other things but there's nothing I strongly dislike. From an adoption perspective, I think a focus on tooling would help a lot. There was a talk at elm-conf where a refactoring suite was written as a chat bot. Ditching the chat bot part and building a language server [1] would make it much easier to pitch the language.

[1] https://github.com/Microsoft/language-server-protocol

For a non-web developer looking to transition into web dev, the main weakness of Elm is that the community is small so you basically have to build your components yourself. This tends to be challenging for experienced programmers coming from other languages because CSS has no abstractive power at all and the traditional layout techniques are incredibly unintuitive. You'll probably have the most success using flexbox everywhere. The community is friendly and I think Evan does a pretty good job leading it. I've pushed a number of younger developers at js meetups to pick it up and they've reported back with positive impressions. Of the compile to js langauges I know, I'd pick Elm as the most likely to succeed.

Overall, I like Elm and am happy with it's progress. I don't think it's ready for unqualified adoption, as you'll be doing a lot of library building you wouldn't need in more mature ecosystems and I'm not completely confident it's on the path to great success. I wouldn't push the language in a workplace at this point. By comparison, I would push Rust. You're in largely the same position in both languages in terms of writing libraries but I think Rust has hit critical mass.

grayrest··on HN comments are underrated
I've been using React as my primary platform for 3 years now and I'd be interested in novel React criticism.

I believe the most important thing when developing software is managing state. The best cross-language technique I know for reducing state is to prefer functional approaches, lock down mutability wherever possible, and prefer persistent datastructures. These techniques cause problems for truly high performance code (HAMT-like datastructures have pointer contention at the head) but very little of the code I write is that performance sensitive.

From the UI side, I believe the reactive programming model has won out and I'm unaware of any medium to large javascript frameworks that don't have some sort of change detection/propagation system. Polymer is the most dom manipulation oriented current gen framework I know about and it still makes substantial use of observables and bound properties.

Put together, I currently believe that the virtual dom diffing approach on persistent datastructures is the best general purpose starting point for building a user interface. The biggest arguments against the approach I've heard are that it's memory inefficient since the entire output virtual DOM has to be retained for diffing and that the diffing process itself is less efficient than direct change propagation using observables. While both valid complaints, I have not found them useful complaints.

For memory, the target market for the apps I've written has yet to include mobile devices that are memory constrained to the point that virtual DOM size is a significant factor and if they did, I'd be inclined to try something like incremental dom before abandoning the pattern.

For performance, the combination persistent datastructures guiding the diff substantially reduces the amount of diffing overhead. I've been able to hit 60 fps on a randomly-update 10k DOM node stress test using Inferno and a custom HAMT implementation on a 2012 Macbook Air and ~25 fps on my 2nd generation Moto X. I consider this good enough but I can see how people who are more focused on mobile and in particular emerging mobile markets would have different opinions.

My counter to these arguments is that I find the performance characteristics of the virtual DOM easy to reason about and performance being primarily driven by the output size has allowed me to take input datasets that I would not have even considered on observable systems. An example: I put together a calendar that was supposed to be a temporary prototype, wound up getting put into production (semi-predictably), and we had the events input grow to 9MB of gzipped JSON (two orders of magnitude more than I expected) before it got replaced. Load time was terrible but once it was up, latency for all actions was ~30ms.

As for React itself, I find it acceptable. Its artificial event system made more sense when it was made but I think it's more overhead than value these days. I've never liked setState and never used it in a production app. The main reason to stick with it over a second-gen vdom library like Inferno is network effects. I tend to not use a lot of third party code so I expect to switch to an alternative vdom at some point in the not too distant future.

grayrest··on Node v6.9.0 (LTS)
They just had a meeting with TC39 about it. Here's the writeup from the node side:

https://hackernoon.com/node-js-tc-39-and-modules-a1118aecf95...

grayrest··on Yarn – A new package manager for JavaScript
> Are people really making projects with dozens (hundreds? more?) of dependent libraries?

Yes.

> Are there aspects of the language or runtime that reward multiple layers of configuration management?

A significant fraction of the node community likes to split their project into really, really small packages and treat them as if they're independent even if they come from the same source repo and tend to get used together. As an example, the popular collection processing library Lodash publishes a package for each method and people actually do depend on individual methods.

There are two major rationales for this. The first is that JS is a dynamic language and in dynamic languages, smaller chunks of code are easier to reason about than larger ones. The second is that the JS community as a whole cares more about artifact size than pretty much any other community. Having smaller packages allows you to produce a smaller payload without having to rely on techniques like tree shaking.

I find micro packages maddening but people give me their code for free and it mostly works so I don't complain about it that much.

grayrest··on Type-Safe Unions in C++ and Rust
There are lots of languages in the world. The majority of them are written by a single person for themselves or (if there's funding involved) a small group of people who deeply understand the compiler. These are either research, hobbyist, or company languages depending on the context of the author. They exist to explore a particular idea or solve a specific problem and don't aspire to be widely used.

If you hear the term used disparagingly it's because they tend to have issues you generally wouldn't want to put up with when you're on the clock: compiler bugs, lack of error messages, large missing pieces in the standard lib, spectacularly bad performance, etc because those weren't the problems the language was meant to explore.

grayrest··on Fantasy Land 1.0
If you're interested in fantasy land, you might also be interested in:

https://github.com/rpominov/static-land

https://github.com/gcanti/flow-static-land

grayrest··on A Critique of Rust's `std::collections`
This showed up on r/rust last night and there's a lot of discussion there:

https://www.reddit.com/r/rust/comments/52grcl/rusts_stdcolle...

grayrest··on Blazing Fast HTML: Elm vs. React vs. Angular vs. Ember
React has never been about speed (if you look at the official dev posts, speed is never listed as a top priority) but rather about not being slow (sCU check and whatnot). It's the slowest vdom implementation I know of, but it's fast enough and the network effects from being the biggest make it good enough. If you're interested in faster vdoms then check out inferno (fast), snabbdom (simple), mithril (compact), or domvm (flexible).
grayrest··on Writing a JPEG Decoder in Rust – Part 2: Implementation I
Since Rust people are reading this.

I find myself wanting to walk an iterator pairwise regularly for stuff like this and I'm using:

    for (cur, next) in (& vec).iter().zip(vec.iter().skip(1)) {
        encoded_data.push(cur);
        if cur == 0xff && next == 0x00 {
            // ...
        }
    }
Is there a better way to write this? What I'd really like is the equivalent to Clojure's partition[1]. I know that the stdlib has windows `(partition n (dec n) seq)` and chunks `(partition n n seq)` implemented on slices but I usually want this on iterators for the lookahead-like behavior shown here.

[1] https://clojuredocs.org/clojure.core/partition

grayrest··on Zero-cost futures in Rust
The construct wouldn't be valid as written for the reasons you mention. The blog post for this discussion glosses over the details by writing `impl Future<Item = Bool>` instead of the concrete type a future would have to have in Rust today.

I'm not an expert but one of the ongoing dicussions in the impl Trait RFC is where the construct can show up. The preliminary version can only appear as a return type from a function where the compiler can always determine the exact details at compile time depending on the chain of calls. I believe typing out the entire type of the future in the struct would work but, again, I only somewhat know my way around the language.

grayrest··on How to use Elm at work
I didn't remember this being too bad. I just checked with Elm 0.17 using the tutorial's [1] nesting/3-gif-pair.elm as the main. Size is 209k out of elm-make, 60k minified (closure compiler advanced), and 19k gzipped. I wouldn't use it for validating a form field but the size seems completely reasonable for a language runtime.

[1] https://github.com/evancz/elm-architecture-tutorial

grayrest··on Scalability, but at what cost? (2015)
If you're interested in reading more, Frank moved his blog to a github repo:

https://github.com/frankmcsherry/blog

grayrest··on IDE for building React Native apps is now free and open source
They're using the same core library and conceptually work the same way but there's no no out-of-the-box unified widgets allowing you to share view code between both. So you can share your controllers, model, viewmodel, and higher order data binding components but you'll be rewriting your views.
grayrest··on Bootcamps vs. College
None of the things you mention are part of the Computer Science academic discipline, which is what they teach. Computer Science undergrad generally covers algorithms, data structures, parsing/compiling, operating systems, discrete mathematics, and linear algebra.
← PreviousPage 6 of 23Next →