Skip to main content
256 votes
Accepted

Why use parentheses for function call when no arguments are passed?

For languages that use first-class functions, its quite common that the syntax of referring to a function is: a = object.functionName while the act of calling that function is: b = object....
Nathan Merrill's user avatar
126 votes
Accepted

Why F#, Rust and others use Option type instead of nullable types like C# 8 or TypeScript?

The purpose of Null Tracking in general (of which Nullable Types are only one of many different forms), is to somehow regain a modicum of safety (and sanity) in languages that have null references. If ...
Jörg W Mittag's user avatar
104 votes
Accepted

Is it a bad design for a programming language to allow spaces in identifiers?

Consider the following. var [Example Number] = 5; [Example Number] = [Example Number] + 5; print([Example Number]); int[] [Examples Array] = new int[25]; [Examples Array][[Example Number]] = [...
T. Sar's user avatar
  • 2,166
87 votes

Why is Arithmetic Overflow ignored?

There are 3 reasons for this: The cost of checking for overflows (for every single arithmetic operation) at run-time is excessive. The complexity of proving that an overflow check can be omitted at ...
Brendan's user avatar
  • 3,995
66 votes

Why use parentheses for function call when no arguments are passed?

Indeed, Scala allows this, though there is a convention that is followed: if the method has side-effects, parentheses should be used anyway. As a compiler writer, I would find the guaranteed presence ...
Robert Harvey's user avatar
66 votes
Accepted

Should "Set" have a Get method?

The problem here isn't that HashSet lacks a Get method, it's that your code makes no sense from the perspective of the HashSet type. That Get method is effectively, "get me this value , please", to ...
David Arno's user avatar
  • 39.5k
65 votes

Why is Arithmetic Overflow ignored?

Who says it's a bad tradeoff?! I run all of my production apps with overflow checking enabled. This is a C# compiler option. I actually benchmarked this and I was not able to determine the difference....
usr's user avatar
  • 2,764
63 votes

Is it a bad design for a programming language to allow spaces in identifiers?

Is it a bad design for a programming language to allow spaces in identifiers? Short answer: Maybe. Slightly longer answer: Design is the process of identifying and weighting conflicting solutions ...
Eric Lippert's user avatar
  • 46.4k
51 votes

Can every language be categorized as either compiled or interpreted?

The answer to your question: Can every language be categorized as either compiled or interpreted? Is "No", but not for the reason you think it is. The reason is not that there is a third missing ...
Jörg W Mittag's user avatar
47 votes

In OOP, isn't the 'protected' keyword required?

It depends on what you mean by "required". Access modifiers are not a necessity. You could replace every access modifier with public and most applications will work just like they did when you used ...
Flater's user avatar
  • 56.3k
46 votes
Accepted

What makes a scripting language "embeddable"?

Embedding a language (I'll avoid characterizing it as "scripting") means that the following has been done: The interpreter and runtime are running in the same process as the host application Enough ...
Berin Loritsch's user avatar
45 votes

Why do "checked exceptions", i.e., "value-or-error return values", work well in Rust and Go but not in Java?

From a scientific point of view, checked exceptions can be seen as alternative return values, e.g. Exactly. They can be seen that way, and they should be but they aren't. Using an Error type like is ...
Jörg W Mittag's user avatar
39 votes

Programming language where every function call/block is done in a separate thread?

every function call/new block (if clauses, loops etc) will work in a separate thread. Read a lot more about continuations and continuation-passing style (and their relation to threads or coroutines) ...
Basile Starynkevitch's user avatar
38 votes

In OOP, isn't the 'protected' keyword required?

No, it's not required: Bjarne Stroustrup, explained how he naively added protected to C++ release 1.2, thinking to provide a useful feature to class developers, just to conclude only 5 years later ...
Christophe's user avatar
  • 80.6k
37 votes

Programming language where every function call/block is done in a separate thread?

You may be interested in reading about the research into data parallel Haskell. If you search around on youtube, Simon Peyton Jones has given some interesting talks related to the subject as well. ...
Karl Bielefeldt's user avatar
37 votes
Accepted

Why is there no static keyword in Kotlin?

Scala also replaces class level declarations with a 'Singleton' object. The main advantage of this is that everything is an object. In Java, static members are treated very differently than object ...
JimmyJames's user avatar
  • 28.9k
35 votes
Accepted

What is a type system?

That all seems like a fine description of what type systems provide. And your implementation sounds like a reasonable enough one for what it's doing. For some languages, you won't need the runtime ...
Telastyn's user avatar
  • 110k
34 votes

Why F#, Rust and others use Option type instead of nullable types like C# 8 or TypeScript?

NULL is Overloaded. NULL simultaneously means: This variable has not been initialised This variable has been initialised, but does not point to a valid object, and as such is invalid This variable ...
Kain0_0's user avatar
  • 16.3k
30 votes

Why is Arithmetic Overflow ignored?

Because it's a bad trade-off to make all calculations a lot more expensive in order to automatically catch the rare case that an overflow does occur. It's much better to burden the programmer with ...
Kilian Foth's user avatar
30 votes
Accepted

Why do heavily object-oriented languages avoid having functions as a primitive type?

IMO... Because Java and C# are not true OO languages. Functional programming was not in vogue when they were designed. I agree with Jörg W Mittag, neither C# nor Java are true object-oriented ...
Schwern's user avatar
  • 1,192
28 votes
Accepted

Is Microsoft discouraging the use of 'var' in C#? (VS2017)

TL;DR: no, Microsoft are not discouraging the use of 'var' in C#. The image is simply lacking context to explain why it's complaining. If you install VS2017 RC and open up the Options panel and go to ...
David Arno's user avatar
  • 39.5k
27 votes

Why do "checked exceptions", i.e., "value-or-error return values", work well in Rust and Go but not in Java?

Disclaimer: This will, to a degree, be my own personal take on the problem. I love programming language design, I've thought, read, and discussed a lot of about PL design in general, and the hard ...
Matthieu M.'s user avatar
  • 15.1k
26 votes

Why do heavily object-oriented languages avoid having functions as a primitive type?

This is a little bit of a silly question. You're asking why object-oriented languages are object-oriented. If they passed functions around as first class types we wouldn't describe them as object-...
Telastyn's user avatar
  • 110k
25 votes

Is there a compelling reason why columns in SQL are nullable by default?

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the ...
Philip Couling's user avatar
24 votes

Should "Set" have a Get method?

You already have the item that is "in" the set - you passed it as the key. "But it isn't the instance that I called Add with" - Yes, but you specifically claimed that they were equal. A Set is also ...
Caleth's user avatar
  • 11.6k
24 votes
Accepted

Why was "self" chosen over "this" for the name of the first parameter of python methods?

The use of self can be traced back to Smalltalk, which is one of the eldest OO languages (the oldest according to python wiki) and influenced the python language designers: There is evidence of a ...
Christophe's user avatar
  • 80.6k
24 votes

Why F#, Rust and others use Option type instead of nullable types like C# 8 or TypeScript?

Much of the angst over nulls are due to languages where every reference type is nullable by default. But this is not an issue for Typescript or C# 8 so lets disregard that. There are two basic ...
JacquesB's user avatar
  • 61k
23 votes

What is a type system?

I like @Telastyn's answer especially because of the reference to academic interest in formalism. Allow me to add to the discussion. What is a type system? A type system is a mechanism for ...
Erik Eidt's user avatar
  • 34.4k
22 votes

Why use parentheses for function call when no arguments are passed?

This is actually a pretty subtle fluke of syntax choices. I'll speak to functional languages, which are based on the typed lambda calculus. In said languages, every function has exactly one argument. ...
gardenhead's user avatar
  • 4,757
19 votes

Should "Set" have a Get method?

Your problem is that you have two contradictory concepts of equality: actual equality, where all fields are equal set membership equality, where only A is equal If you would use the actual equality ...
amon's user avatar
  • 135k

Only top scored, non community-wiki answers of a minimum length are eligible