Herding Code 157: Amir Rajan on dynamic web development with Oak and Gemini

On this episode of Herding Code, the guys talk to Amir Rajan about his Oak and Gemini projects, which bring Rails-inspired dynamic programming to ASP.NET MVC.

Download / Listen:

Herding Code 157 – Amir Rajan on dynamic web development with Oak and Gemini [audio://herdingcode.com/wp-content/uploads/HerdingCode-0157-Oak.mp3]

Show Notes:

  • Overview – Developing with Oak
    • Oak is an approach to building single page applications that are heavy on JavaScript that takes a lot of inspiration from the Ruby community’s development approach.
    • Jon asks Amir to explain his development workflow, including SpecWatcher, NSpec, and Growl.
    • Jon asks about the File / New Project experience. Amir describes how that’s not even required – Oak works with WarmuP to build out a new project.
    • The next step is using Rake – Amir explains how Rake works. Running Rake builds the application and deploys, then sets up IIS against that instance.
  • Dynamic programming and Gemini
    • Oak leverages the dynamic keyword. Amir explains how it just augments what’s already there in ASP.NET MVC.
    • Amir explains how Oak works with Gemini, separate library he’s built to enable building dynamic objects. It allows you to attach properties and methods through mixins. He gives an example of using Gemini to extend a dynamic object with validation methods.
    • Amir describes how Oak leverages Gemini to take advantage of these decorated dynamic model objects throughout the different layers.
    • Scott K asks where the composition happens – is this a pipeline process?
    • Jon says it sounds like this is a more fleshed out version of some dynamic features that were started in ASP.NET MVC, like dynamic views and ViewBag. He explains how Gemini goes beyond Expando, because it also includes support for method missing.
    • Jon says Gemini reminds him of the Clay dynamic objects used in Orchard.
  • Data access and Cambium
    • Jon asks Amir about Cambium, the data layer. Amir says he customized Rob Conery’s Massive library to work with his Gemini objects, and points out that the resulting library uses remarkably little code.
    • Scott K asks Amir if he’s looked at Breeze. Amir says so far he’s just worked with standard ASP.NET MVC controllers, but he’s interested in looking at Breeze, Dapper, and NoSQL ORMs.
  • But why?
    • Kevin asks the silly question: why bother bringing Rails idioms to ASP.NET MVC – why not work in Rails?
    • Jon says the thing he sees Amir’s done is eliminate the shift between development and runtime modes in Visual Studio based development.
    • Jon asks about change tracking support in Cambium.
  • More about data – migrations
    • Amir explains migrations and schema generation in Oak and Cambium.
    • Amir says that SQL based migrations are important in many development environments.
  • Single page and Ajax
    • Jon asks Amir about the Single Page Application story in Oak. Amir explains some of the points of friction that exist in ASP.NET SPAs and explains how Oak is able to round-trip dynamic types.
    • Scott K. asks why it’s so hard to migrate schemas in .NET. Amir says that it’s due to our fixation on trying to define our models using code first in .NET types rather than in the database.
    • Jon asks how the first deployment and upgrade scenarios work in Oak.
    • Jon asks how Ajax interactions work. Amir explains how this works using the TaskRabbit sample to explain.
    • Amir explains how he’s relying on client-side rendering and templating more and more. He asks if we’re seeing that movement as well, and Scott K. agrees with him. They agree that focusing on serving JSON and rendering on the client solves a lot of problems.
    • Jon asks Amir if he’s using one controller to serve HTML and JSON, or if they’re split out. Amir says he’s got one controller to serve the HTML, then does everything else via a separate controller that serves JSON. He says he’s noticed that the ORMs have very little need for state with this approach.
    • Jon says he’s seeing the shift from a little Ajax interaction in mostly HTML focused servers to servers that are almost completely focused on serving JSON.
  • Some misc. questions
    • Jon asks about Canopy. Amir describes how Canopy is a stabilization layer on top of Selinium, and talks about why Canopy is built on top of F#.
    • Scott K. asks if Amir has looked at OWIN yet.
    • Jon asks about Async support in Oak.
    • Twitter question from Bobby Johnson: What do you do to limit the viral nature of dynamic in your code? Amir and Jon talk about how a lot of the assumed safety of static code is an illusion when you think about all the moving parts you’ve got no control over.
    • K. Scott and Scott K. think this is a fascinating project and like the code.
    • Scott K. and Jon joke about variants. Amir mentions that the dynamic nature of Gemini means that all the dynamic properties and methods are case insensitive.
  • Wrap up and getting started with Oak
    • Amir talks about how to get started with Oak.
    • Jon says the sample apps, documentation and screencasts are really nice.
    • Jon asks what’s next. Amir lists a better SPA story, better file uploads, adding dynamic to ServiceStack and Nancy, and growing the number of Gemini modules.
    • Kevin asks about the performance impact of this dynamic focus. Amir that he’s got an included test, and he’s found that dynamic is actually faster in a lot of cases which need to use reflection, such as ORMs, JSON serialization, and model binding.
    • Amir calls out the NSpec project and references their interview on Hanselminutes.

Show Links:

Herding Code 156: Catching up with Andreas HÃ¥kansson and Steven Robbins on NancyFx

The guys catch up with Andreas and Steve on what’s new in NancyFx (a web framework for .NET that was originally inspired by Sinatra).

Download / Listen:

Herding Code 156 – Catching up with Andreas HÃ¥kansson and Steven Robbins on NancyFx [audio://herdingcode.com/wp-content/uploads/HerdingCode-0156-NancyFx.mp3]

Show Notes:

  • Jon asks for a quick overview of NancyFx. Steve and Andreas both say you can write the same app on any number of web frameworks, so what really distinguishes them is the syntax and feel. Andreas says that the web only has a small set of things you really can do – there are only a few HTTP methods – but an infinite number of ways you can build applications; Nancy is one of them.
  • Diagnostics
    • Andreas says Diagnostics is a website built into Nancy itself. It covers things like request tracing and interactive diagnostics.
    • Steve explains how the interactive diagnostics lets you find out what routes were hit and why, poke at live code, etc.
    • Andreas says this works using companion classes for metadata which is then rendered via JavaScript templates, so you can customize it as much as you want.
    • Jon says the code for Diagnostics seems like pretty good sample code for getting an idea of how Nancy code works.
    • Jon asks about how authentication is handled to restrict access.
    • Steve says they’re using Handlebars for JavaScript templates with Backbone and Nancy on the back end.
  • Content Negotiation
    • Andreas explains how routes just return models, and the formatting is handled by response processors. There’s a syntax to allow for more control at the route level if needed.
    • Steve says the response processors are allowed to participate in the selection by specifying how applicable they are for both content types and model types. The content negotiation can also allow you to select different models based on the request, avoiding unnecessary code from executing and weighing the model down unnecessarily.
  • Serializers and dependencies
    • Jon asks about the JSON serializers they’re using, and why they’re not using something like ServiceStack or JSON.NET. Andreas explains that because the Nancy core ships without dependencies, they used Mono code.
    • Jon asks about where Nancy can be be embedded, outside of standard web hosting scenarios.
    • Steve says that because Nancy doesn’t have other dependencies and is strictly focused on returning a response for a request, it’s extremely easy to test.
    • Andreas points out that you can use other serializers very easily via a NuGet package.
    • Jon asks about how packages work in Nancy. Andreas explains how Nancy scans for classes that implement ISerializer.
    • Kevin asks about implementing a processor for generating hyperlinks between models.
    • Jon asks if people are sharing processors. Steve says that they’re so trivial to write that there’s no real point in sharing them.
  • Localization
    • Andreas says this was a community contribution. There are several conventions (including querystring values, URL segments) which can be used to set the culture for the context. There’s a helper on the Razor base class that returns a dynamic object which can return localized values from a resource. Assembly resources are used by default, but you can add others.
    • Steve says that you can also use localized views based on filename.
    • Jon asks for more information on how you’d set up a custom resource location.
  • Architecture, pipelines, and IoC
    • Jon says that he spoke with Jeremy Miller at Codemash, and Jeremy said that it took a while to get the processor architecture set up, but now it’s very easy to add in features. It seems like that’s also paid off for Nancy. Andreas agrees, the pipeline system and dependency injection really simplify adding in new features.
    • Jon asks about how Nancy uses TinyIoC and how you could use TinyIoC in other applications.
    • Kevin and Jon ask about how Steve wrote TinyIoC to run on multiple platforms. Steve describes some issues they’ve worked around and how assembly scanning can get tricky due to test frameworks injecting things into the app domain.
  • Non-standard uses of Nancy
    • Jon asks for some examples. Steve says they seen people embed it into WPF applications for an interface, to provide mobile support, and even on Raspberry Pi. They’d love to hear more about what people are doing with it.
  • Questions from Twitter / Misc. Questions
    • Jim Liddell (@liddellj) asks about the roadmap. Steve talks about work they’re doing for OWIN and Async support.
    • Filip W (@filip_woj) asks "Why tuples instead of classes and structs?"
    • Kristof Claes (@kristofclaes) asks "How do they determine when something is "too much ceremony"? Gut feeling? Set of defined rules? Talk? Compare to other FX?"
    • Ian Battersby (@Cranialstrain) asks "Why dynamic? And don’t say fluency ;)"
    • Tobi Tobsen (@t0bit0bsen) asks "Is there a NancyFx tutorial for devs w/o a background in web development or should they look elsewhere?"
    • Jim Liddell (@liddellj) asks "How do you view Nancy in relation to similar frameworks, such as OpenRasta?"
    • Kevin asks about asset management for Nancy. Steve says that’s probably better handled by external
    • Kevin asks about web socket support. Steve says just use SignalR.
    • There’s a Nancy store now.
    • Daniel Lee (@danlimerick) asks "How many hours a week do you spend on Nancy? What’s ratio of reviewing PR’s vs writing new features?"
    • Jon asks what Steve and Andreas are finding fun and interesting lately. Steve and Andreas both like Mongo.
    • Scott K. asks if they’ll add time zone localization support. They tell him to submit a pull request.

Show Links:

Herding Code 155 – Ward Bell on Single Page Applications and Breeze

On this episode of Herding Code, the guys talk to Ward Bell about single page applications and the Breeze project.

Download / Listen:

Herding Code 155 – Ward Bell on Single Page Applications and Breeze [audio://herdingcode.com/wp-content/uploads/HerdingCode-0155-Ward-Bell.mp3]

Show Notes:

  • General SPA discussion
    • Ward talks about how IdeaBlade has been building tools for working with data in rich clients for a while, and after seeing the move towards desktop experiences in the browser they started the Breeze project, which is open source and free.
    • Jon asks Ward to define single page applications (SPAs) a bit, and Ward says he sees SPA as a funny term since it just describes one attribute of the experience – it’s like calling a car a “horseless carriage.” Ward says the goal is to give the user a rich experience and not rely on the server to deliver that rich experience. A lot of the value comes from maintaining data and state on the client.
    • There’s a discussion about the value and best applications of SPAs.
    • Kevin says there are a few aspects of SPAs – there can be a lot of individual, interactive pages which are separately delivered by the server, or you can have a more full application which handles screen transitions on the client. Ward talks about the tradeoffs of the two approaches. The whole SPA application approach is especially important in newer scenarios like mobile or Window Store applications built in HTML/JS.
    • Scott K asks about the different approaches to data loading – do you preload some of the data, or does the first page request just deliver an HTML client which requests all the data.
    • Scott K asks how often Ward sees offline manifests and local data. Ward says he sees things going that way, but it’s still early. Scott K and Ward talk about the difficulty of synchronizing offline changes when you’re reconnected.
    • Scott K and Ward talk about the use of Web Sockets and / or SignalR to handle locks to allow for multiple users.
  • Breeze
    • Jon asks Ward how Breeze helps
    • Ward says that they’re not trying to solve solved problems – they’re focused on solving the data problem.
  • Breeze, Upshot, and the ASP.NET SPA template
    • Jon asks how this fits in with the former ASP.NET SPA template and Upshot. There’s a discussion the history and state of Upshot and RIA Services.
    • Scott K asks about whether Upshot will be released as open source… or the unreleased ASP.NET MVC Recipes source. Jon starts crying.
    • Jon and Ward talk about how one of the big features of Upshot was that there were both client and server side parts to it.
    • Ward said they’d learned from the Upshot, so they made Breeze very extensible while making for an easy path when using ASP.NET Web API and Entity Framework.
    • Ward says the current ASP.NET MVC SPA app is too simplistic, because it’s just one simple screen.
  • Working with Breeze – client state, server-side interaction
    • Jon asks Ward about how Breeze handles local state. Ward describes how the server can send down metadata (likely from an Entity Framework model) to the Breeze client code so it can understand the models, relationships, validation rules, etc. You can extend things if you need to, but you don’t need to bother with the tedium of creating client models that match your server-side models.
    • The generated client-side models are ready to be hooked up to Knockout so they’re easily bound to the UI.
    • Jon asks how things are different on the server. Ward says that standard ASP.NET Web API controllers are very repetitive – each controller has GET, PUT, POST, DELETE methods that are just boilerplate. Pretty soon you end up with thirty API Controllers which just contain a lot of boilerplate code. Breeze can just expose things as Queryables so you really just need one controller unless you want to customize things. Scott K says it sounds like it’s basically Repository<T>. Scott K says he’d like to see it go further – at Cascadia there were some talks about big data where queries were created on the client and sent to the server.
    • Jon and Ward talk about the difficulties of complex repetitive APIs with too many entry points.
  • How Breeze fits in with other frameworks like Ember, Angular, Backbone, etc.
    • Jon asks how Breeze fits in with Ember, Angular, and other SPA frameworks. Ward talks about different framework philosophies and how Ember and Angular both more of top to bottom stacks. Kevin mentions how Backbone differs – it’s more of a library vs. a framework.
    • Ward says that Breeze really targets the data scenario. Jon asks how close its vision is to Upshot’s. Ward explains how, other than Ember Data, nobody’s looking at solving the data scenarios – they don’t worry about caching, object graphs, change tracking, etc. Scott K says the other frameworks are really MVC focused, so they don’t consider data.
    • Scott K asks what happened to Batman.js. Nobody knows.
    • Jon asks if the happy path for Ember is Rails focused and Breeze is ASP.NET / Entity Framework focused. Ward says yes, with a clarification that we’re really talking about Ember Data.
  • Getting Started
    • Jon asks if it’s difficult to get started with Breeze.
    • Ward talks about the NuGet package that gets a sample project set up quickly.
    • Ward talks about the live tutorial that lets you play with Breeze in a browser.
    • Ward talks about the automated tests they’ve got for Breeze training. Jon compares it to Ruby Koans.
  • Jon, Ward, Kevin and Scott K talk about automated JavaScript testing options – Chutzpah, QUnit, Jasmine, Mocha.
    • Chutzpah is an automated JavaScript test runner that can run inside of Visual Studio.
    • QUnit is pretty simple – tests are functions that take true or false.
    • Jasmine is more BDD style.
    • Mocha is a test framework that supports different front ends, so you can use BDD, standard unit testing, etc. It’s also got great async support.
  • Ward brings up TypeScript and Scott Koon starts cursing.
  • Wrap up small talk
    • Jon says that the talk about mocha reminds him of coffee, and he asks Ward about his new espresso machine. Jon and Ward both get their coffee beans from Sweet Maria’s.
    • Jon says he’s still roasting his coffee on his barbeque.
  • Scott K asks what dependencies Breeze has. Ward says they write to EcmaScript 5 and have gotten rid of all dependencies other than one called Q.
  • It’s time for Pimp Yo Stuff, and Jon takes the occasion to praise Ward’s sartorial skill. Scott K says they’d like to
    • Ward pimps the DevForce and and Cocktail combination. Cocktail is DevForce + Caliburn.Micro.
    • Jon asks about the license for Breeze. Ward clarifies that it’s all free and open source, and they make their money on support and professional services.

Show Links:

Herding Code 154 – Aaron Stannard on MarkedUp, founding a startup, and Windows 8 development

While at the //build/ conference, Jon talks to Aaron Stannard about how he left Microsoft to start up a new company focused on analytics for Windows 8 applications. They discuss Windows 8 development and the Window Store ecosystem and the technology stack Aaron and team settled on for their analytics platform. They end up by discussing the process of going from an employed software developer to running a software startup.

Note: The audio is a bit crackly in a few parts, but just for a few seconds.

Download / Listen:

Herding Code 154 – Aaron Stannard on MarkedUp, founding a startup, and Windows 8 development [audio://herdingcode.com/wp-content/uploads/HerdingCode-0154-Aaron-Stannard.mp3]

Show Notes:

  • Jon starts by asking Aaron about what led him to founding a startup. Aaron explains how his first startup failed and his blog post about Why .NET Adoption Lags Among Startups got him a job as a startup evangelist at Microsoft
  • Opportunities: Windows 8 development and MarkedUp
    • Aaron explains how he saw a key opportunity around the Windows app ecosystem and why the teaming seemed right to really dive into this now. Jon agrees that this is a really interesting time in the Windows developer landscape.
    • Aaron explains that MarkedUp delivers in-app analytics for WinRT and eventually Windows 8, answering questions like how many people use your app every day, how much time they spend using it, which features they use, and what in-app purchases they make.
    • Jon mentions a key difference in the Windows Store which allows you to have one app which can be upgraded from free to paid, whereas other platforms have duplicate applications for free and paid.
    • Aaron talks about his recent blog post comparing iOS economics vs. Windows 8 economics titled Win8 Developers: Don’t Make the Terrible Mistake of Treating the Windows Store like the iOS App Store. He explains that there’s an opportunity for Windows 8 applications to do quite a bit more than simple little hit driven apps, and Windows 8 applications can and should do quite a bit more.
    • Aaron talks about the pricing model – free now, there will always be a free model, and it’s intended to be pretty reasonable for developers with successful applications.
  • Tech talk about WinRT development and how MarkedUp integrates therewith
    • Aaron begins explaining the technology stack, but Jon interrupts him to ask him to explain what a .winmd file is. Aaron discusses some of the key similarities and differences between WinRT and .NET development.
    • Aaron talks about how they’ve cleaned up a lot of the information that’s exposed so it’s useful.
    • There’s NuGet package you add to your Windows 8 application which brings in the .winmd dependency.
    • There’s a managed singleton approach which handles a lot of things automatically, like application startup and shutdown. You can also log additional events through the managed singleton.
    • There’s a JavaScript wrapper that sits on top of the .winmd file for WinJS applications which flattens some of the hierarchies and namespaces for logging.
    • Aaron says he’s seen this as a common pattern for Windows 8 development – write some .NET code, ship it as a .winmd file, and provide a JavaScript wrapper for WinJS.
    • Aaron mentions that he likes this pattern for application development, too: write business logic in C# and expose it through .winmd put a JavaScript wrapper on top of it to write the interface in HTML and CSS. He like the flexbox and grid system for layout, and thinks the CSS3 media selector based layout orientation systems is a lot simpler than trying to do that in XAML.
    • Aaron explains that as an analytics component, they will never degrade the user experience, so they’ll always swallow internal exceptions.
    • The communications system is also designed to prevent impacting the user, so they cache locally and only send a single message at a time.
  • RavenDB and how it compares with other document databases like MongoDB
    • Data is stored in RavenDB. They evaluated both RavenDB and MongoDB but decided RavenDB worked better for them at this point. He describes some differences between RavenDB and MongoDB.
      • RavenDB projections make it easier to do server-side transforms.
      • RavenDB has some nice batch loading features.
      • RavenDB lets you express map-reduce as a pre-computed index.
      • Aaron doesn’t like the way sharded RavenDB clusters work.
      • They’re probably going to go to Cassandra or HBase eventually.
      • Aaron talks about a solution (Hircine) they came up with to precompute RavenDB indexes at build time rather than startup.
      • RavenDB is great for unit testing
    • Aaron talks about their build system using Albacore and talks about their build and deployment system.
    • Jon asks about why they’re planning to move from RavenDB to Cassandra or HBase. Aaron says he doesn’t like the scale-out / sharding system in RavenDB and doesn’t think it will work for them as they scale. Aaron talks about their plans to handle complex analytics at scale.
  • Jon shifts gears to ask about starting a company. How do you get started?
    • Aaron talks about the history of how they got started – with a mission.
    • Next questions: Am I the right person to execute this? Is this a problem worth solving? Is this economically viable?
    • Build a minimum viable product and show it to people you trust. Aaron gives examples from the history of starting MarkedUp, with an application that let you annotate and upload screenshots from iOS. Jon and Aaron discuss how Aaron was able to do most of the minimum viable product development without quitting his job.
    • First step in actually starting the company: talk to a lawyer to get your structure and ownership figured out.
    • How do you make the decision to go fulltime?
    • Figuring out how to pay the bills: can you monetize quickly, or do you raise money?
    • Aaron talks about the process of getting funded and networking with potentials investors.
    • It’s an emotional rollercoaster – be ready to change tactics, but don’t quit.
    • Jon and Aaron talk about the benefits of doing this all incrementally – at least until you go full time.
  • There’s a registration URL for Herding Code listeners (https://markedup.com/account/register/?utm_campaign=herdingcode) – or you can just go through registration and enter the code HERDINGCODE into the registration code field on the form.
  • Aaron says he’d be happy to talk with other developers who are interested in the startup process.

Show Links:

Herding Code 153 – Matt Wrock on RequestReduce, Chocolatey and BoxStarter

The guys talk to Matt Wrock about Matt’s RequestReduce web optimization framework and his work to automate building and configuring Windows developer machines with the Chocolatey and BoxStarter projects.

Download / Listen:

Herding Code 153 – Matt Wrock on RequestReduce, Chocolatey and BoxStarter [audio://herdingcode.com/wp-content/uploads/HerdingCode-0153-Matt-Wrock.mp3]

Show Notes:

  • RequestReduce
    • Matt explains how he got started with RequestReduce – a site optimization system that’s been designed as a plug-and-play system that can work well with legacy sites without any code changes.
    • Matt explains how RequestReduce fits in with other systems like the ASP.NET Web Optimization system and Casette.
    • K. Scott asks Matt how it works and how a user would configure it. Matt explains how it can be installed via NuGet, and how it uses a Response Filter to process the output.
    • Matt explains how everything’s handled via a queue on a background thread, so there’s no performance impact on initial requests.
    • RequestReduce pulls in CSS, images and JavaScript so it can work with remote content and CDNs.
    • Matt gives a shoutout to AjaxMin and the speed at which he and Ron Logan have been able to turn around fixes and improvements.
    • Matt explains the complications involved in creating image sprites, and why he only sprites images with a defined width.
    • Matt explains how both quantization and compression can dramatically affect image size.
    • Matt explains why he doesn’t sprite images when he can’t determine the image width.
    • Scott K talks about his previous job and how they’d looked at converting all images to Base64. Matt says that he’s looked at that, but decided it’s not something you’d necessarily want to apply to all images.
    • Jon asks Matt to explain CSS spriting in more detail. Jon says they use sprites on the ASP.NET site, and Matt says the ASP.NET site is one of his test case sites.
    • K. Scott asks Matt why the code is calculating CSS specificity scores.
    • K. Scott asks about what the results have been. Matt says it varies by site, but on one large site they’ve seen a 33% improvement.
    • Jon mentions that RequestReduce also handles Less and CoffeeScript. Matt says he’s making use of SassAndCoffee.
  • BoxStarter and Chocolatey
    • Matt talks about how he got started with BoxStarter – he was tired of wasting time building development boxes, and he didn’t think VMs were a good solution.
    • Matt thought Chocolatey solved some of the program installation issues, but didn’t handle common customization scenarios like Windows settings, file associations, taskbar links, path, etc.
    • Chocolatey handled some of the things Matt wanted, but not everything. He started by customizing and wrapping Chocolatey, but decided it would be better to contribute directly to Chocolatey.
    • BuildStarter can work with either a local BuildPackages folder or a custom MyGet feed.
    • Matt says he might like to use ClickOnce in the future.
    • Matt talks about how he’d like to have a web based shopping list approach, where you could just click off all the things you wanted and it would set up a package for you – kind of like like Ninite, but a lot more comprehensive.
    • Jon says he was happy to see a recent Chocolatey commit that can turn Windows features on and off.
    • Matt explains how he’s been coordinating with Rob Reynolds to decide what he should contribute directly to Chocolatey and what should be separate Chocolatey packages.
    • Jon says he didn’t get Chocolatey right away, but what sold him on it was the dependency management. Matt explains how this has come in handy in his work in the TFS dev team.
  • TFS
    • Jon asks Matt about his work on new role on the TFS team. Matt says he’s working on the REST API for work item tracking and would love any feedback on work item tracking.

Show Links: