RacketCon 2018

I'm attended RacketCon from September 29-30th this 2018. Here are my talk/conference notes and biased thoughts.

Talks

DSSL2: A #lang For Data Structures Students

DSSL2 is a language designed by a professor at Northwestern to provide a good environment for data structures students. It uses a Python-like syntax to be familiar and accessible to students from a wide range of backgrounds. The language looks like this:

#lang dssl2

def insert!(t, k):
    if empty?(t): new_node(k)
    elif zero?(random(size(t) + 1)):
        root_insert!(t, k)
    elif k < t.key:
        t.left = insert!(t.left, k)
        fix_size!(t)
        t
    elif k > t.key:
        t.right = insert!(t.right, k)
        fix_size!(t)
        t
    else: t

and is constructed entirely using the extensive Racket macro system.

  • It's a really effective DSL because it uses existing knowledge of students, and has been successful in undergrad data structures course.
  • There's no existing standard of who knows what in undergrad engineering (aside from 10 weeks of C++) so they'll have to learn something else anyways, unless the professor wants to manage 10 different languages for each assignment.
  • DSSL2 is also effective in that it essentially forces semantic programming (no mutation, etc.), helping guide them in every step of their programming.

Bringing Back Design By Numbers

Design By Numbers is a pretty old language initially designed for artists who wished to learn programming. Some Racket folks have re-implement Design By Numbers in Racket. Code is simple and looks like plain english:

#lang dbn

Paper 0
Pen 100

Command HL Y {
   Set X 25
   Line X Y X Y
}

HL 50

and supports a lot of different language constructs.

  • I think Design By numbers wasn't particularly successful because it doesn't follow semantic guidelines at all.
  • It has inconsistent capitalization, brackets are not scope, and a really odd standard library.
  • While it's difficult for beginners to learn and understand semantics, making a confusing language will make doing anything advanced at all nonobvious to experienced programmers and especially beginners.

Language-Oriented Programming

Language oriented programming is a term that comes up a lot in the Lisp community. Language-Oriented Programming refers to the paradigm of creating DSLs (Domain-Specific Languages) to serve specific tasks: either an entire language (Racket is a DSL built on top of its core primitives) or a small language for a specific task (see DSSL2 above).

How To Ask For The Time In Racket

Gregor is a date (not datetime!) library for Racket.

  • Gregor's (today) and (now) differ because (today) only holds the data for the current day; not time, utc offset, etc. etc.
  • new Date("2001-01-01") returns something different from the actual day, like Fri Dec 31 1999 18:00:00 GMT-0600 (Central Standard Time), because it interprets this as UTC and localizes it.
  • Many other bugs and caveats like this exist. As such, it's useful to only store the date when you want to store a date, not the accompanying time.

A Racket Story

  • DSLs can be really useful for specific coding classes.
  • #lang minecraft-lang
  • #lang vr
  • Specifically difficult languages (e.g., microcontrollers) can greatly benefit from having a language for them written in Racket, by removing the learning curve for a new environment and providing a similar programming interface (Racket) for each task.
  • Cool Racket Packages
  • Protocol Buffers
  • Generates binary objects storing arbitrary data, and can serialize and deserialize automatically. Useful for network transfers.
  • feature-profile
  • LISP is typically slow, since that's not it's focus.
  • Profiling is underused.
  • Built-in profile functionality in Racket is statistical and typically operaties on limited data.
  • The feature-profile module can operate on individual features. While this can lead to micro-optimizations, it also allows for a greater benchmarking granularity that can result in optimization.
  • for-acc
  • User-specified accumulators with automated post-processing.
  • Now part of the base distribution!
  • fc or find-collection
  • Find a module on disk :)
  • handy
  • A mish-mash library. Just no.

Racket For Everyone (Else)

Teaching programming to people who aren't from a computer science/math background can be difficult, but really fruitful (see next section "Digital Ricoeur").

  • A majority of computer science tutorials use mathematical concepts so math people can understand, but this is a huge barrier to entry.
  • DSLs are a good way to provide small interactive deliverables.
  • Scribble and Frog, specifically, for making academic papers and personal blogs.
  • Dr. Racket significantly lowers the barrier to entry, and has great suppotr for application-y interactive projects.

Digital Ricoeur

Digital Ricoeur is an online archive of Paul Ricoeur's works.

  • Paul Ricoeur published in a lot of different journals, so as a result no one university has access to all of his works
  • What's something that can easily search a lot of sources? Computers!
  • Copyright prevents one organization from digitizing and distributing all works
  • Digital Ricoeur compiles lists of records to tell academics where to look for a specific source
  • DSL application: a DSL to notate publications and publication queries

SINBAD

Sinbad (automated Structure InfereNce and Binding of Data) is a library to access and import data uniformly from online RSS/XML feeds. Examples are:

(require sinbad)

(define faa ;; fetch airport status information
    (sail-to "http://services.faa.gov/airport/status/ATL?format=application/xml"
        (cache-timeout 300)  ; refresh every 5 minutes
        (manifest)           ; display schema for available data upon load
        (load)))

(define-struct port (name loc condition delay?))

(fetch faa (make-port "Name" "State" "Weather/Weather" "Delay"))

=> (make-port "Hartsfield-Jackson Atlanta International" "Georgia" "Fair" #false)

;;
;; do more complicated stuff with large datasets
;;

(define vehicle-data-source
    (sail-to "http://www.fueleconomy.gov/feg/epadata/vehicles.csv.zip"
        (load) (manifest)))

(define-struct auto (make model year trans city-mpg hwy-mpg))

;; pull a random data record...
(fetch-random vehicle-data-source
    (make-auto "make" "model" "year" "trany" "city08" "highway08"))

;; get all ~40,000 (!) of them...
(define all-vehicles
    (fetch vehicle-data-source
        (make-auto "make" "model" "year" "trany" "city08" "highway08")))

(length all-vehicles)
  • Get data feeds online, and get RSS/XML link, by requesting sail-to a URL.
  • Add in labels, and it'll fetch them out of the XML.
  • Easily load fetched data into a Racket struct.

Cassius: Verified Web Pages

Cassius is a mathematical formalization of web page layout.

  • How do you verify the appearance of a webpage?
  • Webpages are programs: taking inputs (font size, horizontal size, vertical size, etc.), and returning visual output.
  • W3C unittests are out of date and often don't even work.
  • For those with low vision, ensuring full accessibility compliance for websites is really important.
  • Cassius formalizes web page layout as a mathematical system and uses existing theorem-proving techniques to verify webpage layout.

Petri-Net Flavored Places

A petri net or transition net diagrams the flow and behavior of a distributed system.

Dataflow Network Programming with Neuron

Neuron is a compositional framework to make network software development easy and fun.

  • What if Facebook likes could actually contribute something?
  • Users can give computing power! But how do you computationally facilitate this?
  • Neuron defines two constructs:
  • Sockets
  • Structure to pair input/output ports.
  • Codecs
  • Reader and writer with encoder and decoder functions.

State of Racket

Racket's moving to a Chez scheme base! Spaghetti-ish core code (written in C) is being replaced with Chez Scheme code. To compile Chez scheme, just run

make cs

instead of

make

when building Racket.

FARM

FARM (Functional Art, Music, Modeling, and Design) (yes I know it's not an acronym, I didn't choose it) was a night of algorithmic and functionally-generated music. I didn't get a chance to go to the talks on how the algorithms worked (they happened at the same time as RacketCon), but they sounded pretty cool. Livecoding was also a major part of the event, and another cool application of DSLs!

Workshops

syntax/parse

  • Canonical reference for learning Lisp macros: Macro-By-Example.
  • racket/private/template - good example of macros
  • ~? operator
x = #'apple
#'(eat (~? x 'nothing'))
= (eat apple) if x is defined
otherwise, (eat 'nothing')

Web Development in Racket

I went to a workshop with the amazing Jesse Alama about the state of web development in Racket. Here were a few standout things:

  • sweet.js provides the goodness of Racket-like hygienic macros to unholy JavaScript.
  • db is a nice ORM.
  • Here is a nice intro to web development in Racket workshop written using the standard Node/Flask/etc. method of URL dispatchers.

Unrelated