New answers tagged

0

One way to approach it: Have a dictionary stored as a trie, and look things up in in, analogous to a spelling corrector. Missing spaces between words can be treated as just another misspelling.


0

Yes, indeed it is possible to have a useful language that isn't Turing complete. See here: http://tkatchev.bitbucket.org/tab/examples.html Another example of a useful Turing incomplete language is SQL. (And yet another is spreadsheets like Gnumeric or Excel, though they aren't really programming languages.) As to why you would want a language that isn't ...


0

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


0

As others have pointed out, everything is both an abstraction and a detail. The abstractions allow you to focus on understanding and manipulating the concepts involved while knowledge of the details allow you to implement them. To a solution architect, the progrmming language is just a detail, to a coder optimising a sort algorithm, a datatype is just an ...


2

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


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


0

As indicated in philipxy's answer, anything digital is an abstraction. Even the electrical engineering view of currents and voltages is an abstraction. I've worked as a computer architect, a compiler writer, and an operating systems developer. I have had the experience of writing Java programs I intended to run on a server I helped design. Cycle-by-cycle ...


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


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


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


0

The way concatenative or stack based languages generally use values is actually "read once", the difference being of course that there are no variables, just values on a stack. As you're relaying on the stack most of the time (variables are usually avoided), and values are consumed by the functions ("words") reading them, you have to explicitly duplicate ...


18

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


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


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


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


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


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


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


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


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


-3

Trial amd error. Actually, I doubt there's a resource without a proper documentation in it. If you really can't find what goes where, then you could type the function's name without parentheses in the chrome live console, and then, if the functiom is not a native function, then it prints out the source of the function.:


0

Although non-ASCII identifiers are supported in a large number of programming languages as 9000 and AhJian have said, it would be bad practice to use such and there are several reasons to do that. The first one is that in some moment in feature a foreign coworkers that don't understand the language can join the the team, or the code may need to be reviewed ...


0

I think that this question is somewhat wider than "can I write Kanji in my favorite programming language". For Java (and probably most other languages) Unicode is supported, and strings should be externalized to property files or similar. This lets you handle some common internationalization issues: The messages are required in multiple languages (well ...


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


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

Perhaps the most common example of late binding is resolving Internet URLs. It supports dynamic systems and large systems without trying to link and bind every site in the world before you can reach any, but on the other hand it does incur some overhead (DNS lookup, much less IP routing) at runtime. By that light, most varieties of binding in language ...


1

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


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


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.


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


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


1

Doesn't anything that mutates eventually manipulate state? Yes, but if it's behind a member function of a small class that is the sole entity in the entire system that can manipulate its private state, then that state has a very narrow scope. What does you should have to deal with as little state as possible mean? From the variable's standpoint: ...



Top 50 recent answers are included