NMath and Silverlight
From time to time, we’re asked about the best way to use NMath to build Silverlight applications. Unfortunately, like so many answers in software development, the answer is: it depends. Silverlight is a great way to build line of business applications, but at its core, Silverlight runs within a sandboxed environment, typically within a browser, and usually within a networked intranet or Internet environment. NMath, on the other hand, uses native libraries to provide high-performance math capabilities to managed code. While it’s possible to build a Silverlight application that calls NMath functions, it’s worth taking a step back to look at what you really want to accomplish with your software project. Most often, we find that developers are tasked with building dashboard-style business applications that allow the user to initiate some sort of data analysis, and then see a visualization of results. In these cases, we generally recommend: 1) Use Silverlight (or HTML5) on the client, perform the analysis on one or more servers, and expose web services to initiate the analysis and deliver the results. This is probably the most favorable approach, and usually the architecture to default to unless there’s a compelling reason to the contrary. Some of the advantages of this approach:
- It’s consistent with typical Silverlight application architecture; capabilities in Silverlight and ASP.NET make it easy to build this kind of application.
- It retains the deployment advantages of Silverlight: there’s no need to distribute and install native components to every client machine.
- It retains the cross-platform advantages of Silverlight: the application will work smoothly regardless of client hardware (including on Mac OS).
- Centralizing the analysis on a server makes it easier to scale up with improved server hardware and/or server farms.
- It makes efficient use of network bandwidth: usually there’s little need to transfer all of the source data between client and server, just the results of the analysis.
- This might drive an architectural shift if it’s not already working in a client-server environment.
- It doesn’t take maximum advantage of available computing resources on the client, at least for the analysis (although the application can potentially use the client’s GPU for the visualization).
- You would need to separately distribute your components and get them preinstalled on the local machine.
- The client applications will only run on Windows; you cannot invoke native code on Mac OS from Silverlight.
- Users will need to explicitly grant elevated trust to the Silverlight application.
- You would also need to build your application with out of browser support (if you’re using COM interop).