Stanford Data Science Researcher Denny Britz on Python, Scala and Machine Learning

Published Apr 17, 2014Last updated Mar 08, 2017

I’m a Stanford CS grad student doing data science research. I got hooked on Denny Britzcoding at 15, building applications in PHP for a web design company. Since then I’ve developed dozens of web and mobile apps and I’ve built and contributed to several large-scale open-source systems.

What advice do you wish someone had told you when you were getting started coding?

It’s normal to make mistakes.

I used to think programming meant sitting down and writing an unbroken stream of code. In reality it’s more like this: Write a few lines of code, test it, rewrite it, write another piece, google for an answer, and write another small piece.

Most of a programmer’s time is spent testing, debugging, and looking for answers, not writing actual code. That’s why reading programming books from beginning to end isn’t very useful – nobody can remember all the syntax and function names. Knowing how to debug and find answers quickly is much more important than knowing all the commands.

What’s your favorite programming language and why?

Python, with Scala as a close second. The great thing about Python is the community and breadth of libraries that exist. No matter what you want to do, someone has probably done it in Python and published a library or package you can use. Python also has great tools, such as iPython and iPython Notebooks that make development flow easy.

Scala, meanwhile, offers a great combination of functional programming and high performance. Scala is based on Java and can make use of all the Java libraries out there. It’s perfect for developing distributed applications.

Could you share any coding tips or tricks that make your life easier?

Always have an interactive shell open that allows you to test pieces of code if your programming language supports it. I make small mistakes all the time, and being able to quickly test pieces of code can be a huge time saver.

When you write a complex piece of code, don’t over-engineer it from the beginning. Write the simplest version you can think of, make sure it works, then refactor it to make it faster, more abstract, or more readable over time.

Test-driven development is great for larger applications. Before implementing new functionality, write tests for it. Then implement the functionality and make sure the tests pass. It takes more time to write the test, but doing so saves time in the long run when you make changes to existing code.

When you’re stuck on a coding problem, how do you get unstuck?

The first thing I always do is search for an answer online. Most likely, someone has come across the same problem and asked about it. This solves more than 95% of my problems.

Sometimes, though, you get stuck on something so specific to your application that you can’t find an answer online. In that case it sometimes helps to take a break. It’s not uncommon for solutions occur to me the next morning in the shower.

What’s your favorite project you’ve worked on and why?

SparkI would say it’s Spark, a distributed processing framework for large amounts of data. I was one of the engineers helping with development in the earlier stages of the project (before it became part of Apache).

It was my first exposure to developing large-scale fully distributed systems. I got to work with amazing colleagues who were more knowledgeable than me. By reviewing code from more knowledgeable developers, I managed to learn much faster than usual. In general, the opportunity to learn from more experienced developers and hear different viewpoints make for the best projects.

What’s your approach to helping someone with a coding problem?

My goal is to to help them find the solution themselves. The first step is usually to have them explain what their code is supposed to do, and then what their current code actually does, line by line. During that process we often stumble upon the solution.

What do you enjoy about mentoring?

If someone has problems using an API, it often indicates that the API design isn’t as intuitive as it should be. I feel like I am becoming a better developer by understanding which parts are unintuitive to people, because this helps me to avoid these mistakes in my own interfaces and APIs.

Denny Britz

Want to learn more about Python, Scala and Spark? Book an 1-on-1 session with Denny!

View Denny’s Profile

or join us as an expert mentor!