Hot answers tagged

140

Temporary files have to be stored into the operating system temporary directory for several reasons: The operating system makes it very easy to create those files while ensuring that their names would be unique. Most backup software knows what are the directories containing temporary files, and skips them. If you use the current directory, it could have an ...


134

Plaintext is binary. When you write an H to a hard drive, the write head doesn't carve two vertical lines and a horizontal line into the platter, it magnetically encodes the bits 010010001 into the platter. From there, it should be obvious that storing plain text data takes up exactly the same amount of space as storing binary data. But plaintext is just ...


122

To address the question you've posted in several comments(which I think you should edit into your post): What I don't understand is how does the computer know lets when it reads a variable's value from and address such as 10001 if is an int or char. Imagine I click on a program called anyprog.exe. Immediately the code starts executing. Does this exe file ...


106

The word you are looking for is not "bit" but "symbol." "Symbol" is the word used to describe the process of mapping hardware signals (such as voltages or magnetic patterns) into logical bits. If a symbol may have 4 states, it can encode 2 bits worth of information. Of course, we aren't saying anything about the resource usage of the symbol in that ...


62

The garbage collector does scan the stack -- to see what things in the heap are currently being used (pointed to) by things on the stack. It makes no sense for the garbage collector to consider collecting stack memory because the stack is not managed that way: Everything on the stack is considered to be "in use." And memory used by the stack is ...


59

Of course it is possible, both theoretically and practically. Theoretically, there are two classes of alternatives: digital number systems with a base other than 2 (in fact, the decimal system as we know it is one such system); and non-digital number systems. Mathematically speaking, we're talking about discrete vs. continuous domains. In practice, both ...


58

What you describe, "smoothing by fives", is a finite impulse response (FIR) digital filter. Such filters are implemented with circular buffers. You keep only the last N values, you keep an index into the buffer that tells you where the oldest value is, you overwrite the current oldest value with the newest one at each step, and you step the index, ...


51

First name and last name are not useful concepts. Names work differently in different countries. In most Asian countries, the family name is written first, but it is still used for sorting—so you may put it in first name, and sorting will be wrong, or in last name, and display will be. And then there are countries like Iceland where they don't use family ...


43

I think your main question seems to be: "If the type is erased at compile-time and not retained at runtime, then how does the computer know whether to execute code wich interprets it as an int or to execute code which interprets it as a char?" And the answer is … the computer doesn't. However, the compiler does know, and it will have simply put the correct ...


42

Since static members are shared between ALL instances of a class, they have to be defined in one and only one place. Really, they're global variables with some access restrictions. If you try to define them in the header, they will be defined in every module that includes that header, and you'll get errors during linking as it finds all of the duplicate ...


33

Should I insist saving to /tmp is the right approach and defend for any failure as "working as intended" (ie. ask your admin for proper permission access)? There are standards for this, and the best thing you can do is conform to them. POSIX, which is followed by pretty much every non-mainframe OS of any significance that you're likely to run into, has ...


31

I'm currently working on a mobile/desktop/distributed app with exactly the same requirements and issues. First of all, these requirements are not inherent to mobile apps per se, but to any disconnected/distributed client-server transactions (parallel programming, multithreading, you get the point). As such they are, of course, typical issues to address in ...


31

The only argument that matters is what are the requirements of your system? Do you need to deal with just one culture? If so, conform to that culture. Otherwise plan for internationalization (as others have pointed out). Do you need to get data to deal with government forms, healthcare or other legal / system requirements? Follow whatever those dictate. ...


26

You're basically describing an analog signal, which are used in sensors, but rarely for internal computations. The problem is noise degrades the quality, you need very precise calibration of a reference point that is difficult to communicate, and transmission is a problem because it loses strength the farther it travels. If you're interested in exploring ...


21

If the data never changes and is read only, then just put it in a code file as a list of constants. public readonly string AppStartUpData = "MyAppNeedsThis"; If this data is different per deployment, then an external file is fine. .Net comes with built in .config files (App.Config). One should use those as there are standard ways (built in to the ...


21

Assuming for a moment that the general performance difference is true... Java has more mature data manipulation libraries. Java has mildly sane string manipulation. Java has a wider userbase. Java will generally be written correctly faster. ETL processes will be disk bound, so speed of your runtime doesn't matter. ...and when your processes take a few ...


21

One quarternary memory cell can store exactly as much information as 2 binary memory cells: Quaternary Binary 0 00 1 01 2 10 3 11 So if you have same number of memory cells, but they are quarternary, then you have twice as much memory. But if this quad cell takes twice as much space on a chip, then there is no benefit. ...


20

Those are called qubits, and are used in quantum computers. You'll find more information about them on the wikipedia entry. Research is being done to make such computers that are stable and economically feasible.


19

Turn your question around. The real motivating question is under what circumstances can we avoid the costs of garbage collection? Well, first off, what are the costs of garbage collection? There are two main costs. First, you have to determine what is alive; that requires potentially a lot of work. Second, you have to compact the holes that are formed when ...


17

A matter of accuracy One reason we use bits is that it helps us store and retrieve information accurately. The real world is analog, therefore all the information computers pass or store is ultimately analog. For example, a current of a specific voltage on a wire, or magnetic charge of a specific strength on a disk, or a pit of a specific depth on a laser ...


16

Nine times out of ten, when you structure your code/models well, optimization will become obvious. How many times have you seen a hornets nest and found it totally suboptimal, where upon restructuring it, lots of redundancies became extremely obvious. A designer knows he has achieved perfection not when there is nothing left to add, but when there is ...


16

Marking a record as deleted is known as soft-deleting. I've never heard an alternate phrase for updating, but I guess that's cause you soft-delete the old record and create a new one. It should be noted, this is a controversial technique. See links: Con vs Pro.


16

Using fscanf() in itself probably explains most of it. fscanf() has to interpret the passed-in format string, and then has to scan the input stream from the file, trying to match the specified pattern. That's actually a huge amount of work. read() just has to read in the specified number of bytes from the file and doesn't have to do any parsing of the input. ...


15

I think the limitation you have considered is not related to semantics (why should something change if the initialization were defined in the same file?) but rather to the C++ compilation model which, for reasons of backward compatibility, cannot be easily changed because it would either become too complex (supporting a new compilation model and the existing ...


15

If the tests are useless without the setup files that you have prepared, then it makes sense to include the files in your VCS along with the test code. While the files used in the test aren't code, you can view them as a dependency that the code relies upon. So there is merit in keeping everything together. As a counterpoint, some VCSs don't handle large ...


15

You can always add a file into your project and set its build type to Embedded Resource so that it is embedded directly into the application itself. Alternatively a file that is encrypted and placed in an accessible location.


15

I find this a great fun thing to think about. Binary is not 1s and 0s in the way you talk about it. Imagine there is a quantity, I can tell you what quantity it is in many different ways: Nine in English Neuf in French 9 in Arabic numerals IX in Roman numerals 1001 in Binary with Arabic numerals on off off on in Binary with on/off high low low high in ...


14

A binary file would be the obvious answer, but it depends on how you are loading it - you might as well make life easy for yourself if you can. XML might be a good choice as there are built in methods in C# for reading this. You could add a checksum to your data, so that if the user alters it, the checksum will no longer match (you need to add a check to ...


Only top voted, non community-wiki answers of a minimum length are eligible