Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: is the java compiler written in c Date: Sat, 22 Aug 2015 17:55:32 +0000 (UTC) Organization: A noiseless patient Spider Lines: 43 Message-ID: References: <893a1a37-881c-4e59-a069-38386dd1b0fd@googlegroups.com> <7b5d28de-2f30-4db7-aec7-03bd9ce81d00@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 22 Aug 2015 17:55:32 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="4296"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DvQzMlvzghFgEaYEPm7ZQublAsooO3BE=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:khkzO5KkxeW+pMrXFcOA50R+lkU= Xref: csiph.com comp.lang.java.programmer:32410 On Sat, 22 Aug 2015 13:11:41 +0100, Eternal Hope wrote: > On 22/08/2015 12:53, Martin Gregorie wrote: >> On Fri, 21 Aug 2015 22:42:11 -0400, Arne Vajhøj wrote: >> >>> To write an OS you need to get real close to the hardware and allow a >>> lot of funky stuff. >>> >> Hardware emulation too. I started to write a 6809 emulator in Java, but >> moved the project to C when I discovered what a pain it was going to be >> to emulate the registers (8 or 16 bit unsigned arithmetic but with the >> option to treat the LHS bit as the sign) It was *much* easier to simply >> declare the registers as 'unsigned short' or 'unsigned byte' than it >> was to fight with Java's insistence on signed arithmetic. > > > https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html > > unsigned ops agogo Integer is a bit too long for what I need: all the 6809 registers are 8 or 16 bits. Byte and Short are the obvious Java classes to use but, then again, Integer,Byte and Short all only do a subset of unsigned arithmetic. Since none of them do unsigned addition or subtraction and none of them have any facilities for treating the MSB as a sign or reporting overflow - all of which are needed to emulate the registers, it remains much easier to do it in C. This is just an observation that Java is unsuitable for some applications, not a criticism. Yeah, I know I could use native code for this sort of stuff but, as much of the reason for using Java was to make the emulator fully portable, dropping bits of native C into the mix would probably have impacted that aim. Meanwhile C fits the bill very nicely. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |