Sunday, November 25, 2012

On Productivity in Grad School

I was recently invited to be on a panel about being productive in graduate school.  This invitation surprised and flattered me.  I do not consider myself to be particularly productive as a graduate student: there are graduate students who have far higher-volume research output and/or greater publication count.  I also don't follow the productivity rules: I don't always remember to track my progress; I don't have a great way of organizing papers I read; I often work on what most catches my attention.  And I spend a good deal of time doing things that are not my research.

That said, I seem to be getting by decently well.  I am happy with the work I have been doing and my papers are in good venues.  When I am in a serious thinking or building mode, itemized goals are not always necessary.  Sure, being more organized about papers would help, but for many topics I am interested in I can give you a short bibliography off the top of my head.  High-level goals usually keep me focused and deadlines can make certain tasks seem pretty damn interesting.  Outside of research, I co-founded Graduate Women at MIT in 2009; we now have over 50 planning committee members running programs serving our over 1200 mailing list members.  This has taught me enormously useful lessons about collaborating with peers, managing people, and managing my time.  The time I spend traveling, doing yoga, and enjoying life with friends also contributes to my happiness and creativity.

Reflecting upon this, I realized that productivity looks different for everyone.  Unlike many people I consider productive, I find it difficult to make myself work.  If I want to work, nothing can stop me; if I don't want to work, then I am better off waiting until I want to work.  To want to work, I need to feel like I am working on something meaningful: technically interesting to me and potentially impactful to the world.  I also refuse to sacrifice a certain quality of life in favor of work: if some end goal requires me to work harder than I would like, then that goal is not for me.

For me, learning how to be productive was about understanding how to harness my motivation and focus it towards productive endeavors.  Below I elaborate on my "top five" strategies that I was asked to discuss at the panel.
  1. Figure out what drives you.  When I am uninspired, I can spend weeks pretty much running in place.  When I am inspired, it is scary what I can do in even one hour.  If you have experienced this, you will agree that the difference between inspired effort and uninspired effort is immense.  Some people are driven by a desire to understand something, others are driven by a desire to create something, and yet others are driven by more abstract goals: a desire to be influential; a desire to be "successful."  Many people are driven by imminent deadlines.  Knowing what you are going after and why you are doing it will make it easier to find those moments.
  2. Stay away from rat races.  Being in a position where you are constantly measuring yourself up to other people is exhausting and, in my opinion, inefficient.  Find your niche; make yourself irreplaceable.  This will give you the freedom to come up with ideas and work at a more leisurely pace.  Discover what topics and groups of people you have the most mutual "chemistry" with.  Figure out what you have that nobody else has--this can be a skill set or a deep interest in some topic.
  3. Learn the rules of the game.  Invest time in figuring out what matters, what doesn't matter, and the relative mileage about different things you can do to achieve your goals.  For instance, I have also been told that your top three papers matter more than how many papers you have.  I have also become increasingly aware of the importance of publicizing work via talks and personal meetings.  I now spend up to one month preparing a talk; if you told me as a young graduate student I would later be doing this, I would have found it preposterous. 
  4. Optimize your environment.  Take time to configure your programming environment, your bibliography collection tools, your way of recording ideas/research notes, etc.  Surround yourself with smart and productive people who motivate you to do good work.  Know the people in your network--a quick e-mail to an expert in a subarea can quickly point you to the most relevant reference materials, saving you days of paper-reading.  Similarly, being in an environment where you are discussing your ideas with peers you respect will make it easier to do innovative research.
  5. Take care of your body and mind.  Learn how to hack your body; one hour of work when you are on top of your game can be equivalent to hours of less high-quality work.  Eating, exercising, sleeping, taking breaks, spending time with friends, and meditating are the solutions to most problems.
A caveat is that this advice is best-suited for those similar to me: workaholics who prefer doing to thinking.  And of course, who knows how good this advice is, as I have yet to really prove myself.  As my own productivity is a work in progress, I welcome what advice you may have.

Related reading:  For those of you who struggle with traditional productivity advice, Structured Procrastination is a nice essay.

Sunday, November 18, 2012

Should You Learn Scala?

It depends on what you want to accomplish*, but the answer is probably yes.

By way of background, Scala is a programming language originally developed at the Swiss university EPFL in an attempt to apply recent innovations in programming languages research to a language that can gain mainstream traction.  Researchers keep coming up with clever ways to it easier for programmers to write correct code and to write less code, but much of the time only academic programmers benefit because these features are implemented in boutique languages (for instance, OCaml and Haskell) that are not in widespread use in industry or open source projects.

On its own, without considering features such a libraries and interoperability, Scala is a nice language.  It is "multi-paradigm," supporting object-oriented programming and functional programming idioms.  Scala allows you to define types associated with both data attributes (with classes behaving like C++/Java classes) and behavior attributes (with traits corresponding to Java interfaces).  In the way of functional programming idioms, Scala functions are first-class (which means you can pass them around as values) and Scala also supports anonymous functions and currying (partial application of multi-argument functions).  This combination of features make it possible to write Scala programs that are quite concise and elegant**.

Scala's libraries and interoperability make it a force to be reckoned with.  Scala runs on the Java Virtual Machine (JVM) and can interoperate nicely with Java code.  This means that you can use Java libraries directly from Scala code.  It is also possible to call Scala code from Java (see here).  There is a nice post about how you can take advantage of Scala parser combinators, which use higher-order functions to help you write concise parsers, to write parsers for systems otherwise written in Java.  Not only can you do all of the things in Scala, you can easily write part of your program in Scala and the rest in Java.  (This is huge for mainstream adoption potential because so much of the world's code is written in Java and so many developers are taught in school!)

Learning Scala will make you more marketable.  Many companies are using Scala these days, including LinkedIn, FourSquare, Twitter, and Quora.  The founders of Quora spent a couple of months building a Scala web framework in order to use Scala.  Martin Odersky, the man behind Scala, is now behind the startup Typesafe for supporting Scala development.  There are some nice Scala web frameworks out there, including Lift and Play.  Scala is also gaining traction in the research community.  Many more people cared about our research on the Jeeves programming language for automatically enforcing privacy policies once we implemented it as an embedded domain-specific language in Scala.

Scala is also relatively easy to learn, especially compared to other strongly statically typed languages (OCaml; Haskell).  I have previously said that Python is the most marketable language for beginners, but I am beginning to change my mind.  Like Python, Scala has clean syntax, nice libraries, good online documentation, and lots of people in industry using it.  Unlike Python, Scala also has a static type system that can prevent you from doing bad things (whereas in Python the bad things just happen when you run the program).

If you are teaching a course using Java, you may want to consider switching to Scala.  I have recently had positive experiences teaching Scala to MIT undergraduates during recitation in 6.005, the software construction course taught primarily in Java.  During three recitations I introduced how to use functional idioms, how to build an evaluator for a simple language by using data types and pattern matching, and how to build an incredibly concise parser for the tiny language using parser combinators.  You may find my notes here, along with the accompanying code examples.

If you are considering the merits of Scala over other languages, you may also be interested in reading my Quora responses to the questions "What makes a good programming language?" and What are the advantages of Scala over C++ and Haskell?.

* If you are building scientific applications, a language with more math support (Matlab; Mathematica; R) may be superior.  If you just want to do a weekend project writing a Craigslist scraper, Python may be better because it is easier to learn and has great web scraping libraries.
** Okay, Scala programs are not as beautiful as OCaml or Haskell (I have another post on ML vs. Haskell) but it's so much more practical in many ways.

Sunday, November 11, 2012

Simple Advice for Being Effective in School

As a result of hijacking a few recitations in MIT's 6.005: Software Construction course to evangelize Scala, I have come into contact with numerous undergraduates.  Engaging with these students, I have realized how much more effective I could have been during college were I less focused on my work and more focused on things like showing up on time.  I have come up with the following list of things that go a surprisingly long way towards academic success.

  1. Show up.  It goes without saying that you miss a lot of things if you don't show up.  There is also a two-way thing.  If you don't get face time with an instructor, it does not matter how good you are.  They are not going to know who you are, they will probably feel less motivated to answer your questions, and they will probably not write you a recommendation letter.  (I am not important enough to have written many recommendation letters so I am extrapolating a bit on the last one.)
  2. Be on time.  During the first few minutes of a lecture/recitation/talk, many important things happen: there might be administrative announcements; there might be high-level motivation; there might be contextualizing facts.  If you show up late, it is more difficult to motivate yourself to pay attention and to follow what is going on.  You will often miss other things when you spend the whole time trying to catch up.
  3. Stay awake.  The more you are able to absorb directly from the person who is trying to convey information to you, the less unnecessary self-teaching and work you will have to do later.  If you are not able to stay awake in lecture, hack your body (get more sleep, drink more coffee, move your body before lecture) until you learn how to stay awake.
  4. Be present.  Focus on being in the classroom rather than surfing the web, doing other homework, or zoning out.  Paying attention, not just to the lecture/exercise but also to other students' responses, can save a lot of work.  I have noticed that students do a fair amount of unnecessary work because they did not listen to either verbal or written instructions or because they missed the answer to another student's clarifying question.  Getting enough sleep helps a lot.
  5. If in doubt, ask.  If you don't understand something, it could probably be explained to you better, either by the instructor or by another student.  Asking makes it more likely that you can get this explanation.  Also, instructors like to see effort.
  6. Be curious.  It is great to ask "what if" and "why" questions.  Instructors love this and they will remember you for it, as long as you are not being obnoxious.
  7. Find the motivation.  Knowing why you (personally) should learn the material will help you with 1-6.  Do not be afraid to ask the instructor what the current topics are good for in the real world and what mastering the current content can do for you.
  8. Don't be lazy.  Read instructions.  For programming classes: look up syntax and try things out with the compiler/interpreter.  Your TA might like to be there for you, but you are better off trying things on your own.  You will not always have a TA in the real world.
  9. Be nice.  How smart you are often matters less than how nice you are.  For instance, the instructor will be much more likely to answer your questions thoroughly if you are nice.  
  10. Be a commitment minimalist.  If you have so many classes and extracurricular activities that you are not able to accomplish 1-9, cut down.  Many people have told me that they would have gotten a superior college education had they had done less and focused on it more.
In summary: school is often not about how smart you are, but about how much you are participating as an engaged human being.