Live data from Hacker News

Algorithms and Data Structures Explained and Implemented in JavaScript

github.com

11–20 of 45 posts

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#12

I like it! Something I've been thinking about recently is using ES6 proxies to visualize algorithms like this. Lay out the arrays and objects as blocks on a canvas, and highlight the blocks as the algorithm reads / writes to the corresponding slots of the arrays / objects.

This kind of visualizations?

https://visualgo.net/en

https://www.cs.usfca.edu/~galles/visualization/Algorithms.ht...

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#13

This repo is beautiful. The README is detailed and clear, and the contents seem pretty exhaustive. As a native JS guy I'm especially excited to check out the implementation of non-tree graphs! Having said all that: The algorithms I've had to tackle at work tend to be fairly trivial or total one-offs involving scheduling events in human time. How much algorithmic work do you other JS folks end up doing?

This is a really great repo!

> How much algorithmic work do you other JS folks end up doing?

I find JS to be the ideal language to implement an algorithm, despite its quirks. Why?

1. Because JS has syntax similar to most other class based languages, or can be used in ways that match functional languages, even if the syntax is different.

2. It is the lingua-franca of the web, so it is easy for others to also understand, use as a reference implementation (into other languages), or literally visualize it in the browser.

3. Along the lines of visualization, browser's have some of the best and state-of-the-art live debugging tools. So often it is easier to implement and test in JS (despite lack of types) than other languages.

4. For better or for worse, a pure JS implementation (no NPM or other packages) has very little standard library tooling, so you are forced to write some pretty low level logic that you might not otherwise write in real low level languages simply because they have good built-in standard libraries.

We also took the time to write some algorithm and explainer articles, but they are largely focused at the high-level conceptual layer, and explaining for kids:

- GIT explained for kids http://gun.js.org/explainers/school/class.html

- Stream sorting interactive explainer http://gun.js.org/explainers/basketball/basketball.html

- Cartoon cryptography http://gun.js.org/explainers/data/security.html

Most all the work we do is algorithmic, not app focused. But that is unusual for JS devs.

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#14

This repo is beautiful. The README is detailed and clear, and the contents seem pretty exhaustive. As a native JS guy I'm especially excited to check out the implementation of non-tree graphs! Having said all that: The algorithms I've had to tackle at work tend to be fairly trivial or total one-offs involving scheduling events in human time. How much algorithmic work do you other JS folks end up doing?

> How much algorithmic work do you other JS folks end up doing? I recently built a questionnaire/form editor/builder which relies heavily on tree structures. I ended up writing a lot of tree walking code. It was the first time I've ever needed to implement interview-like questions in an actual project. I make heavy use of functional programming in Javascript, which lends itself to really clean implementations of algo…

As someone new to JS I find vanilla JS tedious for FP, what library(ies) do you use to ease this?

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#17
Along similar lines, does anyone know of something similar that includes multigraphs? (Graphs with parallel edges).

There's a python library called networkx, but it is so heavily object-oriented (multi-inheritance) as to make it impossible to get any benefit from reading the code.

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#19
post #12

I like it! Something I've been thinking about recently is using ES6 proxies to visualize algorithms like this. Lay out the arrays and objects as blocks on a canvas, and highlight the blocks as the algorithm reads / writes to the corresponding slots of the arrays / objects.

This kind of visualizations? https://visualgo.net/en https://www.cs.usfca.edu/~galles/visualization/Algorithms.ht...

https://visualgo.net/en is super cool! Thanks for posting it

Re: Algorithms and Data Structures Explained and Implemented in JavaScript

#20

Earlier quoted context omitted.

> How much algorithmic work do you other JS folks end up doing? I recently built a questionnaire/form editor/builder which relies heavily on tree structures. I ended up writing a lot of tree walking code. It was the first time I've ever needed to implement interview-like questions in an actual project. I make heavy use of functional programming in Javascript, which lends itself to really clean implementations of algo…

As someone new to JS I find vanilla JS tedious for FP, what library(ies) do you use to ease this?

RamdaJS is my go-to for most new projects. Other contenders in the space include lodash/fp and Elm.
Post reply on HN