Published: August 14, 2018 – Author: Andy Hagerty
Blue Prism’s automation software is a powerful tool with many built-in capabilities. Yet it has its limitations. What if we told you that you could extend Blue Prism’s capacity—pushing the envelope because of its low code technology?
It is possible. Agilify continues to invest time into researching and pushing the envelope with Blue Prism software to integrate more traditional development tools, resulting in limitless potential for leveraging automation to best suit your company’s needs.
If you have a staff of Python developers, you might assume that you couldn’t implement a .NET software like Blue Prism. However, its compatibility allows for true integration, making the seemingly impossible become possible with the help of tools like IronPython, a .NET implementation of Python.
Compatibility = Power at Python Developers’ Fingertips
Blue Prism is built on .NET, so it is able to use any .NET Assembly. IronPython, though it is implemented in .NET, cannot be a CLS-compliant .NET Assembly since its declarations don’t include type information.
Python is a dynamically-typed language, and C# is a statically-typed language. The dynamic keyword introduced in C# 4.0 came about directly as a result of the creation of IronPython, and it can act as a bridge between the languages.
If one chooses not to use the dynamic keyword, or work with a .NET language without the DLR (Dynamic Language Runtime that makes IronPython possible), a less elegant approach must be used that involves excessive casting and converting.
Ugly Coding = Beautiful Interactions
Type information swapping between .NET and IronPython can be confusing at times. Some types are so similar that they can be (and are) seamlessly converted (ie. strings, integers, DateTimes).
Finding out what types seamlessly convert—what types don’t—can be trial and error if you aren’t familiar with the built-in types of either language. A word to the wise: be careful about what you think you’re getting and what the type system has automatically converted for you.
Here’s where you might be asking, “Both have lists, so can’t I just turn a Python list into a C# list?” Unfortunately, the answer is no.
C# -> Python -> C# goes from IList<> to list to IronPython.Runtime.List
Executing a script is effectively running an eval() on your script’s code. As you’ll see in the embedded image above, the script code must be added to a ScriptScope object before compilation or execution.
In the embedded image, we added the code to the ScriptScope only once, but you could add it in chunks if the script is separated for any reason. This also means that keeping track of variables within a given scope can be difficult as you might never see the entire .py file (that ends up being sent to the script execution engine) all in the same place, making it harder to debug in the future.
Going from .NET objects/classes into Python is less painful than the other way around. On the other hand, performing type-specific actions (common in .NET) becomes a bit cumbersome in Python. Calling a .NET class’ overloaded constructor from Python requires redefining the class in Python so that a __new__ (not __init__ which would be more intuitive) function can be added to the type.
The Zen of Python starts with “Beautiful is better than ugly.” There is no getting around some very ugly code in order to end up with a much more beautiful interaction with .NET.
True Integration = Worth the Effort
The integration mentioned here is more easily thought of as a work-around. The code is delivered like text instead of like code, and the underlying operation has its faults. A better alternative would be if Blue Prism implemented IronPython as a language alternative natively.
If that were the case, inputs would be added to the PythonScope; code text would be taken directly from the code editor window; and outputs could be pulled with the scope’s GetVariable function. There would no longer be a need for input and output to be synthesized and mimicked.
Would it be effortless for Blue Prism to include IronPython? Probably not.
Though it isn’t currently a reality, work-arounds like this make true integration possible, though it takes some effort. Is it worth the benefit gained in the end? Absolutely.
Python is rising in popularity, so the consequential quantity and quality and tools written with and for it continue to grow. There are clearly benefits to marrying Blue Prism software with Python, expanding potential automations tremendously by utilizing the available libraries. With this integration, time is saved by not rewriting libraries, which solves the need to bridge Python to .NET.
Curious to learn more about Blue Prism software and how your company might be able to leverage it to save time and money? Check out our Blue Prism Trianing Courses offered by Agilify Academy or fill out the form to the right for any questions and we will be in touch with you shortly!
Automation Innovation Architect, MCTS
Technical innovation architect with 18 years’ experience building enterprise level applications. Currently working on a team focused on exploratory work around ideas leveraging traditional development, robotic process automation, artificial intelligence, natural language processing, optical character recognition and any other technology we can get our hands on.