Hot answers tagged

1119

"Single Entry, Single Exit" was written when most programming was done in assembly language, FORTRAN, or COBOL. It has been widely misinterpreted, because modern languages do not support the practices Dijkstra was warning against. "Single Entry" meant "do not create alternate entry points for functions". In assembly language, of course, it is possible to ...


912

This notion of Single Entry, Single Exit (SESE) comes from languages with explicit resource management, like C and assembly. In C, code like this will leak resources: void f() { resource res = acquire_resource(); // think malloc() if( f1(res) ) return; // leaks res f2(res); release_resource(res); // think free() } In such languages, you ...


735

You can thank the IBM punch card for this limit - it had 80 columns:


506

It's running 2.5 million lines of C on a RAD750 processor manufactured by BAE. The JPL has a bit more information but I do suspect many of the details are not publicized. It does appear that the testing scripts were written in Python. The underlying operating system is Wind River's VxWorks RTOS. The RTOS in question can be programmed in C, C++, Ada or Java....


249

As oded mentioned, this common coding standard is a result of the IBM's 1928 80 column punched card format, since many coding standards date back to a time when programs were written on punch cards, one card/line at a time, and even the transition to wider screens didn't alter the fact that code gets harder to read the wider it becomes. From the wikipedia ...


223

There's a book in Russian, German Noskin, First computers (literally board digital computing machines) for space applications (Герман Носкин, Первые БЦВМ космического применения), ISBN 978-5-91918-093-7. The author himself participated in many early projects (mostly in hardware) and according to him analog hardware was in favor for a long time, he mentions ...


175

The code is based on that of MER (Spirit and Opportunity), which were based off of their first lander, MPF (Sojourner). It's 3.5 million lines of C (much of it autogenerated), running on an RA50 processor manufactured by BAE and the VxWorks operating system. Over a million lines were hand coded. The code is implemented as 150 separate modules, each ...


157

This depends on your definition of high-level and low-level language. When C was developed, anything that was higher-level than assembly was considered a high-level language. That is a low bar to clear. Later, this terminology shifted to the point that some would nowadays consider even Java to be a low-level language. Even within the high-level language ...


147

The problem is that #1 requires you effectively parse and interpret the entirety of the SQL variant you're working against so you know if it is doing something it shouldn't. And keep that code up to date as you update your database. Everywhere you accept input for your queries. And not screw it up. So yes, that sort of thing would stop SQL injection attacks,...


144

To answer the historical aspects of the question: The design philosophy is explained in The C Programming Language written by Brian Kernighan and C designer Dennis Ritchie, the "K&R" you may have heard of. The preface to the first edition says C is not a "very high level" language, nor a "big" one... and the introduction says C is a relatively "...


141

OOP did not invent encapsulation and is not synonymous with encapsulation. Many OOP languages do not have C++/Java style access modifiers. Many non-OOP languages have various techniques available to offer encapsulation. One classic approach for encapsulation is closures, as used in functional programming. This is significantly older than OOP but is in a way ...


117

It has appeared earlier. In fact, this was the original model of getting access to computing resources back in the 1950s till well into the 1980s, when it was called "time sharing", then in the early 1990s it re-appeared under the name "Client/Server", then in the late 1990s again under the name "Thin Client", then "Application Service Provider". However, ...


116

In short, there aren’t any particularly useful subtraction-like operations on strings that people have wanted to write algorithms with. The + operator generally denotes the operation of an additive monoid, that is, an associative operation with an identity element: A + (B + C) = (A + B) + C A + 0 = 0 + A = A It makes sense to use this operator for things ...


113

Because immutable collections absolutely require sharing to be usable. Otherwise, every single operation drops a whole other list into the heap somewhere. Languages that are entirely immutable, like Haskell, generate astonishing amounts of garbage without aggressive optimizations and sharing. Having collection that's only usable with <50 elements is not ...


109

As far as I understand, pipe is a system call which shares a piece of memory between two processes where one process writes and other reads from. Actually, there is no shared memory involved. The reader and writer are NOT sharing any part of their address space, and they are not using any explicit synchronization. The reading and writing processes are ...


102

As mouviciel and Emilio Garavaglia noted, the concept predates computing. However, the first instance of a software loop was the loop Ada Lovelace used to calculate Bernoulli numbers, as described in Note G of her translation of the Sketch of the Analytical Engine Invented by Charles Babbage, by L. F. Menabrea. The Analytical Engine's ability to loop is ...


98

0 is false because they’re both zero elements in common semirings. Even though they are distinct data types, it makes intuitive sense to convert between them because they belong to isomorphic algebraic structures. 0 is the identity for addition and zero for multiplication. This is true for integers and rationals, but not IEEE-754 floating-point numbers: 0.0 ...


97

Writing a compiler seems like a much harder problem than an interpreter. That might be true today, but I would argue that it was not the case some 60 years ago. A few reasons why: With an interpreter, you have to keep both it and the program in memory. In an age where 1kb of memory was a massive luxury, keeping the running memory footprint low was key. And ...


96

Pretty much all mature languages are defined by a specification, and compilers or interpreters attempt to follow the standard defined in that specification. But very rarely do they succeed, unless the standard is defined by the author of the language. You can find the C++ 2003 standard, the C# 4 specification, the Java 7 specification and many more online. ...


88

According to Wikipedia, Internet Protocol Version 5 was used by the Internet Stream Protocol, an experimental streaming protocol. The second version (of Internet Stream Protocol), known variously as ST-II or ST2, distinguishes its own packets with an Internet Protocol version number 5, although it was never known as IPv5. The Internet Stream ...


86

EDIT: Answer from Professor Guibas: from Leonidas Guibas guibas@cs.stanford.edu to of the "Red-Black" term mailed-by cs.stanford.edu hide details 16:16 (0 minutes ago) we had red and black pens for drawing the trees. I believe the term first appeared in "A dichromatic framework for balanced trees" from Leonidas J. Guibas and Robert Sedgewick in ...


86

Originally SQL language was called SEQUEL standing for Structured English Query Language with the emphasize on English, assuming it to be close in spelling to natural language. Now, spell these two statements as you'd spell English sentences: "From Employee table e Select column e.Name" "Select column e.Name From Employee table e" Second sounds closer to ...


86

There's certainly a noticeable trend towards functional programming, or at least certain aspects of it. Some of the popular languages that at some point adopted anonymous functions are C++ (C++11), PHP (PHP 5.3.0), C# (C# v2.0), Delphi (since 2009), Objective C (blocks) while Java 8 will bring support for lambdas to the language . And there are popular ...


81

On the one hand, single return statements make logging easier, as well as forms of debugging that rely on logging. I remember plenty of times I had to reduce the function into single return just to print out the return value at a single point. int function() { if (bidi) { print("return 1"); return 1; } for (int i = 0; i < n; i++) { if (...


80

Because option 1 is not a solution. Screening and filtering means rejecting or removing invalid input. But any input might be valid. For example apostrophe is a valid character in the name "O'Malley". It just have to be encoded correctly before being used in SQL, which is what prepared statements does. After you added the note, it seems you are basically ...


79

In a sense he was right. The original (pre-spec) versions of HTML, HTTP and URL were designed by amateurs (not standards people). And there are aspects of the respective designs ... and the subsequent (original) specs ... that are (to put it politely) not as good as they could have been. For example: HTML did not separate structure/content from ...


77

A mutable collection is not a subtype of an immutable collection. Instead, mutable and immutable collections are sibling descendants of readable collections. Unfortunately, the concepts of "readable", "read-only", and "immutable" seem to get blurred together, even though they mean three different things. A readable collection base class or interface type ...


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