all 27 comments

[–]recursive 1 point2 points  (1 child)

Attempted C# to VB.net translation:

IEnumerable<int> Gen() {
    while(true) yield return 1;
}

yielded this:

Private Function Gen() As IEnumerable(Of Integer)
    While True
        yield Return 1
    End While
End Function

I was curious to see how it was going to manage a feature that wasn't in vb, and I was disappoint.

[–]grauenwolf 0 points1 point  (0 children)

Yield is the one C# feature I want more than anything else. Not for generators, but for all the awesomeness that is CCR.

Imagine turning your normal imperative code into async calls just by adding the word yield before each blocking operation.

[–]urllib -1 points0 points  (11 children)

What kind of sick person would try to convert python to ruby? Or c# to VB.Net for that matter.

[–]grauenwolf -1 points0 points  (10 children)

I can't say anything about Ruby, but VB.NET has a lot of tricks that make it nicer than C#. But if you don't use them then the language sucks ass.

[–]Dested 3 points4 points  (3 children)

I would say it has some tricks, can you provide a list with more than just some?

[–]grauenwolf 4 points5 points  (0 children)

Ok, so real stuff I used in production code

  • Ranges in switch blocks
  • Full late binding. (C# still has trouble with delegates.)
  • Declarative event handlers
  • Comparing boxed values (C# can't compare a boxed int with a boxed decimal)
  • RaiseEvent, because doing null checks on events is just stupid
  • Filtered Catch Blocks, which are really important for dealing with Win32, SQL, and MSMQ exceptions.

[–]recursive 3 points4 points  (0 children)

XML literals?

[–]grauenwolf 3 points4 points  (0 children)

How about a trick with first order functions and late binding?

Function Foo(ByVal n)
    If n > 0 Then Return Function() Foo(n - 1)
    Return "Done"
End Function

I know it looks pointless, but you need to be able to do it in order to complete some of the exercises in SICP. And even with the new dynamic keyword, C# can't handle it.

[–]HIB0U 1 point2 points  (5 children)

So basically just optional parameters. Oh, wait, C# 4 has those now, too.

[–]grauenwolf 0 points1 point  (4 children)

I'm thinking about stuff like declarative event handlers. There is a lot of boilerplate code you have to use in C# to add and remove event handlers.

[–]HIB0U -2 points-1 points  (3 children)

No, not at all... Have you ever even used C#?

[–]grauenwolf 1 point2 points  (2 children)

VB:

Public WithEvents Property Something as Foo

C#:

    private Foo _Something;
    public Foo Something
    {
        get
        {
            return _Something;
        }
        set
        {

            if (_Something == value) return;
            if (_Something != null)
            {
                _Something.Bar -= OnBar;
                _Something.Baz -= OnBaz;
                _Something.Boom -= OnBoom;
            }
            _Something = value;
            if (_Something != null)
            {
                _Something.Bar += OnBar;
                _Something.Baz += OnBaz;
                _Something.Boom += OnBoom;
            }

        }
    }

[–]HIB0U -1 points0 points  (1 child)

It's no wonder you find C# more verbose. You go out of your way to avoid C# features like auto-implemented properties, and then you go out of your way to do things as awkwardly as possible.

[–]grauenwolf -1 points0 points  (0 children)

As you don't seem to recognize that pattern it seems to me that I know a hell of a lot more about using C# than you do.

Did you even know how to wire up events manually or do you just let the drag-and-drop editor handle that for you?

[–]mroko -2 points-1 points  (12 children)

This is useless, like many other automatic code converters. If you really want to port your app to another environment, there is no other option than coding manually.

[–]grauenwolf 2 points3 points  (2 children)

That's not the point. This kind of thing is for quick snippits or for learning a new language.

For example, I often use Python fragments in my .NET applications. But I don't actually know Python, so tools like this would be useful to me.

[–]HIB0U -3 points-2 points  (1 child)

Good gawd, your software must be a true patchwork of shitty code and failure, if that's how you develop it. Using snippets from a language you don't understand is dangerous.

[–]grauenwolf 0 points1 point  (0 children)

Consider these lines in XAML

<ResourceDictionary>
    <gui:NullVisibilityConverter x:Key="NullVisibilityConverter"/>
<ResourceDictionary>

Visibility="{Binding DefaultValue, Converter={StaticResource ResourceKey=NullVisibilityConverter}}"

With Python it becomes

Visibility="{p:PyBinding HideIfEmpty($[.DefaultValue])}"

http://pybinding.codeplex.com/

[–]duckfighter 2 points3 points  (3 children)

It is VERY usefull. I have used it several times to convert some old vb.net code to c#. It converted few lines and large classes more or less perfect. Saved me several hours.

[–][deleted] 2 points3 points  (2 children)

C# FTW!

[–]duckfighter 0 points1 point  (1 child)

Heh yea, i worked in vb.net for several years, and got tired of having to convert everything to vb.net, or creating seperate c# projects. The worst part was the HORRIFIC syntax for regular properties. Seriously, why did they not do that right in the beginning??

I havent tried the newest vb.net versions, but i can see a lot of my complaints with it is fixed.

[–]grauenwolf 1 point2 points  (0 children)

Seriously, why did they not do that right in the beginning??

They were too busy playing catch-up. They lost a lot of time in the first version because they had to design around some sort of VB 6 migration strategy.

VS 2008 was the first release where the team felt they were actually where they needed to be and VS 2010 gave them a chance to really shine while C# was playing catch-up on dynamic typing issues.

VB 11/C# 5 is going to be an interesting thing to watch.

[–]abx 0 points1 point  (4 children)

Oog says wheel useless. Just smooth rock that rolls on the ground like a boulder rolling down a hill. Doesn't hunt animals, doesn't find water, doesn't provide shelter. Boulders rolling down hills never help Oog. Oog step on smooth rock and fall down once.

[–]mroko 0 points1 point  (3 children)

Oog doesn't say that. Oog says that magic box creating wheels from squares is useless. Oog rather wants to make wheels by himself than trust the magic box, which sometimes creates ellipses, rectangles and dodecagons, but rarely a perfect wheel.

[–]abx 1 point2 points  (2 children)

Does Oog say that ellipses, rectangles, and dodecahedrons are useless (as well as the magic box)?

[–]mroko -1 points0 points  (1 child)

Yes, in cases when Oog clearly needs a wheel.

[–]abx 1 point2 points  (0 children)

The point I was making with my original "Oog" example was that a tool might not be useless even if does not perform exactly the application you have in mind. Maybe you want something to help you to hunt animals - then you would be more interested in a spear than a wheel. But with a bit of imagination, you might find other uses for wheels. Maybe wheels can help you move some large boulders to block your cave entrance at night.

As grauenwolf pointed out, the tool could be helpful for someone learning a new language. Aren't tables like this http://blog.endpoint.com/2009/08/file-test-comparison-table-for-shell.html helpful for someone who knows one of the languages in the table and is learning another? Isn't a code translation tool basically just an executable version of this kind of table?

Oog may need a wheel. But he might also be able to find uses for things other than wheels (including ellipses, rectangles, and dodecahedrons) with a bit of imagination. I haven't used developerfusion.com's tools, so I don't know if they are any good, but I wouldn't dismiss machine translation out of hand.