Saturday, January 11, 2014

On Being Me

Hello world,

I'm writing about me today. It's a topic I don't often write about, because it's scary. That's the main reason why I'm writing about me - because I don't want it to be scary. I want to be me, wherever I go, whatever I am doing, and whoever I am with.

First, a story.

For over 10 years of my life, I've confined myself to two or three interests. This limitation felt safe. I felt confident in these areas, and that confidence helped shield me from the fear of being open.

Computer science

Video games

So really, two. I could go on and on about the right programming languages and methodologies to use, comparing alternatives. I loved speaking about and learning about new data structures, their various asymptotics, and where they were appropriate to use. I collected bits and pieces of information about advanced research in innumerable areas of computer science, because it helped protect me from feeling like I wasn't good enough. Maybe this is that impostor syndrome I've read about. It was a constant battle against fear of inadequacy.

And video games. They were a retreat. A place I could go and level up, and improve, and play, without the fear of being seen as less. I could talk about them, too, and compare them, and celebrate the little victories. Still, I couldn't use video games to play with others. It was scary to think that I might invite someone into a place of retreat.

So that was the me that I let myself be for years. I defined myself so strictly that when I finally started looking at who I was, I wasn't even really sure. I often said programmer. I sometimes said gamer. I've used student, as well. I was okay as long as I didn't have to step outside of those boxes.

Then, over the past few years, I've painfully realized that I wanted to be more. This is in no small part due to the patience, diligence, and understanding of my wife, Jessica Cabrera.

So here I am today, trying to figure out what it means to be me. How do I do it? By breaking out of the boxes I've made for myself, I think. By that, I mean, being open and honest wherever I can be. Here, too, in this blog that I started originally because the idea of being able to read books in exchange for reviews sounded awesome. Reader review programs - I'm still pretty fond of them.

All of my blogging efforts in the past have failed, and I think part of the cause was that I tried to narrow myself too much. I wrote only from the filter of my boxes, only one of which I felt safe speaking about in the open.

So here I am, encouraged by the discussions I see being held in the open. Questions of gender, of shaming, blaming, of connectivity, of sexuality, positivity, of empowerment, of the woes of meritocracies, of the individual, of collaboration and education, faltering political systems, and of living the life that only I can live. I want to participate in these discussions, because I don't want to stand by and silently allow for things to continue as they are.

So here I am. This is me, and some of the many things I care about. Nice to meet you, and I'll be writing again in the future.

Hello, world.

Tuesday, December 31, 2013

"Parallel and Concurrent Programming in Haskell" by Simon Marlow; O'Reilly Media;

I want to start writing this, but it's been forever since I actually read this book. I'm concerned I won't be able to do it justice.

So here's the deal: I've read this book once many months ago (June?), and I've been re-reading it since. Some of the details are blurry, but the gist of the book is still with me.

Without further ado, here's the review:



======
Review
======

Disclaimer: I'm reviewing this book under the O'Reilly Blogger Review program. (though I ended up purchasing a hard copy afterwards any way.)

This is The Book that sold me on Haskell for concurrent and parallel programming. Sure, I've read several articles on the benefits of functional languages for programming in the multi-core world, but that didn't really sink in until I saw how elegant it could be in a functional language.

In brief, the main benefits I got from reading this this book were:

* Surveyed parallel programming (in Haskell)
* Surveyed concurrent programming (in Haskell)
* Saw the elegance of the approaches for myself
* Learned about laziness gotchas in parallel contexts
* Learned a bit about what's next and left to improve
* Learned what modules to turn to and watch when in need

I hope I never have to look at OpenCL or CUDA C++ again for parallel programming. The way Repa/Accelerate handles this is beautiful.

The chapters on concurrent programming showed me how much having concurrency primitives built into a language change async programming. Having forkIO to run subsequent computations and a scheduler in the run-time make it very convenient.

In sum, I highly recommend this book. 10/10, one of my top 10 books of 2013.

Saturday, December 14, 2013

10 Ways to Incorporate Haskell into a Modern, Functional, CS Curriculum

I had some time to spare while I was waiting for dinner to be ready. Dinner was being prepared by the local China Gate, and it would probably take on the order of 10 to 15 minutes. So I sat down in the lobby with a notepad in hand.

The topic on my thoughts: how could Haskell be incorporated into a modern CS curriculum? I decided to run as radically as I could with this, writing a rough draft of what such a curriculum might look like.

I won't make any arguments for or against functional programming here. I refer readers instead to papers like this one and this one, talks like this one or this one, and books like this one. This is an exercise in ideation.

Without further ado, let's begin:

0. Haskell for Introductory Computer Science

Imagine this is the first time you're learning programming. You've never been exposed to mutation, to functions, to compiling, algorithms, or any of the details of architecture. Where do we start?

Four weeks of Haskell. Enough to get through the first few chapters of LYAH and be able to start thinking about recursion. End each week with a simple exercise, for example, upper-casing a list of strings, upper-casing only the first letter of every string that is longer than 2 characters - little things to build confidence. The Udacity Introduction to Computer Science course has many appropriate ideas for beginning level exercises.

With that introductory period out of the way, now's the time to show why computer science is relevant! Take the time to show case the areas: operating systems, networking, algorithms, programming languages, cryptography, architecture, hardware, and more. Make it relevant:

* Operating systems: Why are there so many? What does it do? How does my application (email, browser, Steam) run from beginning to end?
* Algorithms: How do you figure out if two characters have collided in a video game? How do you sort a list of address contacts alphabetically by last name?
* Networking: How do you send an instant message or an email to a friend on the other side of the world?
* Programming Languages: As with operating systems.

There are many applicable introductory exercises here that can set the pace for future courses.

1. Haskell for Basic Algorithms

This one, and the latter algorithms course on this "Top 10 List", deserve special attention.

Algorithms are fundamentally pure constructs. You give them a well-defined input, and receive a well-defined output

Take plenty of time to provide weekly exercises. Teaching sorting algorithms, trees, string matching algorithms, and more will be a delight here, I predict.

It's also a good time to introduce basic run-time analysis, e.g., Big O notation.

This is also a beautiful time to introduce QuickCheck in conjunction with invariants.

2. Haskell for Data Structures

Very similar to the basic algorithms course, except now we teach students about some basic ways to organize data. Lists, vectors, trees, hash maps, and graphs - these should be enough to keep most students (and practitioners) well-equipped for years!

QuickCheck and frequent programming exercises will do well here.

If an advanced version of this course is desired, I highly recommend starting from here to brainstorm a variant: Purely Functional Data Structures

3. Haskell for Networking

This can be very low-level (OSI network stack, TCP window buffering, etc.), it can be very high-level (HTTP, distributed systems), or some mix of the two.

I think the most important concepts students can come of this course with would be:

* Validating data at the boundaries and the dangers/usefulness of IO
* How to communicate with other systems
* How to write their own protocols, and why in general, they shouldn't reinvent the wheel

4. Haskell for Operating Systems

Teach them to ask - what is an operating system? How do I manage my resources?

It's worth surveying the concepts of: memory management, file systems, data persistence, concurrency, parallelism, process management, task scheduling, and possibly a bit more.

Great projects in this course include: 1) write your own shell, 2) write a simple, local task manager.

5. Haskell for Comparative Programming Languagues

Let's talk types, functions, composition, and problem solving using different approaches. Ideally, such a course would come after learning how to design solutions to mid-sized programming challenges.

After that, have students write an interpreter for a Lisp.

6. Haskell for Compiler Construction

More on: write your own language. This course should cover parsing, lexical analysis, type analysis, and the conversion from source to assembly.

7. Haskell for Advanced Algorithms

This one's going to be fun. Unleash the power of equational reasoning to put together a course that runs through: graph theory, network flow analysis, greedy algorithms, memoization, and more.

This would also be a great time to discuss how the price one pays for purity in regards to asymptotic performance, and how to overcome that, if necessary.

Also, an extended treatment of algorithmic analysis in the presence of laziness would be valuable here.

8. Haskell for Introductory Design of Programs

Really, this should be higher up in this list, and a very early course.

The goal of this course is to come out of it knowing how to:

* Get a big picture of what they're trying to build
* Break it down into the smaller pieces
* Iterate 'til they get the big picture running

It's a great time to teach some basic ideas for testing, how to experiment with the REPL, and how to take advantage of the type system for simple things.

On a more social level, it's a wonderful time to also guide students towards collaborative design, e.g., how to work together and make it fun and efficient.

9. Haskell for High-Performance Computing

This could be a very fun course. It affords the opportunity to allow students to run wild with simulations and experiments of their choosing, while learning about what it means to do high-performance computing in a functional language.

Given that, it should teach some basic tools that will be applicable to most or all projects. How does one benchmark well? What are the evils of optimization? What is over-optimization? When is optimization needed? What tools exist right now to harness parallelism in Haskell (Repa, Accelerate, etc.)? When is data distribution needed? Why is parallelism important? How is parallelism different than concurrency? How can the type system be wielded to help keep units (km/s, etc.) consistent across calculations?

I'd advocate for letting students choose their own projects built in parallel with the course taking place. A simple default is to optimize the much-lauded matrix multiply to larger and larger scales (distributed even, if they want to go so far!). Writing a collision detection engine for a simple game would be pretty interesting, as well.

Notably (in my opinion) absent topics:

* Hardware: CPUs, cache hierarchies, main memory, storage, interconnects
* Advanced data structures
* Cryptography
* Web development
* Type systems
* Cross-disciplinary development, e.g., Haskell for CS + [Physics, Chemistry, Biology, etc.]

These topics are absent from my list for no reason other than I didn't think of them 'til the list was done and articulated. There's so much one can learn and apply at the level of abstraction that computer science (and mathematics) affords that we could specialize further and further. For my own sake, I'm setting a limit. :)

Final Notes

I've just brain-stormed a curriculum in Haskell. There's a lot of details missing, but it's a working draft.

There's also other things to consider, beyond the technical aspects. Consider the social aspects. How we teach students to work together? How do we keep learning engaging and fun?  How do we help students connect to the greater community of developers that exist outside of academia? How do we keep the lessons relevant to the lives that they lead? How do we encourage them to pursue their passions?

To Be Honest...

I had forgotten that I ramped up this blog. It's been so long since I've looked at it, and I only came across it again since I've been actively considering writing. I was surprised to see that people were still periodically coming here over the past few months, even though it's been nearly six months since I last posted (thanks!).

I've been spending more time publishing mini-blogs over at https://thoughtstreams.io/. I have three categories so far: "Marconi Updates", "Haskell", and "Philosophy Behind Software, Love, and Life".

Thoughtstreams is a very interesting platform. More than any other blogging engine I've ever used, it tries not to get in the way. I just write, as little or as much as I like, and post. It even supports Markdown syntax, with basic support for code blocks! I've felt more compelled to write a little every day using that. It helps!

Marconi Updates is my micro-blog (shared with flaper87 and kgriffs). Herein, I write about our efforts on the Openstack Marconi project, a distributed queuing system written entirely in Python. Most of my updates are storage-centric, since that's one of the more interesting aspects of the project to me.

Haskell is all about Haskell! I've developed a sort of infatuation with the language over the past three years, even though I've yet to use it develop personal or professional projects. The appeal of a functional (double-meaning there), statically-typed language with elegant, terse syntax really gets the language geek in me going. I'll found this channel to be a great place to gush about the language, tidbits I find interesting, and what I hope to do with it.

Philosophy Behind Software, Love, and Life is a new experiment, shared with flaper87. In this microblog, I want to share more personal thoughts and beliefs. Thus far, I've written about mindfulness and about some of the personal struggles I've encountered in working with technology. I hope to share more of my personal story therein, and how they guide my beliefs on my journey through this world.

So that's the story. I think I isolated this blog to be too much about reviewing books in the past, and that really damaged my morale about posting here. In the future, I may discontinue this blog entirely and move over to a service like ThoughtStreams, or I may even spin up my own blog! For the time being, though, books need reviewing, I love writing, and I haven't made the time to designate any other place as my primary review blog spot.

Wednesday, August 21, 2013

"ZeroMQ: Messaging for Many Application" by Peter Hintjens; O'Reilly Media;

Building Distributed Systems and Communities

I was pleasantly surprised by this book. I came in expecting to learn about the magic of ZeroMQ, and I came out knowing not only more about ZeroMQ itself, but also distributed systems and community building.

The first chapter primes the rest of the text, preparing the reader to not only learn more about the world of distributed computing, but also begins instilling a certain excitement about how things could be so much easier, and how ZeroMQ enables this. This is surprising, as very few technical texts manage to become page-turners so quickly.

The next four chapters are a deep dive into ZeroMQ (and distributed systems) best practices. Heartbeats, publish/subscribe, request/reply, round-robin task distribution, and then composing all of these patterns and more. It's a collection of best practices without seeming like a dictionary. I could spend a few months practicing and studying these best practices and I'd feel like I knew more about how to build reliable systems.

The last half of the book is all about how to build communities and processes that last. Building distributed systems requires effective communication. There's a wealth of knowledge in the last portion of the book about how to enable that. Some great advice includes:

- separate maintainers from contributors
- use Github (which can be interpreted as: make issue tracking, persistent comments, and code review *really* easy)

A good chunk of the community building advice is available as the ZMQ C4 guide. It's elaborated on much more deeply in this book, which I appreciate. C4 is the contract; this book is the rationale.

If you're interested in or need to build a system that's highly concurrent, has high reliability and/or performance requirements, and even if you can't use ZMQ to build said system, get this book anyway. You'll learn a lot in the process that you can apply to making network (and team) communication much more effective.