Erciyes Üniversitesi Ipy Semineri

Pazartesi, 26 Ekim 2009 13:48 by ikivanc


Bugün üniversitemde Ironpython hakkında sunum gerçekleştirdim. Desktop Application, Silverlight, Console, COM Nesneleri, .NET kütüphaneleri, WPF, ASP.NET tarafındaki kullanımlarından bahsettim ve bunlardan birer örnek yaptık.

Genel itibari ile güzel geçti seminer, umarım herkes için faydalı olmuştur ;)

Katılan herkese teşekkürler...

Asp.NET with IronPython Integration

Cuma, 16 Ekim 2009 14:09 by ikivanc
One of the IronPython development area is Asp.NET. In this article we will see Visual Studio 2008 Asp.Net integration. 

Then download the Asp.NET IronPython integration for visual Studio 2008 installer here.



Asp.NET with IronPython is really rocks! This combination gives us time/performance advantage. Especially in small scripts for events, python code is too short and powerful! So we can prototype projects quickly.

Because of Dynamic Language, it will work server-side on client’s machine and it works dynamicly. With this feature we can connect websites faster. 

Let’s check out, files in a project from Solution Explorer.
 
    IRONPYTHON                                                             C#
 
After creating a new web project, “bin” folder, "default.aspx" page, "Global.py" file and "Web.config" file are created by Visual Studio.

"bin" Folder
It contains our website DLLs for running IronPython on the web. 

Default.aspx
It’s our default homepage for web project. It work with code-behind file, Default.aspx.py which contains all python code for page.

Global.py
This file contains some situations about web application for some cases.

def Application_Start():
    ' Code that runs on application startup' 
    pass
 
def Application_End():
    ' Code that runs on application shutdown'
    pass 
 
def Application_Error(app, e): 
    ' Code that runs when an unhandled error occurs'
    pass 
 
def Application_BeginRequest(app, e): 
    ' Code that runs at the beginning of each request'
    pass 
 
def Application_EndRequest(app, e):
    ' Code that runs at the end of each request'
    pass 

web.config
Some Asp.NET web project configurations included in it. 

What is the differences between “C# Asp.Net” and “IronPython Asp.Net”?
First differences In Ipy Project, it contains “bin” folder which contains DLL libraries for IronPython and global.py file.

The most helpful advantage of IronPython is easy and short code. Usually people compare C# and IronPython with their code line.

Let’s check out the example below
The web page contains label and a button. First page initialize button text as “Click” and Page title as “IronPython Example” on Page Load. After clicking button, label text will be “Clicked” on Button1 Click. 

C# 
public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Button1.Text = "Click!";
            this.Page.Title = "C# Example";
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "Clicked";
        }
    } 

IronPython 
def Page_Load(sender, e):
    Button1.Text = 'Click'
    Page.Title = 'IronPython Example'
 
def Button1_Click(sender, e):
    Label1.Text = 'Clicked' 
 
Also in IronPython we don’t have to import standard libraries. Now Programming is really enjoyable! :)

PDF verison of this article >>  5 - IronPython ASP.NET Integration

If you have any questions or discover any errors / typos please let me know ik@ibrahimkivanc.com

All The Best!

Introduction to IronPython

Cumartesi, 3 Ekim 2009 11:25 by ikivanc
Python + .NET, That takes the cake! Python runs on .NET… that sounds good.  Flexibility and easy coding of Python and powerful platform .NET together. Also on the great development enviroment of Visual Studio. This must be a dream :)


This news took me to my childhood year; Voltron cartoon! :) Powerful heroes  combined with shining then become most powerful hero, Voltron. IronPython sounds like Voltron :)


In a short time Python became popular and absolutly it will be more popular in the future by performance, easy coding and easy prototyping. Microsoft became aware of Python’s power. Microsoft entegrated Python to .NET platform, and very innovative technology revealed. IronPython is a Python complier runs on .NET.

IronPython Project started at 2004  and now Ipy 2.6 RC1 relaesed. There is the last stable release Ipy 2.0.2 version. It’s on ,Microsoft’s open source portal, Codeplex. And you can easily get the latest release and news from link below.

http://IronPython.codeplex.com/

Jim Hugunin demoed IronPython to Microsoft and was hired by them to work on the CLR architecture team. IronPython 1 is top of CLR. But CLR is too bad for dynamic languages. Then decided create Dynamic Language Runtime(DLR) and built IronPython version 2 on top of the DLR. DLR Including interoperation between statically typed and dynamic languages. DLR will be part of C# 4.0 and .NET 4!

I will write more about DLR as soon as possible in next blog entries.

This license IronPython is released under is the OSI approved Microsoft Public License (MS-Pl), which Microsoft’s licience for opensource projects. IronPython was the first project to be released under this license.

Road Map for IronPython;

•    Visual Studio 2010 integration for IPy 2.6
•    IPy 3.0 which works with Python 3000 together.

As you see versions of IronPython same with which Python’s version is built on. IronPython 2.6 is compatibility with Python 2.6 and IronPython 3.0 is compatibility with Python 3000. Now IronPython developers working on IronPython 3.0.

From codeplex page you can get IronPython Console application which is for exploring IronPython world. You can develop application from IronPython Console command prompt without an IDE like Visual Studio.

With IronPython Console, you can explore IronPython world and develop apps.


With IronPython Console you can easily explore whole Python’s code, Access .NET libraries and use this libraries to build an application.

So what can we do for developing applications with an IDE? We can use Microsoft’s Visual Studio. Like developing C#, Visual Basic projects in Visual Studio we can easily develope IronPython Projects .

We have two options for IronPython IDE. We can use IDE, stand alone IronPython Studio or Visual Studio Integration. Both of them are same. Chose one It’s up to you. Based on IronPython 1.0 and also come with IronPython Intellisense.

How Do I Install IronPython?
http://IronPython.codeplex.com/ on project’s home page there is a download section. You can find easily download the latest version of IronPython msi installer.

How Do I Install IronPython Studio?
There are some pre-request for Installing IronPython Studio. First of all download the IronPython Studio entegrations below.
 
http://www.microsoft.com/downloads/details.aspx?FamilyId=ACA38719-F449-4937-9BAC-45A9F8A73822&displaylang=en

http://www.microsoft.com/downloads/details.aspx?FamilyId=40646580-97FA-4698-B65F-620D4B4B1ED7&displaylang=en

Visual Studio 2008 must be installed on your system and for a succesful installiation, you must install VS 2008 SDK 1.0 which is link below.

http://msdn.microsoft.com/en-us/vstudio/bb887604.aspx

After this installiations;

from Start > All Programs > Accessories > Commad Prompt right-click it and choose "run as administrator" then access the user account control prompt.

Then choose the path which is including IronPythonStudio.msi setup from Command Prompt. Then enter this command “msiexec /i C:\ IronPythonStudio.msi”.
If you are missing any pre-request of installing step there will be a problem about your installiation.


ScreenShot from IronPython Studio it is look like Visual Studio
 

ScreenShot of IronPython Studio which is integrated in Visual Studio

As you see there is a Visual Studio based IDE, IronPython Studio. It has also IronPython code intellisense. Now we can easily develop UI applications with IronPython Studio. It is easy as pressing F5 :)

IronPython is Working With
Now Python combined with .Net and let’s see where can we use IPy.
    * Desktop Applications
    * Silverlight
    * WPF
    * ASP.NET
    * The Microsoft Robotics Kit
    * XNA (Desktop – Xbox/Zune has no DLR)
    * Surface
    * SharePoint
    * WCF
    * WF

Silverlight
Silverlight has Dynamic Languages support now and Silverlight applications can be developing with IronRuby and IronPython code. We can develop web applications with Dynamic Languages! Cool!
 
WPF
With XAML, graphical user interface desing and code independent from each other so we can develop one of them independently.  Now we can use IronPython in WPF code behind side!
 
ASP.Net
We can use IronPython with ASP.NET building web applications. With IPy it’s really short coded and easily fast developing web applications..
 
The Microsoft Robotics Studio
Microsoft’s development platform for various hardware and Robot technology. IronPython can be integrated to Robotic Studio.
 
XNA
With IronPython’s Advantages of being Dynamic Language XNA 3D and game development. In the future this will be a shining star!
 
SharePoint
IronPython can be integrated with share point.

Why do I prefer IronPython to C# or Visual Basic?
There is a lot of reasons for for this question. Python is a Dynamic Language! C# and Visual Basic are static Languages. Because of being Dynamic Language there are some advantages to developing applications. There is no Type validation and Type creation in Dynamic Languages. Types are not verified up front. They are verified when they are used - languages like Python and Ruby are strongly typed languages, not weakly typed. Easliy Prototoyping and rapid development of Applications. For python users It runs on .NET wih same code!. It’s also scripting language.

PDF verison of this article >> 1 - Introduction to IronPython

If you have any questions or discover any errors / typos please let me know ik@ibrahimkivanc.com

All The Best!

Yeni Teknolojiler ve Güncellemeler

Perşembe, 19 Mart 2009 15:08 by ikivanc
Internet Explorer 8
Gün itibari ile internet Explorer'ın kararlı sürümü olan IE 8.0 duyuruldu.
IE8 indir

Silverlight 3 Beta 1
MIX09 konferansında Silverlight 3.0 Beta 1 duyuruldu.

3.0 ile en çok dikkat çeken yenilikleri ise
Multitouch desteği
MPEG, AAC, H.264 desteği
Gelişmiş data gösterimleri
Yeni kontroller geliyor
3D modellemeler
çeşitli efectler uygulanabilecek
TestApp ile Masaüstü olarak offline çalışır modu geliyor...
ve pek çok yenilik ile çok ama çok renk katacak hayatımıza...



Expression Blend™ 3 Preview
SketchFlow, ProtoTyping, Xaml Code IntelliSense, tasarımda kolaylıklar sağlama gibi güzellikleri ile duyuruldu.
Blend 3 Preview indir


IronPython 2.0.1
Geçtiğimiz Haftalarda IronPython 2.0.1 duyuruldu.
IronPython 2.0.1 indir

Asp.NET MVC
MIX09 konferansında Asp.NET MVC 1.0 RC duyuruldu.
Asp.NET MVC indir

Moonlight 1.0

Novell Silverlight'ın linux üzerinde çalışmasını sağlayacak moonlight 1.0 kararlı sürümünü duyurdu.
Moonlight hakkında bilgi için






5 Dkda değişir bütün işler...

Çarşamba, 29 Ekim 2008 11:17 by ikivanc
Yazmaya fırsat bulamadığım ve son zamanlarda büyük ses getiren teknolojik gelişmeler... Şimdi buradan duyurayım, test ettikten sonra tecrübelerimi paylaşırım :)

Visual Studio 2010 .NET 4.0 CTP
Visual Studio'nun 2010 versiyonu sanal makinede duyuruldu
http://www.microsoft.com/downloads/details.aspx?FamilyID=922b4655-93d0-4476-bda4-94cf5f8d4814&DisplayLang=en

IronPython 2.0 Visual Studio 2010 CTP

http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=18448
IronPython
IronPython'ın yeni logosu

Silverlight Dynamic Languages SDK 0.4.0
http://www.codeplex.com/sdlsdk

IronPython 2.0 RC1
http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=17404

ASP.NET MVC Beta
http://www.microsoft.com/downloads/details.aspx?FamilyId=A24D1E00-CD35-4F66-BAA0-2362BDDE0766&displaylang=en

Windows Azure
http://www.microsoft.com/azure/windowsazure.mspx

OSLO

http://msdn.microsoft.com/en-us/oslo/default.aspx

OSLO'nun Intellipad'ı IronPython ile kodlandı
http://blogs.msdn.com/intellipad/

PDC Konferansına gidemedim diye üzülmeyin :)
http://notatpdc.com/

Los Angeles'ta olması itibariyle bir de konferans için gang sign geliştirmişler ki çok güldüm :)
PDC Gang Sings

IronPython ASP.NET Entegrasyonu

Pazar, 26 Ekim 2008 01:02 by ikivanc
Daha önceki yazılarımdan da hatırlayabileceğiniz gibi Ironpython'ın pek çok kullanım alanı vardı. Bunlardan Asp.Net entegrasyonunu inceleyeceğiz.
 
Öncelikle http://www.asp.net/downloads/futures/default.aspx adresinden siteye erişerek Asp.net'in eklenebilir özellikleri hakkında buradan bilgi alabilirsiniz.
buradan da Asp.net'te IronPython entegresyonu için gerekli olan eklentiyi indirebilirsiniz.
 
IronPython'ı Asp.net ile kullanmak çok büyük avantajlar elde etmemizi sağlayacak. Bunlardan en önemlisi zaman/performans. Özellikle küçük scriptler için atayacağımız eventları kısa python kodları ile daha hızlı bir şekilde hazırlayabileceğiz.
 
Solution Explorerde projelerimizde neler var onları inceleyelim şimdi de

                  IRONPYTHON                                                             C#
IronPython projemiz açıldıktan sonra proje klasörümüzde "bin" klasörü "default.aspx" sayfamız "Global.py" dosyamız ve "Web.config" dosyalarımız otomatik olarak oluşturulmakta

"bin" Klasörü
Web uygulumamazın IronPython ile sorunsuzca çalışması için geresinim duyduğu dll kütüphaneleri bulunmakta ve sunucudan bunlardan faydalanarak Asp.net uygulamasını göstermeye yardımcı olur.

Default.aspx
Asp.Net web uygulamamızın anasayfasını oluşturur. Code-Behind şekilde çalıştığı için arka plandaki kodlar Default.aspx.py dosyasında bulunur.

Global.py

Web Uygulamamızın bazı durumlarda sergileyeceği tavırları belirler. İçerisinde aşağıdaki durumlar tanımlıdır.

def Application_Start(): #Uygulama başladığında çalışan kod
    ' Code that runs on application startup'
    pass
def Application_End(): #Uygulama sonlandırıldığında çalışan kod
    ' Code that runs on application shutdown'
    pass

def Application_Error(app, e): #hata oluştuğunda çalışan kod
    ' Code that runs when an unhandled error occurs'
    pass

def Application_BeginRequest(app, e): #istem yapıldığında çalışan kod
    ' Code that runs at the beginning of each request'
    pass

def Application_EndRequest(app, e): #istem sonlandığında çalışan kod
    ' Code that runs at the end of each request'
    pass

web.config
Asp.Net Sayfalarında bulunan ve web uygulamamıza ait tüm özelliklerin ve ayarların bulunduğu sistem dosyasıdır.
 
C# Asp.Net projesi ile aralarındaki farklar neler?
C# projesinde bulunamayan bin klasörü ve global.py dosyası bulunmakta. DLL. kütüphaneleri ve global.py 'da uygulama kodlarının bulunması dikkat çekiyor

Genellikle yapılır IronPython - C# kod karşılaştırmaları ve C#'ın süslü parantezleri her biri birer satıra yazılarak aralarındaki satır farkından/ kod uzunluğundan bahsedilir fakat benim buradaki örnekleri yazmamda temel amaç kodlar arasındaki farkı görmeniz ve C#'ı bildiğinizi farz edip bu sayede python dilinin yapısını kavramanızı kolaylaştırmak.

Şimdi de basit birer örnekle başlayalım:
Sayfamızda bir label ve bir buttonumuz var ve sayfa yüklenirken buttonun text'i "tikla" diye değişiyor sayfanın başlığı da hangi dilde ise onun deneme başlığını atıyor ve button'a da tıklandığında label'ın text'i "tiklandi" diye değişiyor.

C#
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Text = "Tikla";
        this.Page.Title = "C# Deneme";
    }
   
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "Tiklandi";
    }
}
 
IronPython
def Page_Load(sender, e):
    Button1.Text = 'Tikla'
    Page.Title = 'IronPython Deneme'
   
def Button1_Click(sender, e):
    Label1.Text = 'Tiklandi'

Ayrıca IronPython projesinde kodlarda standart kütüphaneleri import etmeye gerek kalmıyor. C#ta hepsini tek tek yazmamız gerekiyor. IronPythonla uğraştıkça daha çok seveceksiniz kod yazmayı. Bu yazımızda Visual Studio 2008'e IronPython nasıl entegre edilir onu gördük ve C# asp.net projesi ile aralarındaki farklar nelerdir onlardan bahsettik. Sormak istediğiniz ve düzeltmek istediğiniz yerleri ibrahim.kivanc@msakademik.net  mail adresine iletebilirsiniz.

Tags:   ,
Categories:   Asp.Net | IronPython
Actions:   E-mail | del.icio.us | Permalink | Yorumlar (0) | Comment RSSRSS comment feed

IronPython Kullanım Alanları

Çarşamba, 22 Ekim 2008 07:29 by ikivanc
IronPython, python'un .net'e geçmesiyle nerelerde kullanıldığına bir göz atalım.

    * Silverlight
    * WPF
    * ASP.NET
    * The Microsoft Robotics Kit
    * XNA
    * SharePoint

Silverlight
Silverlight'ın Dinamik programalama dillerine destek vermesi ile IronRuby ve IronPythonkodlarını kullanarak rahatlıkla web browserlarda geliştirme yapmanıza yardımcı oluyor.
 
WPF
XAML teknolojisi sayesinde görsel tasarım ve kodlamanın birbirinden ayrılmasıyla tanınan WPF'te de kod kısmında IronPython kodları çalışmakta.
 
Asp.Net
Asp.Net ile web development kısmında ironpython kodlarını kullanabilir. Bu sayede hem kısa hemde çok basitçe hızlı projeler geliştirebilirsiniz.
 
The Microsoft Robotics Studio
Microsoft'un çeşitli donanım platformalarının robotik alanında uygulamalar geliştirilmesine yardımcı olan bir geliştirme platformudur. IronPython , Robotic Studio'da da geliştirme sağlamaktadır.
 
XNA
XNA 3D ve oyun geliştirme ortamında da kullanılan IronPython Dinamik bir dil olmasının avantajını kullanarak ileriki zamanlarda bu oyun geliştirme platformunda göz bebeği olmaya aday.
 
SharePoint
IronPython, yeni çıkan ve çok büyük bir geleceği olacağı şimdiden görülen SharePoint ile de geliştirme imkanı sağlamaktadır.

"C#, visual Basic varken IronPython'ı neden kullanayım ki?"
Bu aklınıza geliyorsa bunun için pek çok sebep var... Python Programlama dili dinamik bir dildir. C# ve VB ise statik.Dinamik bir programalama dili olması bazı projelerde size çok çok büyük avantajlar sağlamakta,örneğin tip tanımlaması yapmanıza gerek kalmamakta fakat statik dillerde ilk başta tanımlamak zorundasınız. Daha pek çok artısı var dinamik dillerin. Buna bize sağlayacağı somut faydaları sonraki yazılarımda bulabileceksiniz.
 
Yukarıdaki tüm alanlarda IronPython örneklerini ve uygulamalarını burada bulabileceksiniz.