- Technologies
- Developer Workflow
-
Please interrupt with questions!
-
We'll have a follow-up Q&A session in a week
-
You won't need one for this session.
-
Most people at AI2 use IntelliJ.
- We'll be sharing links and discussing things in the "orientation" HipChat room.
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.
$ scala
> def fac(x: Int): Int = x match {
case 0 => 1
case x => x * fac(x - 1)
}
> fac(10)
$ scala
> def fac(x: Int): Int = {
if (x == 0) return 1
else return fac(x - 1)
}
> fac(10)
$ scala
> def fac(x: Int): Int = {
if (x == 0) 1
else fac(x - 1)
}
> fac(10)
Create a folder "hello-world". Inside, add the following to build.sbt.
name := "hello"
organization := "org.allenai.hello"
scalaVersion := "2.11.5"
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")
}
}
Now make a file src/main/scala/org/allenai/hello/Hello.scala
and enter:
package org.allenai.hello
object Hello extends App {
println("hello")
}
In the directory hello-world
:
$ sbt run
Add the following to your build.sbt:
libraryDependencies ++= Seq(
"com.github.rodneykinney" %% "quisp" % "0.5.0"
)
// %% for Scala dependencies
// % for Java dependencies
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")
}
-
Primary Recommendations
-
Twitter Scala School
-
We have many more resources
- 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 clone
: create a local copy of a respositorygit checkout -b branch
: create a branch namedbranch
and switch to itgit add file
: add a file to "the index"git commit
: commits changes in indexgit push
: push changes to the repository we cloned
- 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
- An interactive, parallelizable build tool
$ mkdir -p github/allenai
$ cd github/allenai
$ git clone [email protected]:username/aristo.git
$ cd aristo
$ sbt
> projects
> project frontend
> reStart
For more details, check out the SBT Cheat Sheet
clean
compile
run
andrun-main
reStart
andreStop
~compile
$ 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
git add frontend/webapp/app/state-views/application.html
git commit -m "Rewording the Aristo frontend tagline."
git push origin new-feature
- Create a pull request
- Assign a reviewer (your mentor is an obvious choice)
- Wait for Shippable to succeed
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.