Questions involving the design and structure of programming languages.
33
votes
13answers
9k views
How have languages influenced CPU design?
We are often told that the hardware doesn't care what language a program is written in as it only sees the compiled binary code, however this is not the whole truth. For example, consider the humble ...
1
vote
3answers
221 views
Why are the arguments for substring functions mismatched?
In many languages, the substring function works like this:
substring(startIndex, endIndex)
returns the substring from startIndex until endIndex-1 (if you view startIndex and endIndex as 0-based) / ...
4
votes
2answers
549 views
Whats the difference between an interpreted language and one compiled to a VM?
It occurs to me that there's not a heck of a lot of difference between
$>python module.py
And:
$>javac module.java
$>java module.class
The former compiles to an intermediate language ...
10
votes
8answers
928 views
Why aren't design patterns added to the languages constructs?
Recently I was talking with a colleague who mentioned that his company was working on adding the MVC design pattern as a PHP extension.
He explained that they wrote C code for adding Controllers, ...
2
votes
4answers
346 views
how can python interpreter recognize code block
The most unusual aspect of Python is that whitespace is significant
instead of block delimiters (braces → "{}" in the C family of languages), indentation is used to indicate where blocks begin and ...
2
votes
3answers
181 views
Implementing `let` without using a macro
I'm learning Lisp, and I've just gotten to let, which I don't quite understand (the implementation of).
A common definition for it is given in terms of lambda as a macro. However, nowhere have I ...
21
votes
7answers
2k views
Why are so many languages passed by value?
Even languages where you have explicit pointer manipulation like C it's always passed by value (you can pass them by reference but that's not the default behavior).
What is the benefit of this, why ...
8
votes
5answers
1k views
Benefits of classic OOP over Go-like language
I've been thinking a lot about language design and what elements would be necessary for an "ideal" programming language, and studying Google's Go has led me to question a lot of otherwise common ...
13
votes
8answers
2k views
Why is x=x++ undefined?
It's undefined because the it modifies x twice between sequence points. The standard says it's undefined, therefore it's undefined.
That much I know.
But why?
My understanding is that forbidding ...
1
vote
2answers
143 views
What are/would be the characterists and applications of a programming paradigm where functions can't have statements?
Suppose there is a language where, instead of statements, functions could only be defined in relation to other functions and operators such as partial application and composition. What would be the ...
6
votes
3answers
374 views
Is there a language where collections can be used as objects without altering the behavior?
Is there a language where collections can be used as objects without altering the behavior?
As an example, first, imagine those functions work:
function capitalize(str)
//suppose this ...
7
votes
3answers
770 views
Why do .NET modules separate module file names from namespaces?
In implementations of the Scheme programming language (R6RS standard) I can import a module as follows:
(import (abc def xyz))
The system will try to look for a file $DIR/abc/def/xyz.sls where $DIR ...
5
votes
1answer
139 views
Pythonesque global variable assignment
I'm designing a language with Pythonesque syntax, including casual creation of variables by assignment. I'm wondering at the moment exactly how to deal with assignment to global variables (and ...
9
votes
5answers
6k views
Why is Python slower than Java but faster than PHP [closed]
I have many times seen various benchmarks that show how a bunch of languages perform on a given task.
Always these benchmarks reveal that Python is slower then Java and faster than PHP. And I wonder ...
4
votes
6answers
628 views
why are both index[array] and array[index] valid in C?
For example consider:
int index = 3;
int array[4] = {0, 1, 2, 3};
then both index[array] and array[index] are valid expressions, much like *(index + array) and *(array + index).
In C arrays why is ...
6
votes
2answers
451 views
Programming languages, positional languages and natural languages
Some programming languages are modeled on machine code, like assembly languages. Other languages are modeled on a natural language, the English language. Others are not modeled on either machine code ...
4
votes
1answer
179 views
Querying types in a co- or contravariant way
I posted a c# feature request here; however, I do not get a lot of attention there. Therefore I am asking you here, what you think of it.
The in and out keywords in generic type declarations are ...
9
votes
3answers
890 views
Appropriate programming language to design music software
I want to design a software for my musical instrument which is a rhythmic one (there is no melody).
All I want these software to do is :
make the user able to compose music
play what user has ...
33
votes
18answers
2k views
Has whitespace in identifiers ever been idiomatic?
C# style suggests using CamelCase in identifiers to delimit words. Lisp tradition suggests using-dashes-instead.
Has there ever existed a programming language where using spaces in identifiers was ...
0
votes
2answers
315 views
Procedure or Event Driven Language For Education [closed]
I am here to ask a question that has been asked many times before. What programming language should I learn to become a intelligent conceptual programmer?
Many people agree, you do not have to ...
3
votes
3answers
206 views
Eliminating tab characters in a new language
I'm working on a new programming language, which determines structure with indentation instead of braces in the manner of Python and CoffeeScript. Obviously placing lines indented with spaces next to ...
0
votes
3answers
248 views
Why do different languages use different Code Line Delimiters? [duplicate]
Possible Duplicate:
Why are statements in many programming languages terminated by semicolons?
I just found out that R Programming Language, which is somewhat belong to the C family (I'm ...
61
votes
8answers
13k views
How were some language communities (eg, Ruby and Python) able to prevent fragmentation while others (eg, Lisp or ML) were not?
The term "Lisp" (or "Lisp-like") is an umbrella for lots of different languages, such as Common Lisp, Scheme, and Arc. There is similar fragmentation in other language communities, like in ML.
...
0
votes
3answers
215 views
Making money from a custom built interpreter? [closed]
I have been making considerable progress lately on building an interpreter. I am building it from NASM assembly code (for the core engine) and C (cl.exe the Microsoft compiler for the parser). I ...
5
votes
5answers
1k views
False friends? Keyword “static” in C compared to C++, C# and Java
To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different ...
2
votes
2answers
187 views
Good resources for language design
There are lots of books about good web design, UI design, etc. With the advent of Xtext, it's very simple to write your own language. What are good books and resources about language design?
I'm not ...
11
votes
7answers
643 views
Are operators clearer to read than keywords or functions? [closed]
It's a bit subjective, but I'm hoping to get a clearer understanding of what factors make an operator clear to use vs obtuse and difficult. I've been considering language designs recently, and one ...
10
votes
4answers
901 views
What did Ruby do right (or was it Rails)?
Most programming languages have some design decisions that influence their usage and applicability.
For example:
Python focused on maintainability/readability of code and had indentation be a part ...
2
votes
1answer
214 views
Giving variables default values vs. treating accessing an undefined variable as an error
Having messed around with several scripting languages and being a bit of a linguist, there seems to be a way to divide dynamically typed languages into two groups: languages that give variables a ...
7
votes
6answers
595 views
Please explain the benefit(s) of using an XML-based syntax (e.g. XAML) instead of normal source code (e.g. WinForms)?
First off, please note that this question is not about WPF vs. WinForms.
What are the highest-ranking benefits that led Microsoft to invent XAML in favour of the “old” approach of generating ...
10
votes
2answers
1k views
In hindsight, is basing XAML on XML a mistake or a good approach?
XAML is essentially a subset of XML. One of the main benefits of basing XAML on XML is said to be that it can be parsed with existing tools. And it can, to a large degree, although the (syntactically ...
10
votes
5answers
444 views
A language built specifically for building languages
As the title suggests, I'm wondering if there are programming languages that were built specifically for building new programming languages?
13
votes
8answers
1k views
Why is C++ still “hybrid”
On a related question, it has been clarified why C++ is not compatible with C in many aspects. However C++ is still a "hybrid"* language. And unfortunately, many programmers still consider C++ as a "C ...
10
votes
7answers
328 views
What is a good alternative to the name variable for a language that only has immutable references or labels?
For example, in functional languages, variables are single assignment and their values are immutable once assigned. So they have two states unbound and bound, once bound they can't be changed.
Is ...
3
votes
6answers
327 views
Would the concept of source code layers be of any use?
I'm talking about something like layers in photoshop, except they apply directly to the source code. For example, in pseudo-code... inventing what some project might look like - say a computational ...
9
votes
2answers
266 views
Developing a dynamic language
I have created several hand written compilers for very simple languages but now I want to try my hand at developing a dynamic language, similar to a simplified Python or Ruby. However, it was easy ...
11
votes
9answers
1k views
Greenspun's Tenth Rule, does every large project include a Lisp interpreter?
Greenspun's tenth rule (actually the only rule) states that:
Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of ...
0
votes
6answers
382 views
Syntax for goto labels
In C, C++ and some dialects of BASIC, goto labels are declared with the syntax label:. I'm working on a language that uses name: type as the syntax for variable declarations, so I'd prefer if possible ...
6
votes
4answers
390 views
Backquoted symbols, good or bad?
I'm designing a programming language which has three kinds of quoted entities: strings and characters as in C, and symbols (interned strings intended for use as lookup keys and such) which I consider ...
10
votes
5answers
583 views
Is there a specific purpose for heterogeneous lists?
Coming from a C# and Java background, I'm used to my lists being homogeneous, and that makes sense to me. When I started picking up Lisp, I noticed that the lists can be heterogeneous. When I started ...
9
votes
4answers
506 views
Literate programming, good/bad design methodology
I have recently found the concept of literate programming. And I found it rather intriguing. Yet I have not been encountered with claims that it is a bad way to structure a program. It seems not ...
9
votes
7answers
779 views
What are the features required for Object Orientation?
I am just wondering, what exactly are the features a language or a library must provide in order for it to be defined as 'Object Oriented'. Is Object Orientation something that can, more or less, be ...
0
votes
4answers
413 views
Why doesn't the DART language use a special character to identify variables?
I come from a PHP background and I have been considering looking at DART in more detail.
DART is an, open source, front-end/back-end, language for web development.
PHP has a special $ (dollar) ...
2
votes
2answers
597 views
What is the reason behind the if syntax of CoffeeScript?
In most other languages the condition comes before the statement to be executed when the condition is met. However, in CoffeeScript (and maybe some other languages) the syntax is:
number = -42 if ...
22
votes
2answers
3k views
Why is 'void' not allowed as a generic type in C#
What were the design decisions that argued in favour of void not being constructable and not being allowed as a generic type? After all it is just a special empty struct and would have avoided the ...
10
votes
2answers
577 views
Why does a Java source file bear the name of the public class it contains?
I am a newbie learning Java. In Java every source file must contain a public class and that source file should have the same name as that public class. Moreover, no source file can contain two public ...
4
votes
8answers
347 views
One-use variables - has any language ever had them?
A principle that I follow is that, when an identifier is established, it should be a signal to the reader that the value referred to is indeed an abstraction which will be used more than once. That ...
1
vote
3answers
330 views
Inc/dec vs +=/-=
I'm looking at a programming language design decision that's difficult to make precisely because there seems to be no objective basis for choosing one option over the other. The question is, given ...
20
votes
8answers
710 views
Why is there such limited support for Design by Contract in most modern programming languages?
I recently discovered Design by Contract (DbC) and I find it an extremely interesting way to write code. Among other things, it would seem to offer:
Better documentation. Since the contract is the ...
8
votes
6answers
947 views
How to verify/prove orthogonality of a programming language?
I know the concept of orthogonality, but from a programming language point of view, is there a way to verify/prove it?
For instance in C#, one can use public or static for a method signature. You can ...
