103

Basically because the designers of Java and similar languages didn't want undefined behavior in their language. This was a trade off - allowing undefined behavior has the potential to improve performance, but the language designers prioritized safety and predictability higher. For example, if you allocate an array in C, the data is undefined. In Java, all ...


101

Consider the following. var [Example Number] = 5; [Example Number] = [Example Number] + 5; print([Example Number]); int[] [Examples Array] = new int[25]; [Examples Array][[Example Number]] = [Example Number] Compare it with the more traditional example: var ExampleNumber = 5; ExampleNumber = ExampleNumber + 5; print(ExampleNumber); int[] ...


72

Undefined behaviour is one of those things that were recognized as a very bad idea only in retrospect. The first compilers were great achievements and jubilantly welcomed improvements over the alternative - machine language or assembly language programming. The problems with that were well-known, and high-level languages were invented specifically to solve ...


60

Is it a bad design for a programming language to allow spaces in identifiers? Short answer: Maybe. Slightly longer answer: Design is the process of identifying and weighting conflicting solutions to complex problems, and making good compromises that meet the needs of stakeholders. There is no "bad design" or "good design" except in the context of the ...


48

The answer to your question: Can every language be categorized as either compiled or interpreted? Is "No", but not for the reason you think it is. The reason is not that there is a third missing category, the reason is that the categorization itself is nonsensical. There is no such thing as a "compiled language" or an "interpreted language". Those terms ...


42

Undefined behavior enables significant optimization, by giving the compiler latitude to do something odd or unexpected (or even normal) at certain boundary or other conditions. See http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html Use of an uninitialized variable: This is commonly known as source of problems in C programs and ...


40

Embedding a language (I'll avoid characterizing it as "scripting") means that the following has been done: The interpreter and runtime are running in the same process as the host application Enough of the standard types and the standard library are also available from within that runtime Most times, the application has its own library available to the host ...


29

As a very high-level overview, the IDE contains a compiler. (Well, most parts of a compiler: it doesn't need to generate code or optimize, but all the rest is there, lexing, parsing, semantic analysis, type inference, type checking, macro expansion, symbol resolution, etc.) From the information gleaned from this analysis, the IDE constructs a semantic model ...


20

In C's early days, there was a lot of chaos. Different compilers treated the language differently. When there was interest to write a specification for the language, that specification would need to be fairly backwards-compatible with the C that programmers were relying on with their compilers. But some of those details are non-portable and do not make sense ...


17

The IDE understands the code. It is able to parse it and extract all the necessary information for autocomplete, like what classes are available, their names and all their members. The IDE team most probably had to implement this parsing themselves, or use private APIs in the compiler. And compilers do the same thing as their main function. The compiler ...


16

One relatively well-known example is of some Fortran code in which a single typo completely changed the meaning of the code. It was intended to repeat a section of code 100 times (with I as the loop counter): DO 10 I = 1,100 However, the comma was mistyped as a dot: DO 10 I = 1.100 Because Fortran allows spaces in identifiers (and because it ...


14

JVM and .NET languages have it easy: They don't have to be able to work directly with hardware. They only have to work with modern desktop and server systems or reasonably similar devices, or at least devices designed for them. They can impose garbage-collection for all memory, and forced initialization, thus getting pointer-safety. They got specified by a ...


14

Exact syntax matters less than you might think. In an interview, you can say something like: I don't remember in this language if a set.add returns a boolean indicating if the item was already in the set or not. It doesn't really matter for this problem because it's easily looked up, but assuming it does return that indication, this is how I would write it.....


13

If we are being pedantic, there is no such thing as a compiled or interpreted language, since any language could be in principle be implemented either by a compiler or an interpreter. However, most languages follow a relatively consistent implementation strategy. C++ is almost always compiled to native code. Python is almost always run via a bytecode ...


13

Behaviour is decisions being made. State is decisions being remembered. When OOP people talk about behaviour what they mean is the gooey sticky part of the code base that has to be changed every time a business rule changes. Rather than state, what this is usually contrasted with is dry structural cerimonial code that exists mostly because the system or ...


12

In absence of an answer of David Arno, who first emitted the hypothese, here a summary of the findings. It appears that the first programming language that offered underscores as digit separator in numeric literals was Ada. No evidence of a prior use in another language was found. Its use in Ada & historical evidence In the paper *The rationale of ...


10

I feel that c# has become a very wordy language and I'm not happy to have to code in the async style like this. Oh, but that is not wordy at all. You are not writting something like this: client.GetAsync("http://www.nzherald.co.nz/").Then ( response => response.Content.ReadAsStringAsync().Then ( pageContents => { ...


10

Isn't above code snippet is just different way of saying "how to solve" problem ? Yes. In the end, computer science is invariably about computing so you're always talking about "how to solve" a problem. But if you read the functional example a certain way: Len :: [Int] -> Int Len [] = 0 Len [x:xs] = 1 + Len(xs) "Length is a function that takes a list ...


10

The main factor is typically the API that's used by host applications to access the language libraries. Languages like Lua are designed to be easily 'connected to' from host applications. The language may be available in library form, the API easily callable from other languages (generally a plain C API). The API usually provides functions to run a script,...


10

In theory any language can be embedded. If there are no constraints on the solution, it is actually the case. It's natural consequence of Turing completeness i.e. you can always build an emulator. What I think you are asking is "what makes a language practical for this purpose?" I think one of the main things that makes a language a good choice for this ...


8

Java and C# are characterized by a dominant vendor, at least early in their development. (Sun and Microsoft respectively). C and C++ are different; they've had multiple competing implementations from early on. C especially ran on exotic hardware platforms, too. As a result, there was variation between implementations. The ISO committees that standardized C ...


8

Is it a bad design for a programming language to allow spaces in identifiers? You forgot important implementation details: what is source code for you? I like the FSF definition of it: the preferred form on which developers work. It is a social definition, not a technical one. In some languages and their 1980s implementation (think of original SmallTalk ...


7

Many functional languages have simple solutions for describing function types. The most common is a syntax rougly like the following, which is used to describe the type of any expression: expr: a where a is the type of the expression. If the expression has a type that is a function, it will be: expr: a -> b where a is the parameter type and b is the ...


7

The Name Derives from the Program/Process Created to Read it The most interesting answer I found on the subject suggest that the name of the language came as a result of the name of the program written to translate it to machine code. Quora.com user David Gish, who stated: "In the very early days of computing, programmers wrote code in binary machine ...


7

How does the IDE become context aware? Code completion and refactoring features are generally implemented by building an abstract syntax tree from the source code. The nodes of the AST represent things such as variables, operators and method calls. When you type foo., the IDE uses the AST to resolve the variable foo to the type Foo and then displays a list ...


7

JavaScript was originally used for tiny things. Often, your entire script would be inlined in your HTML onclick attribute. A large use of JavaScript would be two or three functions in the HTML header. I remember thinking why would anyone ever want to use the ability to put a script in a separate file. It makes zero sense to precompile something that small. ...


6

The real reason comes down to a fundamental difference in intent between C and C++ on one hand, and Java and C# (for only a couple of examples) on the other. For historical reasons, much of the discussion here talks about C rather than C++, but (as you probably already know) C++ is a fairly direct descendant of C, so what it says about C applies equally to C+...


6

The advantage of a 'pure' language of any paradigm is that you (ideally) don't have to keep reminding yourself to follow the paradigm since the language won't let you get anything done if you don't. For example, Java is a 'pure' structural language. Which is just a fancy way of saying it has no goto. Instead you have while, do while, for, break, and ...


6

It is not inherently bad design to allow spaces in symbol names. This can be shown with a simple counter-example. Kotlin allows spaces in names. It also has official coding conventions which state when it is ok to use this feature: Names for test methods In tests (and only in tests), it's acceptable to use method names with spaces enclosed in ...


6

There are a couple factors: whether the language has support for embedding API. Some scripting languages like Python and Lua has officially supported APIs specifically designed to embed those languages into a host application. This includes specifying how the language interacts with foreign function interface, foreign object handles, foreign classes, etc ...


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