multimethod.js

Languages and libraries

javascript library

SHOW HN2011

49points
10comments
#251of 1,097 in 2011
Top 23%of 2011 by points

How HN took it

CuriousMostly questions and neutral comments

2 positive, 3 neutral or asking, 0 mixed, 0 critical, out of 5 comments about the project. Thread score +0.23.

Design: 1 for, 0 againstIdea: 1 for, 0 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Lightweight alternative to switches and if/else chains; source is short and readable

    From 1 comment
    • I like this very much. It's like a lightweight dispatcher/router/alternative to tons of switches/if & elses. And also that the source is very short and readable.
      hyperturtle on HN
  • Liked the approach

    From 1 comment
    • Nice stuff, I liked the approach. But what is the benchmark for this kind of structure against regular JS workflow? I guess it will be slower, but how much ?
      cfontes on HN

Objections

  • Likely slower than native switch statements or prototype lookups

    From 2 comments
    • Nice stuff, I liked the approach. But what is the benchmark for this kind of structure against regular JS workflow? I guess it will be slower, but how much ?
      cfontes on HN
    • Good question. Performance will depend on a number of factors, such as how complex your dispatch function is, how complex your dispatched values and match values are (deep…
      KrisJordan on HN

Requests

  • Benchmarks against regular JavaScript workflow

    From 1 comment
    • Nice stuff, I liked the approach. But what is the benchmark for this kind of structure against regular JS workflow? I guess it will be slower, but how much ?
      cfontes on HN
  • A good concrete use-case for dynamic dispatch

    From 1 comment
    • Could you comment on a good use-case for this? A time when it would actually be better to construct a switch block dynamically vs all at once.
      gerggerg on HN

Questions

  • How much slower is it than plain JavaScript?

    From 1 comment
    • Nice stuff, I liked the approach. But what is the benchmark for this kind of structure against regular JS workflow? I guess it will be slower, but how much ?
      cfontes on HN

Alternatives named

  • Switch statements and prototype chain lookups

    From 1 comment
    • Good question. Performance will depend on a number of factors, such as how complex your dispatch function is, how complex your dispatched values and match values are (deep…
      KrisJordan on HN
  • patterned-function (brian-c's similar project)

    From 1 comment
    • Neat! I made something (I think) similar a while back, also inspired by Clojure. Mine's more of a proof-of-concept, as I have zero Clojure experience outside some very casual…
      brian_c on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/3360769)