Re: Fortran was NOT higher level than C. Was: Computer architects leaving Intel...

Liste des GroupesRevenir à c arch 
Sujet : Re: Fortran was NOT higher level than C. Was: Computer architects leaving Intel...
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : comp.arch
Date : 05. Sep 2024, 16:37:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbcfo4$cd1g$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : slrn/1.0.3 (Linux)
Michael S <already5chosen@yahoo.com> schrieb:
On Thu, 5 Sep 2024 11:36:22 -0000 (UTC)
Thomas Koenig <tkoenig@netcologne.de> wrote:
>
Michael S <already5chosen@yahoo.com> schrieb:
On Wed, 4 Sep 2024 17:08:36 -0000 (UTC)
Thomas Koenig <tkoenig@netcologne.de> wrote:
 
Michael S <already5chosen@yahoo.com> schrieb: 
On Tue, 3 Sep 2024 20:05:14 -0000 (UTC)
Thomas Koenig <tkoenig@netcologne.de> wrote:
  
Stefan Monnier <monnier@iro.umontreal.ca> schrieb:   
My impression - based on hearsay for Rust as I have no
experience
- is that the key point of Rust is memory "safety".  I use
scare-quotes here, since it is simply about correct use of
dynamic memory and buffers.
>
It is entirely possible to have correct use of memory in C,
   
>
If you look at the evolution of programming languages,
"higher-level" doesn't mean "you can do more stuff".  On the
contrary, making a language "higher-level" means deciding
what it is we want to make harder or even impossible.     
 
Really?
 
I thought Fortran was higher level than C, and you can do a lot
more things in Fortran than in C.
 
Or rather, Fortran allows you to do things which are possible,
but very cumbersome, in C.  Both are Turing complete, after
all.   
>
I'd say that C in the form that stabilized around 1975-1976 is
significantly higher level language than contemporary Fortran
dialects or even the next Fortran dialect (F77).   
 
I did write Fortran, not FORTRAN :-)
 
I agree that C had many very useful things that pre-FORTRAN 90
did not have.  This is not surprising, since the authors of
C knew FORTRAN well.
 
[...]
 
Overall, the differences in favor of C looks rather huge.    
 
You are arguing from the point of view of more than 30 years ago.
 
On the other hand, I recollect only two higher level feature
present in old Fortran that were absent in pre-99 C - VLA and
Complex.    
 
You forget arrays as first-class citizens, 
>
In theory, this is an advantage. In practice - not so much.
Old Fortran lacked two key features that make 1st-class arrays
really useful - array length as an attribute and pass-by-value. 
 
You want to pass arrays by value?  In practice, that would mean
copy-in and copy-out.  Is this something that you do often?
>
>
In languages that I use daily it's not something you can decide freely.

My sympathies.

It is not always possible to avoid packing/unpacking of arrays in
Fortran, for example when passing a non-contiguous array slice
to an old-style or contiguous array, but at least gfortran
has -Warray-temporaries, so the user can be notified.

I one group (C, to slightly less extent C++) passing arrays by value is
cumbersome  so I use it less than I would probably do if it was
more convenient.

It is also a potential performance killer - allocating the
temporary array, copying (which will impact the cache), and
then possibly doing the same thing in reverse.

This is one reason why INTENT is quite useful, it can inform
the compiler that copying in or copying out may not be needed.

In other group (Matlab/Octave) pass-by-value is the only available
option, so I use it all the time, but it does not mean much.

I knew there's a reason for me not using matlab or octave :-)
But of course, if it's your day job, you have little choice
in the matter.

I prefer Julia for the more script-oriented stuff, it can be
quite fast.

[...]

Please show an example how you would pass an 2*2 submatrix of a
3*3 matrix in C.
>
>
I said 'arrays'. I never said that it is easy for matrices :(

Two-dimensional arrays or matrices, I don't see a big difference.

But it definitely works for matrices as well. C binding of LAPACK is a
good example of the typical API.

Lapack, whose C interface is as cumbersome as the original FORTRAN one,
is a good example why assumed-shape arrays are so powerful.

The trick is to not forget to keep
lead dimension in separate parameter from number of columns (assuming C
conventions for order of elements in matrix).
I do use this trick in my signal processing practice.
But agree that for case of matrices C is only very slightly more
convenient than old FORTRAN.

The we disagree - old-style FORTRAN was more convenient for arrays
than C.

>
In Fortran, this is, on the caller's side,
 
   real, dimension(3,3) :: a
 
   call foo(a(1:2,1:2))
 
or also
 
   call foo(a(1:3,1:3))
 
and on the callee's side
 
   subroutine foo(a)
   real, dimension(:,:) :: a

Or, maybe even harder to do in C

  call foo(a(1:3:2,1:3:2))

which will pass the elements with indices (1,1),(3,1),(1,3),(3,3)
to foo, whose programmer can be perfectly obvlivious of anything
strange being passed, the arrays just work.

[... going into F95 features...]

- ALLOCATE and ALLOCATABLE variables, where the compiler
  cleans up after variables go out of scope 
>
How does it differ from automatic variables that C together with
nearly all other Algol derivatives, had from the very beginning? 
 
You can allocate and deallocate whenever, so you have the
flexibility of C's pointers with the deallocation handled
by the compiler.
 
For example
 
  type foo
    real, allocatable, dimension(:) :: x, y, z, f
  end type foo
 
...
 
   type(foo) :: p
 
...
 
   allocate (p%x(n), p%y(n), p%z(n), p%f(n))
 
All of this will be deallocated when p gets out of scope.
>
>
I still don't see how it's more capable than C99 except for minor
ability to group automatic VLAs in sort of struct.

You can do the following in Fortran:

  subroutine init_foo(p,n)
    type(foo), intent(out), dimension(:) :: p
    integer, intent(in) :: n
    integer :: i
    do i=1,size(p)
      allocate (p%x(n),p%y(n),p%z(n))
    end do
  end subroutine foo

init_foo will deallocate every component upon entry to the
subroutine (automatically), and then it allocates the components x,
y and z.  The caller then can do things with it.

This would not be possible with pointers to VLA-allocated memory
in C.

It is very much like pointers in C, except the compiler cleans
up after the variables go out of scope.

Fortran also has pointers, which can also point to arrays and
array slices.  For a pointer to point to anything, either
you have to allocate it (same syntax as allocatables, but
you have to deallocate explicitly), or you can associate
it with a target, which has to explicity to be marked TARGET.

Plus, you don't need to pass a pointer to a variable if
you want its value set (or do array stuff on it).  One of
my pet peeves about C is that in

   int a;

   /* Set vaulue for a.  */
   foo(&a);
...
   bar();
  
the value of a could be changed behind the programmer's back
in bar() according to C's language definition.

Date Sujet#  Auteur
27 Aug 24 * Computer architects leaving Intel...529Thomas Koenig
27 Aug 24 +- Re: Computer architects leaving Intel...1Michael S
27 Aug 24 +- Re: Computer architects leaving Intel...1Stephen Fuld
27 Aug 24 `* Re: Computer architects leaving Intel...526John Dallman
28 Aug 24  +* Re: Computer architects leaving Intel...519BGB
28 Aug 24  i`* Re: Computer architects leaving Intel...518MitchAlsup1
28 Aug 24  i `* Re: Computer architects leaving Intel...517BGB
28 Aug 24  i  +* Re: Computer architects leaving Intel...2Robert Finch
28 Aug 24  i  i`- Re: Computer architects leaving Intel...1BGB
28 Aug 24  i  `* Re: Computer architects leaving Intel...514MitchAlsup1
29 Aug 24  i   `* Re: Computer architects leaving Intel...513BGB
29 Aug 24  i    +* Re: Computer architects leaving Intel...501MitchAlsup1
29 Aug 24  i    i`* Re: Computer architects leaving Intel...500BGB
30 Aug 24  i    i +* Re: Computer architects leaving Intel...489John Dallman
30 Aug 24  i    i i+* Re: Computer architects leaving Intel...11Thomas Koenig
30 Aug 24  i    i ii+- Re: Computer architects leaving Intel...1Michael S
30 Aug 24  i    i ii+* Re: Computer architects leaving Intel...8Anton Ertl
30 Aug 24  i    i iii+* Re: Computer architects leaving Intel...2Michael S
30 Aug 24  i    i iiii`- Re: Computer architects leaving Intel...1Anton Ertl
30 Aug 24  i    i iii`* Re: Computer architects leaving Intel...5John Dallman
30 Aug 24  i    i iii `* Re: Computer architects leaving Intel...4Brett
30 Aug 24  i    i iii  +- Re: Computer architects leaving Intel...1John Dallman
2 Sep 24  i    i iii  `* Re: Computer architects leaving Intel...2Terje Mathisen
2 Sep 24  i    i iii   `- Re: Computer architects leaving Intel...1Thomas Koenig
30 Aug 24  i    i ii`- Re: Computer architects leaving Intel...1BGB
30 Aug 24  i    i i`* Re: Computer architects leaving Intel...477Anton Ertl
30 Aug 24  i    i i +* Re: Computer architects leaving Intel...301John Dallman
30 Aug 24  i    i i i`* Re: Computer architects leaving Intel...300David Brown
30 Aug 24  i    i i i +* Re: Computer architects leaving Intel...292Anton Ertl
30 Aug 24  i    i i i i`* Re: Computer architects leaving Intel...291Bernd Linsel
31 Aug 24  i    i i i i +- Re: Computer architects leaving Intel...1Thomas Koenig
31 Aug 24  i    i i i i `* Re: Computer architects leaving Intel...289Thomas Koenig
31 Aug 24  i    i i i i  +- Re: Computer architects leaving Intel...1Thomas Koenig
31 Aug 24  i    i i i i  `* Re: Computer architects leaving Intel...287Bernd Linsel
31 Aug 24  i    i i i i   +- Re: Computer architects leaving Intel...1Thomas Koenig
31 Aug 24  i    i i i i   +* Re: Computer architects leaving Intel...2Thomas Koenig
31 Aug 24  i    i i i i   i`- Re: Computer architects leaving Intel...1Bernd Linsel
31 Aug 24  i    i i i i   `* Re: Computer architects leaving Intel...283Anton Ertl
31 Aug 24  i    i i i i    +* Re: Computer architects leaving Intel...278Thomas Koenig
31 Aug 24  i    i i i i    i+* Re: Computer architects leaving Intel...157Bernd Linsel
31 Aug 24  i    i i i i    ii+* Re: Computer architects leaving Intel...153MitchAlsup1
1 Sep 24  i    i i i i    iii`* Re: Computer architects leaving Intel...152Stephen Fuld
2 Sep 24  i    i i i i    iii `* Re: Computer architects leaving Intel...151Terje Mathisen
2 Sep 24  i    i i i i    iii  `* Re: Computer architects leaving Intel...150Stephen Fuld
3 Sep 24  i    i i i i    iii   +* Re: Computer architects leaving Intel...139David Brown
3 Sep 24  i    i i i i    iii   i+* Re: Computer architects leaving Intel...108Stephen Fuld
4 Sep 24  i    i i i i    iii   ii`* Re: Computer architects leaving Intel...107David Brown
4 Sep 24  i    i i i i    iii   ii +* Re: Computer architects leaving Intel...103Terje Mathisen
4 Sep 24  i    i i i i    iii   ii i+* Re: Computer architects leaving Intel...101David Brown
4 Sep 24  i    i i i i    iii   ii ii+* Re: Computer architects leaving Intel...97jseigh
4 Sep 24  i    i i i i    iii   ii iii`* Re: Computer architects leaving Intel...96David Brown
4 Sep 24  i    i i i i    iii   ii iii `* Re: Computer architects leaving Intel...95Brett
4 Sep 24  i    i i i i    iii   ii iii  +- Re: Computer architects leaving Intel...1Thomas Koenig
4 Sep 24  i    i i i i    iii   ii iii  +- Re: Computer architects leaving Intel...1MitchAlsup1
5 Sep 24  i    i i i i    iii   ii iii  +* Re: Computer architects leaving Intel...8BGB
5 Sep 24  i    i i i i    iii   ii iii  i`* Re: Computer architects leaving Intel...7MitchAlsup1
5 Sep 24  i    i i i i    iii   ii iii  i `* Re: Computer architects leaving Intel...6David Brown
5 Sep 24  i    i i i i    iii   ii iii  i  `* Re: Computer architects leaving Intel...5Niklas Holsti
5 Sep 24  i    i i i i    iii   ii iii  i   `* Re: Computer architects leaving Intel...4David Brown
6 Sep 24  i    i i i i    iii   ii iii  i    `* Re: Computer architects leaving Intel...3BGB
6 Sep 24  i    i i i i    iii   ii iii  i     `* Re: Computer architects leaving Intel...2David Brown
9 Sep 24  i    i i i i    iii   ii iii  i      `- Re: Computer architects leaving Intel...1BGB
5 Sep 24  i    i i i i    iii   ii iii  +* Re: Computer architects leaving Intel...83David Brown
5 Sep 24  i    i i i i    iii   ii iii  i`* Re: Computer architects leaving Intel...82Terje Mathisen
5 Sep 24  i    i i i i    iii   ii iii  i +* Re: Computer architects leaving Intel...79David Brown
5 Sep 24  i    i i i i    iii   ii iii  i i+* Re: Computer architects leaving Intel...2Thomas Koenig
7 Sep 24  i    i i i i    iii   ii iii  i ii`- Re: Computer architects leaving Intel...1Tim Rentsch
5 Sep 24  i    i i i i    iii   ii iii  i i+* Re: Computer architects leaving Intel...74Terje Mathisen
5 Sep 24  i    i i i i    iii   ii iii  i ii+* Re: Computer architects leaving Intel...16David Brown
9 Sep 24  i    i i i i    iii   ii iii  i iii`* Re: Computer architects leaving Intel...15Terje Mathisen
9 Sep 24  i    i i i i    iii   ii iii  i iii +* Re: Computer architects leaving Intel...12David Brown
9 Sep 24  i    i i i i    iii   ii iii  i iii i`* Re: Computer architects leaving Intel...11Brett
10 Sep 24  i    i i i i    iii   ii iii  i iii i +* Re: Computer architects leaving Intel...5Terje Mathisen
10 Sep 24  i    i i i i    iii   ii iii  i iii i i`* Re: Computer architects leaving Intel...4Brett
10 Sep 24  i    i i i i    iii   ii iii  i iii i i +* Re: Computer architects leaving Intel...2Michael S
11 Sep 24  i    i i i i    iii   ii iii  i iii i i i`- Re: Computer architects leaving Intel...1Brett
11 Sep 24  i    i i i i    iii   ii iii  i iii i i `- Re: Computer architects leaving Intel...1Terje Mathisen
10 Sep 24  i    i i i i    iii   ii iii  i iii i `* Re: Computer architects leaving Intel...5David Brown
10 Sep 24  i    i i i i    iii   ii iii  i iii i  +* Re: Computer architects leaving Intel...3Anton Ertl
10 Sep 24  i    i i i i    iii   ii iii  i iii i  i`* Re: Computer architects leaving Intel...2David Brown
10 Sep 24  i    i i i i    iii   ii iii  i iii i  i `- Re: Computer architects leaving Intel...1Stefan Monnier
10 Sep 24  i    i i i i    iii   ii iii  i iii i  `- Re: Computer architects leaving Intel...1BGB
9 Sep 24  i    i i i i    iii   ii iii  i iii `* Re: Computer architects leaving Intel...2Michael S
10 Sep 24  i    i i i i    iii   ii iii  i iii  `- Re: Computer architects leaving Intel...1Michael S
5 Sep 24  i    i i i i    iii   ii iii  i ii+* Re: Computer architects leaving Intel...45Bernd Linsel
6 Sep 24  i    i i i i    iii   ii iii  i iii+- Re: Computer architects leaving Intel...1David Brown
9 Sep 24  i    i i i i    iii   ii iii  i iii+* Re: Computer architects leaving Intel...2Terje Mathisen
9 Sep 24  i    i i i i    iii   ii iii  i iiii`- Re: Computer architects leaving Intel...1Tim Rentsch
14 Sep15:08  i    i i i i    iii   ii iii  i iii`* Re: Computer architects leaving Intel...41Kent Dickey
14 Sep15:26  i    i i i i    iii   ii iii  i iii +* Re: Computer architects leaving Intel...32Anton Ertl
14 Sep21:11  i    i i i i    iii   ii iii  i iii i+* Re: Computer architects leaving Intel...29MitchAlsup1
14 Sep21:26  i    i i i i    iii   ii iii  i iii ii`* Re: Computer architects leaving Intel...28Thomas Koenig
15 Sep17:50  i    i i i i    iii   ii iii  i iii ii `* Re: Computer architects leaving Intel...27David Brown
16 Sep09:17  i    i i i i    iii   ii iii  i iii ii  +* Re: Computer architects leaving Intel...5Thomas Koenig
16 Sep14:45  i    i i i i    iii   ii iii  i iii ii  i`* Re: Computer architects leaving Intel...4David Brown
16 Sep22:15  i    i i i i    iii   ii iii  i iii ii  i `* Re: Computer architects leaving Intel...3Thomas Koenig
17 Sep03:49  i    i i i i    iii   ii iii  i iii ii  i  +- Re: Upwards and downwards compatible, Computer architects leaving Intel...1John Levine
17 Sep11:15  i    i i i i    iii   ii iii  i iii ii  i  `- Re: Computer architects leaving Intel...1David Brown
16 Sep10:37  i    i i i i    iii   ii iii  i iii ii  `* Re: Computer architects leaving Intel...21Terje Mathisen
16 Sep14:48  i    i i i i    iii   ii iii  i iii ii   `* Re: Computer architects leaving Intel...20David Brown
16 Sep15:04  i    i i i i    iii   ii iii  i iii ii    +* Re: Computer architects leaving Intel...14Michael S
17 Sep08:07  i    i i i i    iii   ii iii  i iii ii    `* Re: Computer architects leaving Intel...5Terje Mathisen
15 Sep06:42  i    i i i i    iii   ii iii  i iii i`* Re: Computer architects leaving Intel...2BGB
14 Sep21:00  i    i i i i    iii   ii iii  i iii +* Re: Computer architects leaving Intel...3Thomas Koenig
16 Sep03:32  i    i i i i    iii   ii iii  i iii `* Re: Computer architects leaving Intel...5Tim Rentsch
6 Sep 24  i    i i i i    iii   ii iii  i ii+* Re: Computer architects leaving Intel...3Tim Rentsch
7 Sep 24  i    i i i i    iii   ii iii  i ii`* Re: Computer architects leaving Intel...9Chris M. Thomasson
5 Sep 24  i    i i i i    iii   ii iii  i i`* Re: Computer architects leaving Intel...2MitchAlsup1
5 Sep 24  i    i i i i    iii   ii iii  i `* Re: Computer architects leaving Intel...2MitchAlsup1
7 Sep 24  i    i i i i    iii   ii iii  `- Re: Computer architects leaving Intel...1Tim Rentsch
4 Sep 24  i    i i i i    iii   ii ii`* Re: Computer architects leaving Intel...3Thomas Koenig
6 Sep 24  i    i i i i    iii   ii i`- Re: Computer architects leaving Intel...1Chris M. Thomasson
4 Sep 24  i    i i i i    iii   ii +- Re: Computer architects leaving Intel...1jseigh
13 Sep 24  i    i i i i    iii   ii `* Re: Computer architects leaving Intel...2Stephen Fuld
3 Sep 24  i    i i i i    iii   i`* Re: Computer architects leaving Intel...30Stefan Monnier
3 Sep 24  i    i i i i    iii   `* Re: Computer architects leaving Intel...10Terje Mathisen
31 Aug 24  i    i i i i    ii`* Re: Computer architects leaving Intel...3Thomas Koenig
1 Sep 24  i    i i i i    i`* Re: Computer architects leaving Intel...120David Brown
1 Sep 24  i    i i i i    +* Re: Computer architects leaving Intel...3John Dallman
3 Sep 24  i    i i i i    `- Re: Computer architects leaving Intel...1Stefan Monnier
30 Aug 24  i    i i i +- Re: Computer architects leaving Intel...1MitchAlsup1
30 Aug 24  i    i i i +* Re: Computer architects leaving Intel...4Stefan Monnier
30 Aug 24  i    i i i `* Re: Computer architects leaving Intel...2John Dallman
8 Sep 24  i    i i `* Re: Computer architects leaving Intel...175Tim Rentsch
30 Aug 24  i    i `* Re: Computer architects leaving Intel...10MitchAlsup1
31 Aug 24  i    `* Re: Computer architects leaving Intel...11Paul A. Clayton
29 Aug 24  `* Re: Computer architects leaving Intel...6Anton Ertl

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal