Author Topic: Does anybody learn C any more?  (Read 38880 times)

0 Members and 1 Guest are viewing this topic.

Offline alank2

  • Super Contributor
  • ***
  • Posts: 2196
Re: Does anybody learn C any more?
« Reply #50 on: August 19, 2019, 03:36:07 pm »
There is something about C that is special; I've written in it for 25+ years and it will get the job done, usually with excellent performance.  Like assembly it does what you tell it and if mess up telling it what to do, you'll see the results.  Buffer overruns are caused by bad programming.  You can prevent them by writing proper code.  There are things that modern languages make easier on the developer, but with every concession and automation, raw control is lost.  Same as moving form assembly to C.  I can appreciate how quickly one can put together a C# application, and how it protects you from yourself, but there are always trade offs.  I like some of the benefits of C++ and will cherry pick them when they are useful.  One thing about C# that annoys me is how many different ways there are to do the same thing - if they want to establish proper patterns, why not just have a single way to do something?  I think it has too much complication, but I guess that is what keeps those C# devs in business.  I'm still trying to work my way through C# 7.0 in a nutshell and it is head spinning...
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
Re: Does anybody learn C any more?
« Reply #51 on: August 19, 2019, 03:45:53 pm »
What would drive people to take the leap from the highly abstracted world of things like Python to the 'madness' of C today?

Simple. Just list the languages written in C. Start with Python. Then list the languages influenced by C. Start with Python.
sadly very true.
that's why so many languages need that stupid semicolon at the end of a statement. semicolons move my colon...
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Online Monkeh

  • Super Contributor
  • ***
  • Posts: 8070
  • Country: gb
Re: Does anybody learn C any more?
« Reply #52 on: August 19, 2019, 03:48:51 pm »
It's 2019, people!
C is obsolete, we gotta learn LISP Smalltalk Java Haskell Intercal Rust :scared:
why in the 2019, if they have to invent a new language, why they have to bring the fucking ";" as linefeed along? chr(13) and chr(10) have been used for millenia as linefeed and carriage return, a relic brought down from C/C++ :palm: everything else is a good thing in C/C++ except this (this make C is 99.99% my favourite language) why?
The use of a statement delimiter predates C by a long way. It was introduced because of problems found in early languages, like Fortran, where the end of the line meant the end of the statement. Fortran fixed this with...
for new language... no excuse, regardless... many new languages such as Phyton dont require ";"

Python, where python is not python and whitespace is critical. Seriously, no, not an advantage.
 
The following users thanked this post: ludzinc, Frank

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6576
  • Country: nl
Re: Does anybody learn C any more?
« Reply #53 on: August 19, 2019, 04:50:12 pm »
You can't compare python to c.
Apples and oranges
 

Online Monkeh

  • Super Contributor
  • ***
  • Posts: 8070
  • Country: gb
Re: Does anybody learn C any more?
« Reply #54 on: August 19, 2019, 05:12:49 pm »
You can't compare python to c.
Apples and oranges

I can compare the insanity of whitespace dependency vs anger over having to terminate a statement with a semicolon...
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6576
  • Country: nl
Re: Does anybody learn C any more?
« Reply #55 on: August 19, 2019, 05:25:18 pm »
you need to terminate somehow.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9937
  • Country: us
Re: Does anybody learn C any more?
« Reply #56 on: August 19, 2019, 05:57:38 pm »
you need to terminate somehow.

Yup!  Sooner or later...

Eliminating the semicolon is easy:  Just come up with a way to separate multiple statements per line, multiple lines per statement and some way to tell the compiler where the end of a statement is (useful for error recovery) and you're all set!

Fortran didn't consider white space at all.  It would interpret the following as a DO loop

DO 10 I=1,10

It would also accept as a DO loop

DO10I=1,10

Basically, the compiler didn't know, until if found the comma, whether it was creating a loop or a simple assignment.  If it saw the comma, it had to back up and break the DO10I into pieces.

Not a very nice syntax to compile.  Strictly ad-hoc, no clean recursive descent.

Fortran makes the assumption that every statement terminates at the end of the line unless column 6 in the following card has a mark (or number).  The following statement extends over two lines although legally complete at the end of the first line:

      area = 3.14159265358979
     +       * r * r

What a mess to compile!
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6576
  • Country: nl
Re: Does anybody learn C any more?
« Reply #57 on: August 19, 2019, 07:13:09 pm »
Perhaps it should also be easily readable by a human  :-//
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Does anybody learn C any more?
« Reply #58 on: August 19, 2019, 07:41:50 pm »
I don't really get the issue with the semicolon, once you've written a few dozen lines it becomes second nature.

I don't really have a problem with the whitespace dependency of Python either, as long as you use an editor that doesn't use nonstandard tabs. You get used to it and it's fine, at least I do.

Some people just need something to moan about I guess.
 

Offline djacobow

  • Super Contributor
  • ***
  • Posts: 1169
  • Country: us
  • takin' it apart since the 70's
Re: Does anybody learn C any more?
« Reply #59 on: August 19, 2019, 08:38:15 pm »
I don't really get the issue with the semicolon, once you've written a few dozen lines it becomes second nature.

I don't really have a problem with the whitespace dependency of Python either, as long as you use an editor that doesn't use nonstandard tabs. You get used to it and it's fine, at least I do.

Some people just need something to moan about I guess.

I moan about so many things. I'm really an expert moaner. Should be on my resume.

But neither semicolons or syntactic whitespace bug me much. Actually, have plenty of gripes about Python, but text formatting isn't one of them. As for tabs, I use tools to keep them out of my code entirely. I actually think the tab character was probably a bad idea from the start.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Does anybody learn C any more?
« Reply #60 on: August 19, 2019, 09:10:26 pm »
I've thought that as well, why do we even have a tab character that is not simply a defined number of space characters? I suppose it must have had some purpose, anyone know the history of that?
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7246
  • Country: pl
Re: Does anybody learn C any more?
« Reply #61 on: August 19, 2019, 09:16:47 pm »
Tab isn't just 8 spaces, it aligns to the next multiply of 8 columns. It's useful for, wait for it, ... tables :)

Code: [Select]
1<tab>1
10<tab>10
comes out neatly aligned
Code: [Select]
1      1
10     10
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
Re: Does anybody learn C any more?
« Reply #62 on: August 19, 2019, 10:08:52 pm »
you need to terminate somehow.
yes. CR/LF that is in the code file the moment you hit the return key on your keyboard. How's that for an elegant solution ?
And actually you don't. The parser should be smart enough to figure it out. it knows when a statement is complete. so the next keyword is the beginning of a new statement.

and don't tell me about multiline commands. Then you use a continuation character.
It is madness to demand from the programmer to tell the compiler when a line ends. it makes more sense to have a continuation character as you will need fewer of those than you need line-end characters.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4538
  • Country: nz
Re: Does anybody learn C any more?
« Reply #63 on: August 19, 2019, 10:10:49 pm »
Because programmers, even the best ones...and this might blow your mind...are humans.

You are right. The only reason why I still use C is that can "do Rust" only on x86 (and maybe on Arm), while you can "do C" on MIPS (llvm is weak), HPPA (llvm is unsupported) and PPC (llvm is experimental). That is my problem  :-//

RISC-V just went from experimental to mainstream in LLVM. The Rust people seem happy so far.

I guess I program mostly in what is effectively C, and I do more assembly language than C++.
 

Offline bsfeechannel

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: 00
Re: Does anybody learn C any more?
« Reply #64 on: August 19, 2019, 10:26:59 pm »
I've thought that as well, why do we even have a tab character that is not simply a defined number of space characters? I suppose it must have had some purpose, anyone know the history of that?

Tab characters were introduced by FIELDATA, and later by ASCII.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4538
  • Country: nz
Re: Does anybody learn C any more?
« Reply #65 on: August 19, 2019, 10:34:41 pm »
I've thought that as well, why do we even have a tab character that is not simply a defined number of space characters? I suppose it must have had some purpose, anyone know the history of that?

Are you kidding us? Did you never play with your (grand)father's typewiriter when you were a kid?



Those are tab stops. You position them where you want them and when you press the tab key the carriage moves to the next stop.

Computerised word-processors from Wordstar on to modern MS Word implement the exact same feature.

Here's MacWrite in 1984. The hollow triangles on the ruler are the tab stops.



Computer terminals and printers such as the vt100 and la120 implemented tab stops.  Assuming you wanted tab stop at columns 20 and 40 your program could output something like:

<esc>[3g   clear all tab stops
<esc>[99d  make sure we're at the first column
<esc>[H       set tab stop
<esc>[20C    move right 20 columns
<esc>[H      set tab stop

 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4538
  • Country: nz
Re: Does anybody learn C any more?
« Reply #66 on: August 19, 2019, 10:38:24 pm »
I've thought that as well, why do we even have a tab character that is not simply a defined number of space characters? I suppose it must have had some purpose, anyone know the history of that?

Tab characters were introduced by FIELDATA, and later by ASCII.

The TAB key and tab stops were introduced in the 19th century.
 
The following users thanked this post: SiliconWizard

Offline bsfeechannel

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: 00
Re: Does anybody learn C any more?
« Reply #67 on: August 19, 2019, 11:11:55 pm »
I've thought that as well, why do we even have a tab character that is not simply a defined number of space characters? I suppose it must have had some purpose, anyone know the history of that?

Tab characters were introduced by FIELDATA, and later by ASCII.

The TAB key and tab stops were introduced in the 19th century.

We're not talking about the TAB key. We're talking about the TAB character, which was introduced by the above-mentioned codes.

« Last Edit: August 19, 2019, 11:14:30 pm by bsfeechannel »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4316
  • Country: us
Re: Does anybody learn C any more?
« Reply #68 on: August 19, 2019, 11:29:32 pm »
Quote
What would drive people to take the leap from the highly abstracted world of things like Python to the 'madness' of C today?

Quote
[writing] in C for only one reason - performance. Python gave 2 transactions per second, my C implementation gives 200...
Did you really have to write that first question, when you had that second sentence so soon after?100x the performance (relatively trivially?)

The illusion that you NEED performance, either in terms of speed or program space, is horribly persistent. Even when you don't.

Also, C is essentially the first compiled language I expect to see "deployed" on any new chip that comes out.  Because it can be implemented as essentially a fancy macro assembler, and offered without any libraries, and ... unusually ROMable, compared to many languages.
Python is not ever going to run on a $0.03 Padauk microcontroller, but it showed up with "Min-C", and is well on its way to having SDCC support...
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4316
  • Country: us
Re: Does anybody learn C any more?
« Reply #69 on: August 19, 2019, 11:38:28 pm »
Quote
We're talking about the TAB character
DEC, at least, made good use of the TAB character to save storage space.
When many fortran programs had lines that started with six spaces (5 digits of potential line number label, and a "C" line-continuation column), DEC was "<tab><statement> is fine, <tab>C<space>continuation works too."  Their assemblers favored tabs as well.
At one time, that could've been important - that paper tape cost by the inch, you know!
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9937
  • Country: us
Re: Does anybody learn C any more?
« Reply #70 on: August 19, 2019, 11:42:53 pm »
you need to terminate somehow.
yes. CR/LF that is in the code file the moment you hit the return key on your keyboard. How's that for an elegant solution ?
And actually you don't. The parser should be smart enough to figure it out. it knows when a statement is complete. so the next keyword is the beginning of a new statement.

Clearly, it can't.  My Fortran example above shows a complete statement on one line just before the next card is read with a continuation character.  What keywords?  You can have multiple arithmetic assignment statements and the only symbol you can count on is the '=' sign.  So I guess the syntax should say, in effect, if you see a second '=' sign, the previous statement might be complete except in the case of:
a=b=c=d....;

If there was any way in the world to eliminate the ';', the language designers, the smartest people in computer science, would have done it.  Fortran doesn't have it but it's not a regular grammar and Python, well, Python is special.  If there was a short bus for languages, Python would be on it.  What's with all the ':' symbols?
 

Offline TK

  • Super Contributor
  • ***
  • Posts: 1722
  • Country: us
  • I am a Systems Analyst who plays with Electronics
Re: Does anybody learn C any more?
« Reply #71 on: August 19, 2019, 11:51:18 pm »
you need to terminate somehow.
golang was created by Ken Thompson (the same Unix / C guru from Bell Labs) and they got rid of the semicolon
 

Offline bsfeechannel

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: 00
Re: Does anybody learn C any more?
« Reply #72 on: August 20, 2019, 12:53:02 am »
golang was created by Ken Thompson (the same Unix / C guru from Bell Labs) and they got rid of the semicolon

BCPL, which begat B, which begat C, didn't use semicolons either. However, due to storage limitations, the B compiler had to generate an output in a single pass. This technique was carried forward into C.

In fact, Thompson wanted to use BCPL, but created B as a stripped-down version of BCPL, because the only computer he had at his disposition to write Unix at the time was an obsolete PDP-7 that was collecting dust in a corner of the Bell Labs.

The result is that no one complains about how fast C compiles, despite the so-little-loved semicolon.
« Last Edit: August 20, 2019, 12:54:46 am by bsfeechannel »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Does anybody learn C any more?
« Reply #73 on: August 20, 2019, 12:56:04 am »
I've thought that as well, why do we even have a tab character that is not simply a defined number of space characters? I suppose it must have had some purpose, anyone know the history of that?

Are you kidding us? Did you never play with your (grand)father's typewiriter when you were a kid?



Those are tab stops. You position them where you want them and when you press the tab key the carriage moves to the next stop.

Computerised word-processors from Wordstar on to modern MS Word implement the exact same feature.

Here's MacWrite in 1984. The hollow triangles on the ruler are the tab stops.



Computer terminals and printers such as the vt100 and la120 implemented tab stops.  Assuming you wanted tab stop at columns 20 and 40 your program could output something like:

<esc>[3g   clear all tab stops
<esc>[99d  make sure we're at the first column
<esc>[H       set tab stop
<esc>[20C    move right 20 columns
<esc>[H      set tab stop

Well as someone else said already I was asking about the character, not the tab key or stops. That is fascinating though, I used to play with my mom's typewriter when I was a kid but I don't think I've touched one in 25 years and I don't remember ever being aware of tab stops on it. I'm just young enough to have never used a typewriter for actually typing something useful. I can see now why they got their name.
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1453
  • Country: us
  • Very dangerous - may attack at any time
Re: Does anybody learn C any more?
« Reply #74 on: August 20, 2019, 01:08:44 am »
If there was a short bus for languages, Python would be on it.  What's with all the ':' symbols?

It is also very self-ish.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf