Questions tagged [language-features]

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

Filter by
Sorted by
Tagged with
5 votes
1 answer
2k views

Does a programming language with ML-style modules need packages?

This is a clarification of a closed question. I've limited the scope as requested. First, a few definitions, following e.g. A modular module system. Consider any programming language with a selected ...
Corbin's user avatar
  • 152
1 vote
3 answers
554 views

Why does HTML collapse whitespace?

I've been trying to better understand (at least at a high level) why the early versions of HTML were designed the way they were. Most of the decisions make sense; I can deduce (at least at a high ...
Mathew Alden's user avatar
12 votes
4 answers
5k views

Can Just-In-Time compilation be considered a secure feature?

The commonly endorsed, and considered the most reliable, way of evaluating the security of a program is through examining its source code. That is, this method is based on the fundamental assumption: &...
Al Berger's user avatar
  • 269
2 votes
1 answer
99 views

Hot reloading anonymous functions in a custom scripting language

I am implementing anonymous functions (lambdas) in a scripting language that supports hot reloading. The language currently supports passing user defined functions (pointers) to plugin functions which ...
korri123's user avatar
  • 141
4 votes
4 answers
350 views

Is there a cancel after certain amount of time try catch type of block?

I'm going through a beginner programming learning guides and the teacher brings up the try catch block paradigm. The code you put in the try block is run and if an error happens the code in the catch ...
1.21 gigawatts's user avatar
10 votes
6 answers
1k views

Do any programming languages use types as values? Would there be any point?

The standard way that types are handled in programming languages that have such a concept, is that they are: removed entirely at compile time and are just used to determine memory layout, function ...
AIWalker's user avatar
  • 1,287
-2 votes
1 answer
316 views

Which non-standard C features can I use? [closed]

C and C++ have standards, but support isn't perfect, the only available copies on the internet are drafts, and there are immensely useful things that aren't standard, such as __attribute__((cleanup)). ...
Dan's user avatar
  • 123
1 vote
3 answers
218 views

Unifying and modularizing the while / do feature set in c

disclaimer: I'm a university student who's one-year-new to programming. Please don't slaughter me in your responses as I am still a human being I have an idea that I want some feedback on. I am ...
Jack's user avatar
  • 49
0 votes
2 answers
570 views

Template argument type exclusion: Would this make for a useful C++ feature?

When using templates we can have T be any type upon class instantiation. If T is a specific type that needs to be handled differently or in a special way we can specialize or partial specialize that ...
Francis Cugler's user avatar
-2 votes
1 answer
182 views

Is there a common agreed upon token symbol used in computer science or common across languages?

I have seen tokens like this: var message = "Hello, {Name}"; and like this: var message = "Hello, ${name}"; and like this: var message = "Hello, @NAME"; and a few ...
1.21 gigawatts's user avatar
3 votes
4 answers
630 views

Is checking the type of a variable antithetical to OOP?

As an example, in PHP you can run gettype($myVariable); to obtain the type of a variable $myVariable. Is such functionality antithetical to OOP principles?
gen's user avatar
  • 328
0 votes
2 answers
938 views

Logically, is there a reason why ++i++ can not be a valid expression?

I had to increment my integer twice in a loop, so I thought I would try and be clever: for (int i = 0; !sl.isEmpty(); ++i++) { ... } ++i++ however is not an assignable expression, at least in GCC. ...
Anon's user avatar
  • 3,575
6 votes
2 answers
430 views

What was the first language to allow Unicode in function names?

People often get excited about JuliaLang supporting Unicode function names. But it's not new at all,it's just that the Julia community decided that it was sometimes appropriate, and built tooling to ...
Frames Catherine White's user avatar
1 vote
1 answer
98 views

How to simplify work with class inheritance when a lot of arguments needed to be passed to c-tor?

Let's say I have class that used inside another class and uses inside some nested fields of it. To simplify the example I'll use trivial types. In reality it's something like DataType dataType, Status ...
Liastre's user avatar
  • 171
29 votes
9 answers
10k views

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

Some modern languages (e.g. Swift, Dart) do not support the protected access modifier keyword. Swift is a protocol-oriented language, but I've heard that Dart is a completely object-oriented language. ...
ShutUpILoveYou's user avatar
4 votes
1 answer
7k views

Storage of global variables

In C, global variables are stored with the program code. I.e. the space to hold them is part of the object file (either in the data or bss section), instead of being allocated during execution (to ...
Jet Blue's user avatar
  • 159
0 votes
3 answers
231 views

Idempotent functions as a feature in general

If I want a function to be idempotent, is there any framework, language or extension which can allow me to just mark the function as idempotent and the rest will be taken care of behind the scenes ...
Niklas Rosencrantz's user avatar
0 votes
2 answers
86 views

An 'internal' scope class available only to selected classes

In many languages there is a scope that is just less than public called internal. Wondering, Why none of the language, implemented a feature on internal such that one can specify Only what other ...
Saran's user avatar
  • 397
1 vote
3 answers
523 views

Is it really correct to talk about compiled and interpreted languages? [duplicate]

It is pretty obvious that any interpreted language CAN also be compiled. For a long time I thought that it was not necessarily the other way around. Then I discovered Ch which is an interpreter that ...
klutt's user avatar
  • 1,428
2 votes
0 answers
1k views

Division by zero Java [closed]

The behavior of Java is explained in this topic. But, is Infinity useful for something? Float: public class DivisionByZeroFloat{ public static void main(String[] args) { System.out....
Juliano Costa's user avatar
4 votes
2 answers
538 views

Was Java the first programming language to support inner classes?

The Wikipedia article on the subject of inner classes enumerates a number of programming languages that support nested class definitions. Historically speaking, which programming language first added ...
zepp133's user avatar
  • 221
3 votes
2 answers
505 views

API across multiple languages. Use idiomatic code for each or support the same API structure

I'm currently working on a project which requires to support multiple languages as first class citizens and I'm facing a dilemma. I can choose between implementing the API as closely as possible for ...
John Smith's user avatar
8 votes
3 answers
4k views

What do you need Covariant Return Types for?

In this article, it is written that in C# 8.0 new feature of convariant return type will be included as the community asking for this feature for quite a long time. Can anybody explain why and when ...
Himanshu Mange's user avatar
5 votes
2 answers
2k views

Type-based memory safety without manual memory manage or runtime garbage collection? [closed]

Let's say we wanted a typeful, pure functional programming language, like Haskell or Idris, that is aimed at systems programming without garbage collection and has no runtime (or at least not more ...
Chase May's user avatar
  • 161
1 vote
1 answer
438 views

Can you explain the behavior of PHP in cases when a parent class variable is masked by the child variable of the same name? [closed]

See the comment inside ChildEntity ::__construct(): class ChildEntity extends ParentEntity { /** @var int */ protected $classParameter; function __construct(int $classParameter) { ...
Dennis's user avatar
  • 8,157
3 votes
5 answers
1k views

Why don't OOP languages offer a feature to clone a parent into a child class?

Consider the following c# example: public class MyParentClass { public int MyInt { get; set; } } public class MyChildClass : MyParentClass { } public class AnotherClass { public MyChildClass ...
JᴀʏMᴇᴇ's user avatar
12 votes
4 answers
2k views

Is having a generator language facility such as `yield` a good idea?

PHP, C#, Python and likely a few other languages have a yield keyword that is used to create generator functions. In PHP: http://php.net/manual/en/language.generators.syntax.php In Python: https://...
Dennis's user avatar
  • 8,157
0 votes
1 answer
207 views

Short circuit operator on both sides. Any prior art?

I just debugged a problem which proved to be that "and" evaluated both arguments before checking whether either was false. That's fine, not all languages handle x = (will_return_true() || loop_forever(...
Jon Chesterfield's user avatar
28 votes
3 answers
32k views

In C#, why are variables declared inside a try block limited in scope?

I want to add error handling to: var firstVariable = 1; var secondVariable = firstVariable; The below won't compile: try { var firstVariable = 1; } catch {} try { var secondVariable = ...
JᴀʏMᴇᴇ's user avatar
26 votes
10 answers
7k views

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

I'm currently creating a programming language for fun where the idea is that every function call/new block (if clauses, loops etc) will work in a separate thread. Instead of creating new Threads the ...
Grimbox's user avatar
  • 377
-2 votes
2 answers
237 views

Categorize a language?

Is it true that one doesn't "implement a programming language"? I was told that in some comment around here several years ago and I read that actually you do "implement a programming language". The ...
Niklas Rosencrantz's user avatar
0 votes
2 answers
613 views

What's the point of Swift's function notation?

Why does Swift use this function notation: func greet(person: String, day: String) -> String { return "Hello \(person), today is \(day)." } Like, I don't get why it uses the small arrow -> ...
theonlygusti's user avatar
4 votes
2 answers
3k views

Was template meta programming really discovered "by accident"? [closed]

When I first saw this meme: I thought to myself, yeah right, but now I am not sure any more. So was template meta programming in C++ discovered by accident as the meme claims or was it intentional? ...
Mr. Developerdude's user avatar
1 vote
1 answer
146 views

What is the best way to incorporate new language features into your code? [closed]

My main language is currently JavaScript, and I'd say I'm fairly proficient in it. That is, when I think "I want to do x", I don't (generally) Google "how to do x", but I think "I know! I will use ...
Bluefire's user avatar
  • 157
0 votes
2 answers
263 views

Is it important that a language is coherent to itself?

I am currently designing a programming language and I'm at the stage of making all the design choices that will guide the developement. My language has a slightly different syntax and concept to many ...
user6245072's user avatar
1 vote
2 answers
15k views

Why is having a NotImplementedException a good thing? [duplicate]

C# has made a language feature of the NotImplementedException. It's added to a lot of auto-generated code, such as event handler stubs: // Auto-generated private void TextBox_MouseDown(object sender, ...
ArtOfCode's user avatar
  • 121
4 votes
2 answers
530 views

Is there some rationale behind SQL's lack of closure for what are standard operations in imperative languages?

Is there some historical or practical reason why SQL (or more specifically T-SQL in my case) does not support the closure property in many areas where many other language families like C do? (That is,...
JamesFaix's user avatar
  • 252
1 vote
3 answers
849 views

Which programming languages support operators as first class citizens? [closed]

Which programming languages support operators as first class citizens? eg: Return an operator (+, -, =, ==, etc.) from a function, or store within a variable.
Jordan Mack's user avatar
4 votes
3 answers
3k views

Advantages and disadvantages of an FFI vs. a C/C++/etc API

I am trying to understand the advantages and disadvantages of a Foreign Function Interface (FFI) (in which the high-level languagd can call most C functions directly and can manipulate C data ...
Demi's user avatar
  • 826
43 votes
10 answers
8k views

Why do most mainstream languages not support "x < y < z" syntax for 3-way Boolean comparisons?

If I want to compare two numbers (or other well-ordered entities), I would do so with x < y. If I want to compare three of them, the high-school algebra student will suggest trying x < y < z....
JesseTG's user avatar
  • 657
4 votes
3 answers
514 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 ...
Sirisian's user avatar
  • 505
17 votes
2 answers
2k views

Why were variable length arrays made optional in C 2011?

When VLAs were introduced in C 1999, I thought it was a great innovation to the language. However, having learned it was made optional in C 2011, I am wondering what led to its change in status, and ...
jxh's user avatar
  • 479
2 votes
2 answers
480 views

Why did languages such as shell scripting and perl use $ in front of variable names?

Context Perhaps I'm just use to C-esque styled languages but having a sigil in front of a variable (e.g. $VAR) always strikes me as weird. Question Why do some languages such as Perl and shell ...
unsignedzero's user avatar
1 vote
1 answer
305 views

Alternatives to anonymous class

In the language I work with, Progress OpenEdge 11.5.1, there is nothing like anonymous classes. However, the system design would really benefit the use of such classes. Is there some nice known way ...
AD - Stop Putin -'s user avatar
5 votes
5 answers
1k views

Which programming languages provide a Schwartzian transform like interface for sorting

Introduction The Schwartzian transform -- also known as map-sort-map or decorate-sort-undecorate (DSU) --, attributed to Randal Schwartz of the Perl community, sorts elements of a list or array by a ...
elegent's user avatar
  • 169
3 votes
3 answers
15k views

Why don't empty iterables in python raise Exceptions when you try to iterate over them [duplicate]

I find this behaviour in Python quite peculiar and I believe it can lead to many bugs especially if you have a function/method that takes in a list and returns another list after carrying out some ...
danidee's user avatar
  • 149
1 vote
2 answers
752 views

"Fuzzy" parsing in different languages

I have a bunch of plain-text like this: 1 MILE, PACE, PURSE $1,100. FILLIES & MARES N/W $541 L5 STARTS AE N/A $301 L5 & N/A $60 PS IN 2015-16 DRAW INSIDE ...
dmzkrsk's user avatar
  • 127
-1 votes
2 answers
128 views

Hypothetical extension to C# property initializer syntax

In C#, when you call a constructor, you can add one or more property initializers in curly braces: var foo = new Bar() { Armpit = new Flapdoodle() { Limpet = 2 } }; What if that feature were ...
Ed Plunkett's user avatar
19 votes
3 answers
22k views

Why do you need "self." in Python to refer to instance variables?

I have been programming into a number of languages like Java, Ruby, Haskell and Python. I have to switch between many languages per day due to different projects I work on. Now, the issue is I often ...
vivek's user avatar
  • 453
-2 votes
0 answers
285 views

Reasons to want false-negatives when comparing strings (or string references)? [duplicate]

Java programmers know that new String("some-text") == new String("some-text") evaluates to false because two different objects/references are being compared [and that String.equals should be used to ...
Anonsage's user avatar
  • 105