Questions involving the design and structure of programming languages.

learn more… | top users | synonyms

4
votes
2answers
256 views

Good resources for language design [closed]

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 ...
4
votes
2answers
1k views

Simplifying C++11 optimal parameter passing when a copy is needed

It seems to me that in C++11 lots of attention was made to simplify returning values from functions and methods, i.e.: with move semantics it's possible to simply return heavy-to-copy but cheap-to-...
4
votes
2answers
445 views

What has been learned about making variance part of the type?

In Java, the variance of parameterized types is indicated depending on how it's used: <A extends B,B> void store(ArrayList<B> list, A elem) { list.add(elem); } Whereas in Scala it ...
4
votes
2answers
998 views

What is the logic behind the use of different arrows (-> <-) in Haskell?

I've been thinking about language design lately, and reading over some of the new things in Haskell (always a nice source of inspiration). I'm struck by the many odd uses of the left <- and right -...
4
votes
1answer
185 views

Is there a better alternative than abusing the IDisposable pattern?

Consider the following (Microsoft-sanctioned) code: <% using (Html.Form<HomeController>(action=>action.Index())) { %> <input type="text" id="search" /> <input type="...
4
votes
2answers
120 views

A question about implementing objects in a language written in C

I'm fairly new to programming (about four months learning), and have decided to mess about with an attempt at writing a language in C for both fun and practice, and am wondering how objects are ...
4
votes
2answers
61 views

Type of multi methods in a static object-functional language

I'm currently working on expanding the capabilities of my pet programming language project's type system, and have come across an interesting area where my research into other language's type systems ...
4
votes
1answer
723 views

Why Does F# Contain Both Modules and Namespaces?

I've been assuming that F# includes the module keyword in addition to the namespace keyword due to backwards compatibility with OCaml. Is this the only reason for the inclusion of the module keyword ...
4
votes
1answer
207 views

What would break if there was an option to make undefined not convert to any other type in JavaScript?

The biggest issue I run into in JavaScript is silent typos. For example, the other day I had a variable inIframe. Somewhere else I typed isIFrame. 10-15 mins of debugging later I found it and changed ...
4
votes
2answers
138 views

What do you get when you cross a multi-precision integer with a floating-point number?

I'm working on adding multi-precision integers to the suite of numeric types in my APL interpreter, but I'm not sure what to do about the odd type-combinations that now arise. I now have the following ...
4
votes
1answer
384 views

Why double colon instead of dot?

It is rumoured that early C++ implementations have had dot operator for namespace access. There is an opinion that the dot is more convenient that the modern double colon operator. What was the ...
3
votes
6answers
488 views

Is there a language that allows this syntax: add(elements)at(index); [duplicate]

Possible Duplicate: Is there a language out there in which parameters are placed inside method name? Does a language exist with such a syntax? If not, what are some of the limitations/...
3
votes
5answers
1k views

Why is an interface in Java not allowed to have state?

There must be a good reason why Java designers didn't allow any state to be defined in interfaces . Can you please throw some light on this aspect of design decision ?
3
votes
6answers
1k views

Why is PHP's method of comparing different types bad?

I'm working on designing a new programming language and trying to decide how I will do variable comparisons. Along with many different types of languages, I've used PHP for years and personally had ...
3
votes
3answers
294 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 ...
3
votes
4answers
554 views

Why are cases in a switch statement not isolated? [duplicate]

As far as I can tell in all C-like languages something like this: switch(variable) { case 'a': printf("Hello "); case 'b': printf("World!"); case 'c': printf("\n");...
3
votes
4answers
2k views

Why many programming languages have only 2 data-structures: arrays and hashes?

Many programming languages have only those 2 structures, and even some languages that have more structures still only provide special syntax for those 2; usually, [] and {}. Why is this? Is there ...
3
votes
3answers
1k views

Does macros support make Scala a Lisp dialect?

I've read recently that macro support in Scala is now official. I checked the documentation page and they are reminiscent to the LISP ones. In one of his essays Paul Graham writes that when "you add ...
3
votes
4answers
440 views

Why does the type go after the variable name in modern programming languages?

Why is it that in nearly all modern programming languages (Go, Rust, Kotlin, Swift, Scala, Nim, even Python last version) types always come after the variable name in the variable declaration, and not ...
3
votes
3answers
385 views

Does a Completely Full-Featured Intermediate Language Exist?

Often when translating between languages (whether with program translation or compiling) it's a one-way, destructive translation. The functionality of the "port" isn't lost, but some of the intent ...
3
votes
3answers
4k views

What are the advantages of pass by value?

I always thought pass by value is a legacy from the early languages, because the designers had never seen anything else. But after seeing the brand new languages like Go adapting the same principle ...
3
votes
3answers
176 views

Why don't languages that have big integer support have unsigned versions?

A cursory glance at C#, Java, and other languages indicates this is not a feature that's required. I tried searching for justification for this maybe from a language design team or blog, but I haven't ...
3
votes
2answers
424 views

How much inconsistency arises from Javascript's high flexibility?

I'll admit it, I haven't yet mastered the language, but my experience with it tells me that Javascript is a highly flexible language, allowing prototypal inheritance, dynamic typing, functions as ...
3
votes
1answer
347 views

In C++, why does the main function use 'char *argv[]'?

I was wondering why C++ uses the following function prototype for the main() function: int main(int argc, char *argv[]); instead of something like: int main(std::vector<std::string> argv); ...
3
votes
2answers
4k views

Why does JavaScript count array lengths by the last index?

JavaScript seems to calculate the array length property by the number of the last index in the array rather than counting the number of items in the array. Example: var testArray = ['a', 'b', 'c']; ...
3
votes
3answers
495 views

Readability vs minimalism/compactness/conciseness in language design: are they antagonistic?

Currently, there is a discussion in the PHP-Internals mailing list regarding the implementation of a short syntax for arrays and objects, mainly [1, 2, ...] for standard arrays, ['one'=>1, 'two'=&...
3
votes
2answers
323 views

Comparison of languages by usage type? [closed]

Does anyone know of a good place to go find comparisons of programming languages by the intended platform/usage? Basically, what I want to know, is of the more popular languages, which ones are meant ...
3
votes
5answers
730 views

Should sanity be a property of a programmer or a program? [closed]

I design and implement languages, that can range from object notations to markup languages. In many cases I have considered restrictions in favor of sanity (common knowledge), like in the case of ...
3
votes
3answers
750 views

Why did Apple choose to design its programming language with future and past tense method names?

There are a lot of methods like this in iOS/Objective C: - viewDidLoad - viewWillAppear: - applicationDidFinishLaunching I've just been having a discussion with some colleagues about this design ...
3
votes
3answers
443 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 ...
3
votes
3answers
3k views

Banning zero-argument functions — what problems could it cause in a hypothetical language?

I'm creating a programming language as a hobby, but I encountered a problem with designing its syntax. The problem is the conflict between the syntax for defining zero-argument functions and the ...
3
votes
4answers
214 views

Would implementing a “Throwable Event System” be abusive?

I have been thinking for a couple years now about using Throwable events and implementing a sort of event system that uses throw to dispatch an event, or let a different method handle it with throws. ...
3
votes
1answer
1k views

Is it possible to write a code without class methods, globals, and class variables? [closed]

I'm designing my own programming language for fun, and I'm thinking of making it fully Object-oriented (no statics, no globals, no class variables, no class methods), so I need to find a way to ...
3
votes
1answer
201 views

feature request in language design?

How do language designers decide when a feature should go in a library as an extension or when it needs to have support from the core language?
3
votes
2answers
245 views

Greater than or identical to?

While browsing my code in a weakly-typed language I was seeing that I've trained myself to use identity (===) where logical. Then I came across a greater (or less) than or equal to (>=), and it ...
3
votes
1answer
391 views

Question about Java nested classes design decision

I was shocked today to discover that this code compiles cleanly in Java: public class A { public static class B { private static void x() {} } private static class C { private /* So, ...
3
votes
1answer
129 views

Documentation Generation - FiM++

This is a question I originally asked on Stack Overflow, but as a conceptual design question as opposed to a technical issue, I believe it may be more appropriate, or possibly have alternate parallel ...
3
votes
2answers
557 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 ...
3
votes
2answers
183 views

Why aren't field-like events implemented as a list of delegates?

tl;dr: Why are field-like events implemented as a single delegate field? Wouldn't it be more straight-forward to use a list of delegates, thereby eliminating the null special case and avoiding all the ...
3
votes
6answers
371 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 ...
2
votes
3answers
429 views

Is `isNaN`' a bad design or a has-to-be design with tradeoffs?

My first programming language is python. And recently I'm learning C and javascript. In javascript, there is a design which confused me a lot, default the function isNaN. Put aside its weird ...
2
votes
4answers
939 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 end....
2
votes
3answers
715 views

Why did the Sun engineers decided to make Java only call by value? [closed]

Is there any specific reason they decided to go with Call by value? Is it for simplicity?
2
votes
4answers
443 views

“Imprinting” as a language feature?

Idea I had this idea for a language feature that I think would be useful, does anyone know of a language that implements something like this? The idea is that besides inheritance a class can also ...
2
votes
4answers
153 views

Is the var token necessary to signal variable declaration?

When creating a variable foo, Python lets you just write foo = bar. However many languages, like C# or JavaScript, require additional syntax like var foo = bar or foo := bar to signal the same thing. ...
2
votes
2answers
260 views

Are multi-line comments a critical facility in a modern language?

I'm trying to convince the designers of a language that multi-line comments with an arbitrary start and end are important, and should be included. Currently there is only a "comment-to-end-of-line" ...
2
votes
3answers
412 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) / ...
2
votes
3answers
969 views

What could be the advantages and disadvantages of decay of Nd arrays to N-level pointers?

I have been thinking of a couple of possible extensions to the C language which I'd like to know the opinion of others about.1 This one is about multi-dimensional arrays. Imagine the following ...
2
votes
2answers
131 views

Can a generic piece of C code be converted an FSM?

I understand that any language worth its salt can encode a Finite state machine. My question is the opposite, is it possible to convert an arbitrary piece of code ( say in C ) to a functionally ...
2
votes
2answers
473 views

Why packages and modules are separate concepts in Java 9?

Java 9 will have modules in addition to packages. Usually languages have one or the other. And most programmers perceive two terms as synonyms. Modules are built on top of packages, treating them as ...