5 ms·
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 im
by teachrdan 8y ago
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?
- chatmasta 8y ago> 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 algorithms like tree walking, e.g.: https://hastebin.com/qapawepavi.js https://hastebin.com/qapawepavi.js
- Scarbutt 8y agoAs someone new to JS I find vanilla JS tedious for FP, what library(ies) do you use to ease this?
- Rumudiez 8y agoRamdaJS is my go-to for most new projects. Other contenders in the space include lodash/fp and Elm.
- chatmasta 8y agoI have to admit I’m far from a FP guru, very little experience with true functional languages like Haskell etc. For me it’s more a question of style and applying functional paradigms when possible, eg treating functions as first class citizens, making heavy use of .bind() and passing functions as arguments. I use ES6 via Babel and actually find it to be quite expressive and powerful when used correctly. I just try to keep my functions very small with tight separation of concerns. There are lots of libraries to make JS “more functional,” as the sibling comment alludes to, but I find vanilla JS (or at least ES6) already has many of the features necessary for functional programming, as long as you make the conscious choice to use it that way.
- crooked-v 8y agoIt requires use of Babel, but you might find the function bind operator an interesting alternative to .bind(). https://babeljs.io/docs/plugins/transform-function-bind/ https://babeljs.io/docs/plugins/transform-function-bind/
- chatmasta 8y agoThat’s very cool! But I’d be hesitant to introduce something non-standard into the codebase. Sure the toolchain can handle it but I’d be worried other devs won’t immediately recognize the syntax.
- sbr464 8y agoIs it just me or does the hastebin site load almost instantly? On iOS. Was nice.
- marknadal 8y agoThis 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 http://gun.js.org/explainers/school/class.html - Stream sorting interactive explainer http://gun.js.org/explainers/basketball/basketball.html http://gun.js.org/explainers/basketball/basketball.html - Cartoon cryptography http://gun.js.org/explainers/data/security.html 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.