C or Java for Seismology Equipment: What's Best

Click For Summary

Discussion Overview

The discussion revolves around the choice between learning C or converting existing C code to Java for controlling seismology equipment. Participants explore the implications of each option, considering their familiarity with Java and the challenges associated with C programming.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant suggests that learning C is preferable to converting the software to Java, emphasizing that picking up C should be manageable for someone with a solid understanding of Java.
  • Another participant expresses concern about the time required to learn C, indicating a preference for an easier solution, although they acknowledge the need to learn C eventually.
  • It is noted that while C and Java have similar syntax, they differ significantly in programming paradigms, with C being procedural and Java being object-oriented.
  • Concerns are raised about the complexities of C, particularly regarding pointers and memory management, which are not as prevalent in Java.
  • One participant mentions the existence of translators that could convert C code to Java, suggesting that testing such a tool could be worthwhile.
  • Another participant warns that converting C code to Java is not straightforward and could lead to errors, advocating for learning C instead.
  • There is a suggestion that it might be possible to use Java for GUI development while calling C functions through Java Native Interface (JNI), although this is described as advanced.
  • Resources for learning C and understanding its nuances are shared, highlighting the differences in approach between the two languages.

Areas of Agreement / Disagreement

Participants generally do not reach a consensus on whether to learn C or attempt conversion to Java. There are multiple competing views regarding the feasibility and practicality of each approach, with some advocating for learning C and others suggesting potential alternatives.

Contextual Notes

Participants express varying levels of familiarity with C and Java, and there are references to specific programming challenges in C, such as pointer management and input handling. The discussion reflects differing opinions on the ease of transitioning from Java to C and the potential for using translation tools.

Who May Find This Useful

This discussion may be useful for individuals involved in programming for seismology equipment, particularly those weighing the benefits of learning C versus converting existing code to Java.

mgiddy911
Messages
331
Reaction score
0
I may be taking control of the running of some seismology equipment, which is run via C code. I know very very little about C code. Would it be better for me to spend the time to thoughroughly learn C, or could it be possible for me to convert the software to Java. I have a pretty god understanding of Java. If I knew the concepts behind the C code I may be able to formulate an dea of how to do the same thing with java.
Let me know what you think
 
Technology news on Phys.org
If you know Java thoroughly, picking up C should be a piece of cake. I personally wouldn't convert anything -- just learn C.

- Warren
 
Thank you for the suggestion, I sort of knew the answer was going to be just learn C, but I am very busy and it will take me a long time to learn C right now, i was hoping just somehow there'd be an easier way, But it looks like I'll just have to brush up on C, which I am assuming is going to be quite different than any programming I am used to.
 
The syntax of C is virtually identical to the syntax of Java, with the exception that C does not have classes or exceptions. Java syntax was actually chosen specifically because it would be familiar to C programmers. Don't worry, it probably won't be nearly as difficult as you might imagine. Picking up a second programming language is much, much easier than learning the first.

- Warren
 
Until he finds pointers...
 
Almost everything in java is a pointer. :-p
 
I would say going backwards (Java to C) would be much easier than the other way around.

I thought there is some tranlators that can convert C to Java (or at least C++ to Java which would work). You could look into that and give it a test run. As long as you save your original code, trying a translator couldn't hurt.
 
Java and C might look similar but they are a few light-years away. Most notably Java is an OOP language, C is not. Java makes it hard to screw things up while in C...

In C you must be very very careful. Even at simple things such as reading a line from the Console is pain. e.g. you should not use fgets function since the user can supply null input or gets() is also a dangerous function that can be overflown. Therefore you should use the getline() function but it is not part of the ANSI C only GNU C there is ... complicated even at simple things, and don't get me started on pointers...

You can't just automagically convert C program to Java and expect it to work. You can rewrite the same C program in Java but you should be very careful, it is very easy to make a copy paste error.

I would recommend you, if you have the programm running in C, learn good C programming and just use C to do the job.

On the other hand you can make a GUI or whatever in Java and call C functions from Java via the JNI but that is a bit advanced.

Controlling equipment? Maybe there is a "driver" for Java? I am only a bit familiar with EPICS but I know that you need not program in C, you can get a "driver" that enables you to program in Java (CAJ/JCA) and the driver then takes care of the C part.
 
I don't think it will be a piece of cake, to be honest. I went from Java to C and though the elementary syntax is the same, the general approach is very different. Especially since you'll be reading someone else's code. If the code is more than a small app, expect on spending some time on it. These will be helpful:
http://beej.us/guide/bgc/output/htmlsingle/bgc.html
http://www.cs.cf.ac.uk/Dave/C/
 
Last edited by a moderator:

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
2K
Replies
3
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
21
Views
14K
  • · Replies 33 ·
2
Replies
33
Views
9K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K