Slashdot Mirror


Creating .NET C# Applications for Linux

An anonymous reader wrote to mention an article on the IBM site entitled Mono brings .Net Apps to Linux. From the article: "Mono gives open source developers the programming power and flexibility to build applications for Linux while maintaining cross-platform capabilities, using a variety of .NET-compatible languages. One of the great advantages of Mono for current .NET developers is providing an easier migration path to Linux. The Mono project has a very open and active development community and provides both developer tools and the infrastructure needed to run .NET client and server applications. Perhaps the most important benefit of using the Mono architecture is that you gain language independence. Mono lets you leverage any existing code from languages supported in the .NET runtime. "

27 of 340 comments (clear)

  1. .NET Windows Forms by Anamanaman · · Score: 2, Interesting

    I have a .NET Windows forms app that I'm looking to port to Linux using Mono. Anyone have any experience doing this? Is it something I should even bother trying to do?

  2. portability problems by vlad_petric · · Score: 4, Interesting
    The article is silent on the GUI part. Unfortunately, that's also the most unportable part with .NET. Since winforms was really tailored for the windows api, porting it is no trivial tasks. Windows.Forms/Mono is still under heavy development.

    Keep in mind that Microsoft saw .NET as cross-platform, but only between windows platforms. Java is far better in that respect. While full compatibility is in many cases impossible, the extra effort per platform is much smaller

    --

    The Raven

  3. Re:let me get this straight ... by photon317 · · Score: 2, Interesting


    Sounds just like .NET

    I've always though that Mono was a waste of time. .NET hasn't been around for very long at all. If you've got the brains to switch to Linux now, where were those brains two years ago when you wrote your now "legacy .NET code", and how much trouble would it be, really, to just own up to the mistake and start over from scratch in a better environment instead of bringing your .NET cruft over to Linux with you? I don't see it being practical and useful and interesting until about 5-8 years down the road when almost nobody is writing new software for .NET, and the last few braindead idiots are finally getting the point, and need to move quickly to Linux and bring with them (temporarily while they do real porting) 10 years of built up .NET infrastructure. And I cannot fathom how the (talented and insightful, obviously) Mono developers can stomach putting in all this effort for future idiots who are in the process of committing the sins that will ultimately lead to Mono's usefulness right now, as they code it.

    --
    11*43+456^2
  4. How cross-platform by pmike_bauer · · Score: 2, Interesting

    A few years back, I had a serious Java epiphany. Try taking a JAR that runs on an IBM JVM (AIX) and, without a recompile or glitches, run it on a Sun JVM (Windows). It just works.

    A C# program targeting the Mono runtime will probably be very portable to all operating systems that run Mono. But, will a Mono app/code base developed on Linux run just as smoothly on the .NET runtime in Windows?

    --
    I read /. for the (Score:-1, Conservative) comments.
  5. wxWidgets vs. Qt vs. Windows Forms by everphilski · · Score: 2, Interesting

    I'm looking into wxWidgets vs. Windows Forms at the moment for a project I'm working on at the moment. It's my thesis research.

    Qt was eliminated right out - my project can't be made GPL (due to a piece of the code that is subject to export restrictions), and I can't afford the license cost for a commercial license (and the educational license was too restrictive: I could only develop on campus on a school owned computer.).

    Windows Forms is looking very slick. Cross compatibility isn't a requirement, its something I would like. I havent bought into the whole .net or "managed C++" thing, my project is pure C++. I haven't investigated wxWidgets close enough yet to see if they mandate all of my code has to be GPL yet. If not I will give it a serious look. The sample code didn't look quite as clean or object oriented as Windows Forms did, however, which I do value. One cool thing about Windows Forms is that you can keep the "old" C++ code seperate from the Windows Forms program and just call the classes without converting them to "managed C++" or .net.

    -everphilski-

  6. Re:Here we go again by Anonymous Coward · · Score: 1, Interesting

    I have written a scripting engine in C# and the non-UI portion (i.e both the compiler and virtual machine) compile on Windows and execute on Linux perfectly, even the object files my compiler outputs are platform independant. The development environment I have written does not compile under Linux, which agrees with other posts about Windows.Forms not yet being ported properly.

    I personally think it rocks, and as a Windows developer by trade, allows me to get a wider audience for my programs.

    My scripting enigne will be open sourced and make available in due course (probably via gotdotnet or sourceforge).

  7. Re:I'm sorry by Alkonaut · · Score: 2, Interesting

    C#/.NET was designed to be all that java is in terms of platform independence, but MOST importantly, VM and package versioning was thought of from the beginning. Makes the whole difference.

  8. Re:let me get this straight ... by sloanster · · Score: 2, Interesting

    Linux programmers will use .NET/C# but they won't use Java?? What's up with that?

    Sam


    I'm a long time linux user, and I love java - and I meet a lot of people of like mind in the course of my work. As for mono, we're all pretty much taking a "wait and see" approach. It's a neat hack, but... can we trust that microsoft won't stir up patent trouble? I dunno, java just seems a lot less risky.

    Alright, so who told you that linux programers won't use java?

    YHBT, my friend!

    HAND

  9. GUI applications by DynamiteNeon · · Score: 4, Interesting

    Don't get me wrong, I happen to like both C# and Java, but if I have to create a gui app on windows for some reason, C# and .net wins hands down.

    Yes, I realize I could use SWT, but that's still not necessarily good enough. It surprises me that Swing still sucks so much after all this time. I would love to use one language exclusively if I could, but until I see some decent gui apps being built using Swing, it's hard for me to want to use Java unless I have backend services to create.

    Having said that, I would like to know if anyone can point me to gui applications that use swing and are actually good and fast. I'm curious if they exist at all.

  10. Re:let me get this straight ... by Rycross · · Score: 2, Interesting

    Performance and reliability? I assure you that C# has both. Got any links that indicate that C# is either slow or unreliable? And products being available in Java from vendors doesn't really mean much if you don't intend to use them in the first place, or they are trivial to interface with your code. As far as Java being the de-facto standard, while it is in higher use than C#, C# is being used by large businesses, and there is a large market for C# programmers.

  11. Easier Path to Linux? by tjasond · · Score: 2, Interesting

    I've been working with C# since .NET 1.0 Beta 1 and with Java since 1.2. When it first came on the scene, my initial reaction was very favorable to C#. Creating and consuming Web Services was incredibly easy (this was 2001, when SOAP had just arrived), and the builtin event/delegate model of .NET made event handling much more intuitive then Java.

    Then along came Eclipse, which breathed new life into the Java development experience. Nowadays, Eclipse has become an integral part of using Java; most folks I know don't think twice about the IDE they'd choose to develop Java in. The best part of all this is that Eclipse is cross platform as well, which allows me to switch operating systems without hesitation. This could definitely be considered a path to Linux (and in fact, it has been for me).

    In the same way, Visual Studio .NET enhances productivity in .NET programming, although it is far inferior to Eclipse by way of refactoring tools, incremental compile, and plugin support. Even so, any productivity benefits reaped from using Visual Studio cannot be experienced in Linux, because Microsoft will not port Visual Studio to it.

    The easier path to Linux doesn't come down to a language or its Virtual Machine. In the development world, it comes down to your development environment, which is at the core of what a developer does everyday.

  12. Re:let me get this straight ... by laffer1 · · Score: 3, Interesting

    .NET supports tons of languages, but mono does not! Remember everyone the goal of mono is not to be microsoft .net compliant. It is to be similar to .net but not support everything and add extensions of their own. They don't want you to run windows code on linux, they want you to run mono code on windows and linux with the MONO runtime. Its not portable in the sense that you can run ALL .net 1.0 from windows using microsoft's .net runtime on mono and vise versa. Java gives you portability, mono does not. Finally, java runs on non windows/linux/mac os x systems. I can run java on freebsd but i can not run mono (well it crashes with thread/garbage collection problems all the time).

    Java = portability; mono = novell's quality of software (bad)

    I've personally talked to a mono developer at my university. He works for novell on the project and they never intend to make mono compatible with .NET. He even said i was stupid for wanting it to be compatible. Mono should not be advertised as .NET for linux because its not. Its C# for linux but on a different runtime. VB.NET support is not complete in mono either.

  13. Re:let me get this straight ... by TummyX · · Score: 4, Interesting

    .NET makes it simple to interface with existing libraries written in C which, IMHO, makes it a more natural fit with Linux. C# applications can easily take advantage of existing libraries (GTK etc) whilst Java requires more effort (to force you to be "pure" and cross platform).

    Sometimes having ease and flexibility is more important than being cross platform.

    Besides, most libraries linux C# applications p/invoke are source-portable so the C# application itself will be cross platform as long as you have the platform specific binaries for the native libraries you pinvoked. The binaries you distribute won't necessarily be cross platform but for desktop applications, that's not really a big issue.

  14. Java Vs C# by Rac3r5 · · Score: 3, Interesting

    I've been programming since I was in Gr. 5. From all the languages I've ever programmed in(BASIC,dBase, Java, C/C++, C#, Assembler etc...), my favourite is Java and C#.

    What I like about Java is that it is a modern language that uses modern concepts, is very well documented and its vast lib support makes it very useful.

    C# also follows along the same lines of Java, making it quite similar except you have the option of getting out of the sandbox that Java uses. Some people need to get out of the sandbox for various purposes, and C# allows that, not Java.

    If I were to choose, I would choose C# 1'st for this very reason and then Java. Unfortunately, I'm a hardware programmer, so I am stuck using C :(

  15. Apples and Oranges by AtOMiCNebula · · Score: 3, Interesting

    Mono isn't produced by Microsoft, so it's unfair to compare Mono to Sun's JRE. Yes, Sun requires you to fetch the install file yourself (at least with Gentoo's Portage). But Mono is a GPL thing run by people not affiliated with Microsoft.

    You can't compare the two. Try comparing Mono and Blackdown instead.

    1. Re:Apples and Oranges by Ambassador+Kosh · · Score: 2, Interesting

      Reality does not have to be fair. It is easier to install mono then the sun jvm or any other jvm for that matter and so it will get used more and depended on more. It comes down to the path of least resistance and people will tend to use c,c++,perl,python,ruby as first choices, mono stuff as a second and java farther out mostly because of how easy it is to install that stuff and how standard it is.

      I know when writing python software when I need something outside the standard lib the first place I look is the debian package archives. If there is a package in the archive that can do what I need then it will get the first shot at me using it, if it works without problems I won't look further. The reason is simple I have a lot of work to get done and not enough time to do it all and if something works and was easier for me to get working then why look further especially if it got the job done?

      Java has that problem, it takes a lot more effort to use it then to use something else that will still get the job done.

      --
      Computer modeling for biotech drug manufacturing is HARD! :)
  16. Not for me by vandan · · Score: 2, Interesting
    If the goal is to make it easier for .NET developers to jump ship, then I suppose that sounds OK ... kinda. But it also makes it easier for Linux developers to write .NET stuff, and I don't feel so good about that.

    If people want an open-source, cross-platform environment, then there are plenty to go around. I use Gtk2-Perl, and I've written a number of Perl modules to assist database developers to connect their DB backend with their GUI. See http://entropy.homelinux.org/axis_not_evil

    Gtk2-Perl isn't the only option out there. For Gtk2 ( which runs on Linux, Windows, OS-X, and an impressive number of other platforms ), there are bindings for PHP, Python and Ruby. That covers what most people are recommending for RAD these days.

    Then there's QT. I haven't had much to do with it, but there are bindings for all the above languages and more.

    There's Java.

    I don't see the point in mimicking .NET, especially when Microsoft have such a war-chest of lawyers. Why not concentrate on our technology, and if people want to move to it on it's merits, they will. It's much more likely they'll see the merits if we present them with our technology, rather than an imitation of Microsoft's.

    And remember, as a wise man ( OK, it was Dubya, but anyway ) once said:

    We can outcompete with anybody
  17. Re:let me get this straight ... by Anonymous Coward · · Score: 1, Interesting

    Still I think C# event and delegates are a lot easier to program again than Java's listeners. The same can be said with C# properties, Java has never done anything to support properties, they only claim them by naming them getters and setters. Well if you aks me, I could do that in C++ too...

    I used JBuilder, and Eclipse to make gui's. Eclipse is really a catastroph, but still it isn't as easy as .NET or Delphi.

    And Even when you have a good GUI builder for Java, you still can't get around that it takes a lot of effort to make a swing-gui behave the same as a windows gui that the customers is asking for...

  18. Re:Here we go again by miguel · · Score: 4, Interesting

    There are a number of cross-platform commercial applications that run on Mono, for example:

    * Novell's own iFolder client and servers (same code base, modulo UI which is native on each of the three platforms: Linux/Gtk, Windows/Winforms, Cocoa/OSX).

    * (http:///www.medsphere.com) Medsphere's products (Mono/Gtk# based).

    * Otee's Unity game engine (http://www.otee.dk/index.html).

    You can look for the "Works with Mono" logo on open source .NET applications and various commercial applications.

    For a larger but still incomplete list, see:
    http://www.mono-project.com/Software

    As for your question about what will happen when C# 2.0 comes out, we have good news, we already have implemented it (we are missing two fairly minimal features though), for details you can see our web page on the subject:

    http://www.mono-project.com/CSharp_Compiler

    Generics, itereators, anonymous methods, nullable types, partial classes, per-accessor modifiers, static classes, fixed buffers and co/contra-variant delegates are all implemented and available today.

    And we can not wait to implement the new features in C# 3.0

    Miguel.

  19. apt-get install is overrated by turgid · · Score: 2, Interesting

    It's very easy to download the Sun JRE or JDK from Sun's website and to install it. Not much more effort that typing apt-get install.

    I've been using Debian, Fedora and CentOS recently after years of using Slackware and Solaris, and I can tell you that all the package managers have their advantages and disadvantages, but really, downloading and installing the Java distribution from Sun really isn't that difficult.

    Sun may have some strange attitudes towards the redistribution of Java, but from what I can gather this is due to stupidity and ignorance rather than malice. The wheels of beaurocracy turn very slowly in Sun.

    1. Re:apt-get install is overrated by Ace+Rimmer · · Score: 2, Interesting

      It is not that overrated. Imagine a system dependent on JRE for some or most applications. Now you would be forced to download a huge package from Internet to get it working. Of course then you would have to setup the classpaths, ***_HOMEs and such. And what if you needed JRE for an app to setup an Internet connection or to download what you need...

      On the other hand C/C++, shell, perl, python and all other apps run fine out of the box (and you don't even know what lang it was written in before you examine it in more detail). It is a serious stopper and it could be why mostly only enterprise level apps are written in java.

      --

      :wq

  20. Re:Why so many stories about mono? by Anonymous Coward · · Score: 1, Interesting

    You mention Ruby, Perl, PHP and Python as alternatives to Mono. Now, for one second, which of these alternatives do I choose for a project? In case I want to recycle most of my code in later projects (like every programmer builds up his own library of code over time), isn't the language choice also a one-way lockin to my future choice of language?

    With Mono and .NET, there is true language independence, and say, in one year or two there is a robust PHP implementation for .NET (there is already a first prototype port), Python (IronPython, and Boo are on a good way), and maybe Perl and Ruby some day, or a functional language (eg. Nemerle). Undoubtly the choice of robust language implementations for .NET will grow. Now, given that the code follows the CLS library specifications, I can derive, use, bind, call, etc. that code freely among the languages. The language barrier is non-existent anymore.

    This is the true freedom Mono gives to me, today. My language of choice is C#, but I don't know if it will always be. Java and .NET are here to stay for quite some time, but with Java, I choose both the language and the environment at the same time.

    Another poster mentioned projects such as JRuby, Jython, Groovy, etc., which are interesting. But Jython being around for oh so many years now, proving a stable and fast environment, has it really attracted many users from the Python community?

    Java definitely has its strength and is _the_ major player in both "extremes": the server side heavy data crunching business applications, and the embedded system portable world. But in my opinion, for the common desktop applications, it has failed. How many commonly used desktop applications using Java do you know? I am no Java geek, but the only one that is really usable that comes to my mind is Eclipse and Azureus, and even thats an application only for developers or P2P users, respectively.

    Please don't consider this a flamebait or something, I just express my feelings after developing two years on the Mono platform, which has saved me a large amount of time over my previous development environment (C, C++ on Linux).

  21. Re:let me get this straight ... by Decaff · · Score: 3, Interesting

    One thing I really miss with C++ and Java is properties. What's with a language that will put all the work into a ternary operator so they don't have to type if/then/else, but insists on mutators and accessors because properties are syntactic sugar?

    The reason for the ternary operator is simple - to allow C code to be easily ported.

    As for properties, this is a good point but in practice does not matter - all good Java IDEs have property management built in: The will allow the automated generation and management of get/set methods and the values they change. For example, on NetBeans you simply select the 'properties entry' for the class, and off you go..

  22. Why I worry about .NET by ghakko · · Score: 2, Interesting
    I'm a LAMP programmer, and I think it's a reasonably good platform for web applications. I'd like it to succeed because I really want free software, both as a movement and technical solution, to flourish.

    But I really worry that Microsoft has opened a large lead here with .NET, at least in the medium term. Most people have simply compared C# and the .NET framework classes against Java and base their assessment of .NET as a platform on that. But I think it misses the point somewhat.

    The Bourne shell is powerful because it allows entire programs--even ones not specifically designed to work together--to be connected together: the utility of the system as a whole increases dramatically because of this network effect. With .NET, it's the same, except with classes and objects across languages previously incommunicado.

    On Unix, every scripting language, by contrast, is pretty much an island by itself.

    If you need a binding for say, MySQL, you'd have to implement it for Python, Ruby, Perl, Tcl and whatnot. Although tools like SWIG try to automate this, in general, every new binding (N x M of them) is written from scratch. One might argue that doing it this way makes the binding conform best to the spirit of each scripting language, but in practice bindings for important libraries are often buggy and incomplete, perhaps because the cumulative effort is too great or too much language-specific expertise is needed. This is especially true for complex GUI toolkits like Gtk or Qt, which cause headaches with complicated data structures. .NET bindings, on the other hand, are only necessary if they're for unmanaged code; even then, they need only be written once.

    Re-using code from different scripting languages is very difficult. Suppose if, for example, a PHP programmer doing screen-scraping is fed up with the PHP/Curl bindings and wants to use Perl's excellent LWP::UserAgent module. Or, say, someone writing a Ruby shopping cart would like to borrow one of the payment library bindings in PHP? How is that possible? Wrapping the functionality into a stand-alone program (and hence using the shell and IPC as glue) is often so much of a hassle that people simply don't bother and end up re-implementing it from scratch. In .NET, this is almost trivial.

    Every scripting language has to implement its own interpreter/virtual machine/compiler. Making a thread-safe and efficient one is not easy; making a JIT fast enough to even come near the efficiency of native C/C++ involves a great deal of messy, architecture-specific work. The CLR, by contrast, is common to all .NET languages and any performance enhancement to it is inherited by all. It's well-tuned enough that, for example, PHP.NET actually runs faster than the native PHP interpreter, even with the Zend accellerator product.

    Packaging, deployment and building are different in each language. This can be a major problem when trying to glue scripts written in different languages together into the same project or getting the mess to install on the target system. Suppose it was an application which needs Perl 5.8 for one component, PHP 4.3.x (with mcrypt an GMP support enabled) for another and Python 2.3 (with PostgreSQL or MySQL bindings present) for others? How does one deploy this if the target system does not have one or more of these installed? Is there a simple way to put such an application in a test harness or even build it without resorting to a hodgepodge of install.py, MakeMaker and PHPAR? On the other hand, the only prerequisite for .NET applications need be the .NET runtime itself. Everything is compiled into the same common executable bytecode, so no additional interpreters are needed. Any assemblies the application depends on can be safely bundled with it even if the target system already has different versions of those assemblies installed.

    I believe, after putting seeing all of these advantages put together, that Miguel de Icaza was right and that we cannot afford to dismiss .NET as merely a Java work-alike.

  23. Re:let me get this straight ... by laffer1 · · Score: 2, Interesting

    Great. Someday when you achieve the goal, I can recommend Mono. In the mean time, software written for Microsoft .NET is not guaranteed to run on Mono. GTK# and Cocoa# are great ideas, and I'm not upset that you extended .NET, but I'd rather have you finish a compatible Microsoft .NET implementation first. Also, let your developers know its a goal of the project. I think there is some confusion.

  24. Re:let me get this straight ... by scorp1us · · Score: 2, Interesting

    I am sure this will be modded as flame or troll, but it is not.

    Miguel, I have watched for several years this Mono project. At first I thought it was a bad idea. Now I know it is a bad idea. I don't understand why you continue to fragment the community as the Mono project does. I remember the blurb about MS barring Mono from some conference recently. I don't know why you continue to add momenteum to a platform that you cannot control. That only benefits one person - the same one who controls the platform.

    In the mean time, I see businesses citing Mono if they decide to move to Linux. However my understanding is that if you attempt to run a MS .NET based GUI application on non-MS platforms the most likely result is a spectacular failure because MS still has lock on some critical classes.

    While I realize there is good ideas in .NET (CLI) and Mono, I don't see how this justfies the effort. Mono is adding support to .NET momentum, it is fragmenting the development efforts of the community. It is adding yet another language into the fray (C#).

    The good things are that it gives us a CLI, but we could already have done in the Java, Perl, Python, or Parrot VMs without strengthening MS.

    Now do note that my support would be different had MS released _all_ of .NET - so that the assumptions of business managers are indeed correct. What I am hoping for now is that you correct me and say that all .NET applications will run under Mono without modification and exactly as wthy do under .NET. If this is not the case, nor is it the [achievable] goal, then Mono should be disbanded. Refocus on Parrot or something.

    --
    Slashdot's rate-of-post filter: Preventing you from posting too many great ideas at once.