ascii VS binary files

M

miki

hello,
I was asked this question during a job interview, and didn't know the answer.
could someone please help me with that?
the question was: "Which files are more suitable for working in C, ascii or binary?"

10-x all,
Miki
 
R

Richard Bos

I was asked this question during a job interview, and didn't know the answer.
could someone please help me with that?
the question was: "Which files are more suitable for working in C, ascii or binary?"

Get out of there. If they think that question even _has_ a simple
answer, you don't want to be working for them, it'll be a Dilbert
environment. Unless, of course, they know very well that the answer is
"both; which you use depends entirely on the application", and were
trying to trick you; in which case, ditto.

Richard
 
E

Eric Sosman

Richard said:
Get out of there. If they think that question even _has_ a simple
answer, you don't want to be working for them, it'll be a Dilbert
environment. Unless, of course, they know very well that the answer is
"both; which you use depends entirely on the application", and were
trying to trick you; in which case, ditto.

One way to get an idea of someone's abilities is to
ask a superficially simple question of this sort and see
whether the respondent can peel a few layers from the onion.
C.f. Clifford Stoll's retelling (in "The Cuckoo's Egg") of
his oral examination for his PhD in something astronomical:
One of his examiners asked "Why is the sky blue?" Stoll says
he felt relieved to get such a simple question -- but the
relief soon vanished. The guy kept asking "Can you be more
specific?" and Stoll found himself filling blackboard after
blackboard with equations of quantum electrodynamics ...

It's a mistake to assume too much about an interviewer's
reasons for asking a question.
 
D

Dan Pop

In said:
One way to get an idea of someone's abilities is to
ask a superficially simple question of this sort and see
whether the respondent can peel a few layers from the onion.
C.f. Clifford Stoll's retelling (in "The Cuckoo's Egg") of
his oral examination for his PhD in something astronomical:
One of his examiners asked "Why is the sky blue?" Stoll says
he felt relieved to get such a simple question -- but the
relief soon vanished. The guy kept asking "Can you be more
specific?" and Stoll found himself filling blackboard after
blackboard with equations of quantum electrodynamics ...

Probably a fake story. Or the guy was unable to provide a simple answer
to a simple question. Classical electrodynamics is enough for the
dispersion of electromagnetic radiation in air and the law governing
it is well known. Once you have invoked it and pointed out that,
according to it, higher frequencies are dispersed more than lower
frequencies (and that blue light is toward the high end of the visible
light frequency spectrum), you can't be more specific than that. Maybe
a little colorimetry is needed to explain why blue and not violet.

Dan
 
D

Darrell Grainger

hello, I was asked this question during a job interview, and didn't know
the answer. could someone please help me with that? the question was:
"Which files are more suitable for working in C, ascii or binary?"

Why do you think there is ONE answer? My first thought is, why would
someone ask this question. I can come up with some theories. The
possibilities are endless though. It could be the interviewer wants
someone who asks questions. It could be they believe there is one answer
to this question. It could be the interview is bored, decided they don't
want to hire you and are just messing with you now.

The list can go on and on. I'd just tell him what I think is the right
answer. I might ask a few questions myself (never be afraid to ask for
clarification). In the end, I'd ask the interviewer what they were
expecting from that question.
 
M

Martin M. Pedersen

Richard Bos said:
or binary?"

Get out of there. If they think that question even _has_ a simple
answer, you don't want to be working for them, it'll be a Dilbert
environment. Unless, of course, they know very well that the answer is
"both; which you use depends entirely on the application", and were
trying to trick you; in which case, ditto.

It could be a trick question. In C you have no concept of ascii files. You
have text file and binary files.

Regards,
Martin
 
S

Stephen L.

miki said:
hello,
I was asked this question during a job interview, and didn't know the answer.
could someone please help me with that?
the question was: "Which files are more suitable for working in C, ascii or binary?"

10-x all,
Miki


Without knowing too much about the rest of your
interview, I speculate that the question may
represent a _bias_ against one or the other.

I worked at a company that did their
Middleware as binary but were unsuccessful.
The project managers' perception was that
binary was inherently bad. After a staff
replacement (no kidding), they switched to ASCII.

Even though the bandwidth was reduced significantly,
it was "better". It's difficult to understand
their viewpoint, but it wasn't based on
any sound judgment I'm aware of...


-
Stephen
 
M

Malcolm

Richard Bos said:
Get out of there. If they think that question even _has_ a simple
answer, you don't want to be working for them, it'll be a Dilbert
environment.
You just don't know. If they expect a one word "right" answer then I agree
that the job is probably not worth having. However if they expect you to
talk intelligently about the advantages of each (text is portable, and is
easy to examine by a human, however a binary file is usually portable enough
if specifed correctly, is usually easier to parse, and is more compact) then
I don't see anything wrong with the question.
 
R

Roman Ziak

miki said:
hello,
I was asked this question during a job interview, and didn't know the answer.
could someone please help me with that?
the question was: "Which files are more suitable for working in C, ascii or binary?"

10-x all,
Miki

Interesting discussion indeed:

With standard C, one can store and retrieve even complex data structure (not
containing memory references) or array of these structures with single ANSI
C call. Assuming the same platform endianity, alingment and padding.

I guess somebody can say the same about ASCII files using printf() / scanf()
.... however, arbitrary size arrays will require more than single call.

Anyway, my answer to the question above would be binary.

Roman
 
S

Scott Moore

miki said:
hello,
I was asked this question during a job interview, and didn't know the answer.
could someone please help me with that?
the question was: "Which files are more suitable for working in C, ascii or binary?"

10-x all,
Miki

The answer is, the guy interviewing you does not know C. You have a %50/%50 shot of
getting the answer he wants to hear.

--
Samiam is Scott A. Moore

Personal web site: http:/www.moorecad.com/scott
My electronics engineering consulting site: http://www.moorecad.com
ISO 7185 Standard Pascal web site: http://www.moorecad.com/standardpascal
Classic Basic Games web site: http://www.moorecad.com/classicbasic
The IP Pascal web site, a high performance, highly portable ISO 7185 Pascal
compiler system: http://www.moorecad.com/ippas

Being right is more powerfull than large corporations or governments.
The right argument may not be pervasive, but the facts eventually are.
 
K

Kenneth Brody

miki said:
hello,
I was asked this question during a job interview, and didn't know the answer.
could someone please help me with that?
the question was: "Which files are more suitable for working in C, ascii or
binary?"

"Both, and neither."

This cannot be answered without knowing what the files are to be used for.

Think of the C compiler itself, which is probably written in C. It takes
text source files and creates binary object files. (Though I suppose
that even this might be 'implementation dependent".) It doesn't make much
sense to use binary source files, and it makes even less sense to make
text object files. (Though again, this is a simplification, since the C
compilers I have used on *nix systems actually create text files of
assembler source code. Of course, this is then passed to the assembler
[probably written in C] which takes the text assembler source and then
creates the binary object file.)

Some files are naturally text format, and some are naturally binary, and
which type you use depends on the file's purpose, and not on C.

Are you sure you want to work for a place that thinks the question has an
answer? (Unless the question was meant to get you to thinking about the
concepts of text-vs-binary, and to give more than a simple answer. But,
what are the odss of that?)
 
K

Kenneth Brody

Eric Sosman wrote:
[...]
One way to get an idea of someone's abilities is to
ask a superficially simple question of this sort and see
whether the respondent can peel a few layers from the onion.
C.f. Clifford Stoll's retelling (in "The Cuckoo's Egg") of
his oral examination for his PhD in something astronomical:
One of his examiners asked "Why is the sky blue?" Stoll says
he felt relieved to get such a simple question -- but the
relief soon vanished. The guy kept asking "Can you be more
specific?" and Stoll found himself filling blackboard after
blackboard with equations of quantum electrodynamics ...

It's a mistake to assume too much about an interviewer's
reasons for asking a question.

ObRemindsMeOfAStory:

Young boy asks his father "where did I come from?" Father goes through
the whole "birds and bees" story. Father asks son "do you have any more
questions?" Son says he does, and asks "Billy says he comes from New
Jersey, and I want to know where I came from."
 
K

Kenneth Brody

Dan said:
Probably a fake story. Or the guy was unable to provide a simple answer
to a simple question. Classical electrodynamics is enough for the
dispersion of electromagnetic radiation in air and the law governing
it is well known. Once you have invoked it and pointed out that,
according to it, higher frequencies are dispersed more than lower
frequencies (and that blue light is toward the high end of the visible
light frequency spectrum), you can't be more specific than that. Maybe
a little colorimetry is needed to explain why blue and not violet.

I thought everyone knew why the sky is blue: because if it were green,
we wouldn't know where to stop mowing.
 
R

RoSsIaCrIiLoIA

hello,
I was asked this question during a job interview, and didn't know the answer.
could someone please help me with that?
the question was: "Which files are more suitable for working in C, ascii or binary?"

ascii
 
D

Dr Chaos

Probably a fake story. Or the guy was unable to provide a simple answer
to a simple question. Classical electrodynamics is enough for the
dispersion of electromagnetic radiation in air and the law governing
it is well known. Once you have invoked it and pointed out that,
according to it, higher frequencies are dispersed more than lower
frequencies (and that blue light is toward the high end of the visible
light frequency spectrum), you can't be more specific than that.

Examiner: "you've shown me what the response to scattering in air is.
But still, why is the sky *blue*?"

You need then to assert the Planck black body law for the photosphere
of the Sun (which requires quantum mechanics somewhere)---but then
probably also an examiner will ask you to justify certain assumptions
and pursue what happens if you want a more detailed calculation
(e.g. the QED formulation perhaps to justify the black body law, and
some physical reasoning about scattering lengths to justify the black
body).

A tougher followup on the classical end is to then ask, we know the
sky is blue but how will it look through polarized sunglasses?"
 
D

Dr Chaos

The answer is, the guy interviewing you does not know C. You have a %50/%50 shot of
getting the answer he wants to hear.

Or it was a trick question to weed out bullshitters, and a good reply is
"neither, C has specific capability for stream-oriented I/O as opposed
to strictly record-oriented I/O, but makes little distinction between
ASCII or binary."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top