Questions involving the design and structure of programming languages.

learn more… | top users | synonyms

0
votes
2answers
51 views

Storing tokens during lexing stage

I am currently implementing a lexer that breaks XML files up into tokens, I'm considering ways of passing the tokens onto a parser to create a more useful data structure out of said tokens - my ...
1
vote
2answers
162 views

What's the reason of choosing PascalCasing over camelCasing or vice versa from a programming language design POV?

I like both but I notice languages that use camelCasing for members sometimes need more adjustments when you want to edit your code. For example (in Python): node.customData() vs ...
0
votes
1answer
70 views

Go-like interfaces + multi-methods make sense?

Thinking about the design of a potential new language, I wonder how related are the concepts of built a OO similar to GO interfaces and multi-methods (I get this from ...
4
votes
3answers
200 views

Classes in OOP , methods and attributes memory internals [closed]

I would assume that instances of the same class would actually share their methods, and just have save different attributes in their namespace. How often do you arbitrary add methods to a single ...
-1
votes
0answers
7 views

Latex first page prints: “” [migrated]

It's my first time posting so if I omit anything that I shouldn't have please let me know. I'm using TeXnicCenter, when I view my output after building my first page is blank apart from: "". ...
0
votes
1answer
81 views

Derivations in BNF

I get how to do a derivation of a BNF. My text books do a good job of explaining it (much better than the on-line lecture notes of many profs etc). Example below then my questions: <program> ...
1
vote
3answers
316 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?
25
votes
7answers
2k views

Disadvantages of scoped-based memory management

I really like scope-based memory management (SBMM), or RAII, as it is more commonly (confusingly?) referred to by the C++ community. As far as I know, except for C++ (and C), there's no other ...
9
votes
4answers
917 views

Why do all <algorithm> functions take only ranges, not containers?

There are many useful functions in <algorithm>, but all of them operate on "sequences" - pairs of iterators. E.g., if I have a container and like to run std::accumulate on it, I need to write: ...
10
votes
4answers
674 views

What are the problems of bringing C++-like const into a language?

I am interested in the idea of C++-like const not that particular execution (like casting away const). Take for example C# -- it lacks C++-like const, and the reason for it is the the usual -- people ...
6
votes
5answers
1k views

What negative consequences can arise from this language design rule?

Clarification: the rule is meant to prevent accessing variables that are not declared yet. Clarification 2: the rule mandates that the compiler follows calls to functions which are defined in the ...
5
votes
3answers
370 views

Is there a web-specific reason for the design choices behind the JavaScript language?

With the advent of "the web is the platform", JavaScript is fast becoming the most widely used programming language in the world. However, many tasks that are easy to accomplish in other modern ...
2
votes
3answers
615 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 ...
1
vote
1answer
85 views

If a variable containing a function gave the function's return instead of a reference to the function, what would an array of functions return? [closed]

I'm creating a prototype scripting language similar to something like Javascript. In my language, every single reference to a variable is actually a function call (a getter function), whether it has ...
5
votes
2answers
170 views

Language that embraces mutable state? [closed]

There seems to be a trend towards immutable objects, and pure functional programming. While I recognize the benefits, I find it hard to apply these principles to GUI programming, for example. But I ...
3
votes
2answers
306 views

Is there a name for the 'break n' construct?

In a conversation earlier this week I was discussing certain language features, and I realized I don't have a good word / phrase to describe a particular feature. Some languages, such as PHP, have a ...
2
votes
6answers
716 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 ...
10
votes
6answers
1k views

Are there any ultra high level languages out there? [closed]

Historically a HLL is something like C, Fortran or Pascal and a VHLL is something like Ruby or Python. I am familiar with the terms 4GL, 5GL, DSL and LOP, and those who aren't should read Wikipedia ...
6
votes
3answers
239 views

Clarification about Grammars , Lexers and Parsers

Background info (May Skip): I am working on a task we have been set at uni in which we have to design a grammar for a DSL we have been provided with. The grammar must be in BNF or EBNF. As well as ...
4
votes
5answers
857 views

Programming Languages “Higher Level” Than Python [closed]

In general, I have been presented with these sorts of heirarchies for programming language abstraction: Assembly < C < C++ < Java < Python where C abstracts less than C++ and so on. You ...
5
votes
5answers
1k views

why no native compiler of C# or other “productive” language? [closed]

I've been reading about D and Go and how they aim at being compiled to machine code yet be convenient (like garbage collection, no need to manipulate pointers unless needed) and I agree that there is ...
2
votes
1answer
334 views

Reasoning behind the syntax of octal notation in Java?

Java has the following syntax for different bases: int x1 = 0b0101; //binary int x2 = 06; //octal int x3 = 0xff; //hexadecimal Is there any reasoning on why it is 0 instead of something like ...
-1
votes
2answers
109 views

What are some examples of inverted classical inheritance? [closed]

Are there any examples of inheritance in languages where classes call their subclasses' methods rather than their super classes' methods? It should not behave like traditional inheritance like the ...
24
votes
9answers
1k views

Why most “well-known” imperative/OO languages allow unchecked access to types that can represent a 'nothing' value?

I have been reading about the (un)convenience of having null instead of (for example) Maybe. After reading this article, I am convinced that it would be much better to use Maybe (or something ...
32
votes
3answers
1k views

Does Java development typically involve more subclassing than C#/.NET?

I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly ...
5
votes
4answers
572 views

Is there a math theory or a model behind programming languages design

I'm trying to understand if a programming languages design is built on some a theoretical model. I came across few links that was describing Programming Language Theory, Lambda Calculus, Formal ...
7
votes
5answers
275 views

In retrospect, has it been a good idea to use three-valued logic for SQL NULL comparisons?

In SQL, NULL means "unknown value". Thus, every comparison with NULL yields NULL (unknown) rather than TRUE or FALSE. From a conceptional point of view, this three-valued logic makes sense. From a ...
6
votes
1answer
347 views

Why appending to a list in Scala should have O(n) time complexity?

I am learning Scala at the moment and I just read that the execution time of the append operation for a list (:+) grows linearly with the size of the list. Appending to a list seems like a pretty ...
3
votes
2answers
182 views

Variable declaration versus assignment syntax

Working on a statically typed language with type inference and streamlined syntax, and need to make final decision about syntax for variable declaration versus assignment. Specifically I'm trying to ...
1
vote
3answers
185 views

Requiring a specific order of compilaiton

When designing a compiled programming language, is it a bad idea to require a specific order of compilation of separate units, according to their dependencies? To illustrate what I mean, consider C. ...
22
votes
6answers
2k views

Why do programming languages allow shadowing/hiding of variables and functions?

Many of the most popular programming languges (such as C++, Java, Python etc.) have the concept of hiding / shadowing of variables or functions. When I've encountered hiding or shadowing they have ...
0
votes
1answer
120 views

OOP language design attribute symbol [closed]

I am designing a language, and wondering which character (or string) to use to represent that something is an attribute of something else. In all languages I have used, this is done with a dot - ...
-2
votes
4answers
274 views

What are the advantages of converting empty strings to evaluate to true as compared to false? [closed]

When converting a string to a boolean, what are the advantages of having a programming language evaluate an empty string as true and what are the advantages of having it evaluate it to false?
0
votes
1answer
288 views

Is there any reason zero should still equal false in a new programming language? [duplicate]

I understand that 0 is false because math established that a long time ago and C established it in the programming world, as talked about here. However, other than following established conventions, ...
6
votes
6answers
680 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
306 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
331 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 ...
26
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
200 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
451 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
301 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
563 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
331 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 ...
3
votes
3answers
212 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 ...
6
votes
6answers
1k 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
155 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
151 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
167 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
289 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, ...