Thursday, November 20, 2008

An easy way to override Chrome bookmarks

It is quite easy to manually override Chrome “Other Bookmarks” with your Firefox bookmarks:
1) In Chrome, click on “Other Bookmarks” and, if you have any, right click on each bookmark and delete it.
2) Use “Import Bookmarks and Settings”, switch to import from Firefox, clear all checkboxes except ‘Bookmarks’ one and hit ‘Import’.
3) This will keep all imported bookmarks in one ‘folder’, which is actually good, because next time when you decide to override Chrome bookmarks, you will need to delete only one Other Bookamrks ‘folder’ by right-clicking on it.

(On WinXP machine Chrome keeps bookamrks in C:\Documents and Settings\-your-name-\Local Settings\Application Data\Google\Chrome\User Data\Default\Bookmarks file. This is a text file which looks similar to XML. )

Thursday, November 13, 2008

Configuring MS DTC on WinXP, Server 2003, and Server 2008 machines

Our N-Tier ASP.NET (C# 2008 / SQL Server)  application uses MS DTC transactions for database integrity. This allows a transaction to embrace several BL or DL method calls without sharing the same database connection.
A usage is simple:

using System.Transactions; 

using (TransactionScope myTransactionScope = new TransactionScope()) {
  // Do any database related work you need: call methods, open and close connections, update multiple tables.
  // Database integrity is preserved  even if one of methods which update database fails.


To support MS DTC all servers which run our application (including developers' machines) and servers which host a databases were properly configured. (Configuring developers' machines allowed to work properly with your local copy of application and with a remote database.

1) To configure DTC on Windows XP, Windows Server 2003 machine follow these instructions to open Component Services window and configure DTC.
Make sure that "Use local coordinator" check box is checked on MSDTC tab of computer properties window.
Make sure that "Network DTC access" is checked on MSDTC=>Security Configuration window, that both "Allow Inbound" and "Allow Outbound" are checked, and DTC Logon Account is set to "NT AUTHORITY\NetworkService".
2) On Windows Server 2008 machine it's pretty much the same, except that in Component Services window has My Computer -> Distributed Transaction Coordinator -> Local DTC node, on which you'll need to right-click and choose Properties.
3) After configuring DTC restart your machine.
4) Open Control Panel -> Administrative Tools -> Services and make sure that DTC is set to start automatically and is started.

Reference on using DTC with N-Tier application:

Sunday, November 02, 2008

The best of F# and C# -- Nemerle? Scala? various approaches to mixed OOP - functional languages

Today I was pointed out to yet another mixed OOP and functional language: Nemerle. I looked at the Nemerle features and immediately spotted something very familiar, "Probably the most important feature of Nemerle is the ability to mix object oriented and functional programming styles. The top-level program structure is object oriented, while in the body of methods one can (but is not forced to) use functional style. In some programming problems this is very handy." It sounds exactly the same as what is stated about Scala programming language, "Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages." A main platform for Scala is JVM, but it's CLR variant already exists and is planned to be fully developed.

I think that both C# and Java in their pursuit of simplicity dropped too many functional features which existed in their common parent - C++. I've just blogged about it today. So, both communities felt the need for more functional OOP languages. It looks like that both Scala and Nemerle chose the same approach which creators of Java used: to build up on the base of familiar and wide-spread language in a hope that it gives an immediate advantage of huge number of programmers who are familiar with the syntax and want to try new language. I don't know about Nemerle yet and I still know too little about F#, but Scala language found a very natural and consistent way of combining object oriented and functional features and is even better OOP language than Java.

I think people are absolutely right, when they are saying, that it's hard to catch up with F#, "because the syntax of the ML - derivative languages is just too foreign for those with only imperative language experience". I felt it by myself when I was trying to start learning language using "Expert F#" book, having no prior ML experience.
But there is a flip side: now, when - thanks to an excellent "Real World Functional Programming" book by Tomas Petricek I started to understand both functional concepts and beauty of ML syntax, I feel that more graduate approach taken by Scala (and probably - Nemerle) may in fact postpone real understanding of a functional nature of new languages. It's possible to program in Scala as in "improved Java" and never learn its functional features. And thanks to more steep approach of F# I now better understand and try to pursue functional approach in Scala and better understand ideas behind LINQ...

Learning languages in comparison. How Scala re-introduces what was dropped in C++ to create Java.

An update (30/11/2008): I realize that a title of this post sounds silly. I never tried to say something like "Scala has C++ roots" or so. Scala is "an attempt to come up with a decent statically typed language that is both functional and object-oriented and that interoperates on standard VMs" (Martin Odersky in a comment here). My point is: too much (including some functional features) was dropped when C++ was "simplified" by Java creators. 

Scala allows to pass variable length argument list to a function defined like

def echo(args: String*) =
  for (arg <- args) println(arg)

In "Programming in Scala" authors says that,
'... Thus, the type of args inside the echo function, which is declared as type "String*"  is actually Array[String]'

It immediatelly reminds me C++, which uses similar syntax of passing array arguments. I'm pretty sure Martin Odersky chose asterisk, because it is used in C/C++, although in C/C++ it allows to pass array parameters, not a variable length argument list, and denotes a pointer to a first element of array.

There is definitely a feel, that C++ is more functional language than Java, for example a name of a function is a pointer (reference) variable pointing to a function itself, which allows to pass a function to another function as parameter and return as return value. First-class functions, isn't it?
So, Scala feels partly as a consistent attempt to re-introduce to Java functional features which were dropped when Java creators used C++ to produce new [over?]simplified language.

Personally, I always loved when authors of books described new languages in comparison to existing ones, like Trey Nash is doing in his "Accelerated C# 2008", comparing C# to C++, like David Flanagan is doing in "JavaScript. The Definite Guide", comparing JavaScript to C/C++, and like Bruce Eckel is doing in "Thinking in Java", comparing it to... C++ again. (By the way, Bruce is considering Scala as a next "big" language, which will gradually and partially replace Java the same way Java did to C++.) One fresh and excellent example is "Real World Functional programming in .NET" by Tomas Petricek. This book introduces F# language (a merge of OCaml and .NET platform) and functional concepts in constant comparison to limited functional features of C# 3.0. It helps a lot to understand both F# and functional features of C#. It even helps to understand Scala, because functional concepts are the same in both F# and Scala.
To learn programming languages in comparison is not an easy task. But it is, in my opinion, a most powerful way to obtain real understanding of languages. Footnotes or special text blocks, describing similarities and diffrence between languages make a programming book shine.