English Amiga Board


Go Back   English Amiga Board > Main > Amiga scene

 
 
Thread Tools
Old 24 August 2015, 02:52   #301
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,348
Quote:
Originally Posted by Mrs Beanbag View Post
why do you keep bringing up C even after i've said i'm not advocating C. There are loads of things wrong with C but curly braces are the least of it: they may be butt ugly but they're nothing complex or difficult. I wouldn't advocate C for a beginner mostly because of the pointer arithmetic, rather than the syntax. JavaScript, however, is perfectly viable as a beginner's language, for all its quirks.
Once you get used to curly braces (and learn to type it if you have a non-English keyboard), they may seem simple enough, but they also take some effort for the brain to decode.

Quote:
Originally Posted by Mrs Beanbag
But let's think about what curly braces actually do in C. They delineate code blocks. That is a necessary thing because a loop or a conditional statement (or whatever else) has to have a body. Other languages do it in different ways. Python does it just by indentation, which forces the programmer to write in a neat way, and one can immediately see the structure of the code without having to read any of the keywords.
I had my doubts about trying to teach a beginner programmer the art of Python indentation, but I think I've come to the conclusion that it makes sense. C programmers tend to indent their blocks as well, even though they have their braces, so why do both when one will do?

Quote:
Originally Posted by Mrs Beanbag
BASIC, on the other hand, has no consistent way to delineate a code block at all. There is no way to tell that a pair of statements encloses a block other than by knowing about those statements already, thus intertwining syntax and semantics. Bad enough that there are umpteen different ways to start a code block, each one has a special way to end it as well, so you have to learn symbols in pairs... IF...END IF, FOR...NEXT, WHILE...WEND &c.. the human brain might be able to cope with this, but if it requires a complex parser it is not a simple language.
That is much preferable to { ... } if you ask me. You start a block, and then you finish it with a matching terminator. It removes some of the confusion when sorting out the end of a long program block, which in C might end with }}}}} but in BASIC might end in ENDIF : NEXT B : WEND : ENDIF : UNTIL X>10

Of course, the exact names of these statements may be haphazard, and I think it took me fifteen years to understand what WEND meant. COMAL tries to sort this out by unifying the format of the block terminators – e.g. FOR…ENDFOR, IF…ENDIF, WHILE…ENDWHILE and so forth.

Quote:
Originally Posted by Mrs Beanbag
Megol already mentioned some of the other things i was going to say, but in addition to that, there is even more "ascii garbage" that BASIC syntax typically uses. For instance, arithmetic operators and parenthesis. For instance, one can write:
Code:
Let A = (B+C)*2
That seems nice and clear to me, despite containing non-alphanumeric characters, but maybe you would prefer something like this:
Code:
Let A equal calculate B plus C first times 2
I jest, but, this is more-or-less how Smalltalk works. Or if you really like parenthesis, you might like Lisp, which is about the simplest programming language there is aside from Rule 110. I didn't say "easiest".
There is a difference between the symbols taught in the first years of primary school maths, and those that only mean something to the parser. I'm not suggesting COBOL expressions like MULTIPLY A BY 3 GIVING B in order to avoid the use of non-alphabetic characters. That's why C-inspired languages use a=2+3 when the proper C way should be a=add(2,3).

Lisp may not be so bad, though. When I took a programming course in school at 17, the first teaching language was Scheme.

Quote:
Originally Posted by Mrs Beanbag
But that's not even the worst of it. I think the worst of it is that you can't really talk of "BASIC syntax" at all. Every BASIC statement has its own syntax. Let's just look at a simple print statement:
Code:
Print "There are ";n;" sheep"
Let's just accept that a semicolon is a fine thing to have in a statement, but what does it MEAN? The answer is that it doesn't mean anything outside of a Print statement. One cannot do:
Code:
Let A$="There are ";n;" sheep"
because a ';' is not a string concatenation operator that works on the argument passed to Print. It is only part of Print's special and unique syntax. Well you could define it as a string operator, and that would be nice... but you'd have a job trying to work out what putting a semicolon on the END of a string means (although we all know what it does on the end of a Print statement).
Let's face it, PRINT statements will always be a bit special, because they are a bit special. Everyone, from "hello world" to a senior programmer's debug output, uses it. It can afford to be a bit special. Even "printf" is a special case, because usually functions don't take varying numbers of arguments.

One could wish for a much better string handling in BASIC, but then again one can wish for that in any language that doesn't play on the same level as ARexx.

Quote:
Originally Posted by Mrs Beanbag
And then there's the ascii-garbage equals sign, '='
Code:
10 Let A=5
20 If A=5 Then Print "A is 5"
30 For I=0 To 10 Step 2
...
The equals sign means something different in every one of these statements. The meaning of = on line 20 is responsible for so many errors made by people who learnt to program in BASIC and then graduated onto a more sensible language.
I don't see what's so sensible about using "=" as an assignment operator in the first place, or what's so sensible about using infix notation when every other part of the language puts arguments at the end.

Quote:
Originally Posted by Mrs Beanbag
But on the 30th line it is difficult to know what it means at all. I know what it does, but it is literal nonsense. In any case, one cannot do:
Code:
Let A=0 To 10 Step 2
For I in A ...
Which is a shame, because that would be hella cool. One could it imagine it working also on arrays and strings...
Code:
Let A="Hello world!" : REM Type inference!
For I in A:
   Print I
Result: each character of the string on its own line...
That's nice, but what you're suggesting is one of Meagol's beloved BASIC offspring. It's still got the same basic accessibility of BASIC, or Python if you wish.

Quote:
Originally Posted by Mrs Beanbag
But alas, it was never meant to be, because BASIC was invented in 1964 when "real" programming was only done in assembly language and none of the staple concepts of modern programming had been invented.
Depends on what you mean by modern. Structured programming was invented around 1959-60 with ALGOL, and there was at least some kind of Lisp.
idrougge is offline  
Old 24 August 2015, 12:36   #302
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
Quote:
Originally Posted by idrougge View Post
Once you get used to curly braces (and learn to type it if you have a non-English keyboard), they may seem simple enough, but they also take some effort for the brain to decode.
Not a great deal, unless there is a lot of nesting, which is bad style anyway. Text editors can highlight the matching pairs, as well, which is very useful. There are benefits and drawbacks of every style, of course.

Quote:
I had my doubts about trying to teach a beginner programmer the art of Python indentation, but I think I've come to the conclusion that it makes sense. C programmers tend to indent their blocks as well, even though they have their braces, so why do both when one will do?
It's great until you accidentally get some tabs mixed up in there! It's also pretty easy to screw up the indentation by accident, and then good luck finding that bug.

Quote:
Of course, the exact names of these statements may be haphazard, and I think it took me fifteen years to understand what WEND meant. COMAL tries to sort this out by unifying the format of the block terminators – e.g. FOR…ENDFOR, IF…ENDIF, WHILE…ENDWHILE and so forth.
COMAL is certainly on the right track there, but i think my main problem is that you can't immediately see the structure, because the symbols that delineate the blocks are just words, they are indistinguishable from other kinds of statements without actually reading them. How do you like XML, by the way?

Quote:
Lisp may not be so bad, though. When I took a programming course in school at 17, the first teaching language was Scheme.
If computers had been invented by the Arabs, we'd all be using something like Lisp.

Quote:
Let's face it, PRINT statements will always be a bit special, because they are a bit special. Everyone, from "hello world" to a senior programmer's debug output, uses it. It can afford to be a bit special. Even "printf" is a special case, because usually functions don't take varying numbers of arguments.
Not so... anyone can write a "variadic function" in C. Although it is a pain in the ass so generally nobody does.

Quote:
I don't see what's so sensible about using "=" as an assignment operator in the first place, or what's so sensible about using infix notation when every other part of the language puts arguments at the end.
Quote:
That's nice, but what you're suggesting is one of Meagol's beloved BASIC offspring. It's still got the same basic accessibility of BASIC, or Python if you wish.
It really isn't... my gripe with BASIC is not its absence of features, but the lack of generality and structure in the syntax. The "new features" i've suggested are only the logical extension of existing features that are currently only allowed in a single context. "0 to 10 step 2" is a phrase that already appears in BASIC programs. What i'm suggesting is to interpret it as an object in itself, that can be used generically.

Anyway i'm still puzzled by this claim of BASIC's "accessibility". You still have to learn it, just like anything else. It might "look a bit like English," but it isn't English. You can't just type "hack into CIA mainframe". And anyway that doesn't help anyone who doesn't speak English, which is most people in the world. The most you can say about it is that it doesn't look too scary, and maybe a lack of unfamiliar characters might help with that, maybe it's time for a language that uses emoji.

Quote:
Depends on what you mean by modern. Structured programming was invented around 1959-60 with ALGOL, and there was at least some kind of Lisp.
I mean object oriented programming, functional programming, generic programming... but all you're telling me now is that BASIC was already out of date when it was new.
Mrs Beanbag is offline  
Old 24 August 2015, 21:30   #303
commodorejohn
Shameless recidivist
 
commodorejohn's Avatar
 
Join Date: Jun 2012
Location: Duluth, Minnesota (USA)
Age: 38
Posts: 266
Quote:
Originally Posted by idrougge View Post
I had my doubts about trying to teach a beginner programmer the art of Python indentation, but I think I've come to the conclusion that it makes sense. C programmers tend to indent their blocks as well, even though they have their braces, so why do both when one will do?
Because literal whitespace is an abomination that belongs in the Pit of Eldritch Horrors along with JCL and RPG. Getting an error because you didn't include the correct amount of something is irritating enough; getting an error because you didn't include the correct amount of nothing is absolutely ridiculous.

Quote:
Originally Posted by Mrs Beanbag View Post
If computers had been invented by the Arabs, we'd all be using something like Lisp.
This is an interesting assertion. What makes you say that?

Quote:
It really isn't... my gripe with BASIC is not its absence of features, but the lack of generality and structure in the syntax. The "new features" i've suggested are only the logical extension of existing features that are currently only allowed in a single context. "0 to 10 step 2" is a phrase that already appears in BASIC programs. What i'm suggesting is to interpret it as an object in itself, that can be used generically.
Smalltalk does exactly this; its for-loop equivalent is just a generic iteration message sent to an Interval object:
Code:
1 to: 10 do: [ :x | Transcript print: x ]
commodorejohn is offline  
Old 24 August 2015, 23:34   #304
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
Quote:
Originally Posted by idrougge View Post
Once you get used to curly braces (and learn to type it if you have a non-English keyboard), they may seem simple enough, but they also take some effort for the brain to decode.
Agreed. Although I haven't used any programming languages (as such) that use curly braces, the script that is used to describe scenes in POVray (PC software) does.


Quote:
Originally Posted by idrougge View Post
I had my doubts about trying to teach a beginner programmer the art of Python indentation, but I think I've come to the conclusion that it makes sense. C programmers tend to indent their blocks as well, even though they have their braces, so why do both when one will do?
I always indent my BASIC code (for the languages that allow it, which is most modern BASIC languages) where appropriate. For example...

Code:
For Y=0 to 250
    For X=0 to 319
        MYCOLOR=INT((X/50)+10+(Y*50)) Mod 16
        Plot X,Y,MYCOLOR
    Next X
Next Y
I usually only indent between instructions like While... Wend, If... Endif etc.
Lonewolf10 is offline  
Old 24 August 2015, 23:53   #305
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
Quote:
Originally Posted by commodorejohn View Post
This is an interesting assertion. What makes you say that?
Arabic, as a language of the Semitic family, uses Verb-Subject-Object word order. So much different from English, with its "infix notation" Subject-Verb-Object syntax.

BASIC is loosely based around English syntax. A programming language based around Arabic? Well we can but dream... but modern science and mathematics owes an awful lot to them (i actually have a very good book to read on this subject, and i will get back to you when i have read it.)
Mrs Beanbag is offline  
Old 25 August 2015, 01:18   #306
commodorejohn
Shameless recidivist
 
commodorejohn's Avatar
 
Join Date: Jun 2012
Location: Duluth, Minnesota (USA)
Age: 38
Posts: 266
Interesting.
commodorejohn is offline  
Old 25 August 2015, 08:29   #307
Megol
Registered User
 
Megol's Avatar
 
Join Date: May 2014
Location: inside the emulator
Posts: 377
People that complain about syntactic indentation seem to never have used a language using it, often making ridiculous assertions while ignoring the problems with their favorite language (most often C family languages).

With that said and disregarding the visual clarity of syntactic indentation I personally think block based syntax is a better choice for readability. Examples from my toy project:

Code:
if x=123
  ...          -- actually a valid statement :)
end

if x=123 then ... -- short version without block

for i=0..100 by 2
  ...
end

for i=0..100 by 2 do ... -- short version
Megol is offline  
Old 25 August 2015, 09:27   #308
commodorejohn
Shameless recidivist
 
commodorejohn's Avatar
 
Join Date: Jun 2012
Location: Duluth, Minnesota (USA)
Age: 38
Posts: 266
I don't dispute that indentation is a very useful readability aid. I'm also not going to argue that curly braces are the only way - I'm fine with languages that employ English-like block delimiters or even inferred block delimiters.

What I will have none of, however, is the idea that actually defining scope in terms of whitespace is no problem. That stuff is absolute nonsense.
commodorejohn is offline  
Old 25 August 2015, 10:33   #309
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,193
The fact that tabs OR spaces but not both can be used with Python is a terrible annoyance, indeed. I still lean in favor of a graphical tree gadget though.
Samurai_Crow is offline  
Old 25 August 2015, 12:04   #310
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
Quote:
Originally Posted by Megol View Post
Examples from my toy project:

Code:
if x=123
  ...          -- actually a valid statement :)
end

if x=123 then ... -- short version without block

for i=0..100 by 2
  ...
end

for i=0..100 by 2 do ... -- short version
I like how you use the same keyword for all the end statements. But i would swap round the syntax of the short and long versions, so that "do" is a universal block beginning. Then you can always see that there is a block even when confronted with an unfamiliar statement, which maybe also eases expansion of the language.

Quote:
Originally Posted by Samurai_Crow View Post
The fact that tabs OR spaces but not both can be used with Python is a terrible annoyance, indeed.
Quite... but the width of a tab could be set to anything in the editor so it gets a bit awkward! I've pondered using some other character, maybe |, like so:

Code:
Start of a block:
|   inner statement
|   Start of a block
|   |   inner inner statements
|
|   inner statement
so you can trace down the lines and see where it lines up, which can actually be quite difficult with only whitespace indentation, if you have a very long function (more than a screen).

Quote:
I still lean in favor of a graphical tree gadget though.
i was sceptical of this at first. i still am, in a way, but it's starting to make a sort of sense to me. the thing is, the "graphical tree" on the screen can only be a representation of a data structure in memory, which has to be serialisable, and if that serialisation is human readable, there's a text-based language right there. But it strikes me that that might actually be the best way to go about designing a language. It's tempting to start by thinking about what sort of syntax you'd prefer, and then work out how to compile it, but maybe that's backwards. Maybe we should start by writing the compiler--or rather, an abstract syntax tree--and then work backwards from that: think of the simplest way to serialise it, and then add syntactic sugar to taste.

Quote:
Originally Posted by commodorejohn View Post
Interesting.
Also interesting:
http://mobile.nytimes.com/2015/08/16...ion-uzbek.html

Last edited by Mrs Beanbag; 25 August 2015 at 12:35.
Mrs Beanbag is offline  
Old 25 August 2015, 12:54   #311
Megol
Registered User
 
Megol's Avatar
 
Join Date: May 2014
Location: inside the emulator
Posts: 377
Quote:
Originally Posted by Mrs Beanbag View Post
I like how you use the same keyword for all the end statements. But i would swap round the syntax of the short and long versions, so that "do" is a universal block beginning. Then you can always see that there is a block even when confronted with an unfamiliar statement, which maybe also eases expansion of the language.
I had it like that before but didn't like it - more typing without any advantages (well for some implementations the parser could be simpler). It would be better if short statements had a common keyword, "do" could be used but for some reason I don't like it.
An earlier iteration used colon to indicate a short statement but it was easy to misread. I consider that a problem in Python too.

OTOH in this language short statements should be relatively uncommon due to guarded execution:

Code:
-- guarded variant
factorial: (n: nat)^nat
  ^1 if n=0 -- read: return 1 if n is equal to 0
  ^n*factorial(n-1)
end

-- select variant, not really a guard but sharing similar syntax
-- here the return isn't conditional and the if selects between two values
factorial2: (n: nat)^nat
  ^1 if n=0 else n*factorial2(n-1)
end
Megol is offline  
Old 25 August 2015, 13:05   #312
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
the advantage is that you can always tell there is a block there, basically "do...end" is equivalent to "{...}" but with friendlier symbols. Another idea that just occurred to me, is to use a colon for the long form and a comma for the short form. This is a bit like how we'd use punctuation in English:

Code:
if n=0, return 1
-- or
if n=0:
   return 1
end
unusual if syntax, btw.. it appears to actually reverse the order in which the terms would be executed

Last edited by Mrs Beanbag; 25 August 2015 at 13:10.
Mrs Beanbag is offline  
Old 25 August 2015, 14:10   #313
invent
pixels
 
invent's Avatar
 
Join Date: May 2014
Location: Australia
Age: 53
Posts: 476
My brain hurts (what's the topic again for those who have no clue on coding

I do appreciate the discussion though as it might inspire more..... coding

As a non topic related thought I have been tempted on making maps from the chaos engine tiles for a top down racing game ( then of course change the original tiles to new ones
invent is offline  
Old 25 August 2015, 14:32   #314
nobody
Registered User
 
nobody's Avatar
 
Join Date: Dec 2013
Location: GR
Age: 47
Posts: 1,416
#include <stdio.h>
main()
{
int s=0,i;
for (i=0; i<=10; i++)
{
printf("c%cme back on t%cpic please\n",111,111);
s=i;
}
printf("%d times\n",s);
getchar();
return(0);
}

I am getting better :P
nobody is offline  
Old 25 August 2015, 14:32   #315
beezle
Banned
 
Join Date: May 2015
Location: Australia
Posts: 67
Seriously though, perhaps its time to move the last few pages elsewhere?
Very much off topic by now.
beezle is offline  
Old 25 August 2015, 14:41   #316
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
maybe i opened up a can of worms...

it all began, iirc, when i suggested that what we really lack is a programming environment with the game-oriented feature sets of AMOS/Blitz but with a much more modern & fast compiled programming language. People get trapped in AMOS, unable to escape, even though as a language it is very limited, but nothing else offers a quick or easy way to get better results. It's why i personally took the plunge straight in asm but i appreciate how intimidating that is. I think some better tools are in order.

The idea of a games library for C has been mooted elsewhere (and also criticised, so it goes), personally i think it's a great idea, but i also appreciate that C is not ideal, either. Well you can find faults with anything i suppose.
Mrs Beanbag is offline  
Old 25 August 2015, 14:54   #317
nobody
Registered User
 
nobody's Avatar
 
Join Date: Dec 2013
Location: GR
Age: 47
Posts: 1,416
For me C is fun. I like C. Everything is reasonable so far. There are rules like all languages. I am not into Amos or Blitz, they are dead languages that will not be useful for anything else than Amiga coding from scratch, and i find them very strange for some reason.
I guess then if i approach the Amiga libraries to handle graphics etc given the complexity of the system my head will explode for sure and 0's and 1's will jump out together with some bitwise &, &&, != etc.
nobody is offline  
Old 25 August 2015, 15:29   #318
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,808
Ok one last thing - when I hear - I cant do that because of AMOS lol I always think No! you cant do it because thats you!
I would say Amos can make a platformer etc - without any extentions from my own tests 68000 - would you not agree?
Retro1234 is offline  
Old 25 August 2015, 15:48   #319
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
Quote:
Originally Posted by Boo Boo View Post
I would say Amos can make a platformer etc - without any extentions from my own tests 68000 - would you not agree?
obviously i do agree, because i have made one. but the code that makes it work, and at 50fps, is ugly as hell.

back in the days of AMOS 1.3 i read an article about coding styles (did it actually come in the AMOS 1.3 box?) that said "spaghetti coding" was faster than structured coding, well it astounded me at the time but even in AMOS Pro it turned out to be right. Procedure calls are apparently very costly, don't ask me why, but that's why PuzCat's main loop all happens in one big procedure. So apologies to anyone who's tried to get their heads around it.

Last edited by Mrs Beanbag; 25 August 2015 at 15:57.
Mrs Beanbag is offline  
Old 25 August 2015, 15:59   #320
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,808
Thank you for your reply - my main loop is just controls and then im gosubing everything.
Id love to get the time and motivation to try changing that to procedures and/or just making it all one loop just to test speeds - Im also not sure if theres any difference once its compiled. I think I might even have read Brian Bell thought Amos1.3 compiled was fasted than pro. anyways thats enough of my silliness please continue as you were
Retro1234 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the technically most impressive A500 game? mc68060 Amiga scene 67 03 June 2015 22:32
The Tales of Grupp - Another impressive homebrew ZX Spectrum title! Neil79 Retrogaming General Discussion 3 24 February 2015 19:19
New One Of "Homebrew" 68k Amiga Magazine Idea fishyfish Retrogaming General Discussion 6 16 April 2013 08:57
Impressive and Amazing PD Software! Any thoughts? hamster Retrogaming General Discussion 0 18 July 2004 01:42

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:15.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12163 seconds with 14 queries