What's the Most Concise, Human-Understandable Practical Language?
-
BASIC. The only problem with any of the modern BASIC variants is the the name. It should have been changed years ago to something that sounds better. BASIC is the direction that programming languages should have been taking for decades. A programming language is a tool. A tool is something that makes work easier. C, Java and the like make simple jobs complicated, and complicated jobs - well, we won't go there. Unfortunately BASIC has been all but killed off because it scared the crap out of the C guys. VB was arguably one of Microsoft's biggest successes - suddenly anyone smarter than a manager or an accountant could write useful programs. They weren't always fast, or efficient, but they solved real world problems, then and there. And here lies one of the less understood issues with software - many, many programs are written as quick one offs to answer a question, or extract some data. They do not need the .NET framework or the latest C++ or Java support libs, or some horrendously expensive and complicated Studio Suite to create them BASIC was able to do this AND produce high quality complicated full fledged applications. And it still can. My favourite is PowerBasic - PowerBASIC[^] There are a few others. It seems to me that all the 'new' languages we see are based on C syntax. A whole bunch of cryptic punctuation marks interspersed with some unreadable, unintuitive bits of code. It's time to move on. C was never meant to last this long. It was an interim replacement to FORTRAN, until the 'new' languages came along. Sadly they never did.
Up-vote for the comment on 'C'-style syntax (looking at you C#), but disagree about BASIC - way too wordy for it's own good. It's all down to horses-for-courses really, isn't it? But a programming language for (semi) non-programmers to do actual work (you know, get stuff done, at work) needs to have reasonably transparent syntax and not be cluttered with the kind of stuff systems programmers and computer science professors deem 'essential' for 'clarity' and nerd-'beauty'. OK, apologies to systems programmers :-D - their criteria are very different from the request in the original question... I think the reason Python has become so popular (apart from fashion?) is that it does allow non-programmers to quickly grasp the essentials and actually do stuff - and if they need to then do more complicated stuff, it allows them to do that as well in a natural progression? And because it's (slightly) less verbose that BASIC it makes it more human-readable(?) It's a toughy... :laugh:
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
Just pick C#, whatever your intentions. 5 years of working with high school graduates, and that's the one with the lowest learning curve on average. At a glance, here are definitely more concise and human readable languages out there (lolcode is a nice example) but they all come at the cost of a much higher learning curve and very limited functionality. Notice the lack of "or" in the previous sentence. 🙂
-
Just pick C#, whatever your intentions. 5 years of working with high school graduates, and that's the one with the lowest learning curve on average. At a glance, here are definitely more concise and human readable languages out there (lolcode is a nice example) but they all come at the cost of a much higher learning curve and very limited functionality. Notice the lack of "or" in the previous sentence. 🙂
I was doing Windows programming in C++ for several years before switching to C#, learning many of its small advantages over C++ as I went along. After a number of years with C#, I was going to pick up an old private hobby project in C++, and learned one huge advantage of C# over C++ that I had never realized before: The amount of red tape in C++! You spend an unbelievable amount of code lines on setting up and and initializing things, header files, declarations of all sorts. Module interfaces are handled by VS in a "database" (I grew up with ACID, so I put the term in quotes :-)) rather than header files. Sure, if you go behind the curtain, you will see that VS and WPF do very similar things, but they do it for you! A number of small things are done for you as well, such as heap management. I started using VS when switching to C#; my old C++ project was sprinkled with lint directives (i.e. lint comments) all over, cluttering up the source files. With VS and C# I never missed Lint, there was no need for it. So I could drop lint from my C++ code as well, couldn't I? But VS Intellisense doesn't work half as well with C++ as with C#, much due to the far less controlled use of pointers in C++. So rather than fixing up and completing my old C++ code, I deleted several hundreds of lines, a good bunch of header files, brushed out the heap management code and adapted the remaining code to C# standards. I never looked back. With C++, so much of my attention, and so many source lines, are wasted on things that are not solving the real problem; it is just red tape to facilitate the problem solution part. For C#, this is far less prominent. Certainly, C# has inherited from C/C++ a number of elements I wish it had not. (An example: Why do we have to announce in advance with a "try" that the block has an exception handler? The handler is there, that should be enough!) Some of it may be ascribed to the old single-pass parsing ideals, but today there is no reason to accept such limitation. I can live with it, but it is ugly. But if I have the choice, I will not live with all that other required C++ blurb that really does nothing towards solving the problem at hand.
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
Javascript is obviously dynamically typed - but as I gravitate towards statically typed languages, I'll go for a language like Ocaml, Haskell or F#. They all define record types similarly, but with slightly different keywords and syntax. I'll give an example in Haskell: ```haskell data Location = Location { city :: String } let home = Location { city = "Boston" } ``` and F# ```f# type Location = { City : string } let home = Location { City = "Boston" } // Or we can use anonymous records.... let other_home = {| City = "Boston" |} ```
johnywhy wrote:
I mean, easy to understand at a glance.
I find Haskell's syntax pretty clear for pure functions. Having pattern matching brought out to the top level of function definitions makes it similar to have you might write a piece-wise definition of said function. Having function signatures be optional (the compiler will work out what the signature should be if you leave it out) leaves code less cluttered ```Haskell factorial 1 = 1 factorial n = n * factorial (n-1) list_length [] = 0 list_length (first_element:rest) = 1 + list_length rest ``` and F# again: ```f# let rec fac n = match n with | 1 -> 1 | n -> n * fac (n-1) let rec length list = match list with | [] -> 0 | first :: rest -> 1 + length rest ```
johnywhy wrote:
What's "Concise"?
johnywhy wrote:
What's "Practical"
I'll probably select F#. It's a .NET language, so can use .NET libraries. I like how the various features work together to provide powerful facilities with little code. An example - some code taken from the Microsoft website to download a bunch of URLs in parallel, with async/await ```f# open System.Net open Microsoft.FSharp.Control.WebExtensions // Defines a list of pairs of strings let urlList = [ "Microsoft.com", "http://www.microsoft.com/" "MSDN", "http://msdn.microsoft.com/" "Bing", "http://www.bing.com" ] let fetchAsync(name, url:string) = // The async block means this fucntion defines a task to be run asynchronously async { try let uri = new System.Uri(url) let webClient = new WebClient() // In async {}, let! operates a bit like Javascript's 'async' keyword let! html = webClient.AsyncDownloadStrin
-
It won't be the most concise, human-understandable and practical language but Dart sure is very concise, for a statically typed language, dropping a lot of the oop cruft that languages such as c# or java have
abstract class Item {
use();
}class Chest implements Item {
List contents;Chest(this.contents);
use() => print("$this has ${contents.length} items.");
}class Sword implements Item {
int damage = 5;use() => print("$this dealt $damage damage.");
}main(){
var chest = Chest([Sword()]);chest.use();
for (var item in chest.contents) {
item.use();
}
}It drops
public
andprivate
in favor of using "_" before private instance variables, doesn't require thenew
keyword, has a very concise (and imo clear) function definition style and a constructor definition that can't be made slimmer without impacting heavily on understandability. Regarding | Notice the lack of punctuation. Notice judicious use of whitespace as syntax. (how do you quote text? :) ) Yeah, no, as you can see there is a lot of punctuation and whitespace is basically meaningless For the practicality of this language... outside of Flutter, not much, honestly. I find it to be very neat but it isn't going to replace js any time soon Edit: the code is taken more or less literally from the examples on dart.devLorenzo Bertolino wrote:
(how do you quote text? :) )
Select the text in the original message and click the "Quote Selected Text" button. :) Or paste the text into the "message" box and select "Quoted Text" in the pop-up. Or, if you want to do it the hard way, type the
blockquote
markup around the quoted text:<blockquote class="quote"><div class="op">Quote:</div> Quoted text goes here...</blockquote>
Quote:
Quoted text goes here...
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I was doing Windows programming in C++ for several years before switching to C#, learning many of its small advantages over C++ as I went along. After a number of years with C#, I was going to pick up an old private hobby project in C++, and learned one huge advantage of C# over C++ that I had never realized before: The amount of red tape in C++! You spend an unbelievable amount of code lines on setting up and and initializing things, header files, declarations of all sorts. Module interfaces are handled by VS in a "database" (I grew up with ACID, so I put the term in quotes :-)) rather than header files. Sure, if you go behind the curtain, you will see that VS and WPF do very similar things, but they do it for you! A number of small things are done for you as well, such as heap management. I started using VS when switching to C#; my old C++ project was sprinkled with lint directives (i.e. lint comments) all over, cluttering up the source files. With VS and C# I never missed Lint, there was no need for it. So I could drop lint from my C++ code as well, couldn't I? But VS Intellisense doesn't work half as well with C++ as with C#, much due to the far less controlled use of pointers in C++. So rather than fixing up and completing my old C++ code, I deleted several hundreds of lines, a good bunch of header files, brushed out the heap management code and adapted the remaining code to C# standards. I never looked back. With C++, so much of my attention, and so many source lines, are wasted on things that are not solving the real problem; it is just red tape to facilitate the problem solution part. For C#, this is far less prominent. Certainly, C# has inherited from C/C++ a number of elements I wish it had not. (An example: Why do we have to announce in advance with a "try" that the block has an exception handler? The handler is there, that should be enough!) Some of it may be ascribed to the old single-pass parsing ideals, but today there is no reason to accept such limitation. I can live with it, but it is ugly. But if I have the choice, I will not live with all that other required C++ blurb that really does nothing towards solving the problem at hand.
Member 7989122 wrote:
Why do we have to announce in advance with a "try" that the block has an exception handler? The handler is there, that should be enough!
CallSomeMethod();
try
{
CallSomeOtherMethod();
}
catch (SomeFunkyException)
{
}Without the explicit
try
, how would you indicate that the first method call wasn't covered by thecatch
block?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
Every professional program has 3 audiences: 1. the programmer 2. other programmers 3. the compiler The "fantasy language" fails in all 3 areas: 1. Sure, right now the syntax makes perfect sense. But come back to the same code after a 6 month or even 2 year lapse? Every programmer (including me) I know looks at their own, older code with a "WTF was I doing?" expression on their face. Remove the keywords and punctuation and the problem gets a lot harder. Everyone thinks they'll remember exactly what they were doing at the time; 99%+ of us don't. 2. A professional program is highly likely to be supported (eventually) by at least one other programmer. The problems of point #1 are multiplied by 10 or even 100 because the second programmer has to figure things out. I've supported enough code to have a deep appreciation for well organized code that includes comments which explain "why" something is being done. My effort is reduced tremendously by those 2 things. 3. Use of "judicious" whitespace as syntax is a poor idea. Sure, the compiler can figure it out, but when the whitespace is wrong, the programmer cannot see the mistake. The real problem here is not compiler errors (which should point out the offending line so the programmer can [hopefully] figure it out), but when the program DOES compile and run, but produces wrong results. The constant move towards conciseness is being taken to an extreme, and it's causing more problems than it is solving. The more concise the language, the steeper the learning curve, and the more prone to programmer errors, and those problems are harder to solve. Programming languages are created for people, not computers. The computer runs machine code -- regardless of how the program starts, it ends up in machine code. Write your code so the someone else can figure things out in the least amount of time.
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
Let me explain to you the undesirability of you desire: All that punctuation is to remove ambiguity. You can play games and replace semicolons with new-lines, specific indent counts, whatever, and it's still the same. Is "Start->End" really better than "{->}". Neither logically nor visually. If you have a block of code in a conditional you need some method to mark statements off as part of the block and not just the next statements to be executed after the conditional. As for why things keep copying the 'C-like' structure? Not saying it's the end-all of design but it eliminates a lot of the absurd arbitrary. Like my first language, FORTRAN, having all statements start in column seven. I find your javascript example ludicrous. You make the javaScript unnecessarily complex for the simple act of assigning a value to a symbol - but not in your dream version. Just to start. Coming right down to it - human readable is a nebulous concept as you intend it. Mandarin is human readable - unless you don't know it. So is Hindi, Hebrew, and Arabic. Unless you are not accustomed to it. Those who speak these languages natively would differ with you strongly as to what is readable. Thus it is for a coding language. You learn to look at it and your eyes and brain will translate it. Meanwhile, the efficient interpretation of the syntax is guaranteed by the punctuation.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010
-
BASIC. The only problem with any of the modern BASIC variants is the the name. It should have been changed years ago to something that sounds better. BASIC is the direction that programming languages should have been taking for decades. A programming language is a tool. A tool is something that makes work easier. C, Java and the like make simple jobs complicated, and complicated jobs - well, we won't go there. Unfortunately BASIC has been all but killed off because it scared the crap out of the C guys. VB was arguably one of Microsoft's biggest successes - suddenly anyone smarter than a manager or an accountant could write useful programs. They weren't always fast, or efficient, but they solved real world problems, then and there. And here lies one of the less understood issues with software - many, many programs are written as quick one offs to answer a question, or extract some data. They do not need the .NET framework or the latest C++ or Java support libs, or some horrendously expensive and complicated Studio Suite to create them BASIC was able to do this AND produce high quality complicated full fledged applications. And it still can. My favourite is PowerBasic - PowerBASIC[^] There are a few others. It seems to me that all the 'new' languages we see are based on C syntax. A whole bunch of cryptic punctuation marks interspersed with some unreadable, unintuitive bits of code. It's time to move on. C was never meant to last this long. It was an interim replacement to FORTRAN, until the 'new' languages came along. Sadly they never did.
Bravo!!! :)
Steve Naidamast Sr. Software Engineer Black Falcon Software, Inc. blackfalconsoftware@outlook.com
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
Well, just in terms of the JavaScript, here is how I would write it.
var home =
{
cit : "Boston"
};home.city = function(aCity)
{
if (arguments.length)
this.cit = aCity;
else
return this.cit;
};Yes, the function is a bit longer but there is only one function instead of two and writing pointless "get" and "set" is no longer necessary. That is a holdover from languages which do not have true getter / setter type attributes. I would note that the function would normally be part of a class (or prototype) and not the object itself. In C++, it takes more work, but you can write code so that you can literally write
aCity = home.city;
home.city = aCity;I usually don't do that, but I do do the same thing in C++ as in JavaScript. Note that brace placement may make it look longer, but that is matter of style. Braces are part of a statement block, so I indent the same as the statement block. And don't use unnecessary braces. The make code less readable. I agree with you about APL not being readable. Perl has a lot of the same characteristics. I disagree about COBOL, it is both far less concise and far less readable. If something is too concise, it becomes unreadable. But, conversely, when it is too expansive (non-concise?) then it is also less readable. A straight mathematical expression whether in a conditional or an assignment is generally maximally readable. Assuming that the length and complexity of the expression is not too large. And that weird and strange operators (APL) are not in use. So languages whose basic structure is similar to C tend to be most readable without becoming too concise.
-
Member 7989122 wrote:
Why do we have to announce in advance with a "try" that the block has an exception handler? The handler is there, that should be enough!
CallSomeMethod();
try
{
CallSomeOtherMethod();
}
catch (SomeFunkyException)
{
}Without the explicit
try
, how would you indicate that the first method call wasn't covered by thecatch
block?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
You could e.g. look at CHILL, aka Z.200: Any block may have a handler attached: If there is an ON-clause between the body of the block and the terminating semicolon, the block has a hanlder. If there is no ON-clause, it does not have a handler. THere is no need to pre-announce it. Note that in CHILL, as well as in most other sensible languages of the Algol class, a statement is a block; you don't need to enclose a single statement to make it one. So it would be like
CallSomeMethod();
CallSomeOtherMethod() -- note: no semicolon - block not yet complete
ON (SomeFunkyException):
LogThisException();
END; -- here is the semicolon terminating the blockUsually when you want to attch a handler to a group of statements, that group is e.g. a function body, a loop, an if/then/else etc. defining a block. If these two calls are looped, and you want to attach the handler to the loop - i.e. the it is invoked when the exception breaks out of this loop, you would write it as
DO
CallSomeMethod();
CallSomeOtherMethod();
OD -- note: no semicolon; loop still incomplete
ON (SomeFunkyException): -- handler for exception in the loop statement
LogThisException();
END;The DO-OD bracing of the loop body makes it a block, to which a handler may be attached without any further blocking. If you want to attach a handler to the two calls, not to the loop as such, you have to make them into block by bracing them:
DO WHILE ExceptionCount < 10;
SomeCallNotHanldedByTheOnClause();
BEGIN
CallSomeMethod();
CallSomeOtherMethod();
END -- no semicolon - handler follows
ON (SomeFunkyException): -- handler for exception in the loop statement
LogThisException();
Exceptioncount +:= 1;
END;
AnotherCallWithNoHandler();
OD;Now the handler for the two statements is processed within the loop, and unless another exception is caused, control stays within the loop. CHILL uses keywords rather than braces; that is not the point here. Braces might have saved a few keystrokes, but since keywords often come in pairs, they do their own bracketing, like DO-OD, ON-END, ... You need to indicate which kind of block (like DO), and adding a brace to indicate "I am serious - a block!" is redundant. You could of course save a keystroke by replacing the OD with a closing brace, but I'd find it strange for braces not to come in pairs. I rather have an OD terminating a loop body, a FI term
-
You could e.g. look at CHILL, aka Z.200: Any block may have a handler attached: If there is an ON-clause between the body of the block and the terminating semicolon, the block has a hanlder. If there is no ON-clause, it does not have a handler. THere is no need to pre-announce it. Note that in CHILL, as well as in most other sensible languages of the Algol class, a statement is a block; you don't need to enclose a single statement to make it one. So it would be like
CallSomeMethod();
CallSomeOtherMethod() -- note: no semicolon - block not yet complete
ON (SomeFunkyException):
LogThisException();
END; -- here is the semicolon terminating the blockUsually when you want to attch a handler to a group of statements, that group is e.g. a function body, a loop, an if/then/else etc. defining a block. If these two calls are looped, and you want to attach the handler to the loop - i.e. the it is invoked when the exception breaks out of this loop, you would write it as
DO
CallSomeMethod();
CallSomeOtherMethod();
OD -- note: no semicolon; loop still incomplete
ON (SomeFunkyException): -- handler for exception in the loop statement
LogThisException();
END;The DO-OD bracing of the loop body makes it a block, to which a handler may be attached without any further blocking. If you want to attach a handler to the two calls, not to the loop as such, you have to make them into block by bracing them:
DO WHILE ExceptionCount < 10;
SomeCallNotHanldedByTheOnClause();
BEGIN
CallSomeMethod();
CallSomeOtherMethod();
END -- no semicolon - handler follows
ON (SomeFunkyException): -- handler for exception in the loop statement
LogThisException();
Exceptioncount +:= 1;
END;
AnotherCallWithNoHandler();
OD;Now the handler for the two statements is processed within the loop, and unless another exception is caused, control stays within the loop. CHILL uses keywords rather than braces; that is not the point here. Braces might have saved a few keystrokes, but since keywords often come in pairs, they do their own bracketing, like DO-OD, ON-END, ... You need to indicate which kind of block (like DO), and adding a brace to indicate "I am serious - a block!" is redundant. You could of course save a keystroke by replacing the OD with a closing brace, but I'd find it strange for braces not to come in pairs. I rather have an OD terminating a loop body, a FI term
I must be missing something - with the exception (no pun intended!) of the single-statement / single-block case, why is:
BEGIN
...
END
ON (SomeFunkyException): ...
END;any better than:
try
{
...
}
catch (SomeFunkyException)
{
...
}Is it just the curly-braces you don't like? :confused:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
A couple questions: What is your audience? Non-technical average Joe? Technical (domain expert) but non-programmer? Software engineer? Firmware Engineer?, etc, etc, etc. What is the target program type? Web? Windows/Linux application? Embedded realtime?, etc, etc, etc I believe you're not going to find (or create) the 'perfect' language that's practical and concise that will handle all these user types and targets.
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
Kotlin: maybe not best "human-understandable" but it takes Java and make it more concise. You don't have to write many things the Kotlin that you write in the Java. Red: it's still in the alpha version but you should keep an eye on it. You can write in different styles but you can write small & concise code. It has some "weird features". Ruby: It might be not fastest language but it's very readable. No "parenthesis hell" (same as in the Red) as in other languages.
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
No one has mentioned Python?!? That's interesting.
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
Why? Why optimize for concise? To save YOU time typing? I write code in a pseudo code format for the first pass, then have to translate it to one of many languages depending on the target. Most concepts are clear enough. What about R? (Functional languages?) But again... I prefer a language that has the libraries/components/tools that I need. If I gave you your "perfectly" concise language, without a bunch of caveats, like no libraries, no classes, no protocol support. Would you want to use it? If you had to implement AES, SMTP, HTTP, etc all by hand? == The most important thing I ever learned... Once you know how to write the program properly. The language is not usually what is holding you back. Especially with UDFs. == For me. C was the most elegant language and always my favorite. It was PDP Macro Assembler as a language with indentation and code blocks, UDFs, etc. etc. And probably a bit too concise, LOL!
-
I must be missing something - with the exception (no pun intended!) of the single-statement / single-block case, why is:
BEGIN
...
END
ON (SomeFunkyException): ...
END;any better than:
try
{
...
}
catch (SomeFunkyException)
{
...
}Is it just the curly-braces you don't like? :confused:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Yes, you are missing something. The BEGIN-END really has nothing to do with the exception handling - it does NOT announce the ON. It just creates a block out of smaller ones. It has multiple uses; you could e.g. label the block, and skip out of it if some test is not satisfied, like
ManySteps:
BEGIN
Step1();
IF PreparationWentWrong THEN EXIT ManySteps;
Step2();
IF Specialcondition THEN EXIT ManySteps;
Step3();
END ManySteps;This is just a way to make a block that is not a loop, not a conditional statement, not a function body, but just a sequence of smaller blocks put togeteher for some purpose (such as here: For leaving, when conditions are right). Actually, I sometimes do something similar in C#, using a "do { ... } while (false);" to allow me many exits from the statement sequence without cdreating a deep nest of if-statements - but the C family allows just exiting the innermost block; in CHILL you can exit directly from any labeled surrounding block. Whatever might be: The BEGIN-END has nothing to do with the try {...}. You may say that in CHILL, any block "implies a try {}". I do not like redundant markup, whether extra keywords, braces, parentheses or whatever. If you say "Here come a DO-block" by using a DO keyword, then you should not need to add neither BEGIN nor a brace to say that "this is the block". Of course it is - you said so already! When you say "Here comes a conditional block" by using an IF keyword, you should not need to use an open parenthesis to say that "here comes the condition". Of course - how often do you see an if keyword not followed by a condition? So why do you have to announce it by opening a parentheses pair? In prose text, you never need to write the condition part of a question in parentheses, why do you have to in C? If you want to treat two smaller blocks as one unit, whether for exception handling, exiting or whatever, one way or another you must identify which blocks you are talking about. THat markup is not redundant, whether it is done with keywords, braces or indentation alone. When you are comparing the try{} with the BEGIN-END, you are comparing apples with oranges, redundant with non-redundant markup. In C-style languages, the braces are there for the try (alone):
try {
SingleStatement();
}
catch ...Well, you could argue that in C languages, the parentheses are not redundant, as a single statement is not considered a block, so the braces are required to created o
-
Yes, you are missing something. The BEGIN-END really has nothing to do with the exception handling - it does NOT announce the ON. It just creates a block out of smaller ones. It has multiple uses; you could e.g. label the block, and skip out of it if some test is not satisfied, like
ManySteps:
BEGIN
Step1();
IF PreparationWentWrong THEN EXIT ManySteps;
Step2();
IF Specialcondition THEN EXIT ManySteps;
Step3();
END ManySteps;This is just a way to make a block that is not a loop, not a conditional statement, not a function body, but just a sequence of smaller blocks put togeteher for some purpose (such as here: For leaving, when conditions are right). Actually, I sometimes do something similar in C#, using a "do { ... } while (false);" to allow me many exits from the statement sequence without cdreating a deep nest of if-statements - but the C family allows just exiting the innermost block; in CHILL you can exit directly from any labeled surrounding block. Whatever might be: The BEGIN-END has nothing to do with the try {...}. You may say that in CHILL, any block "implies a try {}". I do not like redundant markup, whether extra keywords, braces, parentheses or whatever. If you say "Here come a DO-block" by using a DO keyword, then you should not need to add neither BEGIN nor a brace to say that "this is the block". Of course it is - you said so already! When you say "Here comes a conditional block" by using an IF keyword, you should not need to use an open parenthesis to say that "here comes the condition". Of course - how often do you see an if keyword not followed by a condition? So why do you have to announce it by opening a parentheses pair? In prose text, you never need to write the condition part of a question in parentheses, why do you have to in C? If you want to treat two smaller blocks as one unit, whether for exception handling, exiting or whatever, one way or another you must identify which blocks you are talking about. THat markup is not redundant, whether it is done with keywords, braces or indentation alone. When you are comparing the try{} with the BEGIN-END, you are comparing apples with oranges, redundant with non-redundant markup. In C-style languages, the braces are there for the try (alone):
try {
SingleStatement();
}
catch ...Well, you could argue that in C languages, the parentheses are not redundant, as a single statement is not considered a block, so the braces are required to created o
Member 7989122 wrote:
This is just a way to make a block that is not a loop, not a conditional statement, not a function body, but just a sequence of smaller blocks put togeteher for some purpose
You can create a similar block in C# using braces. And if you're particularly masochistic, you can mimic the
EXIT
with a goto[^]. :)ManySteps:
BEGIN
Step1();
IF PreparationWentWrong THEN EXIT ManySteps;
Step2();
IF Specialcondition THEN EXIT ManySteps;
Step3();
END ManySteps;{
Step1();
if (PreparationWentWrong) goto ExitManySteps;
Step2();
if (Specialcondition) goto ExitManySteps;
Step3();
}
ExitManySteps:But this example would probably be better handled with SEH - if something went wrong, you don't want to depend on the caller checking a return value, or some unrelated property.
Member 7989122 wrote:
When you say "Here comes a conditional block" by using an IF keyword, you should not need to use an open parenthesis to say that "here comes the condition".
That could potentially lead to ambiguity - which statement(s) are part of the condition, and which are part of the branch? Even if it's always obvious to the compiler, it may not always be obvious to the person reading the code. And the main point of any code is to be read and understood by a person.
Member 7989122 wrote:
That is a major flaw in the language "design".
No, it's a major difference in the language design. (And yes, the language was designed. No need for the sarcisti-quotes.) English doesn't have accents on any letters; you're just supposed to know how to pronounce them. Does that makes the accents in other languages a flaw? Or is English the flawed language for not having them? Just because something is different doesn't mean that it's flawed.
Member 7989122 wrote:
At the end of a deep nest, in C languages there may be a lisp-like sequence of closing parentheses, and you may have a hard time seeing which one closes the outermost loop, the while, the function, the class...
-
Here's my fantasy rewrite of some Javascript. Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest. JS
var home = {
cit : "Boston",
get City () {
return this.cit;
},
set City(val) {
this.cit = val;
}
};Fantasy Rewrite
home
City 'Boston'That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words. What language is like that?
What's "Human understandable"?
I mean, easy to understand at a glance. Here's Game of Life in APL. Extremely concise! And totally NOT human-understandable.
{≢⍸⍵}⌺3 3∊¨3+0,¨⊢
Here's the Whitespace language. Extremely concise, and totally NOT human-understandable. Seeking characters found on a normal keyboard.
By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.
What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.
johnywhy wrote:
Here's some COBOL. Very human understandable. But not concise:
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.The boilerplate required in COBOL in order to encapsulate those three lines is going to be around another 300 lines of code, code which is not particularly human-readable ;P
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
-
Why? Why optimize for concise? To save YOU time typing? I write code in a pseudo code format for the first pass, then have to translate it to one of many languages depending on the target. Most concepts are clear enough. What about R? (Functional languages?) But again... I prefer a language that has the libraries/components/tools that I need. If I gave you your "perfectly" concise language, without a bunch of caveats, like no libraries, no classes, no protocol support. Would you want to use it? If you had to implement AES, SMTP, HTTP, etc all by hand? == The most important thing I ever learned... Once you know how to write the program properly. The language is not usually what is holding you back. Especially with UDFs. == For me. C was the most elegant language and always my favorite. It was PDP Macro Assembler as a language with indentation and code blocks, UDFs, etc. etc. And probably a bit too concise, LOL!
> Why optimize for concise? To save YOU time typing? I don't think typing is a problem when you have IDEs with autocompletion. The problem is reading. Sure, your IDE will colour this and that but you still have, for example, whole line just saying " is the name of the function".