1
$\begingroup$

I often wondered why languages like c do not have simple syntactical allowances that would help readability. For example, large numbers such as 1073741823 can be hard to read so my opinion is modern day languages should allow delimiters such as , (comma) so you can write a statement such as x = 1,073,741,823. That is MUCH more readable. Perhaps you can do this in some languages using #DEFINE but it seems like such a simple thing should be native to the language.

Another feature I would like to see in general purpose languages are huge ints. That is, integers that are not limited to 16 or 32 or even 64 bits but some very large number of bits, perhaps 256. This would help with simulation of certain games with very large state spaces. Why burden the programmer with such tasks? I, as a user of a programming language, would expect some complexity to be hidden from me and handled by the compiler itself. Just like when we drive our cars, many people don't understand the inner workings of it but they don't need to.

It would also be nice if the math library had basic combinatorial functions such as choose(52,5) and the language also had direct syntax for factorial such as x = 52!/47!. That is "syntactical sugar" compared to Factorial(52)/Factorial(47).

Also when I was in college I proposed a computer language that would optionally use indenting to limit the scope of statement like IF, CASE, LOOP, FOR.... For example:

if cardcount < 52  
  ProcessNextCard()  
else  
  deckfinished = TRUE  
next statement goes here and is not part of if statement cuz it is not indented.

Here is an even better example:

for c1 = 1 to 50  
 for c2 = (c1+1) to 51  
  for c3 = (c2+1) to 52  
   ProcessHand()
nextstatement goes here but it is not part of any loop.

Ideally the programming environment would show indentation brackets to confirm the alignment and have a special printing program that does the same.

Of course if there are a lot of lines of code in the body of the if statement then it would be better (clearer) to insert the endif, ifend or fi "missing" part of the if statement. The compiler should allow both options. Forcing the programmer to indent is a good way to teach new programmers good programming practice and to penalize lazy programmers.

Also how about a language that self profiles (or at least assists) using a special directive? For example, if someone wrote a file compressor program and wanted to know where it was eating up most of the time and in what proportion, it would be nice if the language automatically inserted some markers or at least allowed the programmer to insert them easily and then the profiler would tell the programmer what proportion of the runtime was between each set of markers (such as A-A, B-B, C-C... Z-Z).

I could go on and on with a wish list of enhanced features to make programming easier but I will just stick with these few for now.

So my main question is why are many of these features lacking in modern day languages or are they actually there?

$\endgroup$

closed as too broad by D.W. Aug 26 '16 at 15:12

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ You are asking too many questions, making your question impossible to answer. What if I can answer only some of your many questions? $\endgroup$ – Yuval Filmus Aug 26 '16 at 14:24
  • $\begingroup$ @Yuval Filmus - You can comment on any or all I would appreciate it. $\endgroup$ – David James Aug 26 '16 at 14:25
  • 3
    $\begingroup$ Unfortunately, that's not how this site works. Try to focus your question. $\endgroup$ – Yuval Filmus Aug 26 '16 at 14:25
  • $\begingroup$ @YuvalFilmus - the "focus" is missing language constructs that would make the code more readable and promote good programming practices such as proper indenting. If I remove several of the examples then it would just weaken the question. For example, if I only asked about commas in the large numbers then what should I do, post other questions for the other recommendations? Why not just group them together here and get some answers why they are missing in languages like c and if they are present in more modern day computer languages? $\endgroup$ – David James Aug 26 '16 at 14:49
  • $\begingroup$ @YuvalFilmus - should this question be in the theoretical computer site instead? If not, I hope to leave it here and get some answers. $\endgroup$ – David James Aug 26 '16 at 14:56
1
$\begingroup$

You are asking a lot of questions, here are quick answers on some of them:

  1. Syntactic sugar for integer literals: in a language like C, commas already have a function (they are an operator on their own), so there would be an ambiguity. Other languages allow them. In many countries in Europe, the roles of , and . are switched, and this highlights the fact that this type of issue is best handled by a preprocessor.

  2. Large integers: operations on larger integers are slower than ones on smaller integers, so it makes sense to have different types in many circumstances. Libraries typically provide support for large integers even if the language doesn't natively support them.

  3. Math library lacking support for your favorite functions: everybody's favorite functions are different. There is probably a library that supports yours, and otherwise you can write one. Computer algebra systems tend to support all mathematical functions you will ever want to use.

  4. Indentation: you might like indentation, others might not. Generally speaking, the rule in most programming languages (other than Python and perhaps a few others) is that whitespace shouldn't matter. There are many reasons for that, including (historically) macro expansions (or INCLUDEs), and differing indentation styles. If you want to enforce your type of conventions, use a preprocessor.

  5. Built-in profiling: many C compilers already have this feature, and it is part of the tool chain in most widely used programming languages. There is no need for explicit support in language syntax.

In general, one can think of many "improvements" and features for programming languages. That is one of the reasons why there are so many of them. Different compilers might actually implement some of these, perhaps optionally. To answer your general question, why your favorite feature isn't part of your favorite language, the answer is twofold. First, there are many potential features, and programming languages cannot implement all of them (see for example the recent C++ standards, adding lots of features and making the language ever harder to learn). Second, there are some performance issues that you might be ignoring.

$\endgroup$
  • $\begingroup$ If a computer has native 64 bit support then I would think operations on smaller integers would be slower than on native sized integers. For example, even with 32 bit integers, what if I am only working with 4 bits at a time and have to use bitmasks? I don't see why a computer language can't easily accept something like 1,234,567,890 as a number unambiguously. It knows how a number is formed. Also, having a language that is easier to read (in my opinion) is a good tradeoff if it slightly hurts runtime performance. Computers are fast enough nowadays that optimal code is not paramount anymore. $\endgroup$ – David James Aug 26 '16 at 15:16
  • $\begingroup$ On 64 bit machines, C/C++ has native support for 64 bit integers. Regarding the rest, your opinion differs from others', and this should affect your (and everybody's) choice of which programming language to use. $\endgroup$ – Yuval Filmus Aug 26 '16 at 15:19
  • 1
    $\begingroup$ Note also that this is not a discussion forum. If you want to discuss things, you can try your luck on chat. I will not answer any further comments. $\endgroup$ – Yuval Filmus Aug 26 '16 at 15:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.