Write in Java to work with .Net? - c#

I was wondering if anyone have experience writing codes in Java while compiling it into .Net assemblies? What are your thoughts? What library did you use to do so and what are the disadvantages of codes in Java to become .Net application?
I see there are a couple of libraries out there that help out with Java <-> .Net communication (eg. JNBridge http://www.jnbridge.com/, IKVM.NET http://www.ikvm.net/) .
Let me know if you have suggestions on how to go about doing this task, or may be a reason to why not bother doing it and better off starting out with .Net (C# may be)

I would suggest that you are almost certain to be better off starting with C#, unless you are doing a straight port and are ready to deal with lots of integration issues. C# is pretty similar to Java syntactically and conceptually, and the .NET tooling will work with it a lot better.

I wrote my own native JNI bridge from Java to .NET since we couldn't buy one off the shelf. It worked but it was extremely painful to get right. The path of least resistance with Java/.NET integration is to use a web-service (IMHO). This way you can do your Java things in Java and your .NET things on .NET.

Related

How to use the vst sdk on the .net framework

I like making music using mostly my computer and especially love using synthesisers. There is a wide range of synthesiser plugins available online which are quite awesome. I have downloaded the VST (Virtual Studio Technology) SDK which is the platform that most plugins I know of use.
I would like to know if you can use the SDK on the .Net framework to write plugins; the only documentation and tutorials I could find is for C++ and I'm not that trusted with C++. I could learn to use C++, I taught myself C# in a week, but to use an unknown language and to learn other new concepts don't seem like a good combination.
Could anyone just give me pointers in the right direction on how to get started and even if it is possible to program it using .Net?
Regards Charl
Many beginners find VST.NET the perfect choice to start off with. It comes with some samples and with VS2008/VS2010 project templates that yield working plugins. So its a great way to start.
VST.NET provides a framework that structures and groups the VST API into manageable pieces. Out of the box it provides support for common functionality such as plugin parameters and programs.
So drop by at the VST.NET codeplex site and we'll help you get started.
BTW: To my knowledge the noise project has been abandoned and although VST.NET might not appear to be very active, I still continue to react on the questions posted on its codeplex site.
I second obiwanjacobi's sentiment. VST.Net is about the only .Net VST bridge out there that I know of and the community is great. It's an excellent framework.
https://vstnet.codeplex.com/
As for the statement: "doubt .NET platform would be adequate concerning the raw performance that a VST plugin requires". This is entirely untrue. My tests have shown that on a decent computer, .Net can very easily handle basic synthesis without even raising the CPU level above a few percent. Of course, it's not going to match C++'s performance for very complex synthesis, but in cases like this, there's no reason why you can't fall back on C++ to do the more complex stuff. In fact that is where Vst.Net excels. It would allow you to build very complex synthesis as a VST, and then leverage that in .Net.
At the same time, I think you'd be hard pressed to say definitively that .Net couldn't do very complex synthesis as well. I haven't really tried, but there's no real obstacles when you pay attention to the performance of your code, which would go for any programming platform.
On top of all that, there is now .Net Native to add to the picture. .Net Native has the potential to be AS fast as C++.
I remember hearing of noisevst and VST.NET, two C# wrappers for the VST API but I don't know how stable they are. And I really doubt .NET platform would be adequate concerning the raw performance that a VST plugin requires.
So I would recommend learning a little bit of C++. Yes, C++ is so big and complex that nobody on earth knows every feature of it. But for plugin development purposes all you need to do is to implement a couple of methods. You can start from the provided samples in the VST API. Audio DSP code wouldn't look much different if you'd use C#, C++ or any other mainstream language anyway.
If you also want to implement a GUI for your plugin, that's where the things start getting hairy. VSTGUI is simple but lacks many features. I can recommend WDL's iPlug framework but that would require a little more than basic C++.

ArcGIS Development.Java vs .Net(C#)

I'm a computer scientist and i've been working with Java mostly to develop applications.
I just been hired in a company that makes projects with ArcGIS.
The company has hired na electrical engineer to develop the arcGIS projects.
This engineer used to customize ArcMap with VBA and lately extensions with .NET and C#.
I want to take a new path and start using the ArgGIS Engine with Java.
I want to know if this choice is right.Has any of you been developing with Engine-Java and how difficult is it(The use of JNI -for which i have little knoledge- is making it more difficult? ).
Also I have a little experience with .NET and c++ but not C#.I will have a big learning curve with this path?
Also which are the advantages and disadvantages and limitations of each method?
Hard question to answer.
The general opinion seems to be that C# is easy to learn if you know Java.
IMHO your biggest problem is going to be learning and manipulating the massive, convoluted ArcGIS object model. Choice of language is probably secondary.
My instinct is that C#/.Net is probably more popular for desktop programming with ArcGIS, so you'll get more community support with that. But I don't know. There's clearly a lot of folks using Java with ArcGIS - I suspect it's mostly server work, but I'm not sure. You might be able to figure out how popular ArcEngine with Java is by checking out the ESRI forum activity.
EDIT. You probably need to decide whether learning C# is going to be valuable in future to your employer (and your career), and balance that against some assessment of whether using Java with ArcGIS engine is unusual, and therefore more risky. Only you can answer the first question.
I absolutely in all respects suggest you stick with C#/.Net over Java. Last time i looked (take this with a grain of salt), the Java Library + COM inter-opt done with ArcGIS is pretty slow when working with certain elements (Arrays, oh god the arrays), also i am pretty sure Java will most likely be the next language to be put onto the cutting block in the near future(VB6 is now getting the axe). Also ESRI's java community is pretty tiny compared to their C#/.NET (however about 50 times bigger then their C++ :()
I would go for .NET and C#
If you know java and C++ than C# must be easy. You will just need to find your way through the .net framework that's all.
You will be safe with C# if you ever have to make some rich internet application in combination with arcgis and Silverlight (C#).

Effort estimation: using C / Win32 or learning C# / .NET

I intend to write a small application to scratch a personal itch and probably make the life of some colleagues easier. Here is what I have:
10+ years of experience in C
Plenty of experience in programming against the Win16/32 API in C from the Win3.1 to 2000 days.
C library written by myself already doing about 75% of what the application shall do.
What the application shall do:
open a binary, feed it into the mentioned library.
take the resulting text output and feed it into a new Excel Workbook.
apply some formating.
integrate nicely with the Windows environment (availability in "Open With...", remember some stuff using the registry etc.)
(maybe later) before giving the CSV data to Excel, parse it by looking up the meaning of some values in an XML file.
Except for the XML parsing part I have done all of that stuff before including COM / Office Automation in C/Win32. There is a lot of boilerplate code involved, but it is doable and the result will be a pretty small application without the need for an installer.
So why even think about C# / .Net?
no experience with parsing XML
the promise of less boilerplate code for the Windows and Excel stuff (yes, I have done C++ with OWL, MFC, ATL etc. but I am not going there anymore - not for free/fun)
Since I have also experience with C++, VB(not .Net) and a little Java / Objective-C I suppose learning C# will all be about the .Net libraries and not actually about the language.
My considerations so far:
Learning .NET might be fun and might result in less code / first steps in a more modern environment.
Sticking with what I know will lead to a predictable outcome in terms of effort and function (except for the optional XML stuff)
VB looked great at the beginning until the projects where about 80% done, then the pain started and the DLL coding in C. I am concerned history could repeat itself if I choose .Net.
My primary objective is the functionality. Effort is a concern. The XML parsing is optional.
Please advice.
Update: one thing I forgot to mention explicitly is that I am also worried about easy deployment of the tool to my co-workers. With Win32 I am pretty sure I can come up with an EXE file < 1Mb that can be easily emailed and does not require installation. With .Net not so much. Can I create the necessary MSI or whatever in Visual Studio Express (free) or do I need 3rd party tools?
as others have your question mostly covered, I'd just like to quickly comment on your considerations:
Learning .NET might be fun and might result in less code / first steps in a more modern environment.
Totally agreed. It is definitely fun and usually it does result in less code. The investment you make now will certainly benefit you in future projects. It is way faster to program in .Net than in C. Not only it is easier, but it is also safer. You are isolated from many programming errors common in C mostly related to memory mismanagement. You also get a very complete managed API to do stuff you would usually need to build your own framework.
Sticking with what I know will lead to a predictable outcome in terms of effort and function (except for the optional XML stuff)
Hence your indecision. :-)
VB looked great at the beginning until the projects where about 80% done, then the pain started and the DLL coding in C. I am concerned history could repeat itself if I choose .Net. My primary objective is the functionality. Effort is a concern. The XML parsing is optional.
.Net is an entirely different beast from VB. Most of the things you wouldn't be able to do in VB, or at least do them easily, are supported by .Net. For instance, Windows Services are a snap to build in .Net. Socket programming is also supported, but there are very few reasons to do it yourself, as you've got loads of communication APIs with .Net. You've got web-services, .Net Remoting, MSMQ management, and more recently WCF. Proper multithreading is supported by .Net, unlike the idiotic apartment model in VB. In case you really need to go low level, you can also actually use pointers in C#, inside of unsafe code blocks, even though I would never advise to do so.
If you really need to do things in C, then integrating is also relatively easy. You can create COM objects and use interop to work with them from .Net. You can also interact directly with plain ol' dlls using DllImport. Using www.pinvoke.net makes it easier.
When I developed in VB, sometimes I also had to go back to C++ to do stuff that I wasn't able of doing in VB. Since I began programming in .Net, the only extremely rare scenarios I would need to go back to C++ were when I needed to use legacy COM components that used types I was having a hard time to marshal via interop. I wouldn't worry about history repeating itself.
If you're using COM, you may be interested in using C# 4.0 instead of earlier versions - the downside being that it's only in beta. But basically it makes COM stuff somewhat less ugly for various reasons.
I'd expect there to be plenty of good C libraries for XML parsing by now. I would expect the main benefit to actually be the knowledge gained. I doubt that you'll actually produce the code faster for this project, but the next one may well be a lot quicker.
How much do you care about learning new stuff?
It sounds like an ideal project for learning C# & .NET.
You know most of what you need to do so you can use that to gain a base level of understanding of C# & .NET which you can then apply to the stuff you need to learn.
As Rune says though, a key driver could be the timescales. If this is something you need in a hurry then coding it in C & using win32 directly might be the answer.
Sorry I couldn't be more definite.
I think you should use C#. With your experience the learning curve won't be too steep. The code will ultimately be cleaner (and less of it) than you probably could with C/Win32.
There is probably going to be no problem using your existing C-library with the [DllImport] attribute.
It depends. :-) It depends on whether you want to do this quickly or if you want to learn something new. It depends on whether you will be the only maintainer of the code or if others will maintain it in the future. It depends on how complex your xml handling will be and on how complex the COM automation is.
You will probably get a working application quicker if you do it in C than in C#. Both since you have much of the stuff needed already in place and since you know C well.
But this project sounds like a good match for C# and .Net. .Net has great support for XML and COM interop is easy but clumsy in C# (much better in the next version!). So if you are interested in learning C# and .Net this would be a good project to do so.
I would definitely do this in .Net and probably C# (but I am biased). Using .Net would probably result in code that is easier to read and maintain and most probably easier to write. So if you are interested in learning C# I would suggest you go for it!
Edit:
You worry about the size of the executable if you write it in .Net. I doubt that will be a problem, for most if not all of the libraries you will use for a project like this will already be installed on your computer. 1 Mb is rather large for a .Net executable, event for a big project.
a short notice on the installation. .NET is as default xcopy-able so you wouldn't need an installer for the exe to be usable. Mail it around (or with the next release of the .NET framework optionaly leave it on a network share)
You could look at building a hybrid system that uses C++/CLI and C#. C++/CLI provides a nice bridge between the two and lets you easily split different parts of the system between the managed and unmanaged worlds.
Not sure if the setup projects are included in the free versions of visual studio. But you could use clickonce (included with the framework) or WIX (open source XML based msi creation tool).
learning C# will all be about the .Net libraries and not actually about the language
No there are many things you need to learn about the language (delegates , events , generics ...) and also it is object oriented and it manages the memory by itself and yes no pointers :)
anyway C# and .NET are great all you need is some effort to get up to speed

RoR on GAE?

Since Google App Engine will soon full support Java:
Would it be possible to run Ruby on Rails on Google App Engine? Or the limitations imposed by the AppEngine runtime will affect the JRuby implementation?
What about other languages such as Groovy, Clojure, Scheme?
Are there any effort to support .net and C# in JVM?? I think this would create a NEXT level on webdevelopment.
This is already possible. Its not perfect, but I would expect rapid improvement.
More information:
Official Working Library List
Unofficial Working Library List
It looks like the plan is to support those technologies eventually.
http://googleappengine.blogspot.com/2009/04/seriously-this-time-new-language-on-app.html
If you can use the new technologies with GAE to accomplish what you want to, I think it would be in your favor to do that.
GAE has plans to support JRuby on Rails, AFAIK.
.NET and C# already have their own VM, and can run under Linux via Mono... if you're reaching the point where you want a low-level language on the JVM (C#), just use Java, and if you want to use .NET, you're better off staying in the Microsoft world.
JRuby is already supported, insofar as GAE/Java supports any JRE language. The main difficulty - something that can be overcome by users, rather than requiring Google support - is making ActiveRecord work with the Google datastore APIs.
Unfortunately, I'm not familiar with Ruby, so I can't speak as to how difficult this is. I'm sure there are people already working on it.

C# on Linux - Anyone got an opinion based on experience using mono?

Is it worthwhile learning C# if you are a Linux user? There is Mono but it seems destined to always be behind the curve with the constant threat of MS action if they start to lose money.
Currently I am leaning more towards Java as its is fully GPLed and there are no major threats of software patents. It already has a big oss community behind it and has a solid reputation on the server whereas C# still needs to prove itself there.
The big advantage for C# programmers is that they are cheaper than Java developers. I also wonder exactly how portable C# code is though. Can one simply take a C# app written to target Mono and run it on windows?
I've written a number of C# command-line programs, specifically to run as distributed simulation engines, that were targeted for Ubuntu. They work perfectly there or on Windows.
It's hard to say what the future holds, but C# is a powerful language and I think it's worth learning even just for our personal growth. I despise Windows myself but have been writing C# for a while (for Windows mostly) since it pays the bills.
Novell uses Mono extensively for their Linux applications and I think that their relationship with Microsoft adds some weight to the idea that .NET for Linux will stick around.
Here's a list of some of the companies using Mono.
"on the server whereas C# still needs
to proof itself there"
You do know MySpace is built ontop of ASP.NET, right? Millions of hits a day running off a C# backend.
Sorry for the flame-bait, but I've personally had more portability success with mono, than java. Not a blanket statement, just my experience.
This question has already been asked and answered many times on SO.
Is Mono ready for prime time?
Why Use Mono?
Given your scenario, me personally I would learn Java, as you will find the transition into C# further down the line, quite smooth. Also having Java under your belt is a very good thing. I would say Java is much more portable than C# although you have the option of using the Compact Framework, which will be quicker to bootstrap with your program.
I work for a company that uses both Java and C#. I prefer C# because I think Visual Studio blows away Eclipse, and I just like the language better. However, I think you might do better learning Java in your case. You have more flexibility both for your project and career-wise. You can learn C# anytime.
C# is a nice language, and I find it much easier to work with than C/C++, especially for GTK applications.
I also think that learning C# would be a much better investment than learning Java. I'm saying this for no other reason than my personal taste, but I also honestly and objectively believe that C# will have a better future than Java.
As for running Mono apps on Windows, you can usually do this without a hassle, but if it's a GUI application, you will either have to create a Windows version that uses Winforms, or your users will have to install GTK for Windows. Either way, your applications will have a much better look and feel than Java applications on both platforms.
Finally, I don't think M$ will take legal action against Mono anytime soon.
It works very nice. IMHO you should use Mono from the development site (www.go-mono.com) rather than version provided with your distribution.
Also you could try dry-running it with VMWare machine that is also avaliable on the official site.

Categories