Hidden Gems: The Null Coalescence Operator

In a previous Hidden Gems post, I covered the artistic side of programming as expressed through the use of the ternary operator. Here is the original post if you’re interested, otherwise here’s a quick summary of the concept: programming relies on the use of conditional statements, where a certain path is taken depending on the value of a variable or expression, and a ternary operator is an elegant, shorthand way of writing these conditionals. In the example below, the function isItSnowing() will return a true or false value telling us if it is snowing. If it is snowing, then we’ll stay inside, and if it is not, then we’ll go outside. The ternary operator has unlimited potential, with the ability to string multiple conditions together, but must be used carefully; just because it improves readability and style in this scenario does not mean it always will.

The null coalescence operator is a slightly more nuanced version of the ternary operator, but even more interesting due to it’s use cases. Oftentimes in programming, you want to assign a value to a variable, but you don’t know for sure that the value exists. The value might come from another source and you can’t guarantee that it was received correctly or as expected. In most programming languages, trying to use a value that was never created causes a disaster (one can easily see why), and will usually crash the program. However, programmers would usually prefer to provide some default value instead, to prevent the program from crashing. Here is that exact situation presented in relatively simple, but verbose code:

This is a fairly straightforward conditional statement, which says in plain English, “if the value of temperature is known, the message will be that value, but if for some reason we don’t have the temperature, let the message be a default warning that we don’t have the temperature”. If you’ve been paying close attention, you might have noticed that this conditional is very similar to the one we explored when discussing ternary operators, and as a matter of fact, this conditional can be expressed using a ternary operator, as demonstrated here:

Notice again the power of the ternary operator in simplifying the conditional. It compacts the same logic into one statement, which reduces the number of lines and is more efficient to run. Now behold the same statement written using the null coalescence operator:

The differences may be subtle at first, but they are extremely important. Notice that there is no expression to test whether or not “temperature” exists, as it is built into the operator. Also see that it automatically assigns the value of “temperature” if it exists. Finally notice that the default message comes after the null coalescence operator, and is assigned when the value of “temperature” does not exist. A common way to read the operator in English is “reading from left to right, give me back the first thing that exists”. This use case is extremely common in programming, which is what ultimately led to the null coalescence operator being created. Personally, I was thrilled when I discovered this: after writing hundreds of the equivalent ternary versions, I had finally discovered a way to write less code while also improving the style of my code. Once a programmer is used to using this operator, it reads much more naturally than the ternary operator and saves valuable time when trying to understand the code. This operator can also be chained, similar to the ternary operator, as shown in this example, where the default string is used if both the “temperature” and “backupMessage” variables are null:

At the end of the day, the null coalescence operator may not seem like a revolutionary idea, and it isn’t. However, it is a testament to the ingenuity and artistry of programmers, motivated by a unique combination of laziness and empathy for the programmers who follow. It is the accumulation of these small improvements that evolve into the modern programming languages we have today, which are more powerful and easier to read than ever before.

A Box on the Bucket List

Hey guys!

This post is going to be short this week. I’ve been spending way too many hours in the past few days working on a project that I am currently super, super excited about. It’s my first full-length, fully mixed song that I am crossing my fingers will turn out professionally enough to put on Spotify!!! That’s a huge bucket list item for me, and if all goes according to plan, the track will be ready by the end of this month. So… keep a lookout for that!

I’m currently recording on my Yeti microphone with GarageBand and my Mac pro. It’s far from a professional set-up, but it’s also incredibly amazing to see just how much someone with zero (and I mean ZERO) experience recording can do with just a few tools. This has proved to me that literally anyone can be a recording artist if they so choose to be. As long as you put in the time to figure out how your software works, you’ll be able to produce some really awesome stuff.

This new song is called “i used 2 sleep with my phone” (I’ve been feeling the artsy lowercase titles lately) and is my attempt at a typical angsty pop song–which is something I do not ever write. It also is definitely influenced by my experience here at UMich with the a cappella scene. At this point I feel like I have a whole choir of my own voice singing behind me on the track.

I will update on here how everything is going every week until the track is released, but as for right now that’s all I’m going to say! Thanks for reading, and if anyone else is a GarageBand fanatic, let me know! I’d love to listen to some of your stuff.

-Josie

Some Songs Don’t Come from Diaries

Here’s the deal, guys. People think you have to have some deep emotional traumatic experience to write a good song. And sure, lots of angsty ballads are born from tear-stained diary pages, but not all songs have to be that complex. In fact, I find that sometimes the best songwriting exercises are writing about things that have no real significance whatsoever.

For example, here’s a prompt to get you started.

Write a chorus of a song incorporating numbers 1 through 10. You don’t have to use all the numbers, but write as many of them into your chorus as possible.

Here’s my attempt:

You’re the only one
I can call at half past ten
and I can hold onto
through all the could’ve and should’ve beens
But you left at a quarter to 5
baby, what were you yelling for?
Didn’t break the walls round my heart didn’t tear me apart
didn’t realize what this was
until I walked out my door your car not there anymore
you gave up on us
you gave up on us

Notice not all the numbers are in numerical form. But using the words “onto” and “for” give the illusion that I am continuing on with the numbers theme.

An example of this in popular culture would be “New Rules” by Dua Lipa. The chorus goes:

“One: Don’t pick up the phone
You know he’s only callin’ ’cause he’s drunk and alone
Two: Don’t let him in
You have to kick him out again
Three: Don’t be his friend
You know you’re gonna wake up in his bed in the mornin’
And if you’re under him, you ain’t gettin’ over him”

This attempt at using numbers to tie together a chorus is much more structured than my attempt. It’s in list format, and the numbers are all ‘numerical’ and aren’t slipped in through the usage of other like-sounding words.

Here’s one more try by me to create a different sounding chorus using numbers 1-10 as an inspiration:

Lately
I see
All the things
I couldn’t see before
You walked out my door
Baby
trust me
when I say
going my own way
i’ve never felt so insecure
don’t wanna try anymore
take me back
come back
quickly

This one is different because the numbers themselves don’t appear in the lyrics. Instead they influence the number of words in each line. It goes 1-2-3-4-5 / 1-2-3-4-5 / 4-3-2-1. There was no inspiration behind this chorus whatsoever besides thinking of words that would fit this numerical pattern.

Other ideas to base choruses on?

  • Colors!
  • Seasons!
  • Night/Day/Morning/Evening
  • One particular emotion
  • Months
  • etc.

If you get stuck and hit writers’ block while songwriting, simply pick a category and use it to influence a chorus or two. It may not be the best song you’ve ever written, but it’ll usually be enough to get ideas flowing once again!

Songwriting Resources

Hello, all! This week I figured I would share a few of my favorite websites/resources that have helped me with my music throughout my own artistic journey. Hopefully they’ll be able to inspire/instruct a few people just as they inspired and instructed me.

The big one: Ultimate Guitar. This is the place I find the majority of my chord sheets for different songs I cover. Users are able to upload and edit chords and tabs, and each sheet is able to be rated by other users so you can see what kind of quality the particular version is.
https://www.ultimate-guitar.com/

Chordify is another cool site. It takes youtube videos and mp3 files and turns the audio into chords on the spot. It’s not always 100% accurate or reliable, but it’s definitely a cool idea, and I’d say it’s worth checking out.
https://chordify.net/

For anyone who does any Christian religious music, SongSelect is my website of choice. This is a database of worship songs and other religious material which works great for printing out materials for church bands/worship nights/etc.
https://songselect.ccli.com/

Musescore is a great resource but you do have to have an account to gain access to its full features. This is a database of PDFs and sheet music available to purchase or download. It also allows you to create your own sheet music. I don’t have a lot of experience with this particular resource, but I have friends who swear by it.
https://musescore.org/en

If you write music note by note on a staff, Noteflight is the place for you. I’ve used it mostly for arranging for a cappella ensembles in the past, but I know people who arrange/write for choirs, piano, orchestras, bands, etc. on this site. It’s easy to use for the most part, and really allows for you to create whatever you can possibly think up: an A+ resource in my opinion.
https://www.noteflight.com/

OTHER TOOLS:

If you need an online guitar tuner, Fender has your back! I often forget my tuner when I bring one of my guitars somewhere, and this online tool has really helped me.
https://www.fender.com/online-guitar-tuner

The Ultimate Guitar mobile app also has a built in chromatic tuner, brain tuner, metronome, chord library, chord progression database, and much more. Honestly just download it right now. I use it almost every day.

RhymeZone is another big one for me. When I’m writing lyrics I often find myself stuck in a situation where I have one super strong line and nothing to pair it with. RhymeZone allows you to search for perfect rhymes, near rhymes, synonyms, descriptive phrases, and much more, It also displays single word results and entire phrases that may match your rhyme scheme as well.
https://www.rhymezone.com/

Bits and Pieces

I’ve had a rough week or so in terms of writing anything good enough to deem worthy of finishing. So instead of posting a full song this week, I’ve decided to post a few bits and pieces I’ve written down in the last few months.

Some are sad, some are happy. The styles are all different, and I’m not sure exactly what the tune to some of them are yet. But there is a certain beauty in an unfinished song. They’re in their ‘poetry’ stages. So, here you go:

 

#1: (a song for the seasons)

Wake up blanketed in white
stars like tiny twinkling lights
and I’m finally home
porch is dusty striped with snow
air is biting bitter cold
and I’m finally home

And I open shutters wide
should I run, should I hide
Is it finally time

It’s another barely merry Christmas

 

#2: (a song for fading feelings)

What do I say when the feelings all fade
But I promised you my forever
What do I do when I said I’d stay true
But in all my dreams I’m not tethered
You’re all I have, and I know that
What my heart wants, is what it once had
How do I stay when I feel I must stray
Is my only choice now or never

Every new night I add to my lies
And I weave a new stupid pattern
With every word sent and every word meant
My bond to you has but shattered
You’re who I’ve got I want whom you’re not
I need to hold on but everything’s wrong
What do I say when it all fades to gray
And everything’s gone that once mattered

 

#3: (A song for the towns we call home)

Small town small minds
Not too many passersby
Crazy girls simple lives
Its home
Big fields bigger dreams
Everything is as it seems
Stuck there till seventeen
That’s home
Then we leave and we see what the real world says
About us small town home grown women and men

You tell em where you’re from just by naming a state
All they’ll nod like they know but they don’t what to say
And everywhere you go everything is strange
Like what are you doing here?
You try your very best to be a part of this place
But in the end you’re 2000 miles away
And deep inside a part wishes you’d stayed
Home home.

 

#4: (a song for MY town I call home)

I was born in a town
where the greatest place around
was the Culvers on the side of highway sixty
And our idea of a getaway
Was a 40 minute drive away
To the shores of the Great Lake out in Milwaukee

 

#5: (religious, but my attempt at a song of lament)

Oh Father how I feel like old Jerusalem
Once full of people and the vibrant lives they shared
Now like that silent city I will weep away my sorrows
and it’s more than one small single soul can bear

The tears are streaming faster as I count the names of friends who’ve turned their backs as they have carried on their ways
Now like the silent city I will find no rest tonight
for my mortal heart is once again betrayed

Art Biz with Liz: Short Story Writing

Another semester is coming to an end, and what a weird one it has been. With classes over, it’s crunch time for final exams, essays, and projects. One of my final projects this year includes a short story collection, the culmination of a semester’s worth of work. The goal of it is to see my original creative work, which was submitted on a regular basis throughout the past few months, in a complete, polished state.

RCHUMS 325 is a “tutorial,” which is a unique opportunity to participate in one-on-one writing workshops with the Residential College’s creative writing faculty. Tutorials are meant to support students in expanding our understanding of the craft of writing. Through them, we also grow as young artists in developing our voices and creative visions. As such, the course I took centers around creating (and submitting) new and revised stories weekly, which are influenced by critical reflection done both individually and collaboratively with an instructor.

As I learned in another creative writing class, RCHUMS 220 (Narration), I tend to write longer short stories, as contradictory as that may sound. Doing a tutorial this past semester has been invaluable in writing fiction that is around 5-10 pages long, which is shorter than my “short” stories usually are. After this experience, I’d highly recommend that any writer tries their hand at writing a short story from start to finish. Why? Writing short stories can help a person further develop various writing skills, as the process unveils many of the questions and predicaments faced when crafting fiction of any length.

A short story is a chance to create a unique character and storyline, perhaps without requiring as much of a time commitment as a full-length novel. If a writer has trouble with the plot or characters in their short story, it might highlight some areas to work on when writing other works, too. Like any other art form, writing takes practice, and short story writing can help a person improve on a few different elements of general fiction writing.

While it may seem like writing a short story would be easier than writing longer works, it still comes with its own challenges and opportunities for growth as a writer. A good short story must tell a compelling story with a beginning, middle, and end in noticeably fewer pages than a typical novel. Generally, that limits the number of scenes, characters, and plot points that can be included. There’s not as much room for “fluff,” or extraneous information that doesn’t add anything to the story. Thus, writing a short story is good practice for both pacing and extensive editing. While a novel may detail years of a character’s life, a short story may encompass only a day. This was one of the biggest lessons that I learned this semester through my creative writing tutorial. In being accustomed to longer stories, I tried to cover more time than was feasible in one of my short stories, which required heavy revision to improve the storyline and flow.

It can also be deceptively difficult to make a reader feel a certain way about a character when they witness only a snippet of said character’s life. Yet, there are also some advantages to writing stories of shorter length. Shorter timelines may not allow for as an authentic evolution of certain relationships or character arcs, but they can create faster stories. This results in an opportunity to cultivate motion and tension for a more engaging plot and streamlined story. Considering this information can help a writer decide whether they want their idea to be a short story, novella, or longer work based on how much time is necessary for the storyline to unfurl to optimal result. Based on my experiences with RCHUMS 325 this past semester, this is something I’ll keep in mind moving forward, and maybe you will, too.

 

RCHUMS 220: Narration and RCHUMS 325: Creative Writing Tutorial are available during fall and winter semesters through LSA’s Residential College (RC). RC courses are not exclusive to RC students; however, instructor permission is needed to enroll in RCHUMS 325. Check out the RC Writers page here!