Bitcoin maximalist.

Thoughts & Technical Writings.

Under the Hood of Ruby’s Interpreter: A Straightforward Example

| Comments

Flatiron, Day 4:

First, some things Avi said today:

Iteration is about going over a collection of objects. Enumeration is the same thing but you’re given the objects.
object.method… the dot is called dot notation. It’s how we send messages to objects.
.. (read: ‘dot dot’) is a literal constructor for Range.
You need to keep “rf -rf /” handy. You know, in case of those Terminator situations.
Comptuer languages fall into 2 categories: those designed for human problems, and those designed for computer problems. JavaScript was designed to be read quickly by web browsers (i.e. a computer problem).
Computers will get faster, but people won’t get any smarter.

Now, on to the post subject… let’s walk stepwise through a (very) simple program in Ruby:

Step 0:

x = 1
if x == 1
    puts "x is equal to 1!"
end

Step 1:

if 1 == 1
    puts "x is equal to 1!"
end

Step 2:

if true
    puts "x is equal to 1!"
end

Step 3:

puts "x is equal to 1!"  #=> "x is equal to 1!"

FizzBuzz ultimate solution:

def fizzbuzz (i)
    [("fizz" if i % 3 == 0), ("buzz" if i % 5 == 0)].join
end

case vs. if

if x == 1
    puts "x wins"
elsif o == 1
    puts "o wins"
end

case object # only can check if condition applies to one object

when condition # condition cannot be a logical operand; must use if/end if you want a unique logic applied for each “case”

An Argument (Diatribe?) for Embracing Discomfort

| Comments

Simply put, the last 48 hours have been a whirlwind. On Monday, the 4th semeseter of Flatiron School kicked off with me riding shotgun. Today I turned my computer into a fully-customized, command-line-driven learning (and coding) machine over the course of about 12 hours. We’ve basically become proficient in using Git/GitHub as well – no small feat for those who recall trying to quickly climb the surprisingly steep Git learning curve. I want to focus this blog on the amazing things I’ll be learning, for example some of the incredible BASH functionality I’ve picked up recently.

But before doing that, I want to share a story. The story is about a man who decided to spend 9 days in the wilderness with a small group of people, each person carrying only a pocket knife, clothing and some sleeping gear. To set the stage a bit, envision this: you’re dropped in the New Mexican mesas with no food for 7 days, no tents, and you must learn how to start fires by rubbing two sticks together (which takes a day and a half on your first try). Yea, no joke. The insane man’s inspiration for going on this trip?

  1. Perspective. He’d never spent time outside of civilization. I believe the man had a longing to know how our ancestors used to live not even ~300 years ago.
  2. Back to Basics. Modern life has abstracted away so much of the inner machinations of… well, everything. This is true to such an extent that most people no longer have any idea how our most important tools work - think combustion engines, computers, and the Internet, just to name a few. What about a friggin’ microwave, or CERN, or the Hubble Telescope?!
  3. Embracing Discomfort as a Means for Learning. As a result of #2, relative to pre-modern man the flow of our lives has flipped completely on its head: we now enjoy long periods of relative tranquility (i.e. we aren’t freezing, starving, or in imminent danger) only very briefly interrupted with moments of discomfort (e.g. our waiter wasn’t exceptionally polite & servile). You may be wondering: So what? What’s the issue with leading a life characterized by an uninterrupted flow of pleasure and leisure? Isn’t that the goal of a well-functioning, capitalistic society?

The problem is that when all of our problems are solved for us and the solutions are abstracted away, we forget how to solve our own problems. Along the way, we never learn how to consistently approach problems with an open & creative mindset. Hell, we even forget how to recognize a problem in the first place! (Example: many Americans stil do not have access to the Internet. Oh, add healthcare to that list of basic things everyone should have access to today.)

Think of every banker in New York City. Their problems consist of getting their children into the 92nd Street Y preschool; securing a bigger bonus than that other VP they work with; or choosing between the BMW X5 and the Volvo equivalent (since, ya’ know, it’s super safe and all). I don’t mean to triviliaze these people’s existence – I worked in finance for 3 years myself, whatever it’s worth. Rather, I want to point out something that I’ve been gnawing on for a long time: I think that our striving for wealth & comfort (not the subsistence type, but rather the type that screams “… but I have more things than anyone else in this village!”) is utterly misplaced, and has eradicated a good chunk of our collective genius.

Our human legacy can take whatever form we as a species strive for it to take. Like the man who nearly starved over 9 days hiking in the wilderness, let’s try to preserve & even expand our perspective regarding our place on earth. Let’s interrupt the ultimately meaningless and vapid pursuit of über-comfort that constantly distracts us from connecting with one another at a deep, real level. It’s up to each one of us to ensure the human legacy – our sacred imprimitur on the universe – is a worthy one.

Things Avi Said Today

| Comments

I love errors. I can’t wait to get past one and say, “Great, I wonder what my next error is?!”

The answer is in the error itself. Read the entire thing, even the parts that make no sense.

Read error messages backwards. (You shut off your brain’s interpretation & are forced to read each word individually.)

Abstraction in Ruby is the act of hiding away details.

Beautiful code looks beautiful. Fast code is not beautiful code.

Single Responsibility Principle (SRP). One part of a program is responsible for one thing & one thing only.