Any golang code convertors?

4,990 views
Skip to first unread message

AndreR

unread,
Mar 3, 2015, 12:46:12 PM3/3/15
to golan...@googlegroups.com
Are there any good golang code convertors?

I'd like to convert c# to golang, but if there isn't a convertor I'll first use another tool to get to java and then from there to golang.

Thanks!

adon...@google.com

unread,
Mar 3, 2015, 12:59:38 PM3/3/15
to golan...@googlegroups.com, andre....@gmail.com
On Tuesday, 3 March 2015 12:46:12 UTC-5, AndreR wrote:
Are there any good golang code convertors?

I'd like to convert c# to golang, but if there isn't a convertor I'll first use another tool to get to java and then from there to golang.

It's very hard to compile one high-level language to another in a way that preserves the important practical aspects of the program's behavior.  It's nigh impossible to compile one high-level language to another high-level language via a third, especially when the third doesn't support concepts common to source and destination, such as pointers.

So I would advise almost any other course of action.  What are you trying to convert?  Go has many good libraries that might make the task of porting from scratch easier than you might think.  It will certainly be more fun and the result more satisfying, as well as educational.

AndreR

unread,
Mar 3, 2015, 1:49:53 PM3/3/15
to golan...@googlegroups.com, andre....@gmail.com, adon...@google.com
We have about 500 000 lines of code on our news site using only standard c# commands and no 3rd party libraries. 

There are c# to java convertors, and this one is opensource: http://www.cs2j.com/download/.

We'd love to get off C# as it is tying us to Windows. Linux's Mono c# runtime is not fast enough, but it seems like a LOT of work to manually go through all that code and convert to golang.

Even if there is a tool that does 90% it would help us and we can manually do the rest.

Alan Donovan

unread,
Mar 3, 2015, 1:57:01 PM3/3/15
to AndreR, golang-nuts
On 3 March 2015 at 13:49, AndreR <andre....@gmail.com> wrote:
it seems like a LOT of work to manually go through all that code and convert to golang.

Then don't convert all of it. :)   Seriously, it may be the case that 25% of your code delivers 75% of the value, in which case, just port that.  Use whatever kludges you need to keep the remaining value from the old code; I don't know, but I still doubt code that's been automatically translated twice will be worth the paper it's written on.

andre....@gmail.com

unread,
Mar 3, 2015, 4:51:28 PM3/3/15
to golan...@googlegroups.com, andre....@gmail.com, adon...@google.com
I think we'll start by rewriting our newsletter batch sending which is written in PHP and MySQL and get to know the language.

But it would be helpful if there was a golang library that mimics some of c#'s standard libraries such as Date handling, StringBuilder etc, just to make it easier for someone who wants to convert their C# code. More c# developers would take the leap if it was easier. And why stop there, maybe there should also be a golang library that is a duplicate of some of java's etc libraries. Yes I know it will not be optimal but it would be so much easier to get going to convert code and then the code can be optimised later.

tx for your input.

Ingo Oeser

unread,
Mar 3, 2015, 4:58:41 PM3/3/15
to golan...@googlegroups.com
Date handling: http://godoc.org/time
StringBuilder: http://godoc.org/bytes#Buffer and maybe the fmt package. Depending on how you submit your newsletters, net/smtp might be useful, too.

DV

unread,
Mar 3, 2015, 8:04:59 PM3/3/15
to golan...@googlegroups.com, andre....@gmail.com, adon...@google.com
Converting C# to Go seems impossible to me - how would this tool deal with LINQ? Inheritance? Operator & method overloading? Generics? System.Linq.Expression trees? Abstract classes/methods? 

Also, you're not tied to Microsoft with C# as much anymore:

Jan Mercl

unread,
Mar 4, 2015, 3:00:58 AM3/4/15
to golan...@googlegroups.com
On Wed, Mar 4, 2015 at 2:05 AM DV <dimiter....@gmail.com> wrote:

> Converting C# to Go seems impossible to me - how would this tool 
> deal with LINQ? Inheritance? Operator & method overloading? 
> Generics? System.Linq.Expression trees? Abstract classes/methods? 

By definition, any Turing complete language is convertible to any other Turing complete language.


> Also, you're not tied to Microsoft with C# as much anymore:

I always considered C# not as a programming language but as platform locking mechanism. Open sourcing some parts of it cannot change that. Actually, even open sourcing 100% of it would not help because C# programs have to use library APIs which often make little or no sense on any platform but Windows, again by design.

-j

Alex Smith

unread,
Mar 4, 2015, 3:08:46 AM3/4/15
to Jan Mercl, golan...@googlegroups.com
Don't get me wrong I am not / have never been a c# person.  I think good versioning in a simple way is important to user adoption.  If this is first introduced as a hash it is irrelevant because it can be fixed at a later date.
 
Alex 

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chris dollin

unread,
Mar 4, 2015, 3:39:11 AM3/4/15
to Jan Mercl, golang-nuts
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Chris "allusive" Dollin

AndreR

unread,
Mar 6, 2015, 4:27:01 AM3/6/15
to golan...@googlegroups.com, andre....@gmail.com, adon...@google.com
Thanks very much, I'll definitely use this to get onto Linux, and then I will do any new projects in GoLang to test it out.

Thanks all for your considered input.

Lars Tørnes Hansen

unread,
Mar 7, 2015, 10:06:10 AM3/7/15
to golan...@googlegroups.com, andre....@gmail.com, adon...@google.com
@AndreR

Recenly someone had wrote about their expecience with Go.

Read this article and how they use 2 programming languages (Ruby and Go):
Slides for that talk at GoperCon India 2015: https://speakerdeck.com/nexneo/joy-of-single-purpose-services-in-go

I suggest that your business take a similiar approach - take out the most complex part of your C# code and run it as batch jobs, or a backend service - and replace the not-so-complex C# with services written in Go.

Later, you can always rewrite the complex C# code in Go - if it makes sense.

/Lars
Reply all
Reply to author
Forward
0 new messages