Hot answers tagged

40

Eventually, I thought you will become a better programmer knowing this because you'll know what's happening rather than assuming that everything is magic. These are not contradictory things. I have no idea how to pave a road, but I know that it is not magic. But a month ago, I came across this book called Structure and Interpretation of Computer ...


31

I know why abstraction is great, but doesn't that prevent you from learning how computers work? Certainly not. If you want to understand the abstractions at work, then study those abstractions. If you want to understand the low-level technical details of a real, physical, computer then study those details. If you want to understand both, study both. (In ...


20

No, abstractions don't prevent you from understanding how things work. Abstractions allow you to understand why (to what end) things work the way they do. First off, let's make one thing clear: pretty much everything you've ever known is at a level of abstraction. Java is an abstraction, C++ is an abstraction, C is an abstraction, x86 is an abstraction, ...


16

Static type systems are a kind of static analysis, but there are many static analyses that aren’t generally encoded in type systems. For example: Model checking is an analysis and verification technique for concurrent systems that allows you to prove that your program is well-behaved under all possible thread interleavings. Data flow analysis gathers ...


16

A key skill in programming is simultaneously thinking at multiple levels of abstraction. Another key skill is building abstractions; this skill uses the previous one. Low-level programming is valuable in part because it exercises and expands both these skills. SICP models and implements interpreters, simulators for a machine model, and a compiler to that ...


8

First, the very definition of compiled languages is suspicious (actually, it is language implementations that are mostly compiled - and some of them compile to bytecode, but even in most C implementatons the printf format string can be viewed as interpreted by the C standard library; so there is a continuous spectrum between interpreters and compilers). (In ...


8

You hit on one of the only reasons this is useful: mapping external data structures. Those include memory-mapped video buffers, hardware registers, etc. They also include data transmitted intact outside the program, like SSL certificates, IP packets, JPEG images, and pretty much any other data structure that has a persistent life outside the program.


7

This isn't a problem unique to JavaScript, or even just dynamic languages. For example, you might have the equivalent Java code: void init(Configuration conf) { ... } and then discover that Configuration is an final class with no public constructors and you're left searching around for how to obtain an instance of that class. Typically, looking at ...


5

I know why abstraction is great, but doesn't that prevent you from learning how computers work? Am I missing something? Go to a magic show and you'll be entertained but you won't understand how the tricks work. Read a book on magic and you'll learn how tricks work but you still won't be entertaining. Do both. Work hard. And you might be both. ...


5

I think you are creating a bit of a false dichotomy here. Haskell has monad comprehensions built into the language. One reason for that is the use of monads for imperative-style I/O. Therefore, the designers of Haskell decided to make it look mostly like a code block in a generic C-style language, complete with curly braces, semicolons and even return. The ...


4

There are several benefits, the obvious one is at compile time to ensure that things like function parameters match the values being passed in. But I think you are asking about what is happening at runtime. Keep in mind that the compiler will create a runtime that embeds knowledge of the data types in the operations it performs. Each chunk of data in ...


4

C is a low-level language, nearly a portable assembler, so its data structures and language constructs are close to the metal (data structures have no hidden costs - except padding, alignment and size constraints imposed by hardware and ABI). So C indeed does not have dynamic typing natively. But if you need it, you could adopt a convention that all your ...


3

What time is it? Is it time to become a know-it-all programmer or is it time to become a productive programmer? Knowing the abstraction layers that exist below those among which you work is a good thing, it grants you a better understanding behind the structure of your work and it will even allow creating better solutions. Yet, you do that, you study when ...


3

Software engineering has multiple levels of detail. Your question is "what is the most rewarding, worthy, interesting level?" It depends on your task or on what you want to be, what you care about. For big systems you should not care much about bit shifting and clock cycles. For embedded software running on a simple micro controller you will probably want ...


3

The abstractions we teach in computer science are the things which, historically, have been found most beneficial to most people writing most programs. You can't write a modern program in assembly, just due to the sheer size of modern programs and the time constraints business will place on a developer. You have to be ready to accomplish your goals without ...


3

First of all, while most modern operating systems prevent writing to code by default, all common systems provide a way of overriding this behaviour. This is necessary if you want to use a language or environment that has a JIT compiler (e.g. Java, .Net, node.js, etc.). So you don't need a specific os for this. Secondly, many existing languages provide ...


2

I don't have much background on why Scala designers made that particular wording choice, but in F#, local "do notation" equivalent is called a "computation expression". The reasoning behind that word choice is one of PR and marketing rather than any concrete technical reason. Haskell has a hard-earned reputation of being a language for academics, rocket ...


2

Language designers generally try to avoid adding new keywords, especially for language features added after the language has already gained some popularity. Every keyword they add is an identifier that programs aren't allowed to use for other purposes, so adding a keyword could potentially break existing programs. Language designers have to weigh the ...


2

You don't. That's the problem. When types are not declared on a method's arguments, and there isn't a comment on the code saying what it's expecting to receive, there are only two ways to figure out what it expects you to pass. Either examine the function itself and see what it's doing with the input, or look at documentation. (Or sample code, which is ...


2

@JonPurdy's answer is better, but I'd like to add a few more examples: Obvious: syntax checking linting Non-obvious: Rust enables the programmer to specify whether "bindings" are mutable, and enforces these constraints. This is sort-of related: some languages enable some code to be run at compile time, which means that many things that would otherwise ...


2

The short answer here is yes. However, I don't know enough about voice recognition APIs to provide you with code samples. I have played around with the .NET voice recognition API, and from what I remember I was able to set 'variable' commands, so the user could map what voice command did what. You're likely going to have to dive in and get your hands ...


1

Type analysis does not mean a lot. Agda is known to have a Turing-complete type system, very different (and much more difficult to compute) than ML languages (e.g. Ocaml).


1

Abstractions are necessary to manage complexity, which is the Nemesis of all programmers. It's just as important to learn using abstractions as it is to learn the details behind them. A solution to a real-world problem needs to have a representation that closely resembles the model of the problem. It's why a dice game has a class called Die with a method ...


1

You might like to read Zen and the Art of Motorcycle Maintenance which addresses this very question. The conclusion that it arrives at is that you should aim to generate the greatest 'Quality' at the level(s) of abstraction that you choose. Sometimes this means understanding more about the levels above and below you, but generally you won't be able to master ...


1

On the other end of the spectrum is another book that often gets praised as a classic of how to teach algorithms: Donald E. Knuth’s Art of Computer Programming. DEK gave all his algorithms in a (fake, abstracted) machine language, because in his view, programmers will tend to write code that’s simple and efficient in the language they’re using, and the size ...


1

Dynamically typed or not, it's best to consult documentation and/or examples. Even if you know what type a parameter is, it's often quicker and safer to base your code off of an example, with more detailed documentation on hand, than it is to assume you know what you're doing based on the parameter type. Otherwise, you're just making assumptions and ...



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