English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 05 November 2018, 17:58   #701
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
Quote:
Originally Posted by meynaf View Post
It may look ridiculous, but it's still true. Nearly anything looks better than C, even Basic.







Sorry, but C is a terribly poor language. It has nothing elegant, simple, and even though the language itself is easy to learn, you can not do much with it without having to use more hard to learn libraries.

It has awful syntax with parenthesis overload, illogical operator priorities, meaningless closing curly braces.
Why so upset with the curlies? I prefer them to begin and end from pascal. or macro/endm in some assemblers. Or indentation in python. Just denotes scope. Although I will say C compilers usually ignore scope. So in that sense they’re pointless.

Quote:


And its total lack of dynamic sized strings/arrays make it unsuitable as high level language.

And for low level, well... asm is faster and can do everything without having to do dirty tricks.

Yes. This v true. C teases you with everything a high level language should have except the main event. Strings. I agree here.



Quote:



Most of what's written in C will also work in C++ so you're not forced to use the extra features.

Completely agree.
plasmab is offline  
Old 05 November 2018, 18:02   #702
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by plasmab View Post
Why so upset with the curlies?
When reading code with said curlies, you do not know what they mean. However in Basic for example, you immediately see the kind of block.
What does "}" mean ? You don't know without having to look above.
What does "END FOR" or "NEXT" mean ? You know immediately.
meynaf is offline  
Old 05 November 2018, 18:06   #703
Hewitson
Registered User
 
Hewitson's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,771
Quote:
Originally Posted by meynaf View Post
It may look ridiculous, but it's still true. Nearly anything looks better than C, even Basic.
I'm sorry, but that's just not true. I would be interested to see an example of what you would call ugly C code. Just because theres so many different styles of writing it.

Quote:
Originally Posted by meynaf
Sorry, but C is a terribly poor language. It has nothing elegant, simple, and even though the language itself is easy to learn, you can not do much with it without having to use more hard to learn libraries.
Few libraries I've encountered have been difficult to use. I would use OpenGL as an example of one which is extremely difficult to utilise.

Quote:
Originally Posted by meynaf
It has awful syntax with parenthesis overload, illogical operator priorities, meaningless closing curly braces.
I don't understand why you complain about the closing braces so much. It's like saying RTS in a subroutine is meaningless.

Quote:
Originally Posted by meynaf
Most of what's written in C will also work in C++ so you're not forced to use the extra features.
No, you're not, but what would be the point of using a C++ compiler to compile a program using functions/libraries that are available in C?
Hewitson is offline  
Old 05 November 2018, 18:09   #704
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,710
It's true, C often gets really messy if you nest curlies.
Especially if you code like this {
}
8bitbubsy is online now  
Old 05 November 2018, 18:19   #705
Hewitson
Registered User
 
Hewitson's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,771
Quote:
Originally Posted by 8bitbubsy View Post
It's true, C often gets really messy if you nest curlies.
Especially if you code like this {
}
That's by far my preferred style. I do always make sure there's an empty line before and after though. And with a decent editor (eg vim), the opening/closing braces are highlighted, so you know what belongs to what immediately.
Hewitson is offline  
Old 05 November 2018, 18:22   #706
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
Quote:
Originally Posted by meynaf View Post
When reading code with said curlies, you do not know what they mean. However in Basic for example, you immediately see the kind of block.

What does "}" mean ? You don't know without having to look above.

What does "END FOR" or "NEXT" mean ? You know immediately.

Ah. I guess I’m totally used to them. This is probably part of the reason a lot of places have a ~30 line code limit on method size in their coding standards. I use astyle to indent things and most modern code editors highlight the other end of the loop. So I just look at the top or bottom of the block to see what’s going on.

I’m not fond of END FOR etc. I don’t need the distinction. But if you’re not used to it I guess it’s harder. But it’s something you can get used to. I don’t feel the distinction adds much value. Java, C#, C++ etc all do it the same way more or less. So it’s somewhat of an industry standard. Ish.

It did amuse me back in the naughties when developers would go crazy about the curlies as they had to switch from VB6 to C#. I saw some insisting they couldn’t do it. They could. Didn’t take long to get used to it
plasmab is offline  
Old 05 November 2018, 18:27   #707
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
Quote:
Originally Posted by Hewitson View Post
That's by far my preferred style. I do always make sure there's an empty line before and after though. And with a decent editor (eg vim), the opening/closing braces are highlighted, so you know what belongs to what immediately.


You’re the guy who does that!!! I like my braces with equal indents. Easier to keep track of!

Now I just need to track down the guy who doesn’t put curlies around else statements...
plasmab is offline  
Old 05 November 2018, 18:30   #708
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by Hewitson View Post
I'm sorry, but that's just not true. I would be interested to see an example of what you would call ugly C code. Just because theres so many different styles of writing it.
Take some code at the random.
Now perhaps we have different definitions for what's ugly.
It could be interesting to compare some coding examples written in different languages. But we're already OT enough.


Quote:
Originally Posted by Hewitson View Post
Few libraries I've encountered have been difficult to use. I would use OpenGL as an example of one which is extremely difficult to utilise.
Well, have a look at Direct2D to see what's real tough. After that you'll regret OpenGL


Quote:
Originally Posted by Hewitson View Post
I don't understand why you complain about the closing braces so much. It's like saying RTS in a subroutine is meaningless.
Nope - RTS always does the same thing, it exits current routine. Not the curly brace, which can be the end of a for, the end of a while, the end of a function...


Quote:
Originally Posted by Hewitson View Post
No, you're not, but what would be the point of using a C++ compiler to compile a program using functions/libraries that are available in C?
The point is to use whatever suits your needs. Automatic constructor/destructor calls when some class is declared / gets out of scope is handy. Exceptions and templates are also useful.
The C++ compiler won't be slower than C compiler if you write C++ like C. Neither will the compiled code.

But you cannot say C is nice while in the same time saying C++ is ugly : the syntax is exactly the same !
meynaf is offline  
Old 05 November 2018, 18:32   #709
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,710
I'm mostly joking, people can code in whatever style they want. Some of us C programmers are perfectionists and are not having it when we see other coding styles.

@plasmab: I don't put curlies around else statements if both of the conditions are oneliners.

F.ex.
Code:
if (a)
    stuff1();
else
    stuff2();

if (b)
{
    stuff1();
}
else
{
    stuff2();
    stuff3();
}
Someone will shoot me for this...
8bitbubsy is online now  
Old 05 November 2018, 18:37   #710
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
Quote:
Originally Posted by 8bitbubsy View Post
@plasmab: I don't put curlies around else statements if both of the conditions are oneliners.

Someone will shoot me for this...

I’ve seen someone apply that logic with a Macro that had 4 lines of code in it. The macro wasn’t encapsulated in curlies. The consequences were actually v serious. It was a safety critical application.
plasmab is offline  
Old 05 November 2018, 18:38   #711
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by plasmab View Post
Now I just need to track down the guy who doesn’t put curlies around else statements...
Is this what you mean ?
Code:
if (cc) {
    thing1();
    thing2();
}
else thing3();
I don't separate else from the statement for one-liners.
Neither for one-line if, or whatever.
Makes it bearable, but i won't say it's good.


But, who will find THAT readable ?
Code:
                        }
                    }
                }
            }
        }
    }
}
meynaf is offline  
Old 05 November 2018, 18:45   #712
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,710
Quote:
Originally Posted by meynaf View Post
But, who will find THAT readable ?
Code:
                        }
                    }
                }
            }
        }
    }
}
Where did you find my code??
Yeah, that is really awful and always a pain to read.


@plasmab: Yeah I always use curlies if I use a macro in it, I've done that mistake before and it can make you really confused as to why the code doesn't work as intended.
8bitbubsy is online now  
Old 05 November 2018, 18:48   #713
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by plasmab View Post
I’ve seen someone apply that logic with a Macro that had 4 lines of code in it. The macro wasn’t encapsulated in curlies. The consequences were actually v serious. It was a safety critical application.
In my eyes that is the fault of the macro design(er)..
hooverphonique is offline  
Old 05 November 2018, 18:50   #714
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
Quote:
Originally Posted by 8bitbubsy View Post
Where did you find my code??
Yeah, that is really awful and always a pain to read.


@plasmab: Yeah I always use curlies if I use a macro in it, I've done that mistake before and it can make you really confused as to why the code doesn't work as intended.


And it can result in people getting shot. For real. No joke. Don’t ask me to elaborate on that unless you’re handing me a beer in a pub.

I curly everything obsessively now.

Every macro should have a curly round it unless you have a reason not to.
plasmab is offline  
Old 05 November 2018, 18:55   #715
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
C has a beautiful simplicity. It's the most "What you see is what you get" programming language (excluding asm for a sec).

You can almost always guess what the compiler will do behind the scenes. I don't think you can do that with other languages.

This is not to invalidate other views. I respect other views, I just wanted to add mine.
alkis is offline  
Old 05 November 2018, 18:58   #716
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,710
Quote:
Originally Posted by alkis View Post
You can almost always guess what the compiler will do behind the scenes. I don't think you can do that with other languages.
That's not true for modern compilers in high optimization mode with auto-vectorization and what not. If you can still predict what it will output, then you must be from another planet or something.
8bitbubsy is online now  
Old 05 November 2018, 19:05   #717
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by plasmab View Post
I curly everything obsessively now.
I do the same with parenthesis, and not only for (a<<b)+c.

But this also results in more overload and unreadable code.
meynaf is offline  
Old 05 November 2018, 19:07   #718
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by 8bitbubsy View Post
That's not true for modern compilers in high optimization mode with auto-vectorization and what not. If you can still predict what it will output, then you must be from another planet or something.
You will also not really predict when the "optimising compiler" will consider that something you wrote has no effect and remove it altogether, leading to broken code !
(I have no example, but i heard this can happen.)
meynaf is offline  
Old 05 November 2018, 19:39   #719
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
Quote:
Originally Posted by hooverphonique View Post
In my eyes that is the fault of the macro design(er)..

It’s a fail in many ways.

The macro was sh1t.

The person using the macro didn’t check (or understand) that it needed curlies. They just equated one line of code with no need for them.

They ignored the compiler warning because they didn’t understand it.

The person reviewing didn’t spot it.

The person testing the change didn’t test it properly.

All of this led to a v dangerous real life situation.

Really there is no need to not put braces round everything. I wish I could make compilers enforce it.
plasmab is offline  
Old 06 November 2018, 02:15   #720
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,544
Quote:
Originally Posted by litwr View Post
I can't agree, this feature of DOS relies very hard on the segment registers which are the part of ISA giving some superiority to 8086. I can also mention CP/M-86, MP/M-86, ...

68k have had a lot of OS and no one used headerless format,
Ahem...

CP/M
Quote:
The first version in the 16-bit family was CP/M-86 for the Intel 8086, which was soon followed by CP/M-68K for the Motorola 68000. The original version of CP/M-68K in 1982 was written in Pascal/MT+68k, but it was ported to C later on.
Bruce Abbott 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
Any software to see technical OS details? necronom support.Other 3 02 April 2016 12:05
2-star rarity details? stet HOL suggestions and feedback 0 14 December 2015 05:24
EAB's FTP details... Basquemactee1 project.Amiga File Server 2 30 October 2013 22:54
req details for sdl turrican3 request.Other 0 20 April 2008 22:06
Forum Details BippyM request.Other 0 15 May 2006 00:56

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 15:58.

Top

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