:: Re: [DNG] Why C/C++ ?
Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Bruce Perens
Ημερομηνία:  
Προς: David Billsbrough
Υ/ο: dng
Αντικείμενο: Re: [DNG] Why C/C++ ?
Yes, I have found the Rust concepts of *Ownership *and *Lifetimes *very
helpful, and the fact that Rust code without the *unsafe *keyword (which
you should only
be using for hardware access) is both thread-safe and re-entrant-safe is
very useful. I agree that the investment is sizable. Most of my
Microprocessor
work is on ESP-32, both the RISC-V and the Xtensa architectures. Rust is
supported for those platforms.

I bet if you wanted to piss off some Rustaceans, you could wire the Boehm
garbage collector into it. And then publish a library and a tutorial. That
would do it!

On Fri, Aug 9, 2024 at 8:28 PM David Billsbrough <kc4zvw@???> wrote:

> Previously mentioned in this thread:
>
> > Or did you mean Rust and Linux don't work on microcontrollers?
>
>
> Hello Bruce,
>
> I have checked out using a both 'Zig' and 'Rust' spending about 3 days
> with one and a week with the other. Rust is its own animal!
> Rust is a major iinvestment in time not only in learning the language but
> to start to re-thinking about the program your creating in
> the great *Rust* think!
>
> It's about writing code that is *SAFE* and 'C' the language is dangerous
> because 'C' lets you use pointers and they are really, really dangerous!
> You do not initialize your pointers before you use that pointer or you have
> a logic error in mantaining your pointers then
> ... well .... *BOOM* and it got all dangerous.
>
> So in Rust *think* while getting you code to compile in the first place
> the Rust compiler watches you like a big brother hoping to keep
> you out of the Big Bad Troubles. If you code will compile at all without
> too many warning and no errors at all it *not* going to build
> you a runniable executiable.
>
> Also Rust does not have a 'gc' (garbage collector) and you have just like
> the 'C' lauguage the freedom but also the responsibility to manager how
> that memory is used. In 'C' you can allocate memory from the 'heap' to
> build stuff dynamically but you had better
> free that memory later or more *bad* news. The Rust has some technical
> 'borrow' concept to be *SAFER* but I couldn't wrap my
> brain around all that in the week I was checking it out!
>
> I think that 'Rust' and 'Zig' can be used for embedded controllers if the
> parts are built on installation on the host that would match
> your target development system.
>
> To answer the other question in the thread about if 'Linux' or 'Rust' can
> run on a micro-controller?
>
> That would really depend entirely on what is powering the micro-controller
> in question.
>
> Linux is an operating systems and if the memory restriction of the target
> board is too small to support space for a kernel and some
> form of a libc support library ... then that would be no.
>
> Rust is a programming development *SYSTEM* and if it have not been built
> to generate code targeting the 'target' development
> environment ... then that answer would be the same.
>
> I am hobbiest and when paid a "systems admin" so any real developer can
> reply to what I have not really grasped completely.
>
> 73,
>
> David
> --
> David - KC4ZVW
> Chuluota, FL
>
>
> p.s. : Bruce, have you been to any Hamcation or Hamvention, recently?
> *Sent:* Friday, August 09, 2024 at 9:48 PM
> *From:* "Bruce Perens via Dng" <dng@???>
> *To:* "Dan Purgert" <dan@???>, "dng" <dng@???>
> *Subject:* Re: [DNG] Why C/C++ ?
> The answer is historically there were good reasons, but not today. Today
> if you know C and don't want to make a really big investment retraining,
> Write in Zig. If you are willing to make the investment, use Rust.
>
> On Fri, Aug 9, 2024, 18:10 Dan Purgert via Dng <dng@???> wrote:
>
>> On Aug 10, 2024, onefang wrote:
>> > On 2024-08-09 07:59:51, Dan Purgert via Dng wrote:
>> > > On Aug 09, 2024, Didier Kryn wrote:
>> > > > Le 09/08/2024 à 00:10, karl@??? a écrit :
>> > > > > Hendrik Boom:
>> > > > > > On Thu, Aug 08, 2024 at 09:35:50AM -0500, o1bigtenor via Dng
>> wrote:
>> > > > > ...
>> > > > > > > Why is C/C++ so absolutely wonderful?
>> > > > > C is a really nice language compared to assembler.
>> > > > > Though at the time, the assembler of e.g. MC68000 was
>> > > > > a little high level lang. inspired with mult. adressing
>> > > > > modes. [...]
>> > > > >
>> > > >
>> > > >     Fully agree about C. [...]

>> > > >
>> > > >     The problem of C is that it is much more subtle than it looks,
>> and it
>> > > > contains a lot of pitfalls. There is a new, more secure language,
>> > > > which has the distinctive feature of having been accepted into the
>> > > > Linux kernel: Rust, but it is not yet stable.

>> > >
>> > > Nor does it work on microcontrollers ;)
>>
>> >> (...yet)
>>
>> > Um, C works fine for microcontrollers. When I programmed that tiny (RAM
>> > less than a kilobyte) microcontroller in assembler to create a USB
>> > keyboard (plus some extras that the client needed) last decade, there
>> was
>> > indeed an example written in C already.
>>
>> > Or did you mean Rust and Linux don't work on microcontrollers?
>>
>> Rust; though admittedly I may have missed news that someone made it work.
>>
>> C/C++ is /the/ language for microcontrollers -- least they're the only
>> languages I really see anyone in the IRC channels I hang out in talking
>> about -- some of us will talk assembly, but it's niche.
>>
>> "Arduino" too (but that's somewhat more restricted specifically to the
>> "#arduino" channel).
>
>


--
Bruce Perens K6BP