Questions about distinctive aspects of particular computer languages, particularly in the way they are written or in the expressive capabilities provided to the programmer.

learn more… | top users | synonyms

58
votes
9answers
18k views

What is a closure?

Every now and then I see "closures" being mentioned, and I tried looking it up but Wiki doesn't give an explanation that I understand. Could someone help me out here?
37
votes
5answers
3k views

When is a feature considered a “First class citizen” in a programming language/platform?

I have seen many times statements like- "Please make this feature a first class citizen in so and so language/platform". For example, it is said about enums in C#/.net. So, when is a feature ...
28
votes
5answers
2k views

Is it actually possible to have a 'useful' programming language that isn't Turing complete?

Where it is accepted that a language has to be Turing complete to be any good, is it actually possible to have a 'useful' programming language that isn't Turing complete? I should clarify that this ...
22
votes
6answers
10k views

Why the static data members have to be defined outside the class separately in C++ (unlike Java)?

class A { static int foo () {} // ok static int x; // <--- needed to be defined separately in .cpp file }; I don't see a need of having A::x defined separately in a .cpp file (or same file ...
21
votes
6answers
2k views

How can I say that programming language compiles to other languages?

How can I say in english, that programming language can be compiled to other programming languages? The example can be Haxe. On the website the language is decribed as "Multiplatform": ...
18
votes
24answers
1k views

Interesting or unique types in programming languages? [closed]

We have all seen integer, floating point, string, and the occasional decimal type. What are some of the most strange or unique or useful types you have encountered, useful or not?
18
votes
16answers
2k views

Why aren't databases integrated as a language feature?

Are there any programming languages that have a built-in database as a first-class language feature rather than connecting to an external SQL (or other) database? What would be the drawbacks and ...
18
votes
3answers
2k views

Why is a private member accessible in a static method?

The following is pseudo code, I tried it in Java and PHP and both worked: class Test { private int a = 5; public static function do_test(){ var t = new Test(); t.a = 1; ...
16
votes
4answers
2k views

Is Java instanceof operator considered reflection, and what defines reflection?

I had a discussion with a coworker today, whether usage of using the Java operator instanceof is a kind of reflection. And the discussion quickly evolved into what actually defines reflection. So, ...
15
votes
9answers
1k views

Are optional parameters helpful or a hindrance to application maintenance?

As stated in the title, are optional parameters, such as those used in C# helpful or are they a hindrance to application maintenance and should be avoided as they can make the code harder to ...
14
votes
10answers
928 views

Help me catch up on what I've missed since Java 1.4.2 [closed]

I am about to start my first professional career position as a software developer, and I'm likely going to be writing a lot of Java code. I don't know that much about what specifically I'll be ...
12
votes
10answers
1k views

Why dynamically typed languages do not let the developer specify the type?

The dynamically typed languages I know never let the developers specify the types of variables, or at least have a very limited support for that. JavaScript, for example, doesn't provide any ...
12
votes
5answers
2k 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 ...
11
votes
2answers
514 views

How easy should a language development framework be to use?

This is part of a series of questions which focuses on a project called the Abstraction Project, which aims to abstract the concepts used in language design in the form of a framework. Another ...
10
votes
11answers
1k views

What do you do when you can't seem to understand a certain part of programming? [closed]

I'm learning new languages as I go along, I write code for very basic programs in multiple languages, and I go to classes. I've read books, articles, lessons, videos, you name it, however I can't seem ...
10
votes
8answers
1k 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, ...
10
votes
7answers
397 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 ...
10
votes
3answers
3k views

Appropriate programming language to design music software [closed]

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 ...
10
votes
6answers
543 views

Why binding is not a native feature in most of the languages?

IMHO binding a variable to another variable or an expression is a very common scenario in mathematics. In fact, in the beginning, many students think the assignment operator(=) is some kind of ...
10
votes
6answers
645 views

Where, in an object oriented system should you, if at all, choose (C-style) structs over classes?

C and most likely many other languages provide a struct keyword for creating structures (or something in a similar fashion). These are (at least in C), from a simplified point of view like classes, ...
10
votes
5answers
998 views

First Class Functions

I started seriously taking a look at Lisp this weekend (by which I mean I have only been learning Lisp and not reverting back to projects in C#) and must say I love it. I have dabbled with other ...
10
votes
3answers
1k views

Writing a Compiler Compiler - Insight on Use and Features

This is part of a series of questions which focuses on the sister project to the Abstraction Project, which aims to abstract the concepts used in language design in the form of a framework. The ...
10
votes
6answers
3k 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 ...
9
votes
5answers
961 views

Are there technical limitations or language features that prevent my Python script from being as fast as an equivalent C++ program?

I'm a long-time Python user. A few years ago, I started learning C++ to see what it could offer in terms of speed. During this time, I would continue to use Python as a tool for prototyping. This, it ...
9
votes
4answers
999 views

Is there any reason lazy initialization couldn't be built into Java?

Since I'm working on a server with absolutely no non-persisted state for users, every User-related object we have is rolled out on every request. Consequently I often find myself doing lazy ...
9
votes
5answers
951 views

Why no fortran standard library?

To be a language focused on mathematics and scientific computing, I am always baffled by the total lack of useful mathematical routines in the Fortran standard library. One would expect it to be ...
9
votes
3answers
2k views

Why are private variables described in the publicly accessible header file?

OK, so hopefully this is a subjective enough question for Programmers, but here goes. I am continuously broadening my knowledge of languages and software engineering practices... and I've run into ...
9
votes
4answers
1k views

Why design a modern language without an exception-handling mechanism?

Many modern languages provide rich exception handling features, but Apple's Swift programming language does not provide an exception handling mechanism. Steeped in exceptions as I am, I'm having ...
8
votes
4answers
711 views

When to import names into the global namespace? (using x::y, from x import y etc.)

I've been programming in various languages for about 10 years now. And I still haven't figured out when it is a good idea to import something into the global namespace (using x::y in C++, from x ...
7
votes
3answers
955 views

What common programming problems are best solved by using prototypes and closures?

As much as I understand both concepts, I can't see how can I take advantage of JavaScript's closures and prototypes aside from using them for creating instantiable and/or encapsulated class-like ...
6
votes
7answers
612 views

Are Language Comparisons Meaningful? [closed]

Dr Bjarne Stroustrup in his book D&E says Several reviewers asked me to compare C++ to other languages. This I have decided against doing. Thereby, I have reaffirmed a long-standing and ...
6
votes
3answers
476 views

Is the usage of internal scope blocks within a function bad style?

There are some (quite rare) cases where there is a risk of: reusing a variable which is not intended to be reused (see example 1), or using a variable instead of another, semantically close (see ...
6
votes
7answers
2k views

How do you choose to use a specific programming language? [closed]

I was having a small talk between teammates about how you choose a programming language for use in a project which lead me to think that there are many criteria to choose one in the beginning of a ...
6
votes
6answers
1k views

Would a “downcast if block” be a reasonable language feature?

Consider the following "if cast": class A { public void f1() { ... } } class B : A { public void f2() { ... } } A a = foo(); // might return A or B if ( a is B ) { // Inside block, ...
6
votes
3answers
395 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 ...
6
votes
1answer
741 views

Are non Turing-complete languages considered programming languages at all?

Reading a recent question: Is it actually possible to have a 'useful' programming language that isn't Turing complete?, I've come to wonder whether non Turing-complete programming languages are ...
6
votes
5answers
344 views

Is there a better term than “smoothness” or “granularity” to describe this language feature? [closed]

One of the best things about programming is the abundance of different languages. There are general purpose languages like C++ and Java, as well as little languages like XSLT and AWK. When ...
6
votes
5answers
492 views

Java without implementation inheritance

In a recent video on Java, Joshua Bloch states at 4 minutes 20 seconds into the video: And then there's inheritance, and that was a marketing necessity. You know, we can argue whether you really ...
6
votes
3answers
430 views

Is there really a choice of the best language for a specific project?

Programmers.SE has plenty of questions of beginner programmers asking if they must use a specific language or another one in their daily work, or if they must learn a language or another. Those ...
6
votes
2answers
505 views

Why would anyone need this java syntax?

One day while trawling through the Java language documentation, as you do, I found this little beauty lurking within Double: 0.25 == 0x1.0p-2 Now, obviously (!) this means take the number ...
6
votes
3answers
545 views

Is structural typing in a hierarchical model necessary?

This is part of a series of questions which focuses on a project called the Abstraction Project, which aims to abstract the concepts used in language design in the form of a framework. Another ...
6
votes
1answer
6k views

A combined if/switch statement syntax with exception handling for a C#-inspired language

It is sometimes necessary to try/catch exceptions inside the "if" condition, but not the body that follows. In C#, this is really rather cumbersome, requiring locals and code that isn't entirely ...
5
votes
2answers
1k views

Should I feel “uncomfortable” using auto in C++? [duplicate]

C++11 features the new auto type declaration, allowing you to work with an object without ever knowing its actual type. I use only strongly typed languages - C++, Delphi (Object Pascal), Go, etc and ...
5
votes
10answers
374 views

Does your workplace allow the use of multiple, interoperable programming languages?

Since now there are several good languages that target the JVM and can interop with Java with varying degrees of painlessness, and likewise for the CLR (especially with the recent addition of F# as an ...
5
votes
6answers
3k views

Programming languages differences and efficiency, does it matter?

I am fairly new to programming, I have studied in computer science for 3 years at college, but as you know, school is only 2% of what really makes one a fully-fledged programmer. I have a lot of ...
5
votes
2answers
301 views

C++ users proposals

I believe I have some good suggestions to improve the C++ language. Who should I contact to discuss this? Do I have the chance to be heard, especially if I'm not a renowned expert?
4
votes
6answers
2k views

C++: calling non-member functions with the same syntax of member ones

One thing I'd like to do in C++ is to call non-member functions with the same syntax you call member functions: class A { }; void f( A & this ) { /* ... */ } // ... A a; a.f(); // this is the ...
4
votes
3answers
551 views

Does Java have automatic memory management?

I have started learning about C# and I come to what is called 'Automatic memory management' or 'Garbage collectors' and I'm wondering if Java contains something like this as well? and if it does, does ...
4
votes
2answers
363 views

Why do some programming languages have break statements, but not higher-order break statements? [closed]

I may have been exposed to exactly the wrong languages, but though many have loops and break statements, none of the languages I am familiar with have higher-order break statements¹. While a regular ...
4
votes
3answers
886 views

Unusual languages for numerical analysis [closed]

This question is inspired by these questions (here and here). I do mostly numerical work, and I usually use C++, Fortran, and occasionally Numpy. I'm trying to broaden my horizons, and I'm looking ...