VS.NET against JAVA

G

Gabriele

I'm studying differences between those two architecture in order to
choose a setup to develop a completely new application. I'm a
programmer with some experience on C++ and PHP and i have basic
academic knowledge of VS.NET and Java and a few other. My application
is a data driven business application heavily based on GUI and will be
deployed mainly on Windows systems, but i eventually may like the
possibility to deploy it on Mac (most probably) and or Linux (least
probably).

Exclude AWT libraries, because their limited choice and heavyweight,
choose a Java IDE as you like (i.e. Eclipse, JDeveloper,
NetBeans....), include Swing and eventually some other Swing based
libraries.

Questions:

VS.NET (C#) against VS.NET (VB.NET) about easy of development of GUI
and Data access

VS.NET (C#) against JAVA about easy of development of GUI and Data
access

VS.NET (C#) against JAVA about speed of execution of the application
on Windows

VS.NET (C#) against JAVA about availability and compatibility on Mac
(or eventually Linux)

In this specific case, this last question is the least important, but
i would like to know if Mono is going somewhere and is somewhere near
to be functional.
On question 2 and 3 i would prefere to only hear opinion of those of
you who actually know and use or used Java Swing.

Thank you.
 
S

Scott M.

Questions:
VS.NET (C#) against VS.NET (VB.NET) about easy of development of GUI
and Data access

No diffierence. No .NET language is really any better/worse than the other.
It's a matter of preference.
VS.NET (C#) against JAVA about easy of development of GUI and Data
access

My opinion is that VS .NET will provide an easier development path in terms
of GUI and RAD.
VS.NET (C#) against JAVA about speed of execution of the application
on Windows

Just a side note here: All .NET langauages compile to a single Intermediate
Lanaguage (IL), so you don't have to specify C# when you talk about .NET
development when asking gereal questions. In other words, it doesn't matter
what .NET language you use, they will all perform more or less equally when
given the same task to do and written with the same logic.

Having said that, there are numerous benchmark tests that have been done to
compare the performance of applications written in Java vs. .NET
(http://www.google.com/search?q=perf...d=ie7&rls=com.microsoft:en-US&ie=utf8&oe=utf8)
VS.NET (C#) against JAVA about availability and compatibility on Mac
(or eventually Linux)

You didn't mention if this was going to be a client app or a web app. If
it's a web app, the question is irrelevant. Yes there are projects to port
..NET to other platforms (Mono), but it's anyone's guess as to where that
will be in the future as new versions of the Framework appear.
 
G

Gabriele

VS.NET (C#) against JAVA about availability and compatibility on Mac
You didn't mention if this was going to be a client app or a web app. If
it's a web app, the question is irrelevant. Yes there are projects to port
.NET to other platforms (Mono), but it's anyone's guess as to where that
will be in the future as new versions of the Framework appear.

There are parts of the system developed with a web architecture
(mainly the website data aggregator to the benefit of general public
and a subset of the basic functionalities to provide some mobility)
and with this regard i'm also considering about using PHP instead of
ASP.NET and i will probably post another message on this topic later.

Most functionalities of the system, anyway, are inside a desktop
client/server application (to allow a better management of the
interfaces) where the server part is mostly a data server.
 
A

Alun Harford

Gabriele said:
VS.NET (C#) against VS.NET (VB.NET) about easy of development of GUI

Development of GUI in VS/C# is trivial, whereas in Java it's very
painful. Personally I found my GUI development to take 1/10th of the
time when I switched from Java to C#.
and Data access

I prefer JDBC (Java) to ADO.NET (C#), by a long way. But neither is
particularly painful.
VS.NET (C#) against JAVA about speed of execution of the application
on Windows

Java and C# both execute pretty quickly - they're both JIT compiled
languages...
Which is faster depends on what you're doing.

For raw processing power, Java is superior (the C# compiler needs
serious work on optimization).
*However*, AWT/Swing are *much* slower than windows forms, by several
orders of magnitude.
VS.NET (C#) against JAVA about availability and compatibility on Mac
(or eventually Linux)

Mono basically isn't a serious option yet. One of the reasons why C# is
much easier to develop in is that if the framework doesn't contain a
required feature, you can just P/Invoke and send windows messages.
Unfortuately, until Mono merges with Wine, this is unlikely to ever be
supported :-(

Alun Harford
 
J

Jon Skeet [C# MVP]

Development of GUI in VS/C# is trivial, whereas in Java it's very
painful. Personally I found my GUI development to take 1/10th of the
time when I switched from Java to C#.

But do all your forms resize nicely? I've found that (prior to WPF)
it's very easy to create a *bad* UI in .NET, but hard to create a
*good* one. Java's layout managers take a while to get used to, but end
up creating a better app.

Oh, and I believe the Java GUI designers have come on a lot in the last
year or so. I haven't used them myself.

Having done a little bit of WPF now, it looks like that will be a
*much* better way of doing UI in my view - especially as it means I can
avoid the designer and still be nice and quick :)
Java and C# both execute pretty quickly - they're both JIT compiled
languages...
Which is faster depends on what you're doing.

For raw processing power, Java is superior (the C# compiler needs
serious work on optimization).

Most optimisation isn't done by either the C# or Java compilers. It's
done by the JITs. I preferred the earlier sentence: it really *does*
depend on what you're doing. If you're using virtual methods which have
never been overridden and can be inlined, Java will be a lot better. In
other cases, C# will be faster. That goes to raw execution as well as
graphic libraries.
 
A

Alun Harford

Jon said:
But do all your forms resize nicely? I've found that (prior to WPF)
it's very easy to create a *bad* UI in .NET, but hard to create a
*good* one. Java's layout managers take a while to get used to, but end
up creating a better app.

While it's true that you can use the VS "designer" to produce some
really bad code, I'd say that's true of any programming tool.
(All my forms resize nicely - well at least all the ones that I allow to
be resized resize nicely)
Oh, and I believe the Java GUI designers have come on a lot in the last
year or so. I haven't used them myself.

The problem isn't the design tool. I think the .NET framework is
superior to AWT/Swing.
(That said, I've not done UI stuff in Java for about 18 months - because
I prefer C# :) )
Most optimisation isn't done by either the C# or Java compilers. It's
done by the JITs.

The JIT compiler is a compiler :). And ideally it should be able to do
basic optimization.
I preferred the earlier sentence: it really *does*
depend on what you're doing. If you're using virtual methods which have
never been overridden and can be inlined, Java will be a lot better. In
other cases, C# will be faster. That goes to raw execution as well as
graphic libraries.

Swing/AWT is much slower than .NET/Windows forms because it does much
more work... if you were to have 'identical' programs as Java bytecode
and MSIL, I'd be impressed if a program can be constructed to make the
MSIL one go faster.

As an example, I recently found that a particular method I'd written was
running slowly, and had to modify it (I'd rather not have to do the
optimizing compiler's job, particularly in simple cases).
It was a more complex than this, but not much:

//input is a 256x256 bitmap
public Bitmap CopyBitmap(Bitmap input)
{
Bitmap output = new Bitmap(256,256);
BitmapData inputData= input.LockBits(new Rectangle(0, 0, input.Width,
input.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
BitmapData outputData = output.LockBits(new Rectangle(0, 0,
output.Width, output.Height), ImageLockMode.WriteOnly,
PixelFormat.Format32bppArgb);
unsafe
{
byte* inputPtr = inputData.Scan0;
byte* outputPtr = inputData.Scan0;
for(int i=0;i<256*256;i++)
{
for(int j=0;j<4;j++)
{
*outputPtr = *inputPtr;
}
}
}
input.UnlockBits(inputData);
ouput.UnlockBits(outputData);
return output;
}

Any decent optimizing compiler will take that code and copy the data
words at a time instead of bytes at a time. Even the silly little
compilers I wrote as an undergrad could cope with that task!
But not the .NET CLR :-(

Still, I love it really. I just wish somebody at Microsoft would give it
the care and attention (and expert in optimizing compilers) that it needs.

Alun Harford
 
J

Jon Skeet [C# MVP]

Alun Harford said:
While it's true that you can use the VS "designer" to produce some
really bad code, I'd say that's true of any programming tool.
(All my forms resize nicely - well at least all the ones that I allow to
be resized resize nicely)

With the extra space being taken up by the correct components and not
others? How about all the labels etc resizing automatically for
different languages etc? Doing all this stuff properly for non-trivial
apps is relatively tricky in WinForms due to the lack of layout
managers.

It's far from a coincidence that WPF's layout is done in a way which is
*very* similar to Java's.
The problem isn't the design tool. I think the .NET framework is
superior to AWT/Swing.
(That said, I've not done UI stuff in Java for about 18 months - because
I prefer C# :) )

IMO the problem is both the designer *and* WinForms, both of which
encourage absolute positioning instead of a "lay yourselves out in this
way".

Swing and AWT are a pain in different ways, but for layout capabilities
Java wins hands down IMO.
The JIT compiler is a compiler :)

True - but it's not a C# compiler.
And ideally it should be able to do basic optimization.

And indeed it does. With .NET there's only one pass of JIT compilation,
as opposed to HotSpot which is able to
Swing/AWT is much slower than .NET/Windows forms because it does much
more work... if you were to have 'identical' programs as Java bytecode
and MSIL, I'd be impressed if a program can be constructed to make the
MSIL one go faster.

I'll have a go some time - I'm absolutely sure it's possible, as I've
seen plenty of "raw" code which works faster in C# than Java, and vice
versa.
As an example, I recently found that a particular method I'd written was
running slowly, and had to modify it (I'd rather not have to do the
optimizing compiler's job, particularly in simple cases).
It was a more complex than this, but not much:

<snip>

Yes, there are certainly things it could do better. The same is no
doubt true for the Java JIT though.
for(int j=0;j<4;j++)
{
*outputPtr = *inputPtr;
}

Is there meant to be some use of j within that loop? ;)
Still, I love it really. I just wish somebody at Microsoft would give it
the care and attention (and expert in optimizing compilers) that it needs.

Well, I think it already does a fair amount of optimisation, but I'm
sure it'll improve over time.
 
A

Alun Harford

Jon said:
With the extra space being taken up by the correct components and not
others? How about all the labels etc resizing automatically for
different languages etc? Doing all this stuff properly for non-trivial
apps is relatively tricky in WinForms due to the lack of layout
managers.

For simple forms that cannot be resized, I don't want a layout manager -
no need.
For more complex forms, I can use Anchor and Dock to get the right effect.
For even more complex forms, there is nothing to stop you from using a
layout manager.
Is there meant to be some use of j within that loop? ;)

Oops! :)
You probably guessed that it should read:

*(outputPtr++) = *(inputPtr++);

Alun Harford
 
J

Jon Skeet [C# MVP]

Alun Harford said:
For simple forms that cannot be resized, I don't want a layout manager -
no need.

Well, you can use a pretty simple or effectively null layout manager.
However, I'd argue that even for simple forms layout managers are
beneficial - that way you can change things like the contents of labels
without needing to laboriously lay out everything in pixel perfect
fashion.
For more complex forms, I can use Anchor and Dock to get the right effect.

That's really painful compared with using layout managers, in my
experience.
For even more complex forms, there is nothing to stop you from using a
layout manager.

But there's very little support provided in the framework for WinForms.
Fortunately WPF has layout managers as a core part of its design,
making life a lot more straightforward.

(As a case in point, I recently started writing an app in both WPF and
WinForms. I haven't yet finished the WinForms version, because just
trying to get all the resizing right took longer in the WinForms
version than the whole app in WPF.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top