Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fortran | Protocol buffers | Object oriented programming #106

Open
komahanb opened this issue Dec 7, 2023 · 1 comment
Open

Fortran | Protocol buffers | Object oriented programming #106

komahanb opened this issue Dec 7, 2023 · 1 comment
Assignees

Comments

@komahanb
Copy link

komahanb commented Dec 7, 2023

https://protobuf.dev/overview/

Protocol buffers are not well supported in non-object-oriented languages popular in scientific computing, such as Fortran and IDL.

I disagree with the remark about Fortran being not object-oriented. Fortran (since 2003) supports derived-data-types (a.k.a data-abstraction) and type-bound-procedures (a.k.a methods that are invoked on the held data). This, of course, extends to other capabilities such as interfaces, inheritance, polymorphism, etc. Could the documentation be specific about what aspect of Fortran is incompatible with protocol-buffer, or atleast clarify the Fortran versions that are not supported, so that developers are not misinformed?

A simple example from chat-gpt:

module ShapesModule
  type :: Shape
     real :: area
     contains
        procedure :: calculateArea
  end type Shape

contains

  subroutine calculateArea(this)
    class(Shape), intent(inout) :: this
    ! This is a generic method to calculate the area for different shapes
    ! Implement specific area calculations for each shape by overriding this method
    this%area = 0.0
  end subroutine calculateArea

end module ShapesModule

program ObjectOrientedFortran
  use ShapesModule

  type :: CircleType
     type(Shape) :: baseShape
     real :: radius
  end type CircleType

  contains

  subroutine calculateArea(this)
    class(CircleType), intent(inout) :: this
    this%baseShape%area = this%radius**2 * 3.14159
  end subroutine calculateArea

  type(CircleType) :: myCircle
  myCircle%radius = 5.0

  ! Calculate area using the overridden method for circles
  call myCircle%baseShape%calculateArea()

  ! Print the calculated area
  print *, "Area of the circle: ", myCircle%baseShape%area

end program ObjectOrientedFortran
@Logofile
Copy link
Member

I will look into whether this information is outdated, or still applies. (It's possible that protobufs don't work well with Fortran even with its addition of some object oriented behaviors.)

@Logofile Logofile self-assigned this Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants