由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - structure in Java??
相关主题
迷惑了很久,java 和 c++ 到底谁快?java在美国到底怎样?
关于J2EE vs. .NET超级菜鸟问题:什末时候load class
[提问] The JVM could not be startedorg..eclipse.swt error
应该站哪条队:.NET 还是 Java/J2EE?swing 在 mac intel 下的bug怎么修正?
打算quit enterprise Java了帮我了解一下64bit JVM
Where I can find comparison of JVMs问一下swing的前途
新人请教java学习的问题Re: Question: Java Synchronization
what is your opinion in this case?basic java question
相关话题的讨论汇总
话题: java话题: c++话题: structure话题: class话题: type
进入Java版参与讨论
1 (共1页)
l********r
发帖数: 140
1
In C/C++, I like to use structure a lot to define my own (complex) data type.
However, in java, it seems the only way is to use class.
I hear class is quite slow if used as a basic complex data type (when we need
to "New" or use it a lot of times).
Any comments or ideas of this?
Thanks.
c**g
发帖数: 274
2
According to C++, structure is class, period.

【在 l********r 的大作中提到】
: In C/C++, I like to use structure a lot to define my own (complex) data type.
: However, in java, it seems the only way is to use class.
: I hear class is quite slow if used as a basic complex data type (when we need
: to "New" or use it a lot of times).
: Any comments or ideas of this?
: Thanks.

n*****k
发帖数: 123
3

The difference is not the class and struct, but the way how you can create the
data type.
Unlike C++, C#, java doesn't not support stack object, which means the only
way you can create an object is from the heap by using new operator, which is
kind of slow compared to stack memory. For example you can say
MyClass mc;
mc looks like a Stack object in C++, but if you try to use the method of mc
without initializing the mc properly, guess what, you will get a
java.lang.NullPointerException, Which m

【在 l********r 的大作中提到】
: In C/C++, I like to use structure a lot to define my own (complex) data type.
: However, in java, it seems the only way is to use class.
: I hear class is quite slow if used as a basic complex data type (when we need
: to "New" or use it a lot of times).
: Any comments or ideas of this?
: Thanks.

e***g
发帖数: 158
4
don't worry about speed. if you are concerned write a test allocating
and dereferencing objects see how fast it is.

【在 l********r 的大作中提到】
: In C/C++, I like to use structure a lot to define my own (complex) data type.
: However, in java, it seems the only way is to use class.
: I hear class is quite slow if used as a basic complex data type (when we need
: to "New" or use it a lot of times).
: Any comments or ideas of this?
: Thanks.

A**o
发帖数: 1550
5
既然用了Java,就不要担心这些问题。
自己写个程序,测试一下速度,如果接受不了就不要用Java。

type.
need

【在 l********r 的大作中提到】
: In C/C++, I like to use structure a lot to define my own (complex) data type.
: However, in java, it seems the only way is to use class.
: I hear class is quite slow if used as a basic complex data type (when we need
: to "New" or use it a lot of times).
: Any comments or ideas of this?
: Thanks.

m******t
发帖数: 2416
6

Sigh, that's the stuff that doesn't really make you
popular on a forum, my friend.
m******t
发帖数: 2416
7

If you really really (I mean *really* 8-) ) care about
performance, use a final class that has all members public.
It's as close as you can get to struct in Java.
The garbage collection in the latest JVM's has been mature
enough for us to ignore the memory-related overhead, especially
for those extra-short life objects.

【在 l********r 的大作中提到】
: In C/C++, I like to use structure a lot to define my own (complex) data type.
: However, in java, it seems the only way is to use class.
: I hear class is quite slow if used as a basic complex data type (when we need
: to "New" or use it a lot of times).
: Any comments or ideas of this?
: Thanks.

s******M
发帖数: 3435
8
just did a few simple performance test using j2sdk1.4.2_04 to compare with the
gcc compiler and MS compiler under linux and windowsXP respectively, and the
result showed the performance is almost idnetifcial. under linux compiled by
GCC, java even won by around 20%. the JVM is quite mature and efficient now. I
also like the performance of SWT under windows, quite comparable to native GUI
programs built using VC++. t

type.
need

【在 m******t 的大作中提到】
:
: If you really really (I mean *really* 8-) ) care about
: performance, use a final class that has all members public.
: It's as close as you can get to struct in Java.
: The garbage collection in the latest JVM's has been mature
: enough for us to ignore the memory-related overhead, especially
: for those extra-short life objects.

s******M
发帖数: 3435
9
slow? what kind of operations are you using? in C++, structure is class by
definition, with default visibility public.

type.
need

【在 l********r 的大作中提到】
: In C/C++, I like to use structure a lot to define my own (complex) data type.
: However, in java, it seems the only way is to use class.
: I hear class is quite slow if used as a basic complex data type (when we need
: to "New" or use it a lot of times).
: Any comments or ideas of this?
: Thanks.

c********e
发帖数: 383
10
mind of showing ur code here?
I am a C/C++ programmer and just started to get some more
sense about java...
really doubt about ur conclusion of speed.

【在 s******M 的大作中提到】
: just did a few simple performance test using j2sdk1.4.2_04 to compare with the
: gcc compiler and MS compiler under linux and windowsXP respectively, and the
: result showed the performance is almost idnetifcial. under linux compiled by
: GCC, java even won by around 20%. the JVM is quite mature and efficient now. I
: also like the performance of SWT under windows, quite comparable to native GUI
: programs built using VC++. t
:
: type.
: need

相关主题
Where I can find comparison of JVMsjava在美国到底怎样?
新人请教java学习的问题超级菜鸟问题:什末时候load class
what is your opinion in this case?org..eclipse.swt error
进入Java版参与讨论
r**a
发帖数: 630
11
its conclusion is obviously BS, hoho

【在 c********e 的大作中提到】
: mind of showing ur code here?
: I am a C/C++ programmer and just started to get some more
: sense about java...
: really doubt about ur conclusion of speed.

c********e
发帖数: 383
12
混混,你对MM要礼貌一点

【在 r**a 的大作中提到】
: its conclusion is obviously BS, hoho
r**a
发帖数: 630
13
i was just telling the truth, hehe, no intention of offense

【在 c********e 的大作中提到】
: 混混,你对MM要礼貌一点
r**a
发帖数: 630
14
对于各种语言在不同平台上的运行速度,前几个月有人贴过了
java几乎在所有测试参数上都比C++要慢,除了exception handling还是什么

【在 r**a 的大作中提到】
: i was just telling the truth, hehe, no intention of offense
e***g
发帖数: 158
15
who need it to be that fast.

【在 r**a 的大作中提到】
: 对于各种语言在不同平台上的运行速度,前几个月有人贴过了
: java几乎在所有测试参数上都比C++要慢,除了exception handling还是什么

st
发帖数: 1685
16
just want to stop the B.S. that java is not slower and can be even faster. :D
same for c#, it's just slower and it doesnot matter, just dont say it is not

【在 e***g 的大作中提到】
: who need it to be that fast.
e***g
发帖数: 158
17
I rechecked this thread, nobody claims that. however several people
seems to have extreme difficulty of understanding plain english
and keep distoring the subject as java vs C

【在 st 的大作中提到】
: just want to stop the B.S. that java is not slower and can be even faster. :D
: same for c#, it's just slower and it doesnot matter, just dont say it is not

c********e
发帖数: 383
18
including me .haha
but u have to admit it is kinda confusing.
were talking about the speed diff between c++ and java then someone
jumped out and give out some benchmark stats..

【在 e***g 的大作中提到】
: I rechecked this thread, nobody claims that. however several people
: seems to have extreme difficulty of understanding plain english
: and keep distoring the subject as java vs C

st
发帖数: 1685
19
summerMM used to claim that, said it used gcc and java vesion is faster
some time, blah blah... //sniff
"obvious thing can be wrong" is quite obvious to you, right?
wait, found it:
发信人: summerMM (艳阳天~~), 信区: Java
标 题: Re: structure in Java??
发信站: Unknown Space - 未名空间 (Wed May 5 09:19:10 2004) WWW-POST
just did a few simple performance test using j2sdk1.4.2_04 to compare with the
gcc compiler and MS compiler under linux and windowsXP respectively, and the
result showed the performance is almost

【在 e***g 的大作中提到】
: I rechecked this thread, nobody claims that. however several people
: seems to have extreme difficulty of understanding plain english
: and keep distoring the subject as java vs C

st
发帖数: 1685
20
another bgbj

【在 c********e 的大作中提到】
: including me .haha
: but u have to admit it is kinda confusing.
: were talking about the speed diff between c++ and java then someone
: jumped out and give out some benchmark stats..

1 (共1页)
进入Java版参与讨论
相关主题
basic java question打算quit enterprise Java了
Java EE vs. Core Java, 该选哪个呢?Where I can find comparison of JVMs
初学Java, FormLayout一问新人请教java学习的问题
面试的一些题目what is your opinion in this case?
迷惑了很久,java 和 c++ 到底谁快?java在美国到底怎样?
关于J2EE vs. .NET超级菜鸟问题:什末时候load class
[提问] The JVM could not be startedorg..eclipse.swt error
应该站哪条队:.NET 还是 Java/J2EE?swing 在 mac intel 下的bug怎么修正?
相关话题的讨论汇总
话题: java话题: c++话题: structure话题: class话题: type