Ocean
As long as you are using a well-known chip, like esp32 and esp8266, you are not gonna intervene with the built-in AVR-level library, is that correct too?
Ludovic 'Archivist'
The microprocessor itself is built in one go from a silicon waffer, it is then assembled on a board that handles power supply and connectivity for the CPU itself
Ocean
Okay… building a chip itself sounds very cool but is more time-consuming, I guess, possibly with less rewards material-level
Ludovic 'Archivist'
As long as you are using a well-known chip, like esp32 and esp8266, you are not gonna intervene with the built-in AVR-level library, is that correct too?
It depends, the ESP32 doesn't use an AVR CPU but an Xtensa CPU instead (most of the time, different chips integrate different CPUs). Every CPU architecture (and operating system if applicable) would ship with its own set of standard libraries, among which would generally be a standard C library and sometimes a standard C++ library
Ludovic 'Archivist'
For example, the ESP32 does ship with both a C library, a C++ library, and the Espressif library
Ludovic 'Archivist'
I don't remember Arduino (and AVR in general) shipping with a full standard C++ library, and I only remember a partial C library as well, but it is very useful to learn these to implement features that are portable across platforms
B
Okay… building a chip itself sounds very cool but is more time-consuming, I guess, possibly with less rewards material-level
I think there is a misunderstanding here, by build we do not mean building something physical, it is a term used for when you transform source code to the binary (1s and 0s) that runs on the device .
Ocean
I guess I haven’t touched the arena of CPU 🐿 alas…
Ludovic 'Archivist'
For example, this is a diagram of the steps for a C or C++ program to be compiled into a binary file
Ludovic 'Archivist'
Well I don't think running C++ on a microcontroller is a good idea in general .
Nah it is absolutely fine, particularly when you have to handle parsing complex things from the network
Ludovic 'Archivist'
Just don't do OOP like a mad man
Ludovic 'Archivist'
And use constexpr everywhere to offload as much computation at compile time
Ocean
Well I don't think running C++ on a microcontroller is a good idea in general .
Why. Is it too useless? Like when you are using a big knife to cut a small thing?
Ludovic 'Archivist'
Why. Is it too useless? Like when you are using a big knife to cut a small thing?
It tends to generate executables that are a bit bigger than C (in my experience, it can be up to 25% larger), but sometimes they actually end up smaller from offloading computations to the compiler instead of running them on the microcontroller
Ocean
For example, this is a diagram of the steps for a C or C++ program to be compiled into a binary file
I don’t really know what a header is. But it feels like it’s something that tells the system what file it needs and such, and as for the compiling and how the objects is linked into a programme, I have no idea at all, feels like these processes are done automatically by some IDE probably
Ivan
Well I don't think running C++ on a microcontroller is a good idea in general .
I think the opposite. If you ca use C++, use C++, only limit the usage of STL, RTTI and exceptions to the minimum
B
Nah it is absolutely fine, particularly when you have to handle parsing complex things from the network
It's bloated . Especially on stuff like AVRs . if you look at AVR-libc there are flags to to even disable printf flags to speed up execution and reduce size . I don't see why you can't parse complex stuff in C .
Ludovic 'Archivist'
Ivan
Oh, I work in freestanding, no C++ standard lib, just my own stuff
I build my object files with g++/clang++ and then link them with gcc/clang to only link libc. Works great!
Ludovic 'Archivist'
When I am limited to C, I actually embedded a Forth shell on the board to do those parsing tasks under a GC to avoid leaking memory and crashing the device at a critical moment
B
It's not that hard to write C program that doesn't crash .
Ivan
When I am limited to C, I actually embedded a Forth shell on the board to do those parsing tasks under a GC to avoid leaking memory and crashing the device at a critical moment
Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. Or Forth =)
Ludovic 'Archivist'
It's not that hard to write C program that doesn't crash .
Try to parse and process an HTTP request that is 500 times the available RAM on an ESP32 in pure C without making any mistake
Ocean
It tends to generate executables that are a bit bigger than C (in my experience, it can be up to 25% larger), but sometimes they actually end up smaller from offloading computations to the compiler instead of running them on the microcontroller
Sounds authentic. The executables do tend to get smaller since it’s not counting the unused code in the circle if there are any. As for the cases where they “get bigger”, I guess that has to do with our illusion that the default files are not occupying any space before we compile them (while in fact they are there and they have to be taken into consideration)
B
Oh, I work in freestanding, no C++ standard lib, just my own stuff
Does that mean with <strings> or without <strings>?
Ivan
It's not that hard to write C program that doesn't crash .
Yes, but leaking is whole another beast
Ocean
What do you mean by this?
I thought a chip could be built instead of built upon
Ludovic 'Archivist'
Does that mean with <strings> or without <strings>?
nothing from the standard library except cstddef, exit and some template processing utilities. No containers that use new included
Ludovic 'Archivist'
But I do not even use the pmr stuff, I have my own tooling library
Ivan
I thought a chip could be built instead of built upon
As in manually putting transistors together on a single chip????
Ludovic 'Archivist'
No exceptions, no RTTI
Ivan
No exceptions, no RTTI
I would throw away most parts of the stl too
Ivan
No exceptions, no RTTI
Literally Orthodox C++
Ludovic 'Archivist'
I would throw away most parts of the stl too
All I use are concepts, ratio and stddef
B
Yes, but leaking is whole another beast
Leaking and crashing are only a span of time apart with 8kb of RAM.
B
Oh I use my own classes for that
Well and I have my own libs in C 😁 .
Ludovic 'Archivist'
Literally Orthodox C++
Nah, it absolutely is modern C++, no one uses exceptions in modern c++, or RTTI for that matter
Ivan
(btw, whoever was complaining about the "dead" chat - you may be happy now)
Ivan
Nah, it absolutely is modern C++, no one uses exceptions in modern c++, or RTTI for that matter
Really? I guess I am out of context, because I am mostly writing Rust-flavoured C++ with std::uniq_ptr, std::move and no inheritance
Ludovic 'Archivist'
Literally Orthodox C++
Implementation of variants and optionals and error types to have tagged unions and monads, list processing toolkits similar to ranges...
Ludovic 'Archivist'
C++ is just C flavoured Haskell at this point
Ivan
C++ is just C flavoured Haskell at this point
Well, of comparable language complexity at least
Ludovic 'Archivist'
Well, of comparable language complexity at least
Nah, they work basically the same, just that C++ allows you to pop the hood open and shimmy explosives in there
Ivan
In fact, writing good readable "memory-safe and blazing-fast" C++ with C++26 is a breeze. The only pain in the ass is libraries
Ludovic 'Archivist'
In fact, writing good readable "memory-safe and blazing-fast" C++ with C++26 is a breeze. The only pain in the ass is libraries
Yep, I am making my own game engine in C++26 with no inheritance at all and it is a breeze, only place I got crashes were in the interpreted language I use to script things
B
Literally Orthodox C++
New minimal C++ subset everyday, just use the Ultra Orthodox™ Sane™ Nominal™ Embedded™ C++ subset called C89 .
Ludovic 'Archivist'
Do you use some custom implementation or one of your own writing?
One I wrote one day I was drunk and wanted to do C89
Ivan
One I wrote one day I was drunk and wanted to do C89
So do you actually have full-blown GC in there?
Ludovic 'Archivist'
This usecase for Forth just sounds too interesting for me to not ask more (ima sorry for bothering)
Basically, I treat Forth like readable bytecode, because that's what it is, so since my interpreter is stable in terms of API, I can compile Forth on the host and run it on a client, or compile something else to forth and then do whatever
B
This usecase for Forth just sounds too interesting for me to not ask more (ima sorry for bothering)
The FreeBSD bootloader used and still can use Forth, all the menus were programmed in Forth .
Ludovic 'Archivist'
So do you actually have full-blown GC in there?
Yeah, mark and sweep, pretty simple stuff but adds some mild metadata to anything that requires GC
Ivan
Yeah, mark and sweep, pretty simple stuff but adds some mild metadata to anything that requires GC
So basically you allocate whatever (string or some big-sized structure) on the heap and push the pointer on the Forth's stack (which means that pointer is in use)?
John
Clion is now free
Ludovic 'Archivist'
So basically you allocate whatever (string or some big-sized structure) on the heap and push the pointer on the Forth's stack (which means that pointer is in use)?
So, I have an interpreter context in which I manage type ids, user defined types, and garbage collection data, and then for every forth process, each has a function stack and a value stack and I push [typeid, index/value] pairs
Ludovic 'Archivist'
The full state of the interpreter is around 1KB on the heap by default, with all the base functions in there
B
The FreeBSD bootloader used and still can use Forth, all the menus were programmed in Forth .
https://github.com/freebsd/freebsd-src/tree/b064317fa8deb46d5b63bb52375f349fc4d7d5f5/stand/forth
Rose
Heya :) PM me if you have any questions on how to use me!
Xεη0η βψ†ε¢んΞғ
Hello everyone ! I am beginner in C programming
Xεη0η βψ†ε¢んΞғ
I want to share and teach each other between problem
Rose
I want to share and teach each other between problem
Don't ask meta questions. In other words, don't ask to ask. Questions like "Does anyone know XYZ?", "Has anyone used XYZ?" or "Can someone help me?" are all considered meta questions because they don't specify what your actual problem is. These questions give the impression that you want people to approach you and offer their help as if they don't have any other work to do. Now doesn't that expectation make you look like an idiot? If you have a question ask it directly. You are more likely to get a response that way.
ㅤ Question!
кто может помочь
harmony5 🇺🇳 ⌤
Rose
кто может помочь
Don't ask meta questions. In other words, don't ask to ask. Questions like "Does anyone know XYZ?", "Has anyone used XYZ?" or "Can someone help me?" are all considered meta questions because they don't specify what your actual problem is. These questions give the impression that you want people to approach you and offer their help as if they don't have any other work to do. Now doesn't that expectation make you look like an idiot? If you have a question ask it directly. You are more likely to get a response that way.
harmony5 🇺🇳 ⌤
Also, only english according to rules
ㅤ Question!
i need help
Rose
i need help
Don't ask meta questions. In other words, don't ask to ask. Questions like "Does anyone know XYZ?", "Has anyone used XYZ?" or "Can someone help me?" are all considered meta questions because they don't specify what your actual problem is. These questions give the impression that you want people to approach you and offer their help as if they don't have any other work to do. Now doesn't that expectation make you look like an idiot? If you have a question ask it directly. You are more likely to get a response that way.