views:

1637

answers:

7

I was (yes, was) a Python (and before VB6) lover until tried to create GUI applications. It is very (very) difficult to create a GUI, and making executables (A hello world app was 2 MB).

Then, I jumped to VB.NET, but collections looked hard, strange and foolish to me. Then, jumped to C#, but don't really know C# well now. I ordered a good (Turkish) C# book.

Nowadays, I met Boo. It is a bit more Python syntax, .NET, compiled and compiles in C# lang. I liked it, even more than C#. But I didn't find a book about Boo.

And I really don't know, is learning Boo better than C# or learning C# better than Boo. I just want to some Python like data types. Those were:

  • {key1:value1, key2:value2} → dictionary (some like HashTable)
  • [Value1,Value2,Value3] → List (can be edited/changed)
  • (Value1,Value2,Value3) → Tuple (can't be edited/changed)

I use dictionaries more than list and tuples. I want to know, which is better?

A: 

You have lists and dictionaries in .Net: System.Collections.Generic.List and System.collections.Generic.Dictionary.

As for the language: Just learn the one that is more fun for you. The choice of language is most often religious. Expecially on the .Net platform, where each language has almost the same capabilities.

Maximilian Mayerl
"where each language has almost the same capabilities" that only applies to C# vs VB
Mauricio Scheffer
You think so? I don't...I can, for example, do almost everything I can do in C# do in C++/CLI. And I'm sure that I can do almost anything I can do in Boo in C# too somehow. The only different thing would be dynamically typed languages like IronPython, and that will change too in C# 4.
Maximilian Mayerl
try creating a boo-like DSL in C# (even 4.0) or C++. See http://blogs.codehaus.org/people/bamboo/archives/001588_dslfriendly_syntax.html
Mauricio Scheffer
try writing an extension for C# (even 4.0) or C++ to add pattern matching *to the language*. see http://blogs.codehaus.org/people/bamboo/archives/001620_a_pattern_matching_facility_for_boo.html
Mauricio Scheffer
try doing pattern matching in C# (even 4.0) or C++ or IronPython like you can in Boo or F#
Mauricio Scheffer
Try redefining if in C# or C++ http://ayende.com/Blog/archive/2007/10/04/Redefining-If.aspx
Mauricio Scheffer
more examples: http://stackoverflow.com/questions/193862/boo-vs-ironpython/448971#448971
Mauricio Scheffer
try doing string interpolation in C# or C++, like you can on Boo or Nemerle.
Mauricio Scheffer
Yes, this are sure nice features (I love Nemerle, btw.), but it's nothing that you ultimately NEED. In the end, you can be productive to the same extent in almost any .NET language. Of course, it depends on what you want to code, but as I said: take the one that's most fun for you. I think the language which is the most fun will be the one which is the most practical for the things I want to code.
Maximilian Mayerl
I guess we'll have to agree to disagree on this one :-)
Mauricio Scheffer
+2  A: 

Knowing C# will be very useful to you if you want a career in .NET development. But learning Boo would allow you to use the Python-like features you are after in a .NET environment. You should probably also look into IronPython, which does have books available (Iron Python in Action)

Mark Heath
+3  A: 

My general opinion is that it would be better to go for C# since it is from my point of view, easier to find resources, documentation and tutorials for C#.

Jonas B
Nothing wrong with VB.NET either. Technically, that is. People who dislike it usually just don't like the smell of it, they don't actually understand VB.NET. The only truthful complaint I've seen against it is that its syntax is rather verbose, but to me that's a strong point. By now, many VB.NET features have been added to C# (and vice versa), the languages differ in little except the surface syntax.
reinierpost
A: 

I'm not sure what your end goal is, but before you give up on python please do check out the python/Qt combo for building a gui. You can build complex cross-platform guis and it's fairly easy to pick up. Qt, Python Bindings

Will
I already know (and tried) PyQt, wxPython, Boa Constructor, IronPython Studio and others, but tnx for advice (I'm not a Python n00b :S).
Proton
+8  A: 

I have found Boo to be very useful in creating simple one-off scripts, while retaining my Pythonic source style. And since it compiles to runnable EXE or DLL, I can package up a single EXE with all the needed DLLs (including Boo.Lang.dll) using ILMerge, and then send that off to a client, usually for some kind of quick troubleshooting or system diagnosis.

I also use Boo to support my C# development. I often fire up a Boo interpreter to try out variations of string or date formatting, then I can replicate the final version almost directly into C#.

But it is darned difficult to find docs for Boo. I had to Google quite a bit to find the syntax for generics, since they are a relatively new addition to Boo, and not yet mentioned in any tutorials, or even reference pages. And googling for "boo" generates quite a few unwanted hits, making the search even more difficult.

So in short, don't make this a choice between Boo and C# - they actually complement each other pretty well.

Paul McGuire
Try CSharpRepl/Gsharp: http://www.mono-project.com/CsharpRepl
Dykam
A: 

You have lists and dictionaries in .Net: System.Collections.Generic.List and System.collections.Generic.Dictionary.

As for the language: Just learn the one that is more fun for you. The choice of language is most often religious. Expecially on the .Net platform, where each language has almost the same capabilities.

Hmm, I didn't find this in VB.NET. I did some tricks in MSVS and found how to make dic. and lists in C#:

var a = new Dictionary<object, object> {{"asd", "1"}, {"f", "1"}};
var b = new List<object> {"asd","asd"};

This is easier than in VB.NET. I don't remember the "Generic" collections in VB.NET, or my book sucks :S Whatever, when my C# book come, presumably I will continue with C#. Thanks for all comments. Paul McGuire's was the best comment ;)

And, is there a way to make read-only List like Tuples? It will reduces CPU and Memory usage I think. I googled and found some of them (like ReadOnlyCollection and ReadOnlyCollectionBase) but in MSDN, first creates an ArrayList or List then loads ReadOnlyCollection to List. Is there a way to make readonly list without making another list? :S

Proton
Don't use the object type with dictionary and list. The point behin generics is that you can work strongly typed. If you want untyped collections, use System.Collections.Hashtable and System.Collections.ArrayList. but I would recommend using the generic versions and using the correct types.
Maximilian Mayerl
A: 

Don't use the object type with dictionary and list. The point behin generics is that you can work strongly typed. If you want untyped collections, use System.Collections.Hashtable and System.Collections.ArrayList. but I would recommend using the generic versions and using the correct types. – Maximilian Mayerl

Hmm, tnx for the comment. I'm sure I will use same data types for keys and values (so, static) (e.g: Key: string only, value int only etc.) more than dynamic ones. Then, which is better for performance and coding?:

var a = new Dictionary<string, int> {{"one", 1}, {"two", 2}};
var b = new List<string> {"first", "second"};
var c = new Hashtable() {{"one", 1}, {"two", 2}};
var d = new ArrayList() {"first", "second"};

I have a thing that can be made with collections:

private static string City()
{
    switch (region)
    {
        case "AL": return "Alabama";
        case "AK": return "Alaska";
        case "AZ": return "Arizona";
        case "AR": return "Arkansas";
        case "CA": return "California";
        case "CO": return "Colorado";
        case "CT": return "Connecticut";
        case "DE": return "Delaware";
        case "FL": return "Florida";
        case "GA": return "Georgia";
        case "HI": return "Hawaii";
        case "ID": return "Idaho";
        case "IL": return "Illinois";
        case "IN": return "Indiana";
        case "IA": return "Iowa";
        case "KS": return "Kansas";
        case "KY": return "Kentucky";
        case "LA": return "Louisiana";
        case "ME": return "Maine";
        case "MD": return "Maryland";
        case "MA": return "Massachusetts";
        case "MI": return "Michigan";
        case "MN": return "Minnesota";
        case "MS": return "Mississippi";
        case "MO": return "Missouri";
        case "MT": return "Montana";
        case "NE": return "Nebraska";
        case "NV": return "Nevada";
        case "NH": return "New Hampshire";
        case "NJ": return "New Jersey";
        case "NM": return "New Mexico";
        case "NY": return "New York";
        case "NC": return "North Carolina";
        case "ND": return "North Dakota";
        case "OH": return "Ohio";
        case "OK": return "Oklahoma";
        case "OR": return "Oregon";
        case "PA": return "Pennsylvania";
        case "RI": return "Rhode Island";
        case "SC": return "South Carolina";
        case "SD": return "South Dakota";
        case "TN": return "Tennessee";
        case "TX": return "Texas";
        case "UT": return "Utah";
        case "VT": return "Vermont";
        case "VA": return "Virginia";
        case "WA": return "Washington";
        case "WV": return "West Virginia";
        case "WI": return "Wisconsin";
        case "WY": return "Wyoming";  
    }
    return City();
}

EDIT:

    var ren = new System.Diagnostics.Stopwatch();

    ren.Start();
    var a = new Dictionary<string, int> {{"asd", 1}, {"f", 1}};
    var b = new List<string> {"asd", "asdf"};
    ren.Stop();
    var rn1 = ren.Elapsed.TotalMilliseconds;
    ren.Reset();
    ren.Start();
    var c = new Hashtable() {{"asd", 1}, {"f", 2}};
    var d = new ArrayList() {"asd", "asdf"};
    ren.Stop();
    var rn2 = ren.Elapsed.TotalMilliseconds;
    ren.Reset();
    ren.Start();
    var e = new Dictionary<object, object> { { "asd", 1 }, { "f", 1 } };
    var f = new List<object> { "asd", "asdf" };
    ren.Stop();
    Console.WriteLine("Dictionary<string, int> + List<string> = {0} Miliseconds"
                      + "\nHashtable() + ArrayList() = {1} Miliseconds\nDictionary<object,"
                      +" object> + List<object>  = {2} Miliseconds", rn1, rn2,
                      ren.Elapsed.TotalMilliseconds);
    /*
    Returned (Generally the results will be similar):

    Dictionary<string, int> + List<string> = 0,1331 Miliseconds
    Hashtable() + ArrayList() = 0,0145 Miliseconds
    Dictionary<object, object> + List<object>  = 0,0567 Miliseconds
    */

Looks Hashtable and Arraylist is the winner :D (Lol). And the "object" type was better than string and integer. They are almost the same (in coding), so, I will use HashTable and ArrayList...

Proton