August 2007 - Posts

My First look on DLR

My first question is a basic "why aspect". Why I should use dynamic languages if I know MASM, C/C++ and C#? Some non-pragmatic people will easily reply because it is COOL. But you can count how many technologies failed in the market because of COOL reason. In my opinion it must be started from our needs. Just like other languages or technologies, we use them if we needed.  One concrete need is for highly iterative development in which we are having too many cycles:

code --> build --> run --> debug --> test --> refactor

With dynamic language, we can focus only on adding functionality and refactoring. Most dynamic languages provide an interactive console, a high-level syntax, and extensive standard libraries reuse. You can try IronRuby, IronPython (and possibly IronAyu, IronToba, IronBatak or IronLUA one day), and you will know that it is easier to write code comparing to C# and C/C++. "Write less code" is one of the pillars of dynamic language productivity.

Let see how IronPython or IronRuby work from script code to App domain object in the following picture. Dynamic language uses a common type of compiler architecture; the noticeable difference is in code generation. it byte code is MSIL, intermediate language for the CLR, and will eventually be converted into native code. With IL based assembly, the generated object can call both native and managed libraries. 

 

Microsoft provides dynamic language library source codes with Microsoft.Scripting namespace to help us implement Dynamic Language Runtime (DLR). Both IronRuby and IronPython use this DLR library. If you open Microsoft.Scripting spec document (shipped with IronPython, not IronRuby), you can see the following honest statement (I like it) from Microsoft people who built it :

We have a business case to play in this space and have offerings that both make .NET more cool and attractive to programmers as well as making sure we don't lose developer mindshare just because it is easier to go to Flash, Ruby on Rails, LAMP (linux, apache, mysql, php/python).

IronPython runs 1.8X faster than the standard implementation.  We're leveraging the learning we did on IronPython to extract elements that could be common amongst languages (dynamic type system, hosting APIs, cached method dispatch, symbol tables, ASTs, codegen, etc.), and we currently are working on IronPython 2.0, JScript, VBX, and Ruby to vet the common designs.  We'll eventually do (or recruit people to do) PHP, scheme, and maybe one more to believe we really can move language +1 with ease to the DLR.


 

Microsoft also tying into the Silverlight mission for a small, downloadable, xcopy deploy CLR that works for IE and Firefox on the PC, Mac, and linux. That runtime needs a great scripting story and UIFx story to compete with the virtuous cycle Flash/EcmaScript enjoy. We also want to work with a partner on an IDE to eventually make a play for the MS app programmability story so that you can have your choice of dynamic language on a little runtime for scripting, say, Office or VS. You have to have a horizon out there somewhere :-).

While I am thinking about IronLUA, possibly Zeddy thinking about IronAyu/IronToba. Or Bernaridho on IronBatak. DLR opens opportunity to make it possible!

Thx - R.A.M

Share this post: | | | |

My Next Bina-ISV Session | Web Performance Test

Basically you can download my material at CodePlex. But coming to Bina-ISV is easier because I will summarize and demonstrate that.

 

Thx - R.A.M

Share this post: | | | |

Windows Live Web Services

Have you heard about WLWS? This enables us to quickly create more compelling Website. We can reuse:
- Rich Media
- Photos
- Contacts
- Maps
- Search
- Authentication

 

I will share about this in October MSDN Day! Stay tuned guys!

Thx - R.A.M

Share this post: | | | |

The Next Big Thing "from and for INDC"

Four years ago when we started INDC, we didn't expect to reach what we have today. Now we have more than 1.500 members in Geeks Blogs portal, 10.000 in INDC main portal and 11.000 in project OTAK. Assuming that we have total 10.000 members with 60% validity, we can say, 6000 users are expecting "the next big things from and for INDC". But what is that should be?

If I know exactly what is that, I will make sure that will be happen. In this post I want to get some input from members and encourage all of us to think what else we can do with 6000 developers in our community. From my side, a lot of dreams that I think possible:

- Migrating INDC Portals to CS2007 and provide more features by extending CS SDK and utilize Windows Live SDK
- Video streaming of recorded .NET sessions (MSDN Day, Bina-ISV, MIC etc) using Silverlight
- Develop "the next generation of OTAK project" (AgusK bought www.otakproject.org domain for this)  
- Develop "the next generation of INDC portals" (ASP.NET, VB.NET and C#.NET portals)

Yesterday, I downloaded the latest CS2007 SP2 codes and compiled it on my machine. I think I can do some hacks with it as Pak Tahir got its licenses already. I don't really like current CS UI (comparing to what Silverlight and AJAX can do) and really want to improve it. I need some "volunteers" to help me in art/UI works (design HTML, XAML and Silverlight). Hopefully Fu (Dotnetting People) and Dycode teams can help after they finished their project's (am I right Reyza? Fu?). Lets do that once we are ready.

Other important thing in our community is we need more group leaders who will take care ASP.NET, VB.NET and C#.NET portals. If anyone interested, please ping me directly. Student is allowed and I will offer him internship at Microsoft Office for this purpose.
  

Thx - R.A.M 

Share this post: | | | |

Dynamic Language Runtime : IronRuby & IronLUA?

If you visit and read ScottGu blog, you will know that Microsoft will ships a new .NET library called DLR (Dynamic Language Runtime) in very near future. DLR provides a set of "features on top of the CLR" designed explicitly for dynamic language scenarios like shared dynamic type system, language hosting model, and fast dynamic code. The source code of IronPython implementation, including the underlying DLR library, was published on CodePlex.  Not only IronPhyton, Microsoft will also ship other dynamic language implementations:

- IronPython. This should be easy for us as we have many real Iron and Phyton in Indonesia 
- IronRuby. At least still consistent with IronX pattern. John Lam was the first implementor.   
- Javascript. Why it is not just IronJS?  
- Dynamic VB. Why it is not just IronVB?

As DLR opens opportunity to create more embedded scripting language implementation, I think it will be nice if we also have IronLUA (Loo-ah in Brazil means "moon" or "bulan" in bahasa). LUA is an extension programming language designed to support general procedural programming. It offers good support for OO, functional and data-driven programming. With its increasing number of fans, I think the effort to implement "LUA on DLR" will be an interesting journey.

Current LUA implementation is a simple library, written in portable clean C (that is why everybody should know C). If you download it from www.lua.org, its distribution includes a stand-alone embedding program, that uses the LUA library to offer a complete LUA interpreter and binary compiler. LUA is a dynamically typed language. That means that variables do not have types; only values do. There are no type definitions in the language. All values carry their own type. There are eight basic types in LUA: nil , boolean, number, string, function, userdata, thread, and table.

LUA has its own concept for garbage collector, called metamethods for userdata, also called finalizers, that allow us to coordinate LUA’s GC with external resource management (such as closing files, network or database connections, or freeing memory). You can download LUA source codes and compile it straightforward using our beloved VSTS 2008 Beta 2 like I did in my vista machine:

 

Note : please compile LUA interpreter (LUA.EXE) and LUA compiler (LUAC.EXE) separately to start play with it.


I do like PowerShell, Ruby, Perl, and now I want to show you interesting LUA codes to compute N-th Fibonacci number (I hope I am not confusing my brain with too many scripting languages):

-- fibonacci function with cache
-- very inefficient fibonacci function
function fib(n)
    N=N+1
    if n<2 then
        return n
    else
        return fib(n-1)+fib(n-2)
    end
end

-- a general-purpose value cache
function cache(f)
    local c={}
    return function (x)
        local y=c[x]
        if not y then
            y=f(x)
            c[x]=y
        end
        return y
    end
end

-- run and time it
function test(s,f)
    N=0
    local c=os.clock()
    local v=f(n)
    local t=os.clock()-c
    print(s,n,v,t,N)
end

n=arg[1] or 24        -- for other values, do LUA.EXE fib.lua XX
n=tonumber(n)
print("","n","value","time","evals")
test("plain",fib)
fib=cache(fib)
test("cached",fib)

 

I am pretty sure those codes are intuitive enough for you including its general purpose value cache. To execute LUA codes, you can do in three ways (I did with both first and second ways):

- Just write into text format called fib.lua and interpret it by executing LUA.EXE fib.lua.
- Compile into binary format using LUA compiler (LUAC.EXE -o fib.out fib.lua) then execute using LUA.EXE.
- Embed LUA binary in any host application as LUA interpreter size is only 152KB and its compiler is 151KB.

 

Interesting to know that LUA only took 0.075 second for N=24!. You can compare it with the same codes in RUBY or IronRuby, let say:

def fib(n)
  if n<2
    n
  else
    fib(n-2)+fib(n-1)
  end
end

print(fib(24), "\n");


I wish someone can run it with RUBY.EXE (native Ruby) or RBX.EXE (IronRuby, DLR) and report its execution time comparing to LUA. Honestly, I DONT WANT to do that as I can feel it slower :). IronRuby is a baby and it is interesting to know "how the baby grow from its early age". Like my 2nd son Razka, he learns new thing every day. Baby needs time to be mature, right?. ScottGu said that IronRuby has been architected to take advantage of a new DLR feature we call "Dynamic Sites" - which delivers a fast adaptive call-site method caching implementation. This baby also uses the lightweight-code generation features of the CLR that enables dynamic language implementations to create in-memory IL that is then JIT'd into native code at runtime (without ever having to save anything to disk). ScottGZu said this can yield much better runtime performance than interpreted code (like LUA?). The lightweight codegen feature ensures that once we are finished with the JIT'd code we can optionally garbage collect it to avoid leaking. Let see how ScottGu & team prove their statement. I will look on IronRuby source codes sometime and share with all of you here.

IronRuby baby is interesting but someone already took that project (John Lam). The most interesting thing for us in Indonesia is not being a follower anymore but being the innovator. What about IronLUA, LUA implementation on DLR? We can make IronLUA as our new baby without took new wifes. Anyone see a possibility to implement it?    

I am very confident that one day INDC will ship something to the worldwide developer community. I want to let them hear the name of our country as innovator. Not the country of terrorism or maid exporter. Let them know that there are developers in Indonesia who will ship good products to their countries like what Pak Tahir has done and consistently does. With all of us here, we can do many thing. 


Thx - R.A.M

Share this post: | | | |

Blogging from Microsoft Word 2007

I use Windows Live Writer before, but this time I am trying it from Microsoft Word 2007. What you have to do:

- Open Microsoft Word 2007
- New, Blogs Post (register before). For INDC geeks, please use: http://geeks.netindonesia.net/blogs/metablog.ashx
- You can start blogs

Thx – R.A.M

Share this post: | | | |

Extended : What is your favorite data structure?

I want to extend the period for this challenge. So far, Ahmad Masykur and Irwansyah have replied, but choosing 1 from 2 are not fair :). I need at least 5 participants to decide. So, lets extend this challenge until the end of August 2007. I know that "academic guys" like Norman, Zeddy and AgusK will reply during this extended period. So, please wait those experts.

Thx - R.A.M

Share this post: | | | |