Questions involving the design and structure of programming languages.

learn more… | top users | synonyms

6
votes
6answers
752 views

xml based programming languages

I was looking at wikipedia - Category:XML-based programming languages. Why would someone take this approach for designing a language? What are the advantages of it? I can only think of ...
1
vote
2answers
318 views

Should ** bind more tightly than !, ~?

Designing a programming language, I'm including the ** exponentiation operator. In Fortran and Python, the two languages I know of which have this operator, it binds more tightly than unary minus, ...
2
votes
2answers
375 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 ...
27
votes
4answers
1k views

How do programming languages define functions?

How do programming languages define and save functions/methods? I am creating an interpreted programming language in Ruby, and I am trying to figure out how to implement function declaration. My ...
2
votes
3answers
303 views

What is the job of a language virtual machine, and creating one [closed]

Recently I have become incredibly interested in language development. The past few weeks I have written many language front ends (lexer, parser) including a calculator language/expression parser and ...
2
votes
3answers
566 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 ...
2
votes
3answers
346 views

Why is float the default in the majority of languages?

In programming languages, for represent numbers you have (mainly) two types: Int(s) and floats. The us of Int is very easy. However floats cause a lot of unexpected surprises: ...
7
votes
1answer
679 views

Why is the Scala Option type not called Maybe, just as in Haskell?

Why is the Scala Option type not called Maybe, just as in Haskell? Maybe makes a lot more "semantic sense" to me, but maybe Option has different behaviour I am not aware of. Is there any particular ...
-6
votes
4answers
355 views

Why must a constructor's call to the superconstructor be the first call?

It is an error if you do anything in a constructor before calling the superconstructor. I remember that I had problems because of that. Yet, I do not see how this saves us from errors. It could save ...
4
votes
3answers
234 views

What is the proper way to distinguish between keywords and identifiers?

I'm aware that most modern languages use reserved words to prevent things like keywords from being used as identifiers. Reserved words aside, let's assume a language that allows keywords to be used ...
10
votes
6answers
2k views

In Java, why were protected members made accessible to classes of the same package?

From the official documentation... Modifier Class Package Subclass World public Y Y Y Y protected Y Y Y N no modifier Y Y N ...
6
votes
9answers
2k views

Are there any programming languages that make use of adjectives?

Are there any languages where something like the following might be possible? people = [ ... a list of people ...] Person jake = Person("Jake", 165, ...) jake is Tall people.add(jake) for Person ...
1
vote
1answer
179 views

Could it be possible to add the integer type to the ECMAScript standard?

In JavaScript, every number you will ever use will always be represented with what C programmer would call a double. The official type is I believe number. If I recall correctly, that fact was ...
1
vote
2answers
153 views

“every statement and declaration an expression that yields a value” why?

At the end of the answer to "Can I do ++x and x++ in Python?" on this page: http://norvig.com/python-iaq.html, you can read: [...] I'm with my fellow Dane, Bjarne Stroustrup, on this one. He said ...
4
votes
1answer
170 views

How do I implement classes in my scripting language?

Let's suppose I have a code file that reads (I'll use Java-ish syntax) and it is being interpreted. Kind of like a ruby script. class A{ int fieldName = 4; A(){...} void ...
3
votes
1answer
301 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, ...
88
votes
14answers
7k views

Why do most programming languages only support returning a single value from a function?

Is there a reason why functions in most(?) programming languages are designed to support any number of input parameters but only one return value? In most languages, it is possible to "work around" ...
23
votes
4answers
1k views

Why do C# and Java use reference equality as the default for '=='?

I've been pondering for a while why Java and C# (and I'm sure other languages) default to reference equality for ==. In the programming I do (which certainly is only a small subset of programming ...
12
votes
4answers
361 views

Phonetic programming language? [closed]

Many of us coders, programmers and developers struggle with repetitive stress injuries, carpal tunnel, etc. I've been curious about introducing voice control into my workflow in order to save myself ...
2
votes
3answers
202 views

Conditional construct for a kleenean data type

I was thinking of an hypothetical programming language with a kleenean data type which would implement Kleene's three-valued logic. To sum up, it's an extension of the boolean data type with the three ...
58
votes
13answers
8k views

Why is 0 false?

This question may sound dumb, but why does 0 evaluates to false and any other [integer] value to true is most of programming languages? String comparison Since the question seems a little bit too ...
2
votes
2answers
373 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 ...
10
votes
1answer
958 views

How does Go improve productivity with “implicit” interfaces, and how does that compare with C#'s notion of Extension Methods?

In the Go Language Tutorial, they explain how interfaces work: Go does not have classes. However, you can define methods on struct types. The method receiver appears in its own argument list ...
4
votes
1answer
417 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
3answers
631 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 ...
35
votes
9answers
11k views

Why is String immutable in Java?

I couldn't understand the reason of it. I always use String class like other developers, but when I modify the value of it, I need to create new instance of String. What might be the reason of ...
24
votes
4answers
2k views

Why doesn't C# have local scope in case blocks?

I was writing this code: private static Expression<Func<Binding, bool>> ToExpression(BindingCriterion criterion) { switch (criterion.ChangeAction) { case ...
36
votes
2answers
2k views

Why do bitwise operators have lower priority than comparisons?

Could someone explain the rationale, why in a bunch of most popular languages (see note below) comparison operators (==, !=, <, >, <=, >=) have higher priority than bitwise operators (&, |, ...
2
votes
2answers
1k 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']; ...
5
votes
2answers
424 views

How to make support for bindings for a scripting language

Main I'm making a scripting language using C++. I plan to use it with a simple test game editor. But I have to make a support for bindings to call game engine's nodes' methods to update positions, ...
1
vote
2answers
288 views

Should I use a formal grammar for my interpreted scripting language

I have a scripting engine I just published as an open source project. It's been sitting on my harddrive waiting for about a year. My engine of course isn't complete in any way, but it does work for ...
3
votes
4answers
1k 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 ...
5
votes
2answers
739 views

Alternative Scripting Language to Lua?

I would like to add scripting support to an applications and with plenty scripting languages available I am a bit overwhelmed. At first I thought about Python but I guess Python is a little too big ...
0
votes
1answer
396 views

How is developing apps for Windows Phone 8 is different from Windows Phone 7.x?

What has changed with regards to the design patterns? Do both use the same development techniques? If I'm faced with the option of learning Windows Phone 7 vs Windows Phone 8 will learning windows ...
11
votes
3answers
539 views

How to implement lazy evaluation of if()

I am currently implementing an expression evaluator (single line expressions, like formulas) based on the following: the entered expression is tokenized to separate literal booleans, integers, ...
12
votes
4answers
1k views

Is garbage collection needed for implementing safe closures?

I recently attended an online course on programming languages in which, among other concepts, closures were presented. I write down two examples inspired by this course to give some context before ...
10
votes
3answers
1k views

Why there are no compound assignment operators for logical operators (such as ||, && etc)?

According to ECMA-262, part 11.13, following is the exhaustive list of compound assignment operators: *= /= %= += -= <<= >>= >>>= &= ^= |=. According to the part 11.11, var c ...
9
votes
2answers
2k views

How does C++ handle multiple inheritance with a shared common ancestor?

I'm not a C++ guy, but I'm forced to think about this. Why is multiple inheritance possible in C++, but not in C#? (I know of the diamond problem, but that's not what I'm asking here). How does C++ ...
2
votes
6answers
937 views

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

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 ?
54
votes
11answers
4k views

I've been told that Exceptions should only be used in exceptional cases. How do I know if my case is exceptional?

My specific case here is that the user can pass in a string into the application, the application parses it and assigns it to structured objects. Sometimes the user may type in something invalid. ...
1
vote
3answers
896 views

Is function overloading in general considered Evil? [closed]

Recently I found about two new programming languages(Vala and google's GO) which don't support method or function overloading and intend on not supporting them in the future ever! The creators of ...
39
votes
9answers
3k views

Why don't languages include implication as a logical operator?

It might be a strange question, but why there is no implication as a logical operator in many languages (Java, C, C++, Python Haskell - although as last one have user defined operators its trivial to ...
2
votes
1answer
61 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 ...
6
votes
1answer
424 views

Why can't java generics be in arrays?

Why is it that when I try to make an array of ArrayLists: ArrayList<Integer>[] arr=new ArrayList<Integer>[40]; there is an error and java does not allow this? Is there a reason related to ...
22
votes
9answers
2k views

Are there any programming languages that follow a minimalist development approach?

I find it that when languages are considered the same as commercial software, there is always a constant need to add new features to justify new releases. Can there be or are there languages where ...
5
votes
3answers
1k views

Why was GOTO included in PHP 5? [closed]

I discovered some time ago that the GOTO control keyword was introduced in PHP 5.3.0. http://php.net/manual/en/control-structures.goto.php Why did it happen? What are the language design goals ...
13
votes
2answers
1k views

Advantages and disadvantages of structuring all code via classes and compiling to classes (like Java)

Edit: my language allows for multiple inheritance, unlike Java. I've started designing and developing my own programming language for educational, recreational, and potentially useful purposes. At ...
4
votes
8answers
818 views

Is true multithreading really necessary?

So yeah, I'm creating a programming language. And the language allows multiple threads. But, all threads are synchronized with a global interpreter lock, which means only one thread is allowed to ...
7
votes
1answer
1k views

What's the problem with Scala's XML literals?

In this post, Martin (the language's head honcho) writes: [XML literals] Seemed a great idea at the time, now it sticks out like a sore thumb. I believe with the new string interpolation ...
6
votes
4answers
537 views

Could a programming language work as well without statements?

As programming in JavaScript, I've noticed everything that can be done with statements and blocks can be done with expressions alone. Can a programming language work fine with only expressions? And, ...