Code and Poetry, a Conversation

In which I explore their similarities (while you remain skeptical)

Credit: StarLineArts/iStock/Getty Images Plus
const firstName = 'Dante';
const nobiliaryParticle = 'degli';
const lastName = 'Alighieri';
const firstName = 'Dante'
const nobiliaryParticle = 'degli'
const lastName = 'Alighieri'
const
firstName = 'Dante',
nobiliaryParticle = 'degli',
lastName = 'Alighieri'
const firstName = 'Dante', nobiliaryParticle = 'degli', lastName = 'Alighieri'
const [firstName, nobiliaryParticle, lastName] = 'Dante degli Alighieri'.split(' ');
function announceFavoritePoet(name) {
const announcement = "My favorite poet is";
if (name.firstName) {
announcement += name.firstName;
}
if (name.middleName) {
announcement += name.middleName;
}
if (name.nobiliaryParticle) {
announcement += name.nobiliaryParticle;
}
if (name.lastName) {
announcement += name.lastName;
}
return announcement;
}
function announceFavoritePoet(name) {
return (
'My favorite poet is ' +
(name.firstName ? name.firstName + ' ' : '') +
(name.middleName ? name.middleName + ' ' : '') +
(name.nobiliaryParticle ? name.nobiliaryParticle + ' ' : '') +
(name.lastName ? name.lastName + ' ' : '')
)
}
function announceFavoritePoet(name) {
return [
'My favorite poet is',
name.firstName,
name.middleName,
name.nobiliaryParticle,
name.lastName,
]
.filter(Boolean)
.join(' ');
}
name => [
'My favorite poet is',
...Object.values(name)
].join(' ')
name => `My favorite poet is ${Object.values(name).split(' ')}.`
name => Object.values(name).reduce(
(msg, part) => `${msg} ${part}`,
'My favorite poet is'
);
words='', wordless=' '
// I am calm. I am calm.
// It is the calm before something awful.
speak = word => word?
smothered_mouthfuls(word): end()
let smothered_mouthfuls = word => (
// Dutifully swallowing words
word = words ? wordless + word : word,
words = words + word,
speak
)
let end = yet => {
// Grudgingly, my ungainly tongue
// Pokes and stirs, to render
// Empty substance-less nothings
return null, void words? yet: words
}
speak('I')('am')('your')('opus')()

Literature fanatic. JavaScript developer. Author of "If Hemingway Wrote JavaScript" https://anguscroll.com/hemingway

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store