Peter Christensen

  • Presentations
  • Contact Me

Running Windows Programs on OSX Using VMWare Fusion

August 12, 2014 by Peter Leave a Comment

I recently needed to run a Windows application (TurboTax Business) on my Macbook. I know about Parallels, dual boots, etc but those either cost money or seemed like too much work. Based on my experience with the incredible pain of getting a modern Rails stack to run on OSX, I decided to try using a VM, and it worked really well. Can’t recommend it enough.

Step 1: VMWare Fusion

I’m not often wowed by software, but VMWare Fusion is effectively magic. You can do the normal VM experience of having a computer in a window, but you can also run Windows programs separately and they behave like normal Mac apps. The 30 day free trial was plenty for me.

  • Downloads: http://www.vmware.com/go/tryfusion
  • Info: http://www.vmware.com/products/fusion/

Step 2: Windows ISO Images

I thought I was either going to have to buy a copy of Windows or do something shady. At the time, Microsoft has stopped selling Windows 7, but it was not how well supported my program was on Windows 8. I haven’t used Windows regularly since Vista, and I did not want this to suck up a bunch of time.

UPDATE: Microsoft shut down the Digital River links. I was able to find a Windows 8 ISO here: http://getintopc.com/softwares/operating-systems/download-windows-8-pro/

Luckily, you can legally download ISO images of Windows that come with a trial period, and you buy an activation key when the license runs out. I found a link to all the different variations of Windows 7 here: http://www.w7forums.com/threads/official-windows-7-sp1-iso-image-downloads.12325/. I chose Windows 7 Home Premium x64 English: http://msft.digitalrivercontent.net/win/X17-24209.iso (big file).

Step 3: Interacting with VM

From that point, it was easy to create a new VM, using the ISO as the disk. A shared disk folder, networking, etc all work with no additional setup. I downloaded and installed my program, and everything worked.

Bonus links

Discussion threads I read while figuring this out

  • https://blogs.vmware.com/teamfusion/2013/10/vmware-fusion-6-and-os-x-mavericks-the-perfect-combo.html
  • http://www.makeuseof.com/tag/vmware-fusion-6-opens-windows-on-your-mac/
  • http://www.macprovideo.com/hub/mac-osx/using-windows-8-under-vmware-fusion-part-1-installation

Filed Under: Programming

Take a Detour, Love Your City

August 4, 2014 by Peter Leave a Comment

Last week, Andrew Mason, founder and former CEO of Groupon, launched a new company. The company, Detour, makes “immersive, location-aware audio walks”. Just like Uber turns your GPS-enabled smart-phone to your personal driver, Detour turns your phone into a personal tour guide. Andrew and TechCrunch  give more background. I signed up immediately and was given early access, and had a great experience.

[Full disclosure: I used to work for Andrew at Groupon, and I’m a big fan]

I chose the tour of the San Francisco Ferry Building. There were a few minor technical issues getting started (that the team is aware of and working on), but most of the tour went extremely well. The Ferry Building is not hard to love, given it’s design, prominent location, the delicious shops inside. The main guide did a good job narrating the history, but the real treat, but a couple things made it even better than having a live tour guide. Since you’re listening on your headphones, they can provide different background sounds – walking up to the building, I heard old cable cars rumbling, horses neighing and clopping, and talk from a market a hundred years ago. But the real treat was the interviews with old-timers connected to the building. The man who has maintained the clock for decades explained how it is built to last for centuries, and at 120 years old is maybe 1% into it’s design life. A (fourth-generation?) worker on the tower describes hidden graffiti in secret spots, and tells a harrowing accident story about an accident. Detour didn’t just give a tour of a place, it was an intimate look into the life of the city and the people that have built it.

Technically, the app worked well. The marketing copy says that you shouldn’t need to pull out your phone after you start the tour, and that was mostly correct. The content is broken up into chapters, each of which starts when you get to a certain location. The tour guide gave clear directions, and I easily found all except one of the points on the first try. The timing of the directions was also impeccable – every time I thought “Wait, am I going the right way?”, it wasn’t 5 seconds before she said “You should be passing X on your left” and I was right there. I don’t know if they check your location in-between chapters and calibrate, or I walk exactly as fast as the tour guide expected, but it really did feel like magic. It was easy to forget that I was listening to a recording instead of being guided by a live person.

I have no doubts that the technical issues will be fixed – Andrew has great product sense and personality and the tech team is very sharp. As long as the tours remain as high quality as the one I took, Detour should be a great product, for tourists and locals alike. Some people thought Detour was a strange followup from the founder of Groupon, but I disagree. Although the e-commerce aspect is what drove that business, Groupon was, at its heart, about loving your neighborhood and your city more and having a great time. Detour is another, possibly purer expression of that same goal. It makes me want to visit more new places, to see them through Detour’s eyes.

Filed Under: Fun

Learning ClojureScript and Om

July 14, 2014 by Peter Leave a Comment

I missed a few weeks (months?) of writing about my learning sprints, because I’ve been way out of the routine that let me do independent work. At the end of April, I went to RailsConf in Chicago and had tons to process from everything I learned there. At the beginning of May, the company I worked for, Manilla, closed down and I had to find a new job. That took a month, and I started my new job at the Climate Corporation a few weeks ago. I’ve been getting up to speed and learning the code, systems, teams, products, etc there. But now things are settled and I’m back in the saddle.

This sprint I’m going to work on ClojureScript, particularly Om, the view state library built on Facebook’s React. I’ve looked at a lot of Javascript frameworks and libraries, and most of them seem … wrong. Not bad, but each of them bugs me in its own way. React has a very solid conceptual basis and great implementation, and Om builds on that. Add the benefits of ClojureScript over vanialla Javascript and it seems like a great platform to learn.

I’m going to start by working through David Nolen’s Om tutorials:

  • https://github.com/swannodette/om/wiki/Basic-Tutorial
  • https://github.com/swannodette/om/wiki/Intermediate-Tutorial

I have a project in mind if I have time (or maybe next sprint). I swim for exercise, and swim workouts tend to be a lot of: “Swim X yards, Y times, on a time interval of Z”. I’ve looked for an app that lets you setup and run the timer for those workouts, but this is one of the only times I haven’t found a single app that does what I’m looking for. While I don’t want to bring my iPhone to the pool, it seems like a tractable problem for a week or two:

  • Parse a string like “4×100@3:00” and add those sets to the workout
  • Start a workout and count down each of the intervals
  • Bonus: button to indicate when you finish each distance. The timer will continue, but this will let you know if you’re taking 2:30 of 3:00 and getting a short rest, or 1:30 of 3:00 and you should reduce your interval time.

I’ll post my notes, results, and progress in a week or two.

Filed Under: Clojure

Fast Rails Tests Through Behavior Verification

May 17, 2014 by Peter Leave a Comment

[This was originally posted on Manilla’s tech blog, which is no longer up. RIP Manilla]

Most Rails developers have a love/hate relationship with their tests.  We love testing, we love writing tests, we love the confidence that a robust test suite provides when refactoring or adding new features.  But sometimes, especially with a large test suite, running the tests takes a disruptive and discouraging amount of time.

At Manilla, it takes about 20 minutes to run the complete test suite.  This is not terrible, but it’s far too much to run during development.  So we usually only run the spec file for the code file we’re working on, then we’re done developing, we run the whole suite before committing to our master branch.

My previous employer was a much larger company with many times more tests.  It was basically impossible to run the test suite on a developer machine so we had a massive parallelized CI-farm that everyone used every time they were committing code.  So while the situation at Manilla is still tolerable, I know what the future holds.

(most of what I’m about to say is paraphrased from Corey Haines’ excellent talk on Fast Rails Tests)

There are two approaches to making your test suite run faster.

The first is to improve your test infrastructure.  There are lots of strategies for this, like using fixtures instead of factories, using fixture_builder to ease the pain of maintaining fixtures, running spork to speed up running individual tests, etc.  These are attractive because let you continue writing tests in the way most people already do, but they require occasional bursts of non-development work to keep running.

The second approach is what Corey simply calls “changing the design of your code”.  He shows a lot of examples and benefits, but he glossed over the philosophical difference that underlies his approach.  I didn’t really get his talk until I grasped this distinction.

State Verification vs Behavior Verification

The best description of this is in Martin Fowler’s essay Mocks Aren’t Stubs.  Here’s a quick example for those of you who didn’t read that essay like I just told you to.  Imagine you’re writing a class for an ATM, and you want to test the deposit function.

Here’s your function:

## atm.rb
def deposit(account, amount)
  account.create_transaction(amount)
end

With state verification, your test code looks like this:

## atm_spec.rb
it "#deposit - should increase the Account balance" do
  account = Account.new(:balance => 100)
  Atm.new.deposit(account, 100)
  account.balance.should == 200
end

The test ends up being a mini-integration test that not only does your Atm.deposit work, but the Account.deposit works too.

With behavior verification testing, the test code looks like this:

## atm_spec.rb
class FakeAccount
end
it "#deposit - should tell Account to create a transaction" do
  account = FakeAccount.new
  account.should_receive(:create_transaction).with(100)
  Atm.new.deposit(account, 100)
end

In this case, you’re not testing that the balance of the account actually increased, you’re just verifying that you called the account object the way you expect to be calling it.  With behavior verification testing, you treat any class outside the class you’re currently testing as an API.  Most developers already do this with things like email, geocoding, batch processing, etc.

There are two huge implications of behavior verification testing.

Your unit tests for one class or module can’t be broken by code changes in other model.  This is a good thing because a change in one class won’t break hundreds of dependent tests across the entire suite.  But it also makes your integration tests that much more important.  If the interface to a class changes, your behavior verification tests won’t break even though the code no longer works.  State verification tests do test integration as deep as the coupling between the classes, but still need to be backed by real end-to-end integration tests.

The other point, relevant to test speed, is that you don’t need to load any resources that aren’t used by the class or module you’re testing.  So just like you don’t need to actually send emails when you run your email tests, you don’t need to load external classes to make sure you’re calling them correctly.

In the context of Rails, this means that through some slight restructuring of your code, you can avoid calling one big huge heavy API: Rails itself.  Loading any ActiveRecord class requires loading Rails, which takes several to many seconds, and including spec_helper takes many more seconds.

But how do avoid using Rails and ActiveRecord?

Strategies for Writing Fast Tests in Rails

Don’t get me wrong – ActiveRecord is a wonderful thing.  Rails is great.  If lines of code were pollutants, Rails would be the love-child of Al Gore and Captain Planet.  But it has a tendency to take over and get into all of your code.  Rails calls your code, rather than you calling Rails code.  Here’s how to slightly change your code to isolate your business logic from Rails and greatly speed up your test execution:

First, continue using ActiveRecord for persistence, validation, relationships, etc.  It’s wonderful for that.

For class Foo, create a module called FooBehavior (or some more targeted subset, like FooDepositBehavior) and include that in your class.

Move your business logic methods to that module and change them so they do not assume internal knowledge of the class.  For instance, change this:

## account.rb
def approve_loan_request?(withdrawal_amount)
  self.balance > withdrawal_amount
end

to this:

## account_bahavior.rb
def approve_loan_request?(withdrawal_amount, current_balance)
  current_balance > withdrawal_amount
end

The code looks almost identical, but in the first version, the innocent looking ‘self.balance’ requires the whole infrastructure of Rails to be in memory, it might make a database call unless it has already loaded the object, etc.  The second version is just about the easiest line of Ruby code ever written.

Here are some tips to write fast behavoir verification testable code:

  • Extract business logic code into its own module where appropriate
  • In business logic methods, pass all arguments and compute based on those (this also makes your tests more meaningful because they’re not dependent on outside state – see Functional Programming For the Rest of Us for more details)
  • When you need to lookup data using ActiveRecord’s API, use scopes or create your own methods that only contain AR queries and only return results.  This makes stubbing much easier.

And in your tests:

  • Require only the specific file(s) you’re testing
  • Put a dummy class at the top of your file for any external resources you’re calling
  • Use doubles or mocks, not factories or fixtures.  If you’ve separated your business logic from your AR classes, then your code and tests don’t need to know the difference between a full ActiveRecord object and a mock.
  • Put your “fast tests” in a separate directory (e.g. spec/fast/).  This makes them easier to run all at once.
  • Write a script (not a rake task, rake loads Rails) to run all your fast tests.  If you write tests like this, it’s faster to run the whole fast test suite than it is to autocomplete the filename that you’re working on. Ours looks like this:
#!/usr/bin/ruby
def test_files(dir)
 Dir["#{dir}**/*_spec.rb"].join " "
end
exec "rspec #{test_files('spec/fast/')}"

Results

We just started down this road so right now there’s only one file of fast tests, but there’s a look at the difference it makes:

Without Spork running:

$ time rspec spec/models/interstitial_announcement_spec.rb 
…
  11/11:       100% |==========================================| Time: 00:00:03

Finished in 3.47 seconds
11 examples, 0 failures
real    1m40.845s
user    1m29.785s
sys     0m4.165s

With Spork running:

$ time rspec spec/models/interstitial_announcement_spec.rb 
...
  11/11:       100% |==========================================| Time: 00:00:02

Finished in 2.57 seconds
11 examples, 0 failures 
real    0m10.528s
user    0m2.269s
sys     0m0.196s

After converted to fast tests:

$ time fast_tests
…
  12/12:       100% |==========================================| Time: 00:00:00

Finished in 0.07578 seconds
12 examples, 0 failures 
real    0m2.834s
user    0m2.519s
sys     0m0.246s

Summary:

Without Spork 1:40.8

With Spork 0:10.5

Fast Style 0:02.8

Conclusion

If you’re still reading, then you have an amazing attention span.  This journey felt a lot like tracking down an odd bug, where one symptom leads to a whole different root cause and solution.  I did not expect to end up studying testing philosophies when I was grumbling bad thoughts while waiting for my tests to run.  But even without the side benefit of faster tests, I’m grateful I learned a new way to look at testing.

Like so many things in programming, state verification vs behavior verification is “it depends”, not “right or wrong”.  There is some code that just works better with state verification.  Also, I bet most of your tests are already state verification, and there’s no reason to do a big-bang rewrite of everything at once.  Just convert the appropriate parts of a class to use behavior verification testing as you’re working on that class, over time, 5%, 20%, 50% of your test suite will be fast.

The real benefit is only partly to your full suite execution time.  A fast test suite can run thousands of tests per second, so instead of running only the test file you’re working on while you develop, you can run a big fraction of all your test suite. Every. Time. You. Write. Code.  Then, testing can be something you do while you develop instead of after it.

 

Filed Under: Programming

Software Talks for the Ages

May 8, 2014 by Peter Leave a Comment

Sturgeon’s law applies to talks. Despite the best efforts of conference organizers and speakers, most talks about software are too narrow, to vague, too detailed, too specific to the time when they were given. (Don’t anyone take offense, I’ve given some of those!)

But the best talks, oh, the best talks ring in your mind like a crystal glass, bearing fruitful ideas for years to come and on viewing after viewing.

I was at RailsConf 2014 and while I enjoyed DHH’s talk about Writing Software, several of my co-workers were very moved by it. His background as a computer nerd but not a programmer, his life outside of tech hubs, his non-Computer Science background, all spoke to them in a way that few talks by people with more formal and academic backgrounds did not.

I realized that in addition to programming for almost 25 years, I’ve been watching and listening to talks about software for almost 10 years, and some of those talks are as vivid as the day I first watched them. When I mentioned some of them, and my coworkers hadn’t heard of them, I felt a wonderful opportunity to share awesome stuff.

Here are some of the software talks that have made an impact on me.

Growing a Language by Guy Steele

This message unfolds in such a subtle and effective way that I won’t spoil the surprise. But both the words and format of the talk are a masterpiece.

50 in 50

This talk opened my eyes to the creativity and playfulness of programming language design, and made it sink into this thick analytical head that expressing an idea can be its own reward.

  • MP3: http://www.oopsla.org/oopsla2007/podcasts/invited-talks/keynote0104-50-in-50.mp3
  • Video: http://vimeo.com/25958308

YOW! 2010 50 in 50 Keynote Guy Steele and Richard Gabriel from YOW! 2010 on Vimeo.

OOPSLA 2007

I don’t know what magic happened at this conference, but I was blown away by talk after talk after talk. I still remember these talks 7 years after listening to them as a podcast. Two in particular stood out:

  • Fred Brooks – http://www.oopsla.org/podcasts/Keynote_FrederickBrooks.mp3
  • Kathy Sierra – http://www.oopsla.org/oopsla2007/podcasts/invited-talks/keynote0102-kathy-sierra.mp3

Rich Hickey

Rich Hickey, the creator of the Clojure programming language, has unorthodox but appealing and unassailably logical views on software development. These are 3 of his best talks.

  • Hammock Driven Development – the best software comes from the best designs, and the best designs take time. Time thinking, time away from firefighting and away from hacking.
  • Simple Made Easy – Simple is a unit of software that does one thing. Easy is the thing that takes the least up-front effort. Confuse them at your peril.
  • The Value of Values – Immutable data facts better represent the real world, and there are many benefits to inferring state from facts rather than continuous mutation of state.

You and Your Research

This talk by mathematician Richard Hamming covers work habits, producing impactful work, and prioritizing excellence.

  • Transcript: http://www.paulgraham.com/hamming.html
  • Video: https://www.youtube.com/watch?v=a1zDuOPkMSw
  • A lecture series that this talk came from: https://www.youtube.com/playlist?list=PL2FF649D0C4407B30

Randy Pausch – Last Lecture

Before he died, professor Randy Pausch gave this talk about Achieving Your Childhood Dreams

End of Fun by Sarah Mei

A deeply useful talk about the difference between work and play, creativity and process, and open and closed thinking.

  • Slides: https://speakerdeck.com/sarahmei/the-end-of-fun-lone-star-ruby

Structure and Interpretation of Computer Programs

The classic MIT textbook and lecture series. The textbook is amazing in the graceful way it builds up topics in computation while still seeming simple. The 20 part video lecture series from 1986 is so, so great. It’s tempting to dismiss it because of the old fashion and the sloooow Scheme interpreter they use on an overhead projector, but Abelson and Sussman are such clear teachers and so playfully confident that you can’t help but love it. This is time well, well spent.

  • Lecture series: https://www.youtube.com/playlist?list=PLB63C06FAF154F047

Part 1A

Conclusion

These are only some of the great talks that have been given. They are some of the great treasures of programming education and culture

Please, let me know which ones I’m missing!

Filed Under: Clojure, Programming

Pedestal Tutorial Part 2 – Notes and Thoughts

February 5, 2014 by Peter Leave a Comment

I finished working through the 2nd half of the Pedestal App tutorial (see my notes on the first half) and I continue to be very impressed with it, especially when you consider that it’s at version 0.2. Rather than switch to another topic for my next personal sprint, I’m going to continue with Pedestal and write my own Pedestal App project. I’ve learned about as much as I can from following someone else’s example, but I need to dig into it myself and create my own project to get to the next level.

I posted my repos for the app and service projects. It’s the same as the official repo, with two differences:

  • It’s a working 0.2 app
  • The commits are by subsection instead of by page, so they’re a lot smaller. When I got mixed up, it was hard to use the diffs in their repo because all the changes from 2-5 sections on the page.

My repos:

  • pedestal-app-tutorial-by-section
  • pedestal-app-tutorial-by-section-service

Here’s a summary of my understanding of Pedestal App after completing the 29-part tutorial:

  • I get the architecture of the different queues and movement between them. The flow diagrams, step-by-step building up of complexity, and repetition really made this sink in.
  • I get the basic gist of how to write the dataflow definition, but I need a lot of reps to become more familiar with the full API. That looks like the core skill in mastering Pedestal App.
  • I’m still pretty unclear about which messages to use, how to nest them, when to send and capture what, etc. This is the part I expect to gain the most from doing my own project.
  • This is the first Clojure/ClojureScript project I’ve spent more than a toy amount of effort on. Due to my typos and some differences between the tutorial (written for v0.1) and the v0.2 of the library, I encountered some ugly bugs and learned a lot trying to fix them. I got do deal with things like logging in Clojure and ClojureScript, using the Chrome debugger and source maps, leiningen commands, the folder directory structure, etc. I’m still rookie and a half, but at least I have some sense of what planet I’m on for Clojure development.
  • My emacs is sort-of setup for Clojure development, but there are some things I could do to make it better. Mainly configure paredit to turn on automatically, learn how to use it better, and resolve some conflicting key chords. I deferred doing those because that’s the kind of stuff that got me distracted in the past.

Here are my notes on each section of Part 2 of the tutorial:

[Read more…]

Filed Under: Clojure, Personal Sprints

Pedestal Lightning Talk Notes

January 27, 2014 by Peter Leave a Comment

Tonight I gave a lightning talk about Pedestal at the San Francisco ClojureScript meetup. I’m still working through the tutorial so my understanding and experience are both limited, but this was a good chance to gather my thoughts.

Most people hadn’t worked with Pedestal so even though I’m still learning, there was a lot to share and a lot of good questions. Here are the notes I presented.

[Read more…]

Filed Under: Clojure

Pedestal Tutorial Part 1 – Notes and Thoughts

January 23, 2014 by Peter Leave a Comment

[UPDATE: Notes on Part 2]

I’ve been working through the excellent Pedestal tutorial and I am genuinely excited about Pedestal.

So excited about @pedestal_team – the last time I was this excited about a new technology was Ruby on Rails in 2005. Giddy!

— Peter Christensen (@christensenp) January 18, 2014

 

lol @pedestal_team event delta playback is bi-directional, like database migrations in Rails. So awesome it’s silly

— Peter Christensen (@christensenp) January 18, 2014

It’s such a simple, Clojure-y approach to single-page web apps. I expect it to face slow and limited adoption because it’s a very different and strongly opinionated approach with a steep learning curve. It’s not possible to sip Pedestal, you have to swallow it whole. But whether or not you use it for any projects, it’s worth working through to experience its design principles. (Kind of like Lisp.)

Some of the key principles:

  • The application is split into data, application model (the structure of how the data will be rendered), and the rendering.
  • No callbacks – every function does some simple work and puts a message on a queue.
  • Server and client code should be separate, and indeed are in different projects.
  • Apps should handle 2-way data from multiple sources.

There are a few minor changes from Pedestal 0.1 to 0.2, and this affects the tutorial. They’re mostly called out in the wiki but here’s another heads up:

  • Configuration changed from config/config.clj (referred in text and present in the code repo) to config/config.edn. I think the file contents are the same, as EDN is a subset of Clojure.
  • When running a repl for a v0.2 app, you do not need to run (use ‘dev)
  • The test files started in a separate directory (tutorial-client/test/tutorial_client/test/behavior.clj) in v0.1 but moved to the same directory as code files and using a naming convention in v0.2 (tutorial-client/test/tutorial_client/behavior_test.clj)

Here are my notes on the 15 sections of Part 1. Next up, Part 2!

[Read more…]

Filed Under: Clojure

Notes on Web Apps in Clojure+ClojureScript with Pedestal

January 17, 2014 by Peter Leave a Comment

My study project for the month is the Pedestal web app library by Cognitect. I’ve mentioned it before, but it’s worth repeating: the best page to understand what Pedestal is for is What I’ve Learned About Making ClojureScript Applications With Pedestal by Tero Parviainen. This provides the big picture whats and whys that the tutorial doesn’t (or doesn’t begin with). EVERYONE thinking of going through the tutorial should read this first.

Another great resource for understanding Pedestal, including seeing it in action, is Brenton Ashworth‘s talk from Strangeloop 2013: Web Apps in Clojure+ClojureScript with Pedestal. It’s a 39 minute video with slides and demos, which is still a lot less to bite of than the 8-12 hours to work through the whole Pedestal tutorial. I’ve posted my notes on the talk below, hopefully someone else will find them useful.

Thanks Brenton and Cognitect for all the great Clojure work and outreach!

  • What type of app
    • Designed for interactive, 2 way transfer of info
    • Receive inputs from multiple source (not just the user UI)
    • Coordinate events on the client
    • Large, long-running applications
  • Other libs/frameworks depend on mutation, OO concepts, not functional
  • Example app – sales funnel, real-time shopper progression + reaction, process 1000 events/sec, update browser 2x/sec
    • Sweet screenshot at 6:18, simulation demo at 6:45
    • Web_Apps_in_Clojure_and_ClojureScript_with_Pedestal
    • Bad demo 8:45 with choppy animation
    • How do we draw/visualize all this stuff?
      • Pedestal doesn’t help with that – Raphael and HiCharts in widgets
      • Written in regular JS, no state
  • How do we control it? – Pedestal
    • Separation of concerns – rendering/information model+logic/services, communicate by messages + queues
      • rendering, information model & logic, services
    • Information model – standard way to organize and store data
      • data stored in a tree of nested maps, so a list of symbols is a tree traversal to a piece of data
      • basis and derived information
      • some information so support the UI
    • State transition model – an orderly succession of states from one input to a new output
      • associate cause (incoming message) to effect (new state)
      • prefer to store state in one atom that you can watch, monitor, etc
      • Pedestal provides fine-grained change reporting to make lots of data in one atom manageable
    • Dataflow – disconnect functions from how they are executed
      • declarative inputs and outputs
      • automatic minimal propagation
      • no explicit pub/sub or conditionals
      • great way to encode data dependencies
      • promotes adding code instead of updating code – small focused functions that you can recombine instead of tweaking conditionals
      • 21:10 – walkthrough of a dataflow event
      • 22:50 – walkthrough of a roundtrip through event, message, info model, rendering
  • Demo app – everything runs in web workers, except only UI which runs on the main thread
  • 25:15 core.async
    • Good advice: “If Rich Hickey announces he’s working on something related to what you’re doing, just wait for him to be ready.”
    • allows you to program in the browsers as if you had real blocking threads
    • current message processing – change message, map message to function, call function, queue return message
    • new message processing – inform channel – map message to function, call function, return transform messages
      • inform message: “Here’s how I changed”
      • transform message: “Here’s how I’d like you to change”
    • 28:25 Future Pedestal structure
      • view → event → inform mesage → fn → transform message → deterministically update information model → UI change messages → UI change fns
      • allows you to encapsulate changes in widgets, as long as they can handle inform/transform messages
      • widgets aren’t limited to UI – it can also encapsulate communication with external services
  • Q&A
    • shouldn’t be a problem to have a Javascript API that you can plug into
    • core.async doesn’t make it harder to test the declared dataflow functions
      • functions don’t need to be aware of the channels sending the messages
      • You can also write functions that return a channel if the API you’re calling is fast
    • messages can be stored & replayed to replicate rendering scenarios
    • Clojure provides code and structure to get code into webworkers, it’s configurable
      • you can setup channels to correspond to UI/webworker boundaries
    • The declared inputs/outputs let you test beforehand that you don’t have infinite loops
    • It feels quite natural if you are familiar with Clojure principles

Filed Under: Clojure

Sprint Continuation – Pedestal

January 14, 2014 by Peter Leave a Comment

I continued working on the Pedestal Tutorial this week. I’m going to continue working on it for the next 2 weeks.

I’m about halfway done with Part 1. I ran into some problems on Simulating Service Push, where it wasn’t recognizing a method in one of the namespaces I included. I dug around a ton and never figured out what was wrong – I eventually threw in the towel, reverted to a previous commit and re-did the work and the bug didn’t appear. Heisenbastards.

I did also find some helpful, big picture resources:

  • What I’ve Learned About Making ClojureScript Applications With Pedestal by Tero Parviainen. This provides the big picture whats and whys that the tutorial doens’t (or doesn’t begin with). EVERYONE thinking of going through the tutorial should read this first.
  • Web Apps in Clojure and ClojureScript with Pedestal by Brenton Ashworth. I’m halfway through this (I take good notes which I’ll share later), but it includes the tagline that I wish was at the top of Pedestal.io:

Pedestal is designed interactive, 2-way transfer of data

    • I know videos are a pain to watch, but the demo app at 6:45 is pretty spectacular.

More about Pedestal in 2 weeks!

Filed Under: Clojure, Personal Sprints

« Previous Page
Next Page »

Categories

  • Blog
  • Book Review
  • Business
  • Clojure
  • Education
  • Emacs
  • Fun
  • iOS
  • Lisp
  • Personal Sprints
  • Pictures
  • Polyphasic
  • Presentations
  • Programming
  • Rails
  • Startups
  • Uncategorized

Copyright © 2025 · Minimum Pro Theme on Genesis Framework · WordPress · Log in