3 ms·
> Shorter programs have less bugs[1], and run faster[2] I'd heartily disagree with that statement. Short programs can run faster, but that entirely depends on
by shakna 10y ago
> Shorter programs have less bugs[1], and run faster[2]
I'd heartily disagree with that statement.
Short programs can run faster, but that entirely depends on the implementation of the language/architecture that they're running upon.
Consider the following:
struct {
char msg[400];
double d;
int i;
};
struct {
double d;
int i;
char msg[400];
};
The code is nearly identical, only the order is different, but the second uses far far less memory than the first.
Secondly, shorter programs can be bug free, but that depends on the level of abstraction exposed, and how that translates into language that can be understood by those using it.
There's no shortage of regex bugs in the wild, and its a fairly concise language.
Perl has often been criticised for having too concise a language, leaving it prone to code rot.
However, all that being said, I think there needs to be a balance between abstraction, and mathematical analysis, and I would also say there hasn't yet been enough actual research into the effect of syntax, rather, syntax has been a result of the abstraction its presenting, or the underlying implementation the language relies upon.
We do need abstraction, parsing mathematic notation or estoric languages like Malbolge are difficult for the human brain, even with experience.
I mean, Brainfuck isn't that far from what a processor actually runs, being registers and jump statements, but...
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
We don't need a Turing Tarpit.
But neither do we need the insane amounts of boilerplate that Java forces upon you to do even the simplest things that Java is meant to be good at.
I think that in recent years, mathematics has given us the tools to build better syntaxes:
* Better type inference
* Better proofing of type safety
Though I think Scala's syntax is still overly verbose, DOT calculus is a great step in the right direction for being able to create a syntax with both zero cost abstractions, type safety, and a more concise syntax.
- eutectic 10y agoWith GCC, both those structs seem to have a size of 416 bytes. Can you elaborate on what you meant?
- shakna 10y ago32 or 64bit GCC? I was referring to Struct Padding[0]. Assuming a 32bit GCC, then the first would be padded with 24 bytes, the second with 16 bytes. This padding doesn't show up under size, but does affect speed in small ways, and available memory (yay for dealing with memory constrained systems!). [0] http://www.catb.org/esr/structure-packing/ http://www.catb.org/esr/structure-packing/
- eutectic 10y agoBut isn't each field a multiple of the word size on both 32 and 64-bit platforms?
- FreeFull 10y agoint will be smaller than double on x86_64 (edit: x86 too, and most other platforms), but since in both structs int comes after the double, that doesn't matter. 400 is a multiple of 8, so it doesn't matter if it's before or after the double either.
- userbinator 10y agoYou seem to be misunderstanding how padding is applied. As your link says regarding structure alignment: In general, a struct instance will have the alignment of its widest scalar member. ...which is d if we assume sizeof(double) == 8, so the total size will be rounded up to a multiple of 8. Both your structure examples will be exactly the same size: 0 msg 400 d 408 i 412 [+4 padding] 416 TOTAL 0 d 8 i 12 msg 412 [+4 padding] 416 TOTAL
- shakna 10y ago> On some processors, the addressing of a member is more efficient if its distance from the beginning of the structure is less than 128 bytes. > In the first example, to address the d and i fields using a pointer to the beginning of the structure, an offset of at least 400 bytes is required. > Instead, in the second example, containing the same fields in a different order, the offsets to address d and i are of few bytes, and this allows to use more compact instructions.