Archive for June, 2009

Wakoopa

Wakoopa is a social network site which keeps track on what software its members use. I find it a very useful to keep track of what applications I and others use daily. The tracker records the usage of programs, games and web apps and send it to your profile.

To start using Wakoopa you simply sign up, download and install the tracker that is available for Windows, Mac OSX and Linux.

This is my profile.

Here’s my latest top 10 software list:

Software tracking

Dynamic Language Runtime

The Dynamic Language Runtime (DLR) is Microsoft’s effort to bring dynamically typed programming languages to the .NET Framework platform. It has been around for some time now and is being improved now as I write. Currently it is version 0.91. This article aims to be a short introduction to the concepts of the DLR and the programming languages that are dependent of it.

The DLR is actually a runtime library which forms a layer upon the static Common Language Runtime (CLR). It relies heavily on reflection to create code that can be executed dynamically during runtime. So there are basically no changes to the CLR, just a layer of libraries making things seem to be carried out dynamically and then being able to work with other statically typed programming languages like C# and VB.

DLR defines these:

The DLR is built upon the idea of having an abstract syntax tree with expression nodes that are used to dynamically generate the corresponding code at runtime. The compiler of any dynamic programming language that is built on the DLR is generating these DLR abstract syntax trees which later is executed by the DLR libraries.

DynamicSite objects are caches contained in the assembly that are dynamically updated at runtime. Dynamic sites contains objects which points to methods for a fast lookup of their signatures at runtime. The invocation must check if a call is valid and if so bind it to the actual implementation of the method.

.NET Framework 4.0 will be the first release to contain the DLR libraries. You can download and try .NET Framework 4.0 Beta 1 along with Visual Studio 2010 Beta 1 from MSDN.

Microsoft has released the DLR under Microsoft Public License which is an open source license which allows anybody to redistribute it in their own project. That allows the Mono Project to bundle it with their future releases.

Dynamic programming languages

Moving on to the programming languages . The DLR makes it easier to implement dynamic programming languages as Python and Ruby, through IronPython and IronRuby, on the .NET platform. Defining a shared library which makes interoperability between them and the rest of the static languages possible. They have binders to both the CLR and the native main implementations.

IronPython is an open-source implementation of Python running on the DLR. It allows Python program to run and take advantage of the .NET Framework. There are binders to various platforms like CPython and the CLR. It also works with Silverlight (2.0 and above).

The project was initially started by Jim Hugunin, who previously wrote Jython (formerly JPython), the Java implementation of Python. Hugunin wanted to see if Python could run well on the .NET Framework and therefor he started writing IronPython. He thought that it would be inefficient but was rather surprised when it turned out to run very well. Later he was hired by Microsoft as a developer where he took the initiative to create the Dynamic Language Runtime. Since then he has been the leader for both the DLR/Iron Python-team.

from BookService import BookDictionary

booksWrittenByBookerPrizeWinners =
[book.Title for book in BookDictionary.GetAllBooks() if "Booker Prize" in book.Author.MajorAwards]

Likewise there is an implementation of Ruby called IronRuby. It has the same goals as IronPython and the original project called RubyCLR was started by John Lam, who now works as a Program Manager at the DLR Team. Initially it was just a binder to Ruby but it has evolved and is now a open-source project at Microsoft.

sb = StringBuilder.new
sb.Append "Hello"
sb.Append " World!"
puts sb.ToString

Because of their open-source nature both languages run on Mono as well although there are no guarantees they will not do it as IronPython and IronRuby currently are under development.

There are other language implementations as well. Managed JScript and IronScheme among others.

From version 4.0 Microsoft’s implementation of C# will support dynamic typing through the dynamic keyword which makes it easier to interop with DLR languages and COM objects. Visual Basic 10 will have similar functionality with the Dim keyword. Mono will also add this soon. How this really works under the hood will be something to talk about in another blogpost.

Note:

Sun is currently working on a new version of the Java Virtual Machine, called the “Da Vinci Machine”, which adds support for dynamic programming languages to the Java Platform at runtime level. New op codes are being introduced to the instruction set of the Java Bytecode.

Update:

The computational knowledge engine

Two months ago the math-oriented company Wolfram Research launched their new “search engine” Wolfram|Alpha. I write it in quotes because it is even more than just a search engine, it is what they would call a computational knowledge engine.

It is a web service that is based on the company’s flagship Mathematica. Using it as the back-end when processing all the data to get a statistically accurate answer. Unlike search engines like Google and Bing, which only search the web, Wolfram|Alpha has a wider range of functionality. It allows you to get data, statistics on for instance the US, calculate mathematical expression and then plotting them… and yes more.

Here’s some samples:

x^2 + 4x – 1

plot x^2 + 4x – 1

population of the US

sphere, volume = 5 dm^3

Stockholm

Methane

IBM Microsoft

weather Madrid

Michael Jackson

2% of $200

You can write even more advanced queries. Request IP-number lookup and more.

Try it yourself at WolframAlpha.com.

Wolfram|Alpha do not wish to compete with the other search engines that queries web sites.

Lexical scanners

How do a scanner work then? Is it hard to write one by hand? I will show you and no it is not.

Let’s start with theory.

A scanner is a finite state-machine, or more precisely a Deterministic Finite-state Machine (DFSM). It handles different states through regular expressions. In this case it maps the characters in the input stream to the rules. Do not worry if this does do not make sense right now.

The DFSM has a starting state and from that you may fulfill some conditions to reach another state, and another from that. If there are no condition that can be satisfied you simply go back to the initial state.

We will take a look at this example where we have a string: “foozie30 23.3″. A valid DFSM for this input could be drawn like this:

dfa

The most common ways of implementing this state machine in an imperative programming language would be using state controllers like if, while and for or any equivalents. You process each character and when you got the string you return an object of a type which symbolizes the symbol that was found. In an object-oriented language it would be even simpler to implement if you ask me.

If you want to take a look at an implementation you just download my Expression parser project. :)

Most compiler geeks, as they are called, are using parser generators and grammars that create both scanner and parser. A parser is far more advanced than scanner. It is not impossible to write them by hand, as I have shown, but generally it is regarded as better writing a grammar and then let the generator create the scanner and the parser for you.

Compilers are very interesting both in theory and in their implementations. Because it is such a large subject you will probably not find this enough. That is why I am planning to write more articles about compilers and techniques that can be used while writing one.

The dynamics of Dynamic programming languages

One of the things that fascinates me when it comes to programming is the underlaying architecture which allows programs to be executed on your computer. I think it is interesting to know how data is handled. There are many ways of handling data. Usually all the data has got a type bound to it. That means that if we have a value then it must be of a type to ensure some kind of safety at runtime. You declare a variable of type int and it will forever, in the liftime of the program, be a variable of that kind. The compiler will automatically cast an error if you assign a string of character (text) to the it. This is called static typing.

In difference to this there is a concept where you do not need to think of types in this way. In most dynamic programming languages variables do not have fixed types and you can therefore assign what kind of value you want to it. The type will change to the one of the new value at runtime. And to say there are implicit conversions between different types and you do not have to worry about if you want to cast an int to a double or vice versa. This is called dynamic typing. It will be done without any extra effort from you. So the languages are still type aware in a manner. I will now talk more about ideals type-safety. You need to be aware of languages and their differences. I will later mention the behaviours of PHP and its flaws.

Type-safety is a lot. In static programming (the first part) you have the notion of variables with fixed types, and that is an implementation of type-safety. But there is so much more. You do not need to have typed variables to be a lot less than that. Type-safety is also about having a set system where you get the behaviour you want and prevent the unwanted from happening. Many traditional programmers prefer static typing and what it gives because you are guaranteed to write less buggy programs and then execute them “safely”. On the other hand, an experienced programmer may also use a dynamic language despite this and produce safe code without the safety provided by static typing. It depends on the programmer, and of course the underlaying runtime which hopefully protects you from doing things fatal to your system.

All languages are either classified as strongly- or weakly typed depending on their way of handling the types of data. That is regardless of whether it is a statically typed language or not. PHP is an example of a weakly typed language.

Productivity is said to be larger with a dynamic programming language than with a typed because you do not really care about types as much in static, non-dynamic languages, like C, C++, C# and Java. You are then simply concentrating at the algorithms and logic, and not the types of the objects.

Now let us continue with type-safety. PHP is for instance not a very type-safe language (weakly typed in other words) because you may do what ever you want and the runtime will not complain but do exactly what you wrote, unless it is syntactic or logical. If you add a boolean value (true or false) with a number you will probably add them as a number. If you just want to add these as a string you may have to write some more code. But because PHP is a scripting language you may try as you write to find errors in your code. There is usually no way of becoming aware of them when writing the programs, or scripts. Errors are deteced at runtime in the realm of dynamic programming languages.

This tells you that runtime is what matters in dynamic languages, opposed to compile-time which is important in many statically typed languages. That is why very few dynamic languages needs to be compiled before execution. It is carried out on the fly when entering it in the console. Reflection and runtime alteration are usually a feature of the most renowned languages. Everything happens at runtime, baby!

Another dynamic scripting language is Python. It is regarded as one of the most popular of its kind. There is a significant difference in the way it handles types, as in any framework of a programming language. No programming language has the same architecture. Many share similarities though. Python is truly a scripting language and the fact that it comes with an interpreter really confirms that.

The interpreter allows you to type code in a console. The code will then be executed on the fly, dynamically! This is common for many scripting languages. It gives developers a way of really try as they write.

Other features common to dynamic programming languages are support for functional programming. Most of the concepts initially derive from LISP.

So there are many advantages and disadvantages with dynamic programming languages, like all programming languages. I do not want to argue about which one is the best. I think that programming languages shall be chosen by need, and then it is up to the programmer, YOU, to use it right. As a developer you always have to adopt new ways and new techniques to be up to date in a constantly changing world of bits and bytes, data.

Thanks for reading.

Welcome to my blog!

Hello and welcome to my blog!

I am very pleased to announce that I have returned and that I am updating the blog. You can now read my resumé and CV is also available on the About page. If you are interested in my work you may check the Projects page.

I hope to write about more interesting things now when I am attending college this fall. But that depends on how much time I get while studying.

Stay tuned!

/Robert

Student i en klass för sig själv

Publicerad: 9 juni 2009, 01:15

 

Ystad
Robert Sundströms framtid stavas programvara. På fredag blir det studentavslutning vid John Bauergymnasiet. Och handledaren på IT-linjen är smått lyrisk över hans talang.

– Robert har gjort ett mycket avancerat projektarbete inom programmering. Nivån ligger långt över vad som kan förväntas, mycket hög klass, säger utbildningsansvarige Karl-Erik Bolin.

Den 19-årige avgångseleven uppfyller de viktigaste kriterierna med råge, menar han.

Brinnande intresse

– Man måste kunna bolla med språket, man måste vara analytisk och kunna bryta ner problemen i beståndsdelar och helst ha ett brinnande intresse för datorer och programmering.

Robert Sundströms projektarbete består av en kompilatorkonstruktion, eller ett översättningsprogram, som omvandlar förståeligt språk till maskinspråk med matematiska uttryck och maskinkoder.

Robert Sundström är bosatt i Hammenhög, men i höst flyttar han till Ronneby och studier vid Blekinge tekniska högskola.

– Sen hade det varit kul att få jobba vid ett större företag inom programvarubranschen, säger den avgående gymnasten till YA.

Magnus Wegerup

En kommentar länkar till ett inlägg på bloggen till Programvaruteknik (PT)  på BTH. Tack så mycket Mikael Roos, programansvarig på PT, för det här uppmärksammandet!



Robert Sundström

Tweets

  • Waiting for the VS 2010 Beta 2 to be released to public. Only a couple of hours left. But still not sure when. Is it local time? 1 month ago
  • Writing meaningless programs.. 1 month ago
  • I consider myself being a logical being, but my logic is flaud. 1 month ago
  • SvD: Facebook gör dig smart – men Twitter fördummar (http://bit.ly/14XGNr 2 months ago
  • 2 weeks have passed since I came to Karlskrona. I pretty much enjoy living here. College has started and so far little coursework. 2 months ago

Recent Comments

Steve on Windows 3.11 on a virtual…
catchmikey on Wakoopa
Hillary on First days in Delsbo
wilhol on PC or Mac?

Categories

Calendar

June 2009
M T W T F S S
« May   Jul »
1234567
891011121314
15161718192021
22232425262728
2930  

Blog Stats

  • 15,577 hits