 |
 |
Index ‹ java-programmer
|
- Previous
- 4
- How to convert Java class to exe files for performance?I have developped a java application (no awt involved) for my school research.
It's basically a scientific calculation program, which has huge loops.
Now it's very slow to run it in java/JIT.
I'd like to know if there are some existing free program to translate java
code(or class) to C code(or exe) since rewrite my code in C will take too long.
Has anyone used samilar converter before? Any suggestion is appreciated.
Thanks,
Wei
- 8
- A basic tomcat questionHi gang, Tomcat's not my area of expertise but I have to get some simple
things set up -- nothing fancy.
I'm having trouble getting classes & packages to work. The setup is Tomcat
5.5.4 & JDK1.5. I can get basic servlets and JSPs to work, but I'm having
trouble with user classes and packages. Here's an example:
tomcat\webapps\ROOT\Test\TestMovie.jsp
----------------------------------------
<#@ page import="testpackage" @>
<html>
<body>
<% Movie m = new Movie("Gone With the Wind", 1936, 19.95); %>
<%= m.title %>
</body>
</html>
tomcat\webapps\ROOT\Test\WEB-INF\classes\testpackage\Movie.java
-------------------------------------------------------------------------
package testpackage;
public class Movie
{
public String title;
public int year;
public double price;
public Movie(String title, int year, double price)
{
this.title = title;
this.year = year;
this.price = price;
}
}
I've googled this & read the documentation, everything seems to say put all
the classes in packages, create a folder for the package under
WEB-INF\classes, and put the class files in the package folder, and that
should do the trick. But I must have something else missing. Any ideas?
Also, I don't know if this is related, but is there a trick to using new
featured of Java 1.5 in a JSP? I can't get the following JSP to compile:
<%@ page import="java.util.*" %>
<html>
<head>
<title>You're breaking my concentration.</title>
</head>
<body>
<% ArrayList<String> s = new ArrayList<String>();
%>
</body>
</html>
It complains about the first < in the scriptlet. Does that have to be
escaped somehow?
TIA,
--D
- 8
- 11
- [POLL] Dropping support for old SpiderMonkeysHi,
as JavaScript.pm development is moving again I'm considering dropping
support for older SpideyMonkey and focusing on 1.7 and later (the one
used in FF 2.0).
Instead on having to download and install SM manually I was planning
on putting up a source release of the SM 1.7 engine on my server and
add the possibility for Makefile.PL to download and install it.
Alternatively I can bundle the source with JavaScript.pm. You will
still however have the possibility to build against your own SM src.
This way we can better control availability of utf8, threading and
e4x (and future stuff too).
Does this sound like a good idea?
Thanks
/Claes
- 11
- Java Native Interface - passing parameter array of different datatypesGreets!
Yesterday I googled for hours to find a tutorial how to call Java
methods from C++ native code. Unfortunately I didn't find anything
useful, the Java JNI documentation doesn't capture the functionality
of the JNI very well.
I want to do the following: I want to call a Java method from C++
code. The Java method has some parameters of different datatypes, like
public static boolean dosomething(int x, long y, String z)
for example. Is there any way to do this? The Call...Methods() take
the method ID and an array of parameters to pass to the function, but:
HOW TO CREATE AN ARRAY OF DIFFERENT DATATYPES???
It's only possible to create a new array calling something like
NewObjectArray() when passing a datatype given.... I think, the only
way to pass parameters of different datatypes from C++ to Java methods
is to create a new class containing all parameters necessary and to
pass the class as the one and only argument.
Any ideas?
Best Regards
Clemens
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
- 11
- Forcing swing gui to be drawnHey, right now I have a program that analyzes an EKG when a button is
clicked. I want to pop up a progress bar in a new frame to show how far
it is, but I'm having problems. I can create the frame, and it will
appear, but it won't draw the progress bar until it is done executing
all of the other commands.
I ahve tried opening the frame with a separate thread, but it resulted
in the same problem. I guess there must be some draw queue that is on a
low priority, but I really have no idea why it isn't working.
Any help would be great... I show this at a science fair in 2 days.
Thanks!
-Thomas
- 11
- URL in IFRAMELet's say I have a struts action at http://xyz.com/someAction.do and this
URL is referred from one IFRAME via "src" attribute of IFRAME. Is it
possible for me to detect inside someAction.do which page is embedding it in
an IFRAME? How can I do this?
et me put question in a different way, if I refer to Google API with this -
code:
------------------------------------------------------------------------------
<script
src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAHuQre3TX-ZKoHs97iqelnBQn09xNixTqt4LnUZ12n-xJURxIHRRdLvNa4xtUwCJO0gkyTjCSRjfctQ"
type="text/javascript">
------------------------------------------------------------------------------
How does it know that the request is coming from domain xyz.com? It is not
purely based on the key - if I send same key from another domain, it doesn't
work! So how can I do that? Which header do I use? The referer header is
returned as null!
- manish
- 11
- encrypted source file support in jdk?Hi
I an wondering if anybody knows if its possible to extend the
functionality of the sun java compiler/vm in jdk6, with for example
plugins or similar? or if the jdk supports something similar already?
What I am looking for is to set up a jdk environment where the source
code is ecrypted at the file level. This requires javac to be able to
en-/decrypt the source files. For further protection, the jvm would need
such support as well.
some details:
To answer the typical question first. For this scenario I am not
interrested in encrytpted filesystems, because it still leaves the
files vulnerable as long as the filesystem is mounted. The secrecy of
the files can still be compromised from hacking, virus, trojans, skype,
xss and all other sorts of system hacking. With encrypted files the
information in the files are still protected, even in the case a trojan
sends a file by email to somebody on the internet. Enctrypted
filesystems only help protect the integrity of the local system and the
disk while the system/disk is not running. Encrypted files help protect
the information during use as well.
I know there are many other issues as well, I'll be working throuhg it.
here is the list of the issues of most importance:
- en-/decryption support in
- ide / editor
- compiler
- code searching tools
- disassembler/debugger
- remove excess information from class files
- how to handle static content files
- html, css, jsp, configuration files for libraries and frameworks etc
- if class files are also encrypted
- en-/decryption support in the jvm runtime, covers tomcat, jboss etc.
- possible encrypted jar/war/ear files etc
- debugger
- information about classes must also be protected from prying
eyes who have obtained the class files and using the debugger to get
information.
- 11
- Error passing Element to web serviceI'm upgrading from WebLogic 6.1 to WebLogic 8.1 SP 4.
We used to specify weblogic.soap.http.SoapInitialContextFactory and
weblogic.soap.encoding.factory to lookup the web service in the client.
Well, the SoapInitialContextFactory and CodecFactory classes are no
longer around. So now I've used clientgen to generate the stubs and
here is my client code:
MyWebService service = new MyWebService_Impl(wsdlurl);
MyWebServicePort port = service.getMyWebServicePort();
Element result = port.processIt(theElement);
However, I get the following error calling processIt:
java.rmi.RemoteException: web service invoke failed:
javax.xml.soap.SOAPException: failed to serialize interface
org.w3c.dom.Element weblogic.xml.schema.binding.SerializationException:
Failed to serialize Document due to the following error
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
...
Caused by: weblogic.xml.schema.binding.SerializationException: Failed
to serialize Document due to the following error
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
at
weblogic.xml.schema.binding.internal.builtin.DocumentCodec.serialize(DocumentCodec.java:76)
...
Here's the schema and xml file:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://myproject.org/myproject_test.xsd"
xmlns:myproject_test="http://myproject.org/myproject_test.xsd"
elementFormDefault="qualified">
<element name="TEST">
<complexType>
<sequence>
<element ref="TEST_ID"/>
</sequence>
</complexType>
</element>
</complexType>
<element name="TEST_ID" type="string"/>
</schema>
<?xml version="1.0" encoding="UTF-8"?>
<TEST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://myproject_test.xsd"
xsi:schemaLocation="http://myproject.org/myproject_test.xsd"
file:///N:/myproject/metadata/myproject_test.xsd">
<TEST_ID>ABCD1234</TEST_ID>
</TEST>
I've been testing with this bare minimum schema so that I can change
the namespaces and other things easily. The one and only thing that's
made a difference is when I take out the namespace stuff from the xml
file, it does get sent to the server. I.E.:
<?xml version="1.0" encoding="UTF-8"?>
<TEST>
<TEST_ID>ABCD1234</TEST_ID>
</TEST>
However, I can't leave it like that because the server doesn't know
what to do with it. Also, when the server tries to send the response,
it gets the same error as above.
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
at
weblogic.xml.babel.adapters.DOMAdapter.adaptAttribute(DOMAdapter.java:113)
at
weblogic.xml.babel.adapters.DOMAdapter.adaptElement(DOMAdapter.java:147)
...
javax.xml.soap.SOAPException: failed to serialize interface
org.w3c.dom.Element weblogic.xml.schema.binding.SerializationException:
Failed to serialize Document due to the following error
weblogic.xml.stream.XMLStreamException: The local name of an attribute
cannot be null
The web service also returns an Element, but it's a different type from
a different schema, which I haven't touched. So the server is having
the same problem as the client.
If I change the web service to receive and return only strings, it
works fine. But I haven't been able to figure out why it won't work
for the Element. Does this sound like a problem with my WebLogic
configuration, the schemas/xml files, the web service, the client? Is
there a way to tell what attribute it is complaining about?
Thanks,
Christy
- 13
- US-CA: Senior Software Engineers (Java) wanted Immediately!Cataphora is an award winning software company providing technology and
services for high end litigations and investigations. Its customers
include Fortune 500 companies, governmental agencies, and top American
law firms. We pride ourselves on having been funded from the start
entirely by revenues, with no venture capital investment. At Cataphora,
your creativity and versatility will be focused on a wide variety of
software development challenges and developing cutting-edge algorithms
for analyzing very large datasets. We are more than 80 people strong,
and continue to grow our employee-owned San Francisco Bay area company
by providing superior technology to meet the needs of our customers.
This is an excellent growth opportunity for the right candidate in a
rapidly growing, self-funded pre-IPO start-up.
Required Skills
- At least 4 years experience dealing with middleware or enterprise
software applications
- 3 years of Java experience
- Strong analytical and problem solving skills
Desired Skills
- Strong database experience
- Demonstrated ability to develop algorithms for solving complex
problems
- Development experience with a web-based application using J2EE
technologies
To apply, please send your resume (inline preferred; RTF, Word Doc or
PDF otherwise) to: email***@***.com - subject: "EU-DE-M09".
If you have any questions, feel free to contact me:
email***@***.com
Regards,
Markus Morgenroth
- 15
- 16
- Bound Threads (Re: Process vs Thread: what are the consequences?)On Tue, 13 Nov 2007 16:04:12 +0000, Kenneth P. Turvey wrote:
> Just based on some experimentation I was doing, this doesn't seem to be
> true. I'm running Linux with the Sun JVM, and it didn't map each Java
> thread to a native thread until the Java thread was spending enough time
> executing. I was actually trying to get this mapping (1 to 1) and found
> it impossible to guarantee under Linux with the Sun JVM.
>
> Under Solaris there is the -XX:UseBoundThreads (or something similar) to
> get that behavior, but under Linux no such option exists.
>
> I will freely admit that my experiment could have been flawed, but it
> wasn't behaving as if it was using more than a single native thread. I
> suspect that the article above is out of date.
I hate to followup my own post, but I've been looking at this problem
again and I'm really just unhappy with how it works. Since this can so
easily be solved under Solaris, and Lew (I think?) mentioned that this is
all JVM dependent. I was hoping somebody could point me to a JVM that
runs under Linux that supports the -XX:UseBoundThreads option or something
similar. I want a 1:1 mapping between native threads and Java threads and
I just can't seem to get it.
Does anyone have any idea? (BTW, I checked IBM's JVM).
--
Kenneth P. Turvey <email***@***.com>
- 16
- Java Chat Recording.Hi,
A website I use has a chat room and it's chatter-side interface is a Java
application. The comments chatters post come thick and fast and, although
there is a scoll bar, it's no good scrolling down to see comments missed,
as, as soon as a new comment is posted, all the comments scroll up to it.
There is no cut-and-paste/recording facility. As it's possible to scroll
up and down the comments, there must be somewhere where the comments are
held. Would this be just in some sort of video buffer, a
constantly-appended file on my PC's disk drive or just in memory? Is there
any way to record the conversations? Have the output from the Java
application redirected to a file, etc?
Thanks in advance.
Yours,
Gary Hayward.
- 16
- JMF video frame sizeI need to know dimension of the media file played by
javax.media.bean.playerbean.MediaPlayer
I use the code you can see below:
FormatControl formatControl = (FormatControl)
this.mediaPlayer.getControl ("javax.media.control.FormatControl");
VideoFormat videoFormat = (VideoFormat) formatControl.getFormat();
return videoFormat.getSize();
mediaPlayer is known object from another class.
But I get formatControl == null.
It's very very strange, but just one time this code did work.
So I have no idea ... Someone else?
- 16
- Response cache on the application serverIs it a good thing to cache the search result?
The metadata for our system can be as much as 100,000
I am trying to enable the response cache on the web server.
However, I am thinking about the problem i might meet.
When you cache the search result, is it possible the other
person throw the same condiiton and see the same result?
With our system there some security set for each row, so
if this happens there is a security leak.
MD
|
| Author |
Message |
Chris Smith

|
Posted: 2006-7-13 11:15:00 |
Top |
java-programmer, What is a type error?
Marshall <email***@***.com> wrote:
> David Hopwood wrote:
> > Marshall wrote:
> > > Mightn't it also be possible to
> > > leave it up to the programmer whether a given contract
> > > was compile-time or runtime?
> >
> > That would be possible, but IMHO a better option would be for an IDE to give
> > an indication (by highlighting, for example), which contracts are dynamically
> > checked and which are static.
> >
> > This property is, after all, not something that the program should depend on.
> > It is determined by how good the static checker currently is, and we want to be
> > able to improve checkers (and perhaps even allow them to regress slightly in
> > order to simplify them) without changing programs.
>
> Hmmm. I have heard that argument before and I'm conflicted.
>
> I can think of more reasons than just runtime safety for which I'd
> want proofs. Termination for example, in highly critical code;
> not something for which a runtime check will suffice. On the
> other hand the points you raise are good ones, and affect
> the usability of the language.
There doesn't seem to be a point of disagreement here. Programmers
often need to require certain properties to be checked at compile-time.
Others could go either way. There is no property that a program would
rationally desire to *require* be checked at runtime; that would only
occur because the compiler doesn't know how to check it at compile time.
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-7-13 11:15:00 |
Top |
java-programmer >> What is a type error?
Marshall <email***@***.com> wrote:
> David Hopwood wrote:
> > Marshall wrote:
> > > Mightn't it also be possible to
> > > leave it up to the programmer whether a given contract
> > > was compile-time or runtime?
> >
> > That would be possible, but IMHO a better option would be for an IDE to give
> > an indication (by highlighting, for example), which contracts are dynamically
> > checked and which are static.
> >
> > This property is, after all, not something that the program should depend on.
> > It is determined by how good the static checker currently is, and we want to be
> > able to improve checkers (and perhaps even allow them to regress slightly in
> > order to simplify them) without changing programs.
>
> Hmmm. I have heard that argument before and I'm conflicted.
>
> I can think of more reasons than just runtime safety for which I'd
> want proofs. Termination for example, in highly critical code;
> not something for which a runtime check will suffice. On the
> other hand the points you raise are good ones, and affect
> the usability of the language.
There doesn't seem to be a point of disagreement here. Programmers
often need to require certain properties to be checked at compile-time.
Others could go either way. There is no property that a program would
rationally desire to *require* be checked at runtime; that would only
occur because the compiler doesn't know how to check it at compile time.
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Andreas Rossberg

|
Posted: 2006-7-13 16:38:00 |
Top |
java-programmer >> What is a type error?
Marshall wrote:
>
> Okay, sure. But for the problem you describe, both imperativeness
> and the presence of pointers is each necessary but not sufficient;
> it is the two together that causes the problem. So it strikes
> me (again, a very minor point) as inaccurate to describe this as
> a problem with imperative languages per se.
>
> [...]
>
> Right. To me the response to this clear: give up pointers. Imperative
> operations are too useful to give up; indeed they are a requirement
> for certain problems. Pointers on the other hand add nothing except
> efficiency and a lot of confusion. They should be considered an
> implementation technique only, hidden behind some pointerless
> computational model.
Don't get yourself distracted by the low-level notion of "pointer". The
problem *really* is mutability and the associated notion of identity,
which explicit pointers just exhibit on a very low level.
When you have a language with mutable types (e.g. mutable arrays) then
objects of these types have identity, which is observable through
assignment. This is regardless of whether identity is an explicit
concept (like it becomes with pointers and comparison of pointer values,
i.e. addresses).
Consequently, you cannot possibly get rid of aliasing issues without
getting rid of (unrestricted) mutability. Mutability implies object
identity implies aliasing problems.
On the other hand, pointers are totally a futile concept without
mutability: if everything is immutable, it is useless to distinguish
between an object and a pointer to it.
In other words, pointers are essentially just an *aspect* of mutability
in lower-level languages. On a sufficiently high level of abstraction,
it does not make much sense to differentiate between both concepts -
pointers are just mutable objects holding other mutable objects
(immutable pointer types exist, but are only interesting if you also
have pointer arithmetics - which, however, is largely equivalent to
arrays, i.e. not particularly relevant either).
- Andreas
|
| |
|
| |
 |
Joachim Durchholz

|
Posted: 2006-7-13 18:37:00 |
Top |
java-programmer >> What is a type error?
Marshall schrieb:
> Joachim Durchholz wrote:
>> Marshall schrieb:
>>> Joachim Durchholz wrote:
>>>> Marshall schrieb:
>>>>> I can see the lack of a formal model being an issue, but is the
>>>>> imperative bit really all that much of an obstacle? How hard
>>>>> is it really to deal with assignment? Or does the issue have
>>>>> more to do with pointers, aliasing, etc.?
>>>> Actually aliasing is *the* hard issue.
>>> Okay, sure. Nice explanation.
>>>
>>> But one minor point: you describe this as an issue with "imperative"
>>> languages. But aliasing is a problem associated with pointers,
>>> not with assignment.
>> Aliasing is not a problem if the aliased data is immutable.
>
> Okay, sure. But for the problem you describe, both imperativeness
> and the presence of pointers is each necessary but not sufficient;
> it is the two together that causes the problem. So it strikes
> me (again, a very minor point) as inaccurate to describe this as
> a problem with imperative languages per se.
Sure.
It's just that I know that it's viable to give up destructive updates.
Giving up pointers is a far more massive restriction.
> Right. To me the response to this clear: give up pointers. Imperative
> operations are too useful to give up; indeed they are a requirement
> for certain problems.
I don't know any.
In some cases, you need an additional level of conceptual indirection -
instead of *doing* the updates, you write a function that *describes* them.
> Pointers on the other hand add nothing except
> efficiency and a lot of confusion. They should be considered an
> implementation technique only, hidden behind some pointerless
> computational model.
>
> I recognize that this is likely to be a controversial opinion.
Indeed.
In fact "modes" are a way to restrict pointer aliasing.
> I heartily support immutability as the default, for these and other
> reasons.
OK, then we're in agreement here.
>> Some functional languages restrict assignment so that there can exist at
>> most a single reference to any mutable data structure. That way, there's
>> still no aliasing problems, but you can still update in place where it's
>> really, really necessary.
>
> Are we speaking of uniqueness types now? I haven't read much about
> them, but it certainly seems like an intriguing concept.
Yup.
It's called "modes" in some other languages (Mercury or Clean IIRC).
>> I know of no professional language that doesn't have references of some
>> kind.
>
> Ah, well. I suppose I could mention prolog or mercury, but then
> you used that troublesome word "professional." So I will instead
> mention a language which, if one goes by number of search results
> on hotjobs.com for "xxx progammer" for different value of xxx, is
> more popular than Java and twice as popular as C++. It lacks
> pointers (although I understand they are beginning to creep in
> in the latest version of the standard.) It also posesses a quite
> sophisticated set of facilities for declarative integrity constraints.
> Yet for some reason it is typically ignored by language designers.
>
> http://hotjobs.yahoo.com/jobseeker/jobsearch/search_results.html?keywords_all=sql+programmer
Oh, right. SQL is an interesting case of getting all the problems of
pointers without having them ;-)
Actually SQL has references - they are called "primary keys", but they
are references nevertheless. (Some SQL dialects also offer synthetic
"ID" fields that are guaranteed to remain stable over the lifetime of a
record. Seems like SQL is imperative enough that programmers want this,
else the SQL vendors wouldn't have added the feature...)
SQL also has updates.
The result: updates with undefined semantics. E.g. if you have a numeric
key field, UPDATE commands that increment the key by 1 will fail or work
depending on the (unspecified) order in which UPDATE touches the
records. You can have even more fun with updatable views.
With a "repeatable read" isolation level, you actually return to a
declarative view of the database: whatever you do with it, you won't see
it until you commit the transaction. (As soon as you commit, the
declarative peace is over and you better watch out that your data
doesn't become inconsistent due to aliasing.)
Aliasing isn't really related to specific programming practices. If two
accountants chat, and one talks about the hot blonde secretaire and the
other about his adorable wife, you can imagine the awkwardness that
ensues as soon as they find out they're talking about the same person!
The only thing that can really be done about it is not adding it
artificially into a program. In those cases where aliasing is part of
the modelled domain, you really have to carefully inspect all
interactions and never, never, never dream about abstracting it away.
Regards,
Jo
|
| |
|
| |
 |
Joachim Durchholz

|
Posted: 2006-7-13 18:48:00 |
Top |
java-programmer >> What is a type error?
Darren New schrieb:
> Joachim Durchholz wrote:
>> Actually, in a functional programming language (FPL), you write just
>> the postconditions and let the compiler generate the code for you.
>
> Certainly. And my point is that the postcondition describing "all valid
> chess boards reachable from this one" is pretty much going to be as big
> as an implementation for generating it, yes?
Yes. It's a classical case where the postcondition and the code that
fulfils it are essentially the same.
> The postcondition will
> still have to contain all the rules of chess in it, for example. At best
> you've replaced loops with some sort of universal quanitifier with a
> "such that" phrase.
Correct.
OTOH, isn't that the grail that many people have been searching for:
programming by simply declaring the results that they want to see?
> Anyway, I expect you could prove you can't do this in the general case.
> Otherwise, you could just write a postcondition that asserts the output
> of your function is machine code that when run generates the same
> outputs as the input string would. I.e., you'd have a compiler that can
> write other compilers, generated automatically from a description of the
> semantics of the input stream and the semantics of the machine the code
> is to run on. I'm pretty sure we're not there yet, and I'm pretty sure
> you start running into the limits of computability if you do that.
No, FPLs are actually just that: compilable postconditions.
Computability issues aren't more or less a factor than with other kinds
of compilers: they do limit what you can do, but these limits are loose
enough that you can do really useful stuff within them (in particular,
express all algorithms).
Regards,
Jo
|
| |
|
| |
 |
Joachim Durchholz

|
Posted: 2006-7-13 18:55:00 |
Top |
java-programmer >> What is a type error?
Marshall schrieb:
> David Hopwood wrote:
>> This property is, after all, not something that the program should depend on.
>> It is determined by how good the static checker currently is, and we want to be
>> able to improve checkers (and perhaps even allow them to regress slightly in
>> order to simplify them) without changing programs.
>
> Hmmm. I have heard that argument before and I'm conflicted.
I'd want several things.
A way for me to indicate what assertions must be proven statically.
Highlighting (be it compiler messages or flashing colors in an IDE) that
marks assertions that *will* break.
And highlighting for assertions that *may* break.
In the language, a (possibly) simplicistic inference engine definition
that gives me minimum guarantees about the things that it will be able
to prove; if something is out of the reach of the engine, a
straightforward way to add intermediate assertions until the inference
succeeds.
(Plus diagnostics that tell me where the actual error may be, whether
it's a bug in the code or an omission in the assertions. That's probably
the hardest part of it all.)
Regards,
Jo
|
| |
|
| |
 |
Marshall

|
Posted: 2006-7-13 23:05:00 |
Top |
java-programmer >> What is a type error?
Andreas Rossberg wrote:
> Marshall wrote:
> >
> > Okay, sure. But for the problem you describe, both imperativeness
> > and the presence of pointers is each necessary but not sufficient;
> > it is the two together that causes the problem. So it strikes
> > me (again, a very minor point) as inaccurate to describe this as
> > a problem with imperative languages per se.
> >
> > [...]
> >
> > Right. To me the response to this clear: give up pointers. Imperative
> > operations are too useful to give up; indeed they are a requirement
> > for certain problems. Pointers on the other hand add nothing except
> > efficiency and a lot of confusion. They should be considered an
> > implementation technique only, hidden behind some pointerless
> > computational model.
>
> Don't get yourself distracted by the low-level notion of "pointer". The
> problem *really* is mutability and the associated notion of identity,
> which explicit pointers just exhibit on a very low level.
>
> When you have a language with mutable types (e.g. mutable arrays) then
> objects of these types have identity, which is observable through
> assignment. This is regardless of whether identity is an explicit
> concept (like it becomes with pointers and comparison of pointer values,
> i.e. addresses).
Hmmm, well, I cannot agree. You've defined away the pointers
but then slipped them back in again by assumption ("objects
of these types have identity".)
First let me say that the terminology is somewhat problematic.
For the specific issue being discussed here, pointers, identity,
and objects are all the same concept. (I agree that "pointer"
connotes a low-level construct, however.) Sometimes I think
of this issue as being one with first class variables. An object
with mutable fields is a variable, and if we have pointers or
references or any way to have two different pathways to
that object/those variables, then we run in to the aliasing problem.
However if the mutable types are not first class, then there
is no way to have the aliasing. Thus, if we do not have pointers
or objects or identity but retain mutability, there is no aliasing
problem.
> Consequently, you cannot possibly get rid of aliasing issues without
> getting rid of (unrestricted) mutability. Mutability implies object
> identity implies aliasing problems.
Mutability by itself does not imply identity. I agree that mutability
plus
identity implies aliasing problems, however.
> On the other hand, pointers are totally a futile concept without
> mutability: if everything is immutable, it is useless to distinguish
> between an object and a pointer to it.
Agreed.
> In other words, pointers are essentially just an *aspect* of mutability
> in lower-level languages.
Again, I disagree: it is posible to have mutability without
pointers/identity/objects.
Marshall
|
| |
|
| |
 |
Andreas Rossberg

|
Posted: 2006-7-13 23:36:00 |
Top |
java-programmer >> What is a type error?
Marshall wrote:
>
> However if the mutable types are not first class, then there
> is no way to have the aliasing. Thus, if we do not have pointers
> or objects or identity but retain mutability, there is no aliasing
> problem.
Yes, technically you are right. But this makes a pretty weak notion of
mutability. All stateful data structures had to stay within their
lexical scope, and could never be passed to a function. For example,
this essentially precludes object-oriented programming, because you
could not have objects with state (the alternative, second class
objects, would be even less "objective").
Generally, second-classness is an ad-hoc restriction that can work
around all kinds of problems, but rarely with satisfactory results. So I
would tend to say that this is not an overly interesting point in the
design space. But YMMV.
>>In other words, pointers are essentially just an *aspect* of mutability
>>in lower-level languages.
>
> Again, I disagree: it is posible to have mutability without
> pointers/identity/objects.
OK, if you prefer: it is an aspect of first-class mutability - which is
present in almost all imperative languages I know. :-)
- Andreas
--
Andreas Rossberg, email***@***.com
|
| |
|
| |
 |
Marshall

|
Posted: 2006-7-13 23:46:00 |
Top |
java-programmer >> What is a type error?
Joachim Durchholz wrote:
> Marshall schrieb:
> > Joachim Durchholz wrote:
> >> Marshall schrieb:
> >>> Joachim Durchholz wrote:
> >>>> Marshall schrieb:
> >>>>> I can see the lack of a formal model being an issue, but is the
> >>>>> imperative bit really all that much of an obstacle? How hard
> >>>>> is it really to deal with assignment? Or does the issue have
> >>>>> more to do with pointers, aliasing, etc.?
> >>>> Actually aliasing is *the* hard issue.
> >>> Okay, sure. Nice explanation.
> >>>
> >>> But one minor point: you describe this as an issue with "imperative"
> >>> languages. But aliasing is a problem associated with pointers,
> >>> not with assignment.
> >> Aliasing is not a problem if the aliased data is immutable.
> >
> > Okay, sure. But for the problem you describe, both imperativeness
> > and the presence of pointers is each necessary but not sufficient;
> > it is the two together that causes the problem. So it strikes
> > me (again, a very minor point) as inaccurate to describe this as
> > a problem with imperative languages per se.
>
> Sure.
> It's just that I know that it's viable to give up destructive updates.
> Giving up pointers is a far more massive restriction.
Oddly, I feel the opposite. While it's true there are many domains
for which purely functional programming is a fine choice, there
are some domains for which it is insufficient. Any kind of data
managament, for example, requires that you be able to update
the information.
On the other hand, there is no problem domain for which pointers
are a requirement. I agree they are deucedly convenient, though.
> > Right. To me the response to this clear: give up pointers. Imperative
> > operations are too useful to give up; indeed they are a requirement
> > for certain problems.
>
> I don't know any.
> In some cases, you need an additional level of conceptual indirection -
> instead of *doing* the updates, you write a function that *describes* them.
But then what do you do with that function? Let's say I have an
employee database. John Smith just got hired on 1/1/2006 with
a salary of $10,000. I need to record this fact somewhere. How
do I do that without variables? Current-employees is a variable.
Even if I have the space to keep all historical data, so I'm not
deleting anything, I still have to have a variable for the latest
version of the accumulated data. I can solve this without
pointers, but I can't solve it without variables.
> > Pointers on the other hand add nothing except
> > efficiency and a lot of confusion. They should be considered an
> > implementation technique only, hidden behind some pointerless
> > computational model.
> >
> > I recognize that this is likely to be a controversial opinion.
>
> Indeed.
>
> In fact "modes" are a way to restrict pointer aliasing.
I should like to learn more about these. I have some vague
perception of the existence of linear logic, but not much
else. However, I also already have an excellent solution
to the pointer aliasing problem, so I'm less motivated.
> > I heartily support immutability as the default, for these and other
> > reasons.
>
> OK, then we're in agreement here.
>
> >> Some functional languages restrict assignment so that there can exist at
> >> most a single reference to any mutable data structure. That way, there's
> >> still no aliasing problems, but you can still update in place where it's
> >> really, really necessary.
> >
> > Are we speaking of uniqueness types now? I haven't read much about
> > them, but it certainly seems like an intriguing concept.
>
> Yup.
> It's called "modes" in some other languages (Mercury or Clean IIRC).
Cool.
> >> I know of no professional language that doesn't have references of some
> >> kind.
> >
> > Ah, well. I suppose I could mention prolog or mercury, but then
> > you used that troublesome word "professional." So I will instead
> > mention a language which, if one goes by number of search results
> > on hotjobs.com for "xxx progammer" for different value of xxx, is
> > more popular than Java and twice as popular as C++. It lacks
> > pointers (although I understand they are beginning to creep in
> > in the latest version of the standard.) It also posesses a quite
> > sophisticated set of facilities for declarative integrity constraints.
> > Yet for some reason it is typically ignored by language designers.
> >
> > http://hotjobs.yahoo.com/jobseeker/jobsearch/search_results.html?keywords_all=sql+programmer
>
> Oh, right. SQL is an interesting case of getting all the problems of
> pointers without having them ;-)
Oh, pooh. SQL has plenty of problems, sure, but the problems
of pointers are not among its faults.
> Actually SQL has references - they are called "primary keys", but they
> are references nevertheless.
I strongly object; this is quite incorrect. I grant you that from the
50,000 foot level they appear identical, but they are not. To
qualify as a reference, there need to be reference and dereference
operations on the reference datatype; there is no such operation
is SQL.
Would you say the relational algebra has references?
Or, consider the classic prolog ancestor query. Let's say we're
setting up as follows
father(bob, joe).
father(joe, john).
Is "joe" a reference, here? After all, when we do the ancestor
query for john, we'll see his father is joe and then use that to
find joe's father. Keys in SQL are isomorphic to joe in the
above prolog.
> (Some SQL dialects also offer synthetic
> "ID" fields that are guaranteed to remain stable over the lifetime of a
> record.
Primary keys are updatable; there is nothing special about them.
> Seems like SQL is imperative enough that programmers want this,
> else the SQL vendors wouldn't have added the feature...)
I believe you are making a statement about the general level of
education among the user base of data base management systems,
and not a statement about the nature of the relational algebra.
> SQL also has updates.
Yes; SQL is imperative. But no pointers and thus no aliasing.
Plenty of *other* problems, though; no argument there!
> The result: updates with undefined semantics. E.g. if you have a numeric
> key field, UPDATE commands that increment the key by 1 will fail or work
> depending on the (unspecified) order in which UPDATE touches the
> records.
This does not sound correct to me, and in any event does not
appear to illustrate anything about aliasing.
> You can have even more fun with updatable views.
I suppose. Views are something for which the practice has
rushed ahead of the theoretical foundation out of need. The
"right" way to do views is not yet known. Again: plenty of
problems with SQL, but no aliasing. (Actually, there probably
is aliasing with SQL99, since IIUC they've gone ahead and
introduced reference types. (Cue Charlton Heston on the beach
saying "You Maniacs! You blew it up! Ah, damn you!"))
> With a "repeatable read" isolation level, you actually return to a
> declarative view of the database: whatever you do with it, you won't see
> it until you commit the transaction. (As soon as you commit, the
> declarative peace is over and you better watch out that your data
> doesn't become inconsistent due to aliasing.)
Alas, transaction isolation levels are a performance hack.
I cannot defend them on any logical basis. (Aside: did you mean
serializable, rather than repeatable read?)
> Aliasing isn't really related to specific programming practices. If two
> accountants chat, and one talks about the hot blonde secretaire and the
> other about his adorable wife, you can imagine the awkwardness that
> ensues as soon as they find out they're talking about the same person!
Heh, that's not aliasing. That's the undecidability of intentional
function equivalence. <joke>
> The only thing that can really be done about it is not adding it
> artificially into a program. In those cases where aliasing is part of
> the modelled domain, you really have to carefully inspect all
> interactions and never, never, never dream about abstracting it away.
Yes, aliasing introduces a lot of problems. This is one reason
why closures make me nervous.
Marshall
|
| |
|
| |
 |
Darren New

|
Posted: 2006-7-14 1:01:00 |
Top |
java-programmer >> What is a type error?
Andreas Rossberg wrote:
> Yes, technically you are right. But this makes a pretty weak notion of
> mutability. All stateful data structures had to stay within their
> lexical scope, and could never be passed to a function.
Not really. The way Hermes handles this is with destructive assignment.
Each variable holds a value, and you (almost) cannot have multiple
variables referring to the same value.
If you want to assign Y to X, you use
X := Y
after which Y is considered to be uninitialized. If you want X and Y to
have the same value, you use
X := copy of Y
after which X and Y have the same value but are otherwise unrelated, and
changes to one don't affect the other.
(As almost an aside, the non-scalar data structures were very similar to
SQL data tables.)
If you declare (the equivalent to) a function, you can indicate whether
the paramters matching the arguments are passed destructively, or are
read-only, or are copy-in-copy-out. So you could declare a function, for
example, that you pass a table into, and if it's marked as a read-only
parameter, the compiler ensures the callee does not modify the table and
the compiler generates code to pass a pointer. One could also mark a
variable (for example) as uninitialized on entry, intialized on return,
and uninitalized on the throw of an exception, and this could be used
(for example) for the read-a-line-from-a-socket routine.
The only value that came close to being shared is an outgoing connection
to a procedure; the equivalent of the client side of a socket. For
these, you could make copies, and each copy would point to the same
receiver. The receiving process could change over time, by passing its
end of the socket in a message to some other process (live code
upgrading, for example).
Since everything could be passed as part of a message, including code,
procedures, tables, and "inports" and "outports" (the ends of sockets),
I don't see that it had any problems with first classness.
> OK, if you prefer: it is an aspect of first-class mutability - which is
> present in almost all imperative languages I know. :-)
I disagree. It's entirely possible to make sophisticated imperitive
languages with assignment and without aliasing.
--
Darren New / San Diego, CA, USA (PST)
This octopus isn't tasty. Too many
tentacles, not enough chops.
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-7-14 1:04:00 |
Top |
java-programmer >> What is a type error?
Joachim Durchholz <email***@***.com> wrote:
> OTOH, isn't that the grail that many people have been searching for:
> programming by simply declaring the results that they want to see?
Possibly.
> No, FPLs are actually just that: compilable postconditions.
This seems to me a bit misleading. Perhaps someone will explain why I
should stop thinking this way; but currently I classify statements like
this in the "well, sort of" slot of my mind. If functional programming
were really just compilable postconditions, then functional programmers
would be able to skip a good bit of stuff that they really can't. For
example, time and space complexity of code is still entirely relevant
for functional programming. I can't simply write:
(define fib
(lambda (x) (if (< x 2) 1 (+ (fib (- x 1)) (fib (- x 2))))))
and expect the compiler to create an efficient algorithm for me. This
is true even though the above is (the LISP transcription of) the most
natural way to describe the fibonacci sequence from a mathematical
standpoint. It still runs in exponential time, and it still matters
that it runs in exponential time; and LISP programmers adapt their so-
called declarative code to improve time bounds all the time. This makes
it harder for me to call it declarative (or "compilable postconditions")
and feel entirely honest.
(Yes, I realize that the above could be optimized in a language that
does normal order evaluation with common subexpression elimination. and
become linear-time. However, that's not true of algorithms in general.
It is not the case that all that's needed to find an efficient algorithm
for something is to plug it into a Haskell compiler and observe what
happens. Or, if that is the case, there are a few CS professors I know
who would be quite interested in hearing so.)
> Computability issues aren't more or less a factor than with other kinds
> of compilers: they do limit what you can do, but these limits are loose
> enough that you can do really useful stuff within them (in particular,
> express all algorithms).
Is it really consistent to say that postconditions allow you to express
algorithms?
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Joachim Durchholz

|
Posted: 2006-7-14 1:22:00 |
Top |
java-programmer >> What is a type error?
Marshall schrieb:
> Mutability by itself does not imply identity.
Well, the implication certainly holds from identity to mutability.
The only definition of identity that I found to hold up for all kinds of
references (pointers, shared-memory identifiers, URLs etc.) is this:
Two pieces of data are identical if and only if:
a) they are equal
b) they stay equal after applying an arbitrary operation to one of them.
This means that for immutable objects, there's no observable difference
between equality and identity (which I think it just fine).
For the implicaton from mutability to identity, I'm not sure whether
talking about mutation still makes sense without some kind of identity.
For example, you need to establish that the object after the mutation is
still "the same" in some sense, and this "the same" concept is exactly
identity.
> I agree that mutability
> plus identity implies aliasing problems, however.
Then we're agreeing about the most important point anyway.
>> In other words, pointers are essentially just an *aspect* of mutability
>> in lower-level languages.
>
> Again, I disagree: it is posible to have mutability without
> pointers/identity/objects.
I'm sceptical.
Any examples?
Regards,
Jo
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-7-14 1:28:00 |
Top |
java-programmer >> What is a type error?
Marshall <email***@***.com> wrote:
> Hmmm, well, I cannot agree. You've defined away the pointers
> but then slipped them back in again by assumption ("objects
> of these types have identity".)
>
> First let me say that the terminology is somewhat problematic.
> For the specific issue being discussed here, pointers, identity,
> and objects are all the same concept. (I agree that "pointer"
> connotes a low-level construct, however.)
Unless I'm missing your point, I disagree with your disagreement.
Mutability only makes sense because of object identity (in the generic
sense; no OO going on here). Without object identities, mutability is
useless. What's the use of changing something if you're not sure you'll
ever be able to find it again?
You may limit the scope of object identity arbitrarily, even to the
point that aliasing is impossible (though with lexical closure, that
gets even more limiting than it may first appear)... but you're just
trading off power for simplicity, and the really interesting uses of
mutations are those that allow access to specific objects from any
number different bits of code, on a program-wide or at least module-wide
scope. Most mediocre programmers could replace assignment with
recursion if that assignment is limited to local variables of a single
subroutine. I don't necessarily agree that the result will be a better
program despite others' conviction on the matter; however, the
difference certainly isn't worth complicating the language with mutation
unless you're willing to allow the interesting uses of mutation as well.
> Mutability by itself does not imply identity. I agree that mutability
> plus identity implies aliasing problems, however.
We might have a terminological issue, then. I'd tend to say that
mutability definitely does imply identity, but identity doesn't imply
aliasing. Same difference.
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Darren New

|
Posted: 2006-7-14 2:08:00 |
Top |
java-programmer >> What is a type error?
Chris Smith wrote:
> Unless I'm missing your point, I disagree with your disagreement.
> Mutability only makes sense because of object identity (in the generic
> sense; no OO going on here).
Depends what you mean by "object".
int x = 6; int y = 5; x = y;
I'd say x was mutable, with no "identity" problems involved?
Why is it problematic that variables have identity and are mutable?
Certainly I can later "find" whatever value I put into x.
--
Darren New / San Diego, CA, USA (PST)
This octopus isn't tasty. Too many
tentacles, not enough chops.
|
| |
|
| |
 |
Joe Marshall

|
Posted: 2006-7-14 2:15:00 |
Top |
java-programmer >> What is a type error?
Marshall wrote:
>
> Again, I disagree: it is posible to have mutability without
> pointers/identity/objects.
I think you are wrong, but before I make a complete ass out of myself,
I have to ask what you mean by `mutability'. (And
pointers/identity/objects, for that matter.)
Alan Bawden discusses the phenomenon of `state' in his Ph.D.
dissertation "Implementing Distributed Systems Using Linear Naming".
MIT AI Lab Technical Report AITR-1627. March 1993 He makes a
persuasive argument that `state' is associated with cycles in naming.
|
| |
|
| |
 |
David Hopwood

|
Posted: 2006-7-14 3:31:00 |
Top |
java-programmer >> What is a type error?
Marshall wrote:
> David Hopwood wrote:
>>Marshall wrote:
>>
>>>Wouldn't it be possible to do them at compile time? (Although
>>>this raises decidability issues.)
>>
>>It is certainly possible to prove statically that some assertions cannot fail.
>>
>>The ESC/Java 2 (http://secure.ucd.ie/products/opensource/ESCJava2/docs.html)
>>tool for JML (http://www.cs.iastate.edu/~leavens/JML/) is one system that does
>>this -- although some limitations and usability problems are described in
>><http://secure.ucd.ie/products/opensource/ESCJava2/ESCTools/papers/CASSIS2004.pdf>.
>
> I look forward to reading this. I read a paper on JML a while ago and
> found it quite interesting.
>
>>>Mightn't it also be possible to
>>>leave it up to the programmer whether a given contract
>>>was compile-time or runtime?
>>
>>That would be possible, but IMHO a better option would be for an IDE to give
>>an indication (by highlighting, for example), which contracts are dynamically
>>checked and which are static.
>>
>>This property is, after all, not something that the program should depend on.
>>It is determined by how good the static checker currently is, and we want to be
>>able to improve checkers (and perhaps even allow them to regress slightly in
>>order to simplify them
.. or improve their performance ..
> ) without changing programs.
>
> Hmmm. I have heard that argument before and I'm conflicted.
>
> I can think of more reasons than just runtime safety for which I'd
> want proofs. Termination for example, in highly critical code;
> not something for which a runtime check will suffice.
It is true that some properties cannot be verified directly by a runtime check,
but that does not mean that runtime checks are not indirectly useful in verifying
them.
For example, we can check at runtime that a loop variant is strictly decreasing
with each iteration. Then, given that each iteration of the loop body terminates,
it is guaranteed that the loop terminates, *either* because the runtime check
fails, or because the variant goes to zero.
In general, we can verify significantly more program properties using a
combination of runtime checks and static proof, than we can using static proof
alone. That may seem like quite an obvious statement, but the consequence is
that any particular property is, in general, not verified purely statically or
purely at runtime.
I am not opposed to being able to annotate an assertion to say that it should
be statically provable and that a runtime check should not be used. However,
- such annotations should be very lightweight and visually undistracting,
relative to the assertion itself;
- a programmer should not interpret such an annotation on a particular assertion
to mean that its static validity is not reliant on runtime checks elsewhere;
- if the class of assertions that are statically provable changes, then a
tool should be provided which can *automatically* add or remove these
annotations (with programmer approval when they are removed).
I'd like to make a couple more comments about when it is sufficient to detect
errors and when it is necessary to prevent them:
- If a language supports transactions, then this increases the proportion
of cases in which it is sufficient to detect errors in imperative code.
When state changes are encapsulated in a transaction, it is much easier
to recover if an error is detected, because invariants that were true of
objects used by the transaction when it started will be automatically
reestablished. (Purely functional code does not need this.)
- Almost all safety-critical systems have a recovery or safe shutdown
behaviour which should be triggered when an error is detected in the
rest of the program. The part of the program that implements this behaviour
definitely needs to be statically correct, but it is usually only a small
amount of code.
Safety-critical systems that must either prevent errors or continue
functioning in their presence (aircraft control systems, for example) are
in a separate category that demand *much* greater verification effort. Even
for these systems, though, it is still useful to detect errors in cases
where they cannot be prevented. When multiple independent implementations
of a subsystem are used to check each other, this error detection can be
used as an input to the decision of which implementation is failing and
which should take over.
--
David Hopwood <email***@***.com>
|
| |
|
| |
 |
David Hopwood

|
Posted: 2006-7-14 3:57:00 |
Top |
java-programmer >> What is a type error?
Chris Smith wrote:
> Joachim Durchholz <email***@***.com> wrote:
>
>>OTOH, isn't that the grail that many people have been searching for:
>>programming by simply declaring the results that they want to see?
>
> Possibly.
>
>>No, FPLs are actually just that: compilable postconditions.
>
> This seems to me a bit misleading. Perhaps someone will explain why I
> should stop thinking this way; but currently I classify statements like
> this in the "well, sort of" slot of my mind. If functional programming
> were really just compilable postconditions, then functional programmers
> would be able to skip a good bit of stuff that they really can't. For
> example, time and space complexity of code is still entirely relevant
> for functional programming. I can't simply write:
>
> (define fib
> (lambda (x) (if (< x 2) 1 (+ (fib (- x 1)) (fib (- x 2))))))
>
> and expect the compiler to create an efficient algorithm for me.
This is true, but note that postconditions also need to be efficient
if we are going to execute them.
That is, the difference you've pointed out is not a difference between
executable postconditions and functional programs. Both the inefficient
functional definition of 'fib' and an efficient one are executable
postconditions. In order to prove that the efficient implementation is
as correct as the inefficient one, we need to prove that, treated as
postconditions, the former implies the latter.
(In this case a single deterministic result is required, so the former
will be equivalent to the latter.)
--
David Hopwood <email***@***.com>
|
| |
|
| |
 |
Marshall

|
Posted: 2006-7-14 4:00:00 |
Top |
java-programmer >> What is a type error?
Joe Marshall wrote:
> Marshall wrote:
> >
> > Again, I disagree: it is posible to have mutability without
> > pointers/identity/objects.
>
> I think you are wrong, but before I make a complete ass out of myself,
> I have to ask what you mean by `mutability'. (And
> pointers/identity/objects, for that matter.)
Responding to requests for examples from Joachim, Joe, and Chris....
The very simple example is the one Darren New already mentioned.
Consider the following Java fragment:
void foo() {
int i = 0;
int j = 0;
// put any code here you want
j = 1;
i = 2;
// check value of j here. It is still 1, no matter what you filled in
above.
// The assignment to i cannot be made to affect the value of j.
}
Those two local primitive variables cannot be made to have the same
identity. But you can update them, so this is an example of mutability
without the possibility of identity.
Earlier I also mentioned SQL tables as an example, although SQL
supports *explicit* aliasing via views.
> Alan Bawden discusses the phenomenon of `state' in his Ph.D.
> dissertation "Implementing Distributed Systems Using Linear Naming".
> MIT AI Lab Technical Report AITR-1627. March 1993 He makes a
> persuasive argument that `state' is associated with cycles in naming.
I would like to read that, but my brain generally runs out of gas at
about 21
pages, so it's about an order of magnitude bigger than I can currently
handle. :-( As to "cycles in naming" that's certainly an issue. But it
it
a requirement for state? Back to Java locals, it seems to me they meet
the standard definition of state, despite the lack of cycles.
As to pointers/references, I earlier mentioned the existence of the
reference/dereference operations as being definitional. Note that
one can go to some lengths to obscure them, but they're still there.
For example, Java has the reference and dereference operators;
Java's "." operator is actually C's "->" operator.
I am not so bold/foolish as to attempt a defintion of "object" however.
:-)
Marshall
|
| |
|
| |
 |
Joe Marshall

|
Posted: 2006-7-14 6:07:00 |
Top |
java-programmer >> What is a type error?
Marshall wrote:
>
> Consider the following Java fragment:
>
> void foo() {
> int i = 0;
> int j = 0;
>
> // put any code here you want
>
> j = 1;
> i = 2;
> // check value of j here. It is still 1, no matter what you filled in
> above.
> // The assignment to i cannot be made to affect the value of j.
>
> }
True, but you have hidden the pointers. Semantically, the identifiers
i and j refer not to integers but to locations that hold integers. The
assignment modifies the location.
> Those two local primitive variables cannot be made to have the same
> identity. But you can update them, so this is an example of mutability
> without the possibility of identity.
The identity is temporal: You use the same variable name at two
different times. Do you intend for the second `i' to mean the same
variable as the first `i'?
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-7-14 6:22:00 |
Top |
java-programmer >> What is a type error?
Darren New <email***@***.com> wrote:
> Chris Smith wrote:
> > Unless I'm missing your point, I disagree with your disagreement.
> > Mutability only makes sense because of object identity (in the generic
> > sense; no OO going on here).
>
> Depends what you mean by "object".
>
> int x = 6; int y = 5; x = y;
>
> I'd say x was mutable, with no "identity" problems involved?
The variable x definitely has identity that's independent of its value.
Some might call that a problem in and of itself, as it complicates the
formal model of the language and makes it difficult to predict what
result will be produced by normal order evaluation.
On the other hand, this thread seems to be using "identity" to mean
"identity with potential for aliasing", in which case it is vacuously
true that eliminating identity also prevents the problems that arise
from aliasing. It is true, and I agree on this with Marshall, that
eliminating the potential for aliasing solves a lot of problems with
checking invariants. I also see, though, that the majority (so far, I'd
say all) of the potential uses for which it's worth introducing mutation
into an otherwise mutation-free language allow the possibility of
aliasing, which sorta makes me wonder whether this problem is worth
solving. I'd like to see an example of code that would be harder to
write without mutation, but which can obey any restriction that's
sufficient to prevent aliasing.
> Why is it problematic that variables have identity and are mutable?
> Certainly I can later "find" whatever value I put into x.
I simply found the language confusing. I said it would be nonsensical
for a language to have mutation without identity.
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-7-14 6:25:00 |
Top |
java-programmer >> What is a type error?
David Hopwood <email***@***.com> wrote:
> This is true, but note that postconditions also need to be efficient
> if we are going to execute them.
If checked by execution, yes. In which case, I am trying to get my head
around how it's any more true to say that functional languages are
compilable postconditions than to say the same of imperative languages.
In both cases, some statement is asserted through a description of a
means of computing it. There may be a distinction worth making here,
but I'm missing it so far.
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Licence code storing for java appHello,
I want to create a app which will have something similar to licence
(i.e. user have to enter licence code to run the app). The problem
arises when I want to make it that user have to specify it only once.
So I need to store somewhere the information, that the app has already
been activated. I am thinking about main jar file (as something which
can work ,although it is nothing sophisticated), but when I add extra
characters at the end then my jar was corrupted :(. Do you know any
nice way to do this:)? Thank you!
Regards, mark
- 2
- TRYING TO CREATE A SIMPLE FORM. HELP HELP HELP!!!!trying to make a simple form, just an empty window with no button.
ive tried this
import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.*;
public class Canvas
{
private static Canvas canvasSingleton;
public static Canvas getCanvas()
{
if(canvasSingleton == null) {
canvasSingleton = new Canvas("BlueJ Shapes Demo", 300, 300,
Color.white);
}
canvasSingleton.setVisible(true);
return canvasSingleton;
}
}
but it doesnt work :( any ideas guys?
- 3
- Run Excel Macro from JavaI want to run the macro present inside the excel sheet using the Java
code. Is is possible using Java code? Please help
- 4
- Read the index of item with X value.On Mar 26, 10:42 pm, "Mariano" <email***@***.com> wrote:
> I've a ComboBox ..
>From where? There is no ComboBox in the JSE.
Are you perhaps referring to java.awt.Choice,
or javax.swing.JComboBox?
..
> How could I resolve?
1) Be specific about the classes used, rather
than simply 'making the names up, as you go along'
2) ..
Andrew T.
- 5
- Junit tests, setting up tests without having to create a billion methodsJames McGill wrote:
> On Wed, 2006-02-15 at 19:42 +0000, Andrew McDonagh wrote:
>
>>email***@***.com wrote:
>>
>>>Is there a more dynamic way of setting up tests? We have legacy test
>>>code that we are trying to convert to junit.
>
>
> I really enjoyed using Fitnesse. A whole different idiom for testing,
> but very flexible and accessible to nonprogrammers.
>
> http://fitnesse.org/
>
>
> Anyway, it sounds like you're working backwards. You've already written
> the code you want to test, which is backwards from TDD, which sort of
> means JUnit isn't exactly the right tool for what you're doing. Still
> it occurs to me that you should be able to automatically generated
> wrappers for your legacy tests, and put those into a testsuite, and be
> done with the legacy stuff and move forward with JUnit.
>
>
>
Hi James,
You seem have have attributed the OPs remarks to me...
That being said, the OP is specifically talking about the case where we
have a legacy code base which wasn't tested with Junit - not that it
wasn't tested. There's no mention of whether TDD was used or not -
though I think we both suspect it wasn't and that the code base was
merely Unit Tested.
Unfortunately, working with legacy code is currently the most common
starting point on projects that adopt TDD. Greenfield projects using TDD
are still rare.
Also, keep in mind, whilst JUnit was developed as a tool to Aid TDD,
Beck et al do realise that some people won't or can't do TDD but still
need a decent Unit Testing tool.
As I'm sure you know - but as an aid for others - TDD is not Unit Testing.
TDD is actually a design methodology that happens to use unit tests to
describe the design. Much like RUP uses UML, etc. In fact this usage of
the term Test has causes so many to concentrate on the testing side of
TDD that some are now starting to question whether a better name could
be found.
e.g.
Behavior Driven Development (http://behaviour-driven.org/)
Specification Driven Development
etc.
Andrew
- 6
- Casting Object[]Hi :o)
I've created a useful routine that "appends" an Object on to the end of an
array of Object, creating a new array with slack space if there is not
enough space available (sort of like a light-weight Vector):
public static final Object[] append(Object[] buf, int buf_len, Object addxn,
int slack)
{
Object[] ptr = buf;
if (buf == null || (buf_len + 1) > buf.length)
{
ptr = new Object[buf_len + 1 + slack];
if (buf != null) System.arraycopy(buf, 0, ptr, 0, buf_len);
}
ptr[buf_len] = addxn;
return ptr;
}
Anyway, this works fine, no probs, etc.
I am having problems, however, casting Object[] onto String[] or any other
such cast. Even if, obviously, all the elements of the array are String.
Now, I can state straight off where the problem lies. If I choose a large
enough String[] buffer so that the appended String fits inside it, then the
returned array can be cast back onto String[] - however, if the buffer is
exceeded, and line 6 is executed (creating a new buffer) then it can no
longer be cast back onto String[].
Does that make sense?
Anyway, the question! Is there any way of creating an Object[] array
generically which is of the same type as the original array. In other words,
it would create a new String[] array or Color[] or Rectangle[] or whatever
as appropriate?
Is there a way of doing it by reflection??? (perhaps)
Cheers :o)
And if you don't understand what I going on about, just shout! (hehe) and
I'll try and explain better!
Will
- 7
- Open source Java on the way! (Re: BEA Weblogic blows away .NET, other J2EE servers in review by PC magazine)"codewriter" <email***@***.com> wrote in message news:<Swd1b.4631$email***@***.com>...
> Java days are numbered. Dot Net is going to take over. This is the reality.
> So, you guys better get some C# books before it is too late.
> Amen.
ROTFLOL!
how many times did i hear this from j++ guys awhiles back, and even
from some ASP and COM jocks in AT&T (where i worked) in 1997(?) or so.
guess what happened? i'm still laughing my way to the bank and they're
trying to figure out c#/vb.net - the old microsoft treadmill,
methinks....
http://www.angrycoder.com/article.aspx?cid=1&y=2003&m=7&d=17
believe me, java will still be here years from now when microsoft has
moved on to the next BIG THING (dragging along all the developer
baggage for the ride - most of whom will be c#/vb.net developers in
india, no doubt).
in the meantime, some interesting news:
it seems sun may not be so stupid after all, and is working very
closely with open source organizations like apache and red hat to
spread java.
after apache announced a few weeks ago that it would be creating its
own open source J2EE app server, red hat announced that it was
planning on an open source java, with sun's blessing.
http://www.freeroller.net/page/kalimantan/20030822#red_hat_and_sun_to
methinks microsoft is in very big trouble.
- 8
- Returning a reference to an objectHi,
I've created a class to implement a state machine, so it's got a State
attribute. It has algo got a private java.util.Stack attribute.
In order to work, State classes need to access the stack to push and pop
data, etc.
To access it from State, I have wrote a method called getStack() which
returns a reference to the stack, but I think this is not recommended
beacause all objects sharing the reference can modify it, and led to errors
difficult to debug, etc. Returning a stack's clone is not valid solution,
as I have to make changes on the real one.
So my question is, is there a cleaner way to do this?
Thank you very much
--
PGR
- 9
- Simple While Loop problemJohn wrote:
> ththx.
>
> the code is wrong. months will be determined by the loan amount not just an
> arbitary number
>
>
> cheers
>
>
Can you not top-post please, John? It makes threads very hard to follow...
alex
- 10
- Hibernate, connection pool and firewall questionAn odd combination of topics, to be sure.
My current web application (Tomcat hosted) has a custom-rolled
connection pool. The Informix DB I connect to is across a firewall
that terminates existing connections after 120 minutes, regardless of
their current activity. My pool handles this by detecting the
creation date of a connection it wants to reuse. If that connection
was created > 60 minutes ago it closes the connection and fetches a
replacement to use in the pool.
Simply using a connection until the 120 minute barrier is reached
isn't acceptable because the DB isn't smart enough to realize that the
firewall has stopped the connection's use. The explicit release after
60+ minutes releases the connection and keeps the simultaneous
connection use down (we are licensed by the number of simultaneous
connections).
When I look at Hibernate and its connection pools (DBCP and C3P0,
there might be others) I'd like to use their stuff instead of my
home-grown pool. But I don't really see a parameter like "only use
this connection for 60 minutes" or such. Can I find such a parameter
in one of the pool possibilities?
TIA,
Jerome.
- 11
- Getting ready for 1.5I'd like to prepare for JDK 1.5. I know that generics/templates
will be in there. Will standard Java classes be retofitted to
use this new feature as appropriate? I'm thinking of course
about the collections, but also wondering about stuff such as
the clone interface.
I also know that enums will be in there. (Because the bug status
changed to closed/fixed.) But in what form? There were at least
two JSRs for that last time I checked.
Thanks!
-Wayne
- 12
- jigsaw's jdbmI like that I can use the jigsaw outside if jdbm. For
writing j2me (personal java) that don't have any sort
of record manager on the device I want to also use
jdbm there. However jdbm requires some of the file
classes that are not universally available within
j2me. I don't have the error posting just now (stupid
me) from javac to show what's missing. Has anyone
worked through this or have another idea for an
embedded data (flatfile) manager for j2me?
Mike
- 13
- eclipse, integrating crystal reports plugin with rcp appHello,
I have got a problem, I have to integrate Crystal Reports plugin with
my RCP app. I want Crystal Reports perspective aviable in my
application.
I've downloaded crystal reports plugin, and unpacked it to my_rcp_app
\plugins,
and I've run eclipse with -clear flag. but crystal reports plugin
isn't visible in Plug-In details window.
How can I cope with that problem ?
Is the any tutorial, or sth. about integrating plugins with RCP app ?
thanks a lot for any help
- 14
- JVM sourcesHi,
Where can I find C sources for JVM 1.4 for Windows ?
Thanks
Xavier
- 15
- looking for some hands on experience... i have bought and read LEARNING JAVA by niemeyer
i loved it but find i need some hands on experience.
any help?
kevin
--
Sometimes I'm in a good mood.
Sometimes I'm in a bad mood.
When all my moods have cum to pass
i hope they bury me upside down
so the world can kiss me porcelain,
white, Irish bottom.
|
|
|