English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 16 July 2023, 02:14   #621
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
C++ is also full of nonsense keywords such as void, empty parentheses of different shapes, and lots of declarative nonsense such as

Struct struct = struct;

or anything similar that will make any thinking man squint and blink. It is rather terrible for readability compared to let's say, ideal pseudocode where you break down a problem into constituent parts with as little of the nonsense as you can manage.

But I'm succumbing a bit here to the criticisms of C, which was not my intent. Rather to provide positives from coding in Assembler over C, and I don't have anything to add to what I already suggested.

Main point is have fun coding for Amiga, my friends.
Photon is offline  
Old 16 July 2023, 02:31   #622
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,337
Quote:
Originally Posted by grond View Post
Um, I bet the next time you run the program, the Dynamo thingy can just load its stats from the first time it ran the program and doesn't have to wait another two minutes to perform the same optimisations to the same code.
Clang has an option to load a profile from a profiled run of a program and recompile it using that information to reorganise the code according to hot paths identified during the profiling stage. It is not quite as dynamic as a JIT, but allows static optimisation to get closer to dynamic optimisation – assuming your profiling run is close enough to all your users' use cases.
idrougge is offline  
Old 16 July 2023, 09:49   #623
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
Quote:
Originally Posted by Photon View Post
C++ is also full of nonsense keywords such as void, empty parentheses of different shapes, and lots of declarative nonsense such as

Struct struct = struct;

or anything similar that will make any thinking man squint and blink. It is rather terrible for readability compared to let's say, ideal pseudocode where you break down a problem into constituent parts with as little of the nonsense as you can manage.
C++ is a huge multiparadigm language, so yes, it has a lot of syntax. None of which you are obliged to use if all you want to do is write tightened up C.
Karlos is offline  
Old 16 July 2023, 11:14   #624
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 532
Quote:
Originally Posted by meynaf View Post
So now C's preprocessor is not C. This means all C programs in existence contain parts that use another language. Preposterous.
For a good laugh, read Peter van der Linden's book "Expert 'C' programming: Deep 'C' secrets". You couldn't make this stuff up if you tried it, because it has already been tried, successfully, between 1972-1973 and no further experiments have been conducted since.

There must be a reason why contemporary 'C' literature (introductory or reference) is what it is: either brief and/or out of print or so large you may wonder whether you bought a C++ book by mistake. 'C' is the perfect combination of weird and useful.
Olaf Barthel is offline  
Old 16 July 2023, 11:33   #625
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
The fact is, the C preprocessor has it's own syntax and is separate from C, even though it's part of any standard C compiler distributions included tooling. It doesn't understand C itself (though implementations are free to improve upon that) and just operates on the raw text. It will happily mangle C code via macros into something that either doesn't compile, or worse still will compile but just not into what the developer may have expected.

So no, it's not part of the compiled C language syntax. It's a separate tool that's included to make conditional compilation of C more manageable. I've used the C preprocessor to process other languages.
Karlos is offline  
Old 16 July 2023, 12:00   #626
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
Quote:
Originally Posted by Karlos View Post
I've used the C preprocessor to process other languages.
Fun fact: if an assembly language source file's name ends with ".S" instead of ".s", GCC will run it through the C preprocessor before assembling it!

(I abused this horribly in the early days of my CPU project because I was too lazy to write an assembler until I was sure the project was worth carry to completion: http://retroramblings.net/?p=1272 )
robinsonb5 is offline  
Old 16 July 2023, 12:20   #627
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
Quote:
Originally Posted by robinsonb5 View Post
Fun fact: if an assembly language source file's name ends with ".S" instead of ".s", GCC will run it through the C preprocessor before assembling it!

(I abused this horribly in the early days of my CPU project because I was too lazy to write an assembler until I was sure the project was worth carry to completion: http://retroramblings.net/?p=1272 )
I used the preprocessor to allow me to express MC64K bytecode as something human readable for testing the interpreter before writing an actual assembler. Just don't as what that ended up being written in.
Karlos is offline  
Old 16 July 2023, 12:39   #628
malko
Ex nihilo nihil
 
malko's Avatar
 
Join Date: Oct 2017
Location: CH
Posts: 4,884
Quote:
Originally Posted by Karlos View Post
[...] as something human readable [...]
Anything can be humain readable as soon as you have learned it. All the different languages that exist on earth prove it everyday.
So you should better say "as something I have learned and understand".
malko is offline  
Old 16 July 2023, 13:11   #629
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,233
Quote:
Originally Posted by malko View Post
So you should better say "as something I have learned and understand".
No, tnat is not quite the point. For assembly, you are just distracted by all the low-level register logic and cannot quite focus on the algorithmic details of a problem. Also "brainfuck" is "human readable", if you are trained to it, but it is still not a practical language.
Thomas Richter is offline  
Old 16 July 2023, 13:45   #630
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
Quote:
Originally Posted by malko View Post
Anything can be humain readable as soon as you have learned it. All the different languages that exist on earth prove it everyday.
So you should better say "as something I have learned and understand".
Sure, you can read a long array of byte values that contains a mixture of opcode values and encoded multibyte values for branch offsets and varying size integer and floating point immediates. I don't think it's quite as friendly as a bunch of function like C macros that generate the same using mnemonic like names.
Karlos is offline  
Old 16 July 2023, 14:20   #631
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,337
Quote:
Originally Posted by Karlos View Post
Precisely. You cite complications in C from the preprocessor which is just a macro text processor as a defect of the language that is not possible in assembler. That's only true fo assemblers that have no macro functionality at all.

How about an example of where the compiled language after preprocessing stage creates problems that can't happen in assembly language? After all, I can write a C program with absolutely zero involvement of the preprocessor just as you can write assembly without macros.
But we all know that that is a purely academic exercise, both for C and asm. C wouldn't be a useful language without the preprocessor, it does so much that is done in the language/compiler itself in higher-level languages but that was left out of the core C language. To begin with, you can't even include a basic header file without the preprocessor.

One cannot realistically separate C from its preprocessor.
idrougge is offline  
Old 16 July 2023, 15:00   #632
malko
Ex nihilo nihil
 
malko's Avatar
 
Join Date: Oct 2017
Location: CH
Posts: 4,884
Friendliness in reading will vary from people to people.

https://www.protemgl.com/articles/th...-movie-arrival



You can use this keyboard also :

[ Show youtube player ]



Edit : If you have never seen this one : start at 5:15

[ Show youtube player ]

Last edited by malko; 16 July 2023 at 19:31.
malko is offline  
Old 16 July 2023, 15:45   #633
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
Quote:
Originally Posted by idrougge View Post
But we all know that that is a purely academic exercise, both for C and asm. C wouldn't be a useful language without the preprocessor, it does so much that is done in the language/compiler itself in higher-level languages but that was left out of the core C language. To begin with, you can't even include a basic header file without the preprocessor.

One cannot realistically separate C from its preprocessor.
Yes, you can. You can use a different preprocessor or no preprocessor. You just wont be able to compile existing code written for the standard preprocessor. You'd be mad for wanting to do so, but if the preprocessor is so noxious to your sensibilities because it can produce broken and invalid code if you misuse it, you can be a masochist and write a giant single C source*, declare every standard library function and structure you intend to use based on their existing definitions in their respective headers and compile and link it. You will not necessarily be able to compile this on a different target because you forewent the sensible approach of using what is included and the abstractions they use to generalise across implementations.

Of course, writing single gigantic file programs that only work on a single platform is probably water off a ducks back to your common or garden variety assembler programmer. Maybe they'd enjoy C a lot more this way.

*Not strictly required if you don't mind duplicating all your declarations in multiple files.

Last edited by Karlos; 16 July 2023 at 15:54.
Karlos is offline  
Old 16 July 2023, 16:48   #634
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,763
Quote:
Originally Posted by Karlos View Post
Of course, writing single gigantic file programs that only work on a single platform is probably water off a ducks back to your common or garden variety assembler programmer. Maybe they'd enjoy C a lot more this way.
Not a chance Multiple files in both ASM and C is the best thing since sliced bread
Thorham is online now  
Old 16 July 2023, 18:08   #635
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
Quote:
Originally Posted by Thorham View Post
Not a chance Multiple files in both ASM and C is the best thing since sliced bread
As per the disclaimer, multiple files still works.
Karlos is offline  
Old 16 July 2023, 18:49   #636
Hypex
Registered User
 
Join Date: May 2015
Location: Australia
Posts: 131
Quote:
Originally Posted by Thorham View Post
Yes, you could, because Bethesda isn't writing it

Which didn't change a damned thing

Who now hold the keys of Doom. ;-)



Speaking of Doom, here's an example. So it's made made clear why C would be used over ASM for practicality to deal with an algorithm. In particular graphic algorithm. And with Doom we see it is written in C and not ASM, though the PC did have coding tutorials in ASM just like the Amiga.


Now the Amiga received several Doom ports. But some has some ASM optimisation. If the C code already existed with a decent compiler, which the Amiga had, then why attempt to rewire the wheel?


Furthermore, and here's a clincher, if at the end of the day C is the best tool for job with compilers like SAS/C then why did they write those chunky to planar algorithms in ASM instead of C? :-?

Last edited by Hypex; 19 July 2023 at 15:27.
Hypex is offline  
Old 16 July 2023, 20:58   #637
chb
Registered User
 
Join Date: Dec 2014
Location: germany
Posts: 439
OT: The original DOS version of doom included routines for the texture mapping inner loops in asm.
chb is offline  
Old 16 July 2023, 21:13   #638
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,105
Quote:
Originally Posted by chb View Post
OT: The original DOS version of doom included routines for the texture mapping inner loops in asm.
As did quake, and likely every other "serious" game that used software rendering until things switched to using GPUs. More interesting (for this discussion) I think, is that even wolfenstein (1992) used C for most part (though with heavy use of [inline] assembly).
paraj is offline  
Old 16 July 2023, 21:17   #639
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
Quote:
Originally Posted by paraj View Post
As did quake, and likely every other "serious" game that used software rendering until things switched to using GPUs. More interesting (for this discussion) I think, is that even wolfenstein (1992) used C for most part (though with heavy use of [inline] assembly).
Actually, quake initially had no asm code, even for DOS. That's what Abrash was there for. Almost everything written by Carmack was pure C.
Karlos is offline  
Old 16 July 2023, 21:19   #640
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,165
Just to nitpick, DOS was not the original Doom. It was written on a 68040 powered NeXT system IIRC.
Karlos 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
Chat GPT Amiga Assembly rcman Coders. Asm / Hardware 3 26 March 2023 20:24
An Amiga coder was banned without a reason - is it ok? litwr project.EAB 1 18 June 2021 20:38
Beginning Amiga Assembly Tutorial(s) Curbie Coders. Asm / Hardware 15 29 May 2020 00:21
Beginning Amiga Assembly Programming Hewitson Coders. Tutorials 32 09 October 2012 18:25
Amiga Assembly sources - Please help! W4r3DeV1L Amiga scene 21 16 July 2008 08:13

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 07:20.

Top

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