aspose file tools*
The moose likes Linux / UNIX and the fly likes is java good lang for kernel programmig? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "is java good lang for kernel programmig?" Watch "is java good lang for kernel programmig?" New topic
Author

is java good lang for kernel programmig?

Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

Friends,I want to know 'is java is good for kernel programming?'.
Should I have to use only c for kernel programming.?

please brief me about it.

best regards
omi


Back to Java , again.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

No, Java isn't usable for linux kernel programming.

Java needs a running kernel, to start the VM.


http://home.arcor.de/hirnstrom/bewerbung
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Unless you have hardware that can execute the JVM directly.

In general, using Java for these tasks is not a good idea.

And in general, kernel programming is not for mortals.
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

Oh, then C would be best for kernel programming.

By the you said 'kernel programming is not for Mortals' what's that mean?

best regards
omi
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
you said 'kernel programming is not for Mortals' what's that mean?

If you have to ask then it's not for you


Ping & DNS - my free Android networking tools app
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

Now, I have to know what's that mean.It looks interesting please tell me
the secret of 'Mortals'.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
It's a noun, not a name: http://www.merriam-webster.com/dictionary/mortal
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

LOL, I know it's noun and what it means But I don't know why he used that word.Did he call java programmers the mortal jokingly.?
[ March 30, 2008: Message edited by: omi sharma ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
No, it means that kernel programming in general isn't for human beings like us. It needs beings that have higher powers. (Obviously, there's some amount of involved here.)
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

HaHa,then It's not for Java programmer.For kernel programming I have to leave
Java and stick with OS data structures and C language which I don't want to
do that.So, how about network and shell programming in Linux via Java.?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

you do shell programming in a shell. You can use perl or bash or tsh or whatever floats your boat.

Java does networking very well, open a socket and talk.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by omi sharma:
LOL, I know it's noun and what it means


Mortals are humans that will die eventually.
as in Mere Mortals....

folks who hack kernels are godlike.

Or as the old maps used to say "thar be dragons"
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

I agree with you.Who does kernel programming is nothing but god of programming.And I know I am mortal I can't do that.

I think for kernel programming one have to spend one's whole life to
program in assembly and c language.

Interesting,you advised me Java is good for network programming.I want to
go in security field ,so Can we write good protocols in Java as compared to C
language.My future goal is to move next to oracle and Linux security.

So brother,Should I learn advanced C also or Java is enough.?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

It depends how far you want to go. If you want to do really low-level systems programming, then you will have to learn C someday. In my opinion, it never hurts to know more than one programming language and since C is so widely used, it's not a bad idea to have a look at C.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

Yes , of course I will learn C ,after all It is the father of Java.
Knowing friend's Daddy is not a bad idea.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Actually, except in cases where some really heavy customizations have been done to the C compiler, there's a certain core to most kernels that can't even be done in C - it's done in assembly language.

Assembly language is rarely used these days - it's too labor-intensive and most of the "efficient" assembly language claims were a myth. Modern-day compilers can almost always do a better job of optimization than hand-optimization, especially on frequently-modified code, where the compiler could make far-reaching changes in the way the registers were used in milliseconds instead of the days or weeks that hand-recoding would require.

Although the biggest insults to assembler "efficiency" were all the abuses of algorithms. I've seen so many "efficient" bubble sorts. A bubble sort can be written in assembly in an afternoon. I spent 3 days on the next-most-complex algorithm once.

Nevertheless, at the heart of an OS, you need to do things in under 20 machine-language instructions, and some of those instructions may not be supported in high-level languages.

For anyone interested in the details of how OS's work at their most basic levels, I can recommend a couple of good examples.

The source for Linux is readily available, although it's not considered a good example by academic purists if you want to learn theory as opposed to practice. You might also look at BSD.

A better example of a practical example that's almost completely theoretically pure is the Amiga Exec. It's an almost literal realization of Edsger Djikstra's T.H.E. OS, where he proved that you could create any of the modern OS's based on a few simple building blocks. The Amiga was the only commercially-released OS that was a true real-time OS. Unfortunately, between incompetent corporate guidance and having to run on a non-MMU CPU, it's no longer considered a "live" OS (amiga.com notwitstanding).

I also learned a lot from Primos, the operating system from the little-remembered Prime Computer corporation. This minicomputer's OS was based on non-copyrightable code developed for NASA - Prime was founded by a disaffected set of ex-Honeywell employees who designed hardware optimized to run FORTRAN and were quite successful at selling to NASA and Ford Motor Corporation (among others) until minicomputers went extinct. Like Linux, Primos had a fairly fat assembly-language nucleus containing the task dispatcher and interrupt services, but the bulk of the OS was in FORTRAN. I still have a lot of the printouts.


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

Joined: Mar 18, 2008
Posts: 574
    
    1

OH Mine !! , I have got precious and invaluable information from you.
Thanks for that.For kernel programming I need the reincarnation because
In this life I can't and I will never do that.

I hate reading theories so I won't bother to read Linux kernel.
I can do c and Java that would be fine for life time.

As you can my future plans on my signature ,I will go for them without
even thinking about kernel programming.

Now ,I swear the supreme power who sent me in this world ,I will never ever
think about doing kernel programming or something like stuff.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Tim Holloway:
Actually, except in cases where some really heavy customizations have been done to the C compiler, there's a certain core to most kernels that can't even be done in C - it's done in assembly language.
.


Even among kernel hackers, there are mortals and folks who do the assembly voodoo.

Long ago, and far away, DEC's VMS was done in Bliss, no assembly language. And no C, at least at first.

I loved doing assembly language OS stuff, but that was before VMS was around, and most folks think of VMS as pre-history.
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

Yea,you are right ,I have even seen some PHP developers who know assembly but do not program in it because they don't have time.

One can do ASM programming but for that one need to make time for that.

My friend told for doing assembly one need to know Martian language.

A friend mine have created DDos attack in combination of asm and to destroy his ex-girl friend's cell phone.

Don't mind my above line I was just kidding.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Originally posted by Pat Farrell:


Even among kernel hackers, there are mortals and folks who do the assembly voodoo.

Long ago, and far away, DEC's VMS was done in Bliss, no assembly language. And no C, at least at first.

I loved doing assembly language OS stuff, but that was before VMS was around, and most folks think of VMS as pre-history.


I made a bad choice of words when I said "C" compiler. Bliss, like IBM's PL/S (and like Concurrent Pascal) was a language specifically designed to write OS's in.

The main requirements to make a progamming language suitable for writing an OS include the ability to intercept interrupts, the ability to mask interrupts and the ability to serially control access to critical code (semaphores). It's also useful if there's a way to emit the more obscure machine-language instructions such as Purge Translation Lookaside Buffer. A final, but less critical requirement is the ability to take direct control over how parameters are passed between procedures and/or how registers are being used in critical bits of code.

Java actually does support most of the above to some degree. There actually are "Java OS" implementations after a fashion - BEA has been working with this kind of technology (among others), where the JVM is essentially the machine's microcode and there is no OS underlying it.

Interestingly, so one has ever made a serious effort to create and market a CPU designed from the ground up as a hardware JVM - or "JM", if you prefer, since unless you're designing for running multiple instances, it wouldn't be virtual. It would have seemed natural for Linux Torvald's old employer. The benefits, evidently, aren't worth the effort.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Originally posted by Tim Holloway:

The main requirements ...


You left out a critical one that Java by design can't do:

directly address/deal with physical memory so you can talk to hardware devices, control registers, etc.

I've never missed it in any Java work, but sometimes you gotta tickle registers to do kernel stuff
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

If we program with combination of c and assembly then we can do anything.
As far as I have understood by your discussion , I think so.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Originally posted by Pat Farrell:


You left out a critical one that Java by design can't do:

directly address/deal with physical memory so you can talk to hardware devices, control registers, etc.

I've never missed it in any Java work, but sometimes you gotta tickle registers to do kernel stuff


Good point. Especially for memory-mapped I/O. Although it's a fairly minor VM mod. IIRC, Prime FORTRAN had a special named COMMON area that mapped to absolute memory location zero, so you could get at absolute memory using that. They didn't have any memory-mapped devices, but I think there were special PEEK and POKE functions to talk to the I/O ports like the way old-time BASIC programmers did.

So no language mods really required, just an additional low-level memory and I/O native class.

Although a true Java machine wouldn't really need these, since in these modern times, the kind of intelligent I/O device that once was almost unique to IBM mainframes is now common. You could probably get by with hardware designed for direct access from Java's I/O classes.
 
Consider Paul's rocket mass heater.
 
subject: is java good lang for kernel programmig?