Skip to content

Instantly share code, notes, and snippets.

@schmmd
Last active August 29, 2015 14:22
Show Gist options
  • Save schmmd/40631b10882acb66561f to your computer and use it in GitHub Desktop.
Save schmmd/40631b10882acb66561f to your computer and use it in GitHub Desktop.
Engineering Orientation

inline 120% Eric Kolve

inline 75% Michael Schmitz

inline 75% Sam Skjonsberg


Engineering Orientation

Getting Started Wiki Page

  • Technologies
  • Developer Workflow

Before We Start

  • Please interrupt with questions!

  • dev-help@allenai.org

  • We'll have a follow-up Q&A session in a week


IDE

  • You won't need one for this session.

  • Most people at AI2 use IntelliJ.

inline


HipChat

  • We'll be sharing links and discussing things in the "orientation" HipChat room.

inline


Languages


inline 50%

A JVM-based programming language that mixes functional programing with object-oriented programming.

  • Access to useful JVM components from the academic community.
  • Functional constructs for rapid prototyping and productivity.

fit


First steps with Scala REPL

$ scala
> def fac(x: Int): Int = x match {
    case 0 => 1
    case x => x * fac(x - 1)
  }

> fac(10)

First steps with Scala REPL

$ scala
> def fac(x: Int): Int = {
    if (x == 0) return 1
    else return fac(x - 1)
  }

> fac(10)

First steps with Scala REPL

$ scala
> def fac(x: Int): Int = {
    if (x == 0) 1
    else fac(x - 1)
  }

> fac(10)

Creating a simple Scala application

Create a folder "hello-world". Inside, add the following to build.sbt.

name := "hello"
organization := "org.allenai.hello"
scalaVersion := "2.11.5"

Creating a simple Scala application

Now make a file src/main/scala/org/allenai/hello/Hello.scala and enter:

package org.allenai.hello

object Hello {
  def main(args: Array[String]): Unit = {
    println("hello")
  }
}

Creating a simple Scala application

Now make a file src/main/scala/org/allenai/hello/Hello.scala and enter:

package org.allenai.hello

object Hello extends App {
  println("hello")
}

Creating a simple Scala application

In the directory hello-world:

$ sbt run

Adding dependencies

Add the following to your build.sbt:

libraryDependencies ++= Seq(
  "com.github.rodneykinney" %% "quisp" % "0.5.0"
)

// %% for Scala dependencies
// % for Java dependencies

A slightly more complex Scala application

import quisp.Plot._
 
object Main extends App {
  val primes = Stream.from(2).filter { n =>
    (2 until n).forall(m => n % m != 0)
  }
  println(primes.take(10))
  val pi = Iterator.from(0).map { x =>
    primes.takeWhile(p => p < x).size
  }
  val chart = line(pi.take(100).toSeq)
  chart.title.text("Prime Counting Function")
}

Scala Resources


ReactJS and the Frontend Stack


Developer Workflow


inline 100%

  • Distributed version-control system
    • Each "clone" has complete version history
    • Fast because most operations use local disk
    • Stable because everyone has a complete copy

Git Basics

  • git clone: create a local copy of a respository
  • git checkout -b branch: create a branch named branch and switch to it
  • git add file: add a file to "the index"
  • git commit: commits changes in index
  • git push: push changes to the repository we cloned

GitHub inline 15%

  • A cloud host for Git repositories
    • We don't need a central Git repository, but it's convenient
  • A UI for Git operations
  • Additional mechanisms for code sharing
    • Forks
    • Pull requests

inline 100%

  • An interactive, parallelizable build tool

Running an existing Scala application

$ mkdir -p github/allenai
$ cd github/allenai
$ git clone git@github.com:username/aristo.git
$ cd aristo
$ sbt
> projects
> project frontend
> reStart

Common SBT Commands

For more details, check out the SBT Cheat Sheet

  • clean
  • compile
  • run and run-main
  • reStart and reStop
  • ~compile

Developing a new feature

$ git checkout -b new-feature
$ vim frontend/public/index.html
$ git grep "Answering Science Questions"
$ vim frontend/webapp/app/state-views/application.html
$ sbt 'project frontend' run

Developing a new feature

git add frontend/webapp/app/state-views/application.html
git commit -m "Rewording the Aristo frontend tagline."
git push origin new-feature

Developing a new feature


Sample Project

Write a CLI that runs a sentence through the Nlp Stack Part-of-Speech tagger and prints the results. Write the code in a fork of the interns repo. When you are done, create a pull request and code review your solution with a peer.

Bonus: create a web application performs the above behavior in a web UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment