Nicolás Bevacqua writes about JavaScript, ES6, modules, and browser internals, and also runs a weekly newsletter.
Commenters call the articles excellent and the newsletter consistent and high quality, though one says the emphasis in some posts adds noise.
Question for JIT experts: JS and Python are extremely hard to optimize because they both allow redefining anything at any time, yet V8 crushes Python by an order of magnitude in many benchmarks[1]:
All times in seconds (lower is better)
benchmark Node.js Python 3 Py takes x times longer
==================================================================
regex-redux 5.06 1.34 ** Py3 is faster (PCRE C)
pidigits 1.14 1.16 0.02
reverse-complement 2.59 6.62 2.56
k-nucleotide 15.84 46.31 2.92
binary-trees 7.13 44.70 6.27
fasta 1.91 36.90 19.3
fannkuch-redux 11.31 341.45 30.19 (wut?)
mandelbrot 4.04 177.35 43.9 (srsly?)
n-body 8.42 541.34 64.3 (no numpy fortran cheat?)
spectral-norm 1.67 112.97 67.65 (Python for Science[TM])
(If Python is allowed to call fast C code (PCRE) for regex-redux, I don't see why Python shouldn't be allowed to call fast Fortran BLAS/etc for n-body, but rules are rules, I guess. V8 doesn't cheat at spectral-norm, it's 100% legit JS.)
Both ecosystems have billions invested by corporations worth trillions; bottomless money exists to make Python faster. So why isn't Python faster?
V8's tactics include dynamically watching which loops/calls get run more than (say) 10,000 times and then speculatively…
`feross-standard` is much less popular than `eslint-airbnb`, and it faces a struggle being adopted because it enforces some very unpopular choices.
Notably, it uses a "no semicolon" style which is used by around 11% of JS devs[1] and is always capable of igniting a heated argument, but it also has some other questionable choices: For example, it enforces spaces after function names (eg, "function valid (size, name) {/.../}" versus "function invalid(size, name) {/.../}"), which no other style guide or linting rules agrees with.
The point of posts like OP's is, I think, to advocate people standardize on the best tools, or when multiple tools are equally good, the most popular ones. `eslint-airbnb` is at least as good, and much more popular by basically any metric (eg, the `airbnb/javascript` repo has 31k stars, the `feross\standard` repo has 4k stars, etc.). To the extent that there is (or should be) a standard for linter rules, I think it's airbnb's.
[1]: https://ponyfoo.com/articles/javascript-developer-survey-results
SEEKING WORK. Remote front-end specialist.
Front-end specialist with 6+ years of experience, currently focused on all things JavaScript and a full-stack Node.js developer.
I enjoy writing code in small modules. I love working with ES6, architecting Angular and Backbone apps, and helping out with React and performance. I'm a prolific open-source developer and I've published hundreds of small modules.
Location: Buenos Aires, Argentina (GMT -3)
Technologies: Node.js, JavaScript, (Angular, Backbone, React, Open-Source Modules, etc), CSS, all things web
GitHub: https://github.com/bevacqua
Blog: https://ponyfoo.com
Resume: http://careers.stackoverflow.com/bevacqua
JavaScript Application Design (a book I wrote): https://ponyfoo.com/books/javascript-application-design
You can reach me at hire@ponyfoo.com
> JS is not parallelized
https://johnresig.com/blog/web-workers/
https://ponyfoo.com/articles/understanding-javascript-async-await
> Python is also compiled to a bytecode before interpretation; were still don't call it a compiled language.
https://softwareengineering.stackexchange.com/questions/24558/is-python-interpreted-or-compiled
> macros aren't significantly faster
> you can always precompile your abstraction on program load at the expense of slower start times
http://www.ilikebigbits.com/blog/2015/12/6/the-fastest-code-is-the-code-that-never-runs
> How can I ask it what type a function returns or what types it's arguments should take?
http://www.braveclojure.com/core-functions-in-depth/
FWIW the clean code approach led me to this pattern which has allowed me to build some seriously complex systems in JS/Node: https://ponyfoo.com/articles/action-pattern-clean-obvious-testable-code.
I agree with the sentiment that you don't want to over abstract, but Bob doesn't suggest that (as far as I know). He suggests extract till you drop, meaning simplify your functions down to doing one thing and one thing only and then compose them together.
Hands down, one of the best bits I learned from Bob was the "your code should read like well-written prose." That has enabled me to write some seriously easy to maintain code.
> But there is only one type of number in javascript. Everything is just a double(BigInt aside).
There is nothing stopping JS engines from trying to infer when a number is only an integer and optimize for that. In fact, that's what Small Integer (SMI) optimizations are all about[0].
It's just that |0 isn't really able to guarantee that our number value is the type of SMI that V8 optimizes for (since the V8 SMIs are 31 bits, and bitmasking operations only guarantee 32 bit integers)
https://ponyfoo.com/articles/an-introduction-to-speculative-optimization-in-v8