This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes C / C++ and the fly likes C vs Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "C vs Java" Watch "C vs Java" New topic
Author

C vs Java

Venu Chakravorty
Ranch Hand

Joined: Aug 19, 2009
Posts: 46
What are the things that can be done in C and not in Java. Let's keep aside JNI.

Thanks and regards,
venu
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Depends on the Java implementation.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Pointer arithmetic. Returning multiple values from a method (through pointer variables). Creating objects (actually structs) on the stack instead of on the heap. Manually cleaning up memory*. Communicating directly with the OS and hardware platform.


* my onetime real-time Java project could really have used this. With little strain it ran for a few minutes, then crashed with an OutOfMemoryError because the garbage collection could not run.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Gert Jan Kruizinga
Greenhorn

Joined: May 09, 2010
Posts: 16
Yes, pointer math (or magic) is what i miss the most.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18914
    
  40

Gert Jan Kruizinga wrote:Yes, pointer math (or magic) is what i miss the most.


I used to miss it (in Java), but not anymore... In fact, I am more used to not using it, that I try not to do pointer arithmetic, even when I am working in C / C++.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Oh come on... you must miss writing neat little functions like this:
You just gotta love that!
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Rob Prime wrote:You just gotta love that!


Nope, I never loved that, even when I was writing PDP-11 assembler code. Note the PDP-11 and later Vax has single hardware instructions to implement the critical construct.

Using null delimited strings has been a huge source of evil bugs over the decades. And of course, it fails totally with non-ASCII data. The world is bigger than just the folks who speak English.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I miss it, although I still do enough embedded work that I don't have to miss it for very long :) What I *really* miss is making dynamic, extensible language implementations in resource-constrained systems a la Piumarta-style stuff, which makes use of pointer arithmetic. Quite enjoyable.
Gert Jan Kruizinga
Greenhorn

Joined: May 09, 2010
Posts: 16
Yes Rob Prime, that is what i miss, and it starts getting interesting if *dest points to the i/o space of an device.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Moving thread as not a "beginning Java" question.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
It's even more fun using FORTH the way I do it where I have to do pointer arithmetic directly on the stack!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Everything is more fun in Forth :)

If there's one language I truly miss working with, it's Forth, although I may take up Factor again. On an only vaguely-related note, I did get to work with actual PostScript for awhile when working at a high-speed printer manufacturer. In addition to the language, we also had really fast cameras to take pictures of how paper moved through the printer--before then I had never really given such thing any thought: paper physics. Crazy stuff.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
David Newton wrote:Everything is more fun in Forth . . .
Even the segmentation errors when you can't see where they happened.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: C vs Java