602 karma · joined June 4, 2013
Excuse me for not accepting the pseudo-science weasel word "toxic". Vitamin C is toxic at certain levels. If you do not bring in more specifics, then what you are saying is meaningless. Just saying "I choose to reserve judgement, but have a gut feeling that it will be shown to be more harmful than cigarettes" is about as far as strong a claim you can make based on the evidence you have presented.
I searched through some old archives and found a scanned in PDF of the algorithm I wanted to implement from a late 60s fortran implementation. I converted it to node.js and Presto! The thing takes the exact same inputs, gives the exact same outputs, and does it all in... 35 milliseconds.
With the complexity of the algorithm and size of the dataset I am pretty sure it would have taken a mainframe the size of a warehouse and weeks to compute back then, but it showed me that the underlying data structures and mathematics have not changed in the least.
I have always tried to take it to heart that "we stand on the shoulders of giants" and all that, but this was really a turning point for me over the last few weeks, that many of the greats from the past would make us all look like morons if they were around today.
There are implementations of this algorithm in C, C++, Java, Python, Javascript, and probably others, but they are all at least an order of magnitude slower than the one that came out back then, given the same modern hardware, even in a language that is not exactly known for its computational prowess.
1) The approach has been tried countless times before and failed.
2) Programmers don't need code abstracted away. Text is great for telling a machine what to do. The real pain point is in linking pieces of relevant text, something that OOP does pretty successfully, but still leaves some room for improvement.
3) Nobody has 25 feet of screen space to see an entire program on, and scrolling around over giant flows is a huge PITA.
4) Attempts to solve the screen real estate issues through collapsable nesting of flow paths usually lead the same incomprehensible rat's nests of logic that regular old code does.
5) Business people don't want to code, despite their fantasies of kicking all the expensive programmers to the curb. Computers usually do exactly what you tell them to, and talented programmers are different than your typical business people in that they have a knack for taking high level requirements and turning them into highly complex, low level implementations. Someone who has no interest in this sort of work will ever be any good at it IMHO.
6) Building flows requires 99% of the implementation to already be complete. Stringing together prebuilt modules with if/thens is not that difficult or unreadable in textual code anyway.
callback hell -- 1) Define your callback functions instead of passing anonymous functions everywhere. 2) Use a control flow library like async. https://npmjs.org/package/async This will greatly help in complex scenarios and the "waterfall" mode is particularly useful to accomplish something similar to chaining where values flow through multiple functions. Callback hell is not really an issue for most people after looking into these two things.
data manipulation -- https://npmjs.org/package/lodash lodash is a fast functional utility library that makes it much easier to do the everyday data manipulation tasks. I pretty much assume this will be a dependency whenever I start a non-trivial project now.
lack of standards -- Most people who really like node.js see this as a feature not a bug. This definitely drives away many people, but the intention is to promote as much choice as possible. Node.js people tend to be obsessed with choice and modularity. This is not meant as "you should think this way too" type explanation, but just a rough description of how the community is, good or bad. That being said, there are some standards out there. For example Felix's style guide is followed pretty well throughout the community (with a couple notable exceptions such as some of TJ Holowaychuk's stuff) http://nodeguide.com/style.html.
mocha output -- It appears you have your reporter option set to "spec". This is a great reporter for visualizing a set of features, but for integration with something like Jenkins, I would recommend "tap" instead. It is also pretty trivial to write your own reporter, and then you can get whatever type of output you want. https://github.com/visionmedia/mocha/wiki/Third-party-report...
mocha integration testing -- I agree that the example you showed was more of an integration test than a unit test. Mocha is not really doing anything to discourage unit testing though, and I would note that integration tests can be valuable. If it were me, I would tend to have my unit tests working against the actual module, instead of an endpoint, which is kind of sloppy.
I hope that helps though :) I know it is often frustrating coming into a new language ecosystem, especially a "friendly-anarchy" oriented one like node.js.
Q:
Should return 3 for this test case
x = add(1, 2) assert.equals(x, 3)
A:
function add(a, b){ return 3 }