npm install karimsa
karim@hirefast.ca
Hiring on autopilot.
karim@hirefast.ca
Write
Parse
Compile
Run
Devs write clear code
Transform code into AST
AST transforms into machine code
Machine code is executed
karim@hirefast.ca
Write
Parse
Compile
Run
dev time
Compiled Languages
dev time
Interpreted Languages
karim@hirefast.ca
karim@hirefast.ca
bitly.com/2kJ6u79
karim@hirefast.ca
Write
Parse
Compile
Run
Parse
Compile
JS engine
karim@hirefast.ca
karim@hirefast.ca
karim@hirefast.ca
270 bytes
219 bytes
const mockStdout = []
const isTestEnv = process.env.NODE_ENV === 'test'
function sayHello(greeting, name) {
const message = `${greeting}, ${name}!`
if (isTestEnv) {
mockStdout.push(message)
} else {
console.log(message)
}
}
sayHello('Hello', 'world')
const mockStdout=[],isTestEnv=process.env.NODE_ENV==='test',sayHello=(greeting,name)=>{const message=`${greeting}, ${name}!`;if(isTestEnv){mockStdout.push(message)}else{console.log(message)}};sayHello('Hello', 'world')
karim@hirefast.ca
const a = []
const b = process.env.NODE_ENV === 'test'
function c(d, e) {
const f = `${d}, ${e}!`
if (b) {
a.push(f)
} else {
console.log(f)
}
}
c('Hello', 'world')
184 bytes (from 270 bytes)
karim@hirefast.ca
const mockStdout = []
const isTestEnv = process.env.NODE_ENV === 'test'
function sayHello(greeting, name) {
if (isTestEnv) {
mockStdout.push(`${greeting}, ${name}!`)
} else {
console.log(`${greeting}, ${name}!`)
}
}
sayHello('Hello', 'world')
259 bytes (from 270 bytes)
karim@hirefast.ca
Note: some env variables can be constant
const isTestEnv = 'production' === 'test'
const isTestEnv = process.env.NODE_ENV === 'test'
const isTestEnv = false
const mockStdout = []
const isTestEnv = false
function sayHello(greeting, name) {
if (false) {
mockStdout.push(`${greeting}, ${name}!`)
} else {
console.log(`${greeting}, ${name}!`)
}
}
sayHello('Hello', 'world')
229 bytes (from 270 bytes)
karim@hirefast.ca
const mockStdout = []
function sayHello(greeting, name) {
console.log(`${greeting}, ${name}!`)
}
sayHello('Hello', 'world')
128 bytes (from 270 bytes)
function sayHello(greeting, name) {
console.log(`${greeting}, ${name}!`)
}
sayHello('Hello', 'world')
105 bytes (from 270 bytes)
karim@hirefast.ca
270 bytes
62 bytes
const mockStdout = []
const isTestEnv = process.env.NODE_ENV === 'test'
function sayHello(greeting, name) {
const message = `${greeting}, ${name}!`
if (isTestEnv) {
mockStdout.push(message)
} else {
console.log(message)
}
}
sayHello('Hello', 'world')
function a(b,c){console.log(`${b}, ${c}!`)}a('Hello','world')
28 bytes
console.log('Hello, world!')
karim@hirefast.ca
For every 100ms decrease in homepage load speed, Mobify's customer base saw a 1.11% lift in session based conversion, amounting to an average annual revenue increase of $376,789.
Source: WPO Stats
karim@hirefast.ca
Programs should be written for people to read, and only incidentally for machines to execute.
from "Structure and Interpretation of Computer Programs"
karim@hirefast.ca
alibhai.co/fallaciesofjsperf
karim@hirefast.ca
karim@hirefast.ca
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
app.disable('etag')
app.disable('x-powered-by')
app.post('/hello', bodyParser.json(), function(req, res) {
res.json({ hello: req.body.name, query: req.query })
})
app.listen(3000, () => {
console.log('Listening :3000')
})
329 bytes
51 dependencies
714, 969 bytes bundled (~0.7 MB)
568, 675 bytes after minification (~0.6 MB) - only ~20% saved
karim@hirefast.ca
karim@hirefast.ca
require('express')()
.get('/hello', (_, res) => res.json({ hello: 'world' }))
.listen(1024, () => console.log('listen :1024'))
require('http')
.createServer((req, res) => {
if (req.method === 'GET' && req.url === '/hello') {
res.writeHead(200, {
'Content-Type': 'application/json',
})
res.end(JSON.stringify({ hello: 'world' }))
} else {
res.writeHead(404)
res.end('404 Not Found')
}
})
.listen(1024, () => console.log('listen :1024'))
we want to write this
but run this
karim@hirefast.ca
karim@hirefast.ca
karim@hirefast.ca
karim@hirefast.ca
karim@hirefast.ca
karim@hirefast.ca
karim@hirefast.ca
karim@hirefast.ca