Skip to content

Instantly share code, notes, and snippets.

Avatar

Erik Osheim non

  • Providence / Philly
View GitHub Profile
View answer.md

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

@non
non / godel14.md
Created Mar 12, 2015
Gödel's fourteen point outline of his philosophical views.
View godel14.md

Gödel left in his papers a fourteen-point outline of his philosophical beliefs, that are dated around 1960. They show his deep belief in the rational structure of the world. Here are his 14 points:

  1. The world is rational.
  2. Human reason can, in principle, be developed more highly (through certain techniques).
  3. There are systematic methods for the solution of all problems (also art, etc.).
  4. There are other worlds and rational beings of a different and higher kind.
  5. The world in which we live is not the only one in which we shall live or have lived.
  6. There is incomparably more knowable a priori than is currently known.
  7. The development of human thought since the Renaissance is thoroughly intelligible (durchaus einsichtige).
  8. Reason in mankind will be developed in every direction.
@non
non / seeds.md
Last active Nov 12, 2020
Simple example of using seeds with ScalaCheck for deterministic property-based testing.
View seeds.md

introduction

ScalaCheck 1.14.0 was just released with support for deterministic testing using seeds. Some folks have asked for examples, so I wanted to produce a Gist to help people use this feature.

simple example

These examples will assume the following imports:

View csv.scala
package cats.parse
package examples
import cats.implicits._
import Parser.{char, charWhere, charsWhile, string1}
object Csv {
def mkString(p: Parser1[Char]): Parser[String] =
@non
non / calc.py
Created Dec 2, 2012
python calculator
View calc.py
#!/usr/bin/python
#
# by Erik Osheim
#
# This program uses a recursive descent, LL1 parser to generate a Code object
# for the given input. Code objects are pure expressions whose behavior can
# only be controlled via a dictionary of strings-to-numbers provided to run.
#
# Syntax:
#
@non
non / transducers2.scala
Created Jan 25, 2015
Basic encoding of Transducers with a little fanciness
View transducers2.scala
import spire.algebra._
import spire.implicits._
object Transducer {
type RF[R, A] = (R, A) => R
def apply[A, B](f: A => B) =
new Transducer[B, A] {
def apply[R](rf: RF[R, B]): RF[R, A] = (r, a) => rf(r, f(a))
}
@non
non / half.scala
Last active May 29, 2020
Scala implementation of 16-bit floating point numbers. Also, a test prgoram.
View half.scala
package half
import scala.math.{pow, round, signum}
import scala.util.Random.nextInt
import java.lang.{Float => JFloat}
/**
* Float16 represents 16-bit floating-point values.
*
* This type does not actually support arithmetic directly. The
@non
non / Wild.scala
Last active Apr 9, 2020
Interesting trick to lift existentials into values, so we can later refer to them.
View Wild.scala
package demo
import cats.{Applicative, Functor, Id, Semigroupal, Traverse}
import cats.arrow.FunctionK
/**
* Type-lifting operation to replace the wildcard type (i.e. _).
*
* In some cases we end up with code like: List[Option[_]]. This is
* fine unless you later need to write code in terms of a particular
@non
non / massdel.py
Created Jan 9, 2020
Script to delete all issues for a repo. This is different than just closing all of them. It uses the v4 GraphQL Github API.
View massdel.py
#!/usr/bin/env python
#
# by Erik Osheim
#
# STEPS TO USE
#
# 0. install deps
# - pip install requests
#
# 1. generate personal access token
@non
non / sizes.txt
Last active Oct 16, 2019
Size of various JVM data structures in bytes (top column is number of elements).
View sizes.txt
COLLECTION 0 1 5 10 50 100 500 1000
Array[Int] 16 24 40 56 216 416 2016 4016
immutable.BitSet 24 24 24 24 24 32 96 160
immutable.IntMap[Int] 16 40 328 688 3568 7168 35968 71968
immutable.List[Int] 16 56 216 416 2016 4016 20016 40016
immutable.Map[Int,Int] 16 40 304 720 4856 9680 53504 111760
immutable.Queue[Int] 40 80 240 440 2040 4040 20040 40040
immutable.Set[Int] 16 32 264 480 3016 5840 27696 57952
immutable.SortedMap[Int,Int] 40 88 280 520 2440 4840 30008 62008
immutable.SortedSet[Int] 40 104 296 536 2456