Languages ​​suitable for development without dynamic memory allocation

Are there any languages ​​other than C and C ++ that can be used explicitly without using dynamic memory functions (like heaps). On some critical embedded systems , heap is not allowed to fix memory leak problems for software that can run continuously for many years. Some special purpose compilers also explicitly disable new and malloc to enforce this practice.

I looked at some of the functional languages, namely Timber and Erlang for their built-in accent, but both seem to use heaps with the garbage collector. OCaml and Haskell also use garbage collectors, despite static typing and, obviously, Python, Ruby, and other dynamically typed languages ​​are heavily dependent on garbage collection and heap space.

  • Do high-level languages ​​support this requirement of not dynamically allocating memory?
  • Is it even possible for compilers of functional statically typed languages ​​to do this taking into account their language semantics?
+4
source share
2 answers

You can take a look at ADA. A few years ago, I used ADA83 on embedded platforms. It didn't require dynamic allocation at all, and it's as tall as C (it's even better than C in my opinion). The problem, of course, is to get the ADA compiler for your platform. Maybe GNAT will work for you.

+1
source

A program is essentially data structures and their manipulations using appropriate algorithms. Data must be stored somewhere in memory. It can be either on the global stack or on the heap of memory.

Just because the heap is not used does not guarantee that the global or stack will not be corrupted by bad code.

If the system is well designed, then to fulfill the required function, it must have all the necessary resources, that is, processor, memory, os, bandwidth, power, cooling, etc.

It can be implemented by managing global memory instead of heap memory, but this will make many libraries that use pointers useless.

I believe that the best approach is to keep it simple, to get a lot of dynamic visibility in the system at startup / debugging, and to make sure that unit tests, code coverage tests, and tests at the system boundary are performed carefully before declaring them suitable for deployment.

If he is well designed, well designed, and well tested, he should do everything well, what he should do, and not do what he should not do.

There are compiled languages ​​that do not have pointers, for example. Fortran, but I don’t know any embedded systems that use Fortran exclusively to implement the system.

-3
source

Source: https://habr.com/ru/post/1484854/


All Articles