[2018 oracle code one] beyond git add/commit/push

Beyond git add/commit/push
Speaker: Jorge Vargas and Victor Orozco
@edivargas and @tuxtor

Full deck: http://www.jorgevargas.mx/wp-content/uploads/2018/10/Git-SCM-en-v5.pdf

For more blog posts, see The Oracle Code One table of contents


Review

  • add – puts in to staging area (from working directory)
  • commit – puts in local repo
  • push – puts in remote repo
  • reset hash – override working directory with local repo
  • fetch – get from remote repo to local repo
  • pull – fetch + merging into your local branch
  • clone – get from remote repo to working dir

Workflow

  • select a workflow – varies by project, but all team members should know what using
  • Common workflows
    • Centralized – all commits to master. Usually for new git users.
    • Feature branch – do feature in a branch and then merge in.
    • Gitflow – do changes in branch and merge into develop. Then merge development into master. Only commit to master for hotfixes or when develop ready for release
    • Forking – copy of repo and merge in
  • Recommendations
    • No one workflow to rule them all.
    • Code in master should be complete and functional at all times
    • Create short lived branches
    • Use meaningful names for branches

Advanced Git commands

  • stash – a quick save of your working directory

Demo

  • git init – to create repo
  • git status – showed file in staging area
  • git commit – add file
  • Edit .gitignore – to omit .class files
  • git log – see actual commit
  • git log –oneline –graph –all – list commits one line per commit so easier to read. Shows which branch the change is in
  • git checkout -b newBranch – create new branch and switch to it
  • git branches – list all branches
  • git checkout master – switch to master
  • git checkout -b branch2 – create a second branch off master
  • git merge newBranch – first merge smooth
  • git merge branch2 – created merge conflict. Fix manually
  • git branch -d newBranch – delete branch

My take: I had trouble understanding their accents at first, but then it got easier. The content itself was good. I was also a little distracted getting ready for my session next. I like that they did a live demo. I thought the content was going to be more advanced. The mention of stash was a good one. But then the demo was easy. To be fair, a bunch of people in the room didn’t raise their hands for using git. They got to the advanced part right when they ran out of time. I look forward to reading the rest of the deck at least.

 

 

[2018 oracle code one] how to program a quantum computer

You’re thinking too classically – how to program a quantum computer
Speaker: Tim Ellison
IBM

For more blog posts, see The Oracle Code One table of contents


General

  • When reach maturity of computers have today, will significantly outperform today’s classical computers
  • Need quantum computer to model quantum mechanics

Classical computers

  • Classical data and logic representation – data encoding (binary/ascii), logic gates (binary), computing circuits (built out of logic gates)
  • Need resilient bit store, data representation and algorithms. Don’t think about it much because data is reliable
  • Some problems are hard/not a good fit
    • Traveling salesman – 10 cities is 1.8 million routes. 20 cities is 1 billion billion routes
    • Optimizations (ex: minimize wastage cutting wood)- requires starting with a guess and trying all options
    • Modelling molecutes (simulate electron interactions – 25 electrons is laptop sized problems. 43 electrons ins Titan supercomputer
    • Modeling caffeine is impossible on today’s computers. But could represent in 160 quantum bits. And pharmaceuticals are far more complicated.

Quantum

  • Qubit in both 0 and 1 state at same time. Superposition
  • Collapses to a value when observe.
  • Can influence probability of it being a 0 or 1
  • Combine qubits to cause correlation of random results. Quantum entanglement “causes” both “linked” qubits to git save values.
  • Call experiments (vs programs) for quantum because results not deterministic
  • Power doubles every time add qubit.
  • 275 qubits is more states than number of atoms in universe
  • Fast to factor prime numbers using Shor’s algorithm [watch out security!]
  • Expect quantum computers to be used – chemistry, AI (classification, machine learning, linear algebra), financial services (portfolio optimization, scenario analysis, pricing)
  • Built with ions, photons, superconducting circuits.

Demo

https://quantumexperience.ng.bluemix.net/qx

  • 5 qubits
  • Get 21 units (since free, it is rate limited.) Once experiment completed, get results back
  • Can run on real quantum computer or on simulator
  • Result gives you the probability of different results
  • Shows openqasm. A quantum assembly language
  • H gate puts into superposition state
  • Large program runs in O(square root of n) vs O(n^2) complexity

Resources

  • Python API: https://github.com/QISKit – build, compile/transpile and execute
  • Run experiments: https://quantumexperience.ng.bluemix.net/qx

Journey

  • Science is well understood
  • Machines currently error prone. Nothing can do on quantum that can’t do on classical (yet)
  • Quantum Advantage – being able to benefit from quantum
  • Prediction: less than 5 years for chemistry. 10-15 years for breaking cryptography
  • Starting to build data centers in Poughkeepsie (upstate NY)

My take: The basics of this I’ve heard before. It was cool seeing IBM’s experiment generator used. It’ll be interesting seeing where this goes. The speaker said this was normally a 2 hour talk. I liked the part about applications of quantum and how they are built. I also liked seeing the assembly and graphical code.

[2018 oracle code one] Var with Style

Var with Style – Local Variable Type Inference with Java
Speaker: Stewart Marks
Oracle

#VarWithStyle

For more blog posts, see The Oracle Code One table of contents


Local variable type inference

  • “var” tells compiler to infer the type
  • Still a static type. Should compile same as if typed the class name
  • Type inference is not new. Lambdas did it in Java 8

Where can use

  • local variables
  • resource variables in try-with-resources
  • loop variable in for-each loop
  • [and lambadas in Java 11]
  • can’t use in places where API/written into class file/affects binary compatibility

How compiler determines type

  • Looks at initializer’s type
  • Can’t use when not info info
    • var customer = null (not allowed because ambiguous)
    • var fun = (int a, int b) -> a + b (not allowed because lambda needs type for context)

Other notes

  • Can reassign using normal assignment rules. (aka same or compatible type as to what var really is)

Benefits of var

  • Add features to language so can write better code
  • Using var in right way results in better code
  • Reduces verbosity/clutter/redundancy
  • Let’s variable name stand out which is more important
  • About readability; not amount of typing.

Local Variable Type Inference Style Guide

You can write code with or without var. See style guide to mitigate usage concerns – new idea to release style guide at same time as feature. There’s also a FAQ

Principles

  • P1 – Reading code is more important than writing code
  • P2 – Code should be clear from local reasoning – had considered inferring from context all over class. But then hard to figure out and reader has to type inference in his/her head
  • P3 – Code readability shouldn’t depend on IDEs
  • P4 – Explicit types are a tradeoff

Guidelines

  • G1 – Choose variable names that provide useful information
  • G2 – Minimize the scope of local variables
  • G3 – Consider var when the initializer provides sufficient information to the reader
  • G4 – Use var to break up chained or nested expressions with local variables
  • G5 – Don’t worry to much about “programming to the interface” with local variables
  • G6  – Take care when using var with diamond or generic methods.
  • G7 – Take care when using var with literals.

General

  • “you read the internet and it’s such a great source of conference talks”
  • var x = getSomething() – already terrible code because a bad method name
  • InputStream inputStream = socket.getInputStream() – mentioning input stream twice instead of three times seems ok. Covers G1 and G3. The variable name and context is sufficient
  • try with resources – often long code so hard to spot variables. Using var aligns them.
  • Long class names penalizes doubly. Using var lets you put in once.
  • Helps with generics. Have a very long type name
  • var list = new ArrayList,String>. Can’t use diamond operator or would have ArrayList<Object>. Want to avoid using var and diamond together. Note that the type is now ArrayList and not List. Ok because just using as local variable. The method return type would still be List.
  • Also be careful with methods returning generics. List.of() returns List<Object> when don’t pass any parameters.
  • Fun side effect – less imports because type names not all mentioned explicitly

My take: This was an awesome session. I like that he covered the background and style guide. I also REALLY liked the before/after examples to show when it is good to use var. Also, time flew in this session!