Video: https://www.youtube.com/watch?v=NPB34lDZj3E
Programming languages are full of clutter because programmers are hoarders.
"POST-javascript? Why not PUT- or PATCH-javascript?"
The HTTP verbs do similar things but have possible edge cases.
That's not helpful, that's clutter.
money quote from this talk:
When confronted with two or more ways of doing the same thing, keep the one you can't get rid of.
"We can't get rid of Space, so the one that has to go is TAB.
let
has block scope which makes it less confusing to the Java guys (his joke,
not mine), so use let
.
const
means you can't reassign the variable which is better, so given the choice,
use const
over let
.
Keep double quotes. "and use single quotes for something's apostrophe."
These are "bottom" values. Every language should have one. And only one.
Keep undefined
, ditch null
.
The null
implementation in JavaScript is broken, should be an object that contains
nothing, and any property access on null
should return null
instead of throwing
an error.
This portion is funny. Pure functions mean immutability, no side-effects, etc. Things to be removed in order to prohibit mutation include:
Date
Math.random
delete
Array.splice
Array.sort
RegExp.exec
- assignment
var
let
- the
for
loop - that also meansfor in
andfor of
- user interaction
- networks...
In other words, the universe is mutating. So keep pure where you can, but you need to account for the changing input (an account balance cannot be a constant for all time, e.g.).
This feature is a mistake (!) - "weird syntax, unproductive, unnecessary" - just need to understand how a JavaScript function can return another function.
Factory is a well-understood pattern:
function factory(...) {
// state variables
return function generator() {
// update state, then...
return value
}
}
function element(array) {
let i = 0;
return function generator() {
if (i < array.length) {
let value = array[i];
i += 1;
return value;
}
}
}
Due to ES6 rest parameter syntax, ...rest
, callbacks should now be in first position.
Not originally for asynchronicity. We can do better.
mentions RQ
project - seems to be deprecated in favor of parseq
project
Syntax is all about fashion, it's not about functionality
[ here follows a very interesting look at BCPL which got the if
statement right ]
if a = 0 { a := b; }
But how about algol-68 if-fi plus python significant whitespace?
if a = 0
a : b
fi
No more curly braces, semi-colons, use colons for assignment, etc...
In the JVM, the finally
clause is a symptom, that Java did not originally have free-standing functions. To get around this, the Exception
system was overloaded to get around the design error in the Type system (catch
). Result: overly complicated control flows - AKA goto
. In JavaScript, try {} catch(e) {}
is enough.
Should have returned null
or undefined
rather than an int
.
Binary floating point cannot accurately represent decimal expressions. And that breaks associativity.
Proposal: Decimal64 number type: Number = coefficient (56-bit) * 10 (raised to the exponent)
See https://github.com/douglascrockford/DEC64
Undefined? NaN? 0? 1? 2?
For theoretical mathematical purposes, 'not defined' or 'not allowed' or 'Not a Number' makes sense, but for business purposes ('how much profit did we make on the items we didn't sell?'), then 0
is the right answer.
NaN
! Which is part of that binary floating point spec, which punishes the wicked, slows things down for moral reasons, not for mathematical reasons.
Just return 0
and let compilation be faster, forget compilation jumps, etc.
Too restrictive. Memory constraints on the early compilers no longer apply.
Proposal:
In any function, a word may used as a language keyword (
if
) or a name (variable) but not both.
Neither. "Names with spaces" instead.
Eiffel language in any function allowed for pre-conditions and post-conditions, right in the function.
More effective than Type systems, more effective than unit tests because they're right there in the code. Should get back to that, and leave them on in production.
Make this the first requirement of the next language.
Take advantage of multiple cores, and nodes across the network. The next language should have something
like actors
(i.e., actor model), a new paradigm, not Fortan but with new syntax.
Be careful out there because the web is cluttered and full of errors.