Skip to content

Instantly share code, notes, and snippets.

View mtomko's full-sized avatar

Mark Tomko mtomko

View GitHub Profile
@mtomko
mtomko / bool-rant.md
Last active December 13, 2022 21:39
Boolean values are overrated

Boolean values are overrated

...and overused. Every time I espouse this unpopular opinion amongst fellow programmers, I am met with stunned silence. Then, the questions start. How can you hate bools? people want to know. It does seem like an unlikely target for ire, something so small, so seemingly benign, so simple.

To be perfectly clear, bools and boolean logic are an unavoidable fact of programming. One cannot just do away with them. But one should be careful to use them like a scalpel rather than a sledgehammer. So, what is the problem with bools? In short, the semantics of boolean values depends on the context where they're used rather than where they're assigned. As programmers, we often control the latter, but not the former, and thus, they are an invitation to error.

Keybase proof

I hereby claim:

  • I am mtomko on github.
  • I am mtomko (https://keybase.io/mtomko) on keybase.
  • I have a public key ASAZC6kAUOEkh_pDPfJHkTUCO7a3k5OPeir_FQkUvS-Q2go

To claim this, I am signing this object:

@mtomko
mtomko / neither.scala
Created March 31, 2016 18:02
Neither ADT
sealed trait Neither[A, B] {
def isntA: Boolean = true
def isntB: Boolean = true
}
@mtomko
mtomko / TwitRPC.md
Last active August 29, 2015 14:18
TwitRPC

TwitRPC

This document describes an RPC mechanism that uses Twitter feeds as an underlying transport protocol. What could possibly go wrong?

Requests

A request to the service consists of a tweet or series of tweets. The service requested is identified by hashtag #<method> and the request is given an ID by hastag #id<id>. Multi-part messages are given the hashtag #<k>/<n> where k is the message number and n is the total number of messages. The request body is the concatenation of all tweets in the series with the method, sequence, and id hashtags removed.

Responses

Each request is found by a message processor that searches for the hashtag associated with its request method. A response is posted mentioning the caller by name @<caller> with the request ID repeated back. Multi-part messages are given the hashtag #<k>/<n> as described above.

@mtomko
mtomko / Projects.md
Last active December 18, 2015 10:18

Projects

watch

This is a simple command-line utility that acts as a sort of "meta-tail": it watches all of the files in a provided directory (or set of directories); when any of the files has a line (or data) appended to it, it prints the new data to the tty. This would be a great opportunity to tinker with OCaml, in particularly the information in the book http://ocamlunix.forge.ocamlcore.org/.