aspose file tools*
The moose likes Linux / UNIX and the fly likes Systems level difference between osx linux and unix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Systems level difference between osx linux and unix" Watch "Systems level difference between osx linux and unix" New topic
Author

Systems level difference between osx linux and unix

jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Hi guys : From a systems programming perspective, how different are the os x, linux and unix kernels ? Would systems level function calls and code at this level port well and perform similarly ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14276
    
  21

Mac OS X is based on Darwin, which is largely a version of BSD, which is a Unix-like operating system. Linux is also a Unix-like operating system. Both are POSIX-compliant, which means that most system calls have the same API.

If you write software in C or C++, without using OS X-specific GUI or other libraries, then it should not be very hard to compile it on OS X as well as on Linux.

Ofcourse, for Java code that all hardly matters - Java bytecode runs anywhere where you have the right version of the JVM available.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

As @jesper says, most will work the same. The problem is that "most" is undefined and impossible to discuss in general. The exact results vary with versions, and you have at least two sets of versions, one for OS-X and one for Linux. Plus throw in the Java Native stuff that probably has a version of its own.

From my experience as a systems programmer, Java would not be the language of first choice. Machine independence is the last thing that a systems programmer usually wants.
jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Well... Just out of curosity.....

Could you directly call systems level methods against
The jvm? Since all the jvm does is abstract
Lower level methods like open() read(), etc.....

Could you actually program directly against the jvm
Rather than using the I/o classes?

I know this would be silly... But I was just wondering.

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Perhaps we have different definitions of systems programmers.

For me, a systems programmer is doing very low level work. Not using a Socket (as a Java programmer) but implementing the socket code at the OS level. Doing that can get down into the hardware level, with device drivers, etc. None of that is something you want to do in the JVM. The JVM works at a high level to the operating system. Systems programmers work in or below the operating system.
jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Yeah that makes sense... But I'm wondering wether doing operations directly against the jvm might even be possible at all.

Maybe a question for another post....?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

When my job title on my business card said "Systems Programmer", that meant that I worked with operating system internal code that was not available to applications programmers. The concept of having a separate corporate department for that kind of function is pretty much non-existent outside the mainframe world, but there were reasons for the title - our code HAD to work or the entire company would shut down, and we worked with stuff that the bulk of the programmers were denied access to for security reasons. It carried a significant premium in salary for that reason.

Technically, BTW, I believe that BSD is 100% considered as "Unix". Linux is not, although for 90% of everything, the differences are mostly cosmetic. SCO's lawyers notwithstanding.

To tap into low-level OS functions from Java, you need to create JNI classes (Java Native Interface). These are classes that, instead of being implemented in bytecodes like regular Java classes are, are implemented in hardware/OS-specific binary executable code. I can consider this as systems-level programming, since the usual protection mechanisms aren't effective. You, as the native-code class developer can do anything you like, including violation of the usual Java security processes. And, if the class fails, it will take down the entire JVM.

In over a decade of work, I've not done any JNI since at least Y2K. Java these days is pretty complete, I'm not needing direct access to specialized hardware, and the JVM optimizers are sufficiently powerful that in almost all cases a good Java algorithm can more than make up for the time and expense needed to code a critical routine in machine code.

Still. there are times when you need it, so it's good that it's there.


Customer surveys are for companies who didn't pay proper attention to begin with.
jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Well, what I'm actually asking is, can you do "assembly" style programming at the JVM level. i.e. would byte code programming be a "JVM" equivalent of assembly language ? And if so, would it be possible to learn the basics of computing and assembly language by coding against the JVM ?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Yes, you can program the virtual instruction set of the JVM just like you can any other assembly language. That is, in fact, what JVM-interpreted languages like Jython do. There exist libraries to help in the manipulation of bytecodes although I'd have to google to see if there's a full-blown assembler. JDKs come with a disassembler.

The only major difference between this approach and coding actual hardware machine language is that the Java protection rules are built into the JVM, so it won't let you do things that violate Java's run-time restrictions.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14276
    
  21

If you would like to try programming with Java bytecode directly (just like programming in native assembly language), then you could try using a look like ASM, a bytecode assembler.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Systems level difference between osx linux and unix