Hot answers tagged

141

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 ...


133

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 ...


105

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 ...


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, ...


50

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 ...


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 ...


32

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 ...


32

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. ...


24

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

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

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. ...


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. ...


16

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 ...


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 think there's more to this than simply that the workflow for ETL is typically I/O bound, not CPU bound; that's just the justification. The real issue here is development cost. C++ applications of comparable functionality are slower to build and harder to maintain than java ones. There are many reasons for this; poor C++ package management, low level ...


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 ...


14

In the C language expressions are typed inside-out: literals have types. E.g. 123 is an int, and 123U is an unsigned int, 123L is a long int and so on. The type of an expression depends on the types of the subexpressions: the type of a + b depends on the types of a and b. Ensuring the correct type is particularly important when doing bit-fiddling. You also ...


13

You are looking for the builder pattern. Essentially it's an object with setters where you can set the parameters for construction and a createResult() method that will create the object you are looking for (or fail if it wouldn't be valid). You can use it to contain the defaults for the properties and group some of them into a single setter. ...


13

Microdata is not dead. While Microdata will not become a W3C standard¹, it’s still part of WHATWG’s HTML Living Standard. Differences between JSON-LD, Microdata, and RDFa (in the context of HTML documents) Microdata and RDFa are conceptually similar: both syntaxes define attributes that get added to your existing HTML elements. JSON-LD is a syntax that ...


13

Every problem can be solved by adding an additional level of indirection. So do that. You can't delete part of an array in C++. But you can create a new array holding just the data you want to keep, then delete the old one. So you can build a data structure that allows you to "remove" elements you don't want from the front. What it will actually do is ...


13

Does storing plain text data take up less space than storing the equivalent message in binary? No, never. Your computer already stores the plain text data in the equivalent binary representation. Storing something as plain text versus binary just signals how the computer should interpret that identical binary stream. It seems to me like using letters ...


12

I have "inherited" a lot of legacy code using your first variant, and also written lots of code by myself using Point2D and Point3D classes instead (essentially the same what your Vector<int> is about). The first variant leads always to functions with too many parameters and too many repeated constructs where simple vector addition or scalar ...


12

The computer doesn't "know" what addresses are what, but the knowledge of what's what is baked into the instructions of your program. When you write a C program that writes and reads a char variable, the compiler creates assembly code that writes that piece of data somewhere as a char, and there is some other code somewhere else that reads a memory address ...


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