Archive for January, 2009

Script.NET Video Tutorial

Friday, January 30th, 2009

This post lists video tutorials about Script.NET. I have decided to create them after watching presentations from the latest PDC conference. It is true that: “its better once to see than ten times to hear”.

I hope it will simplify the use of Script.NET for a new users and will help me to explain advanced concepts of the language.

Getting started with Script.NET

Describes basic concepts of Script.NET together with simple example of interaction between script and hosting .NET application

  • Presentation: AVI,
  • Examples used in presentation: BIN.

Using Contracts in Script.NET

Explains contracts and their usage in Script.NET to produce verifiable scripts.

  • Presentation: AVI.

Making .NET application Scriptable 

In this demo I will show how to make existing .NET application available to the script. The script will be able to interact with the hosting application and manipulate with its objects using ObjectModel exposed to the script runtime.

Please share you feedbacks at: piter.protsyk@gmail.com

More on Script.NET . . .

Matrix Calculator

Tuesday, January 27th, 2009

One of my tools started to became more and more popular. This is Matrix Calculator. It appears on the first page of a google search in Ukrainian segment:

Matrix Calculator on Google

It was written about 5 years ago when I was a university student. There is a great tool for dealing with matrices - called MathLab. It is very powerful, but also a very large and probably expensive tool. One of the great feature of MathLab is its syntax: very simple and straightforward. And it is very good suitable for console input.

So, what I’ve tried to do is to simply use MathLab syntax and implement most recently used matrix functions in my calculator. It works under Windows XP in Console mode. Here is a sample of using Matrix Calculator:

Sample Calculations

It supports following functions:

  • iden(dim) - identity matrix of dim x dim 
  • det(identifier) - determinant of matrix
  • slae(identifier) - solves linear equations
  • transpose(identifier) - transpose
  • inv(identifier) - invariant matrix
  • rank(identifier) - rank of the matrix
  • gauss(identifier) - diagonalization of matrix using Gauss method

Matrix Calculator may be download by the following link:  Download Matrix Calc (Zip)

Today I am 25

Tuesday, January 20th, 2009

Today is my 25-th birthday!

25.JPG

Expression evaluator in 15 minutes with Irony & Dlr

Thursday, January 15th, 2009

Evaluation of a string expression to a value is a common programming task. Almost any college course in informatics includes this excercise. It involves implementing some fundamental algorithms and structures such as: recursive-descent parser, regexp matching, traversal algorithms, syntax tree, hash-tables, etc. And for sure it should be done on some pure programming language such as ANSI C or Pascal.

.NET Framework brought a lot of in-box algorithms and structures which simplifies the usual live of software developer. However it is still a good excercise to evaluate a string expression, say 2+(4*5)^12.

But fortunately there are some new tools that facilitate producing language parsers and their interpreters/compilers. If you are interested in such kind of tasks I would suggest you to look at following libraries:

DLR will be a part of the upcoming .NET Framework 4.0 and C#. It is a base for Iron languages: IronPython and IronRuby.

Irony is a library for creating parsers in C#. It is very convenient and efficient.

About a year ago I’ve posted few posts about using DLR for creating dynamic languages:

  • DLR Language Part 1
  • DLR Language Part 2
  • DLR Language Part 3
  • Also I’ve used Irony to create Script.NET.

    So today I’ve looked at the recent releases for both of these tools and tried to create string expression evaluator once again. And it took aproximately 15 minutes! Wow!

    Irony already had examples of parsers for arithmetic expressions and I’ve used them. The next step is to evaluate parsed syntax tree. For these purpose one may use very convenient Expression class which comes as a part of DLR under Microsoft.Linq.Expressions namespace.

    So, please take a look at the results. Bin+Src.

    This console application will accept a single line valid string expression on natural numbers. It supports following operations: +,-,*,/,** (Pow).

    Making .NET Application Scriptable

    Tuesday, January 13th, 2009

    Today, I’ve published new video tutorial about Script.NET language. It should show one of the main use cases of this language: making .net application scriptable. In this demo I will show how to make existing .NET application available to the script. The script will be able to interact with the hosting application and manipulate with its objects using ObjectModel exposed to the script runtime.

    [AVI] [Sample Application]

    The list of all video tutorials is available by one of the following links: