View previous topic :: View next topic |
Zig vs Rust 2023 |
Zig |
|
50% |
[ 2 ] |
Rust |
|
50% |
[ 2 ] |
|
Total Votes : 4 |
|
Author |
Message |
gso321 n00b
Joined: 02 Jan 2023 Posts: 15
|
Posted: Tue Feb 28, 2023 3:18 am Post subject: Zig vs Rust 2023 |
|
|
Which language would you rather see more used in practical code (kernel) in 2023, zig or rust and why? |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9709 Location: almost Mile High in the USA
|
Posted: Tue Feb 28, 2023 6:18 am Post subject: |
|
|
Neither, write code correctly by design in C/assembler. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Banana Moderator
Joined: 21 May 2004 Posts: 1445 Location: Germany
|
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54421 Location: 56N 3W
|
Posted: Tue Feb 28, 2023 9:30 am Post subject: |
|
|
eccerr0r++ _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
stefan11111 l33t
Joined: 29 Jan 2023 Posts: 922 Location: Romania
|
Posted: Tue Feb 28, 2023 9:32 am Post subject: |
|
|
eccerr0r wrote: | Neither, write code correctly by design in C/assembler. |
I would say zig between the two, but this is the right answer. _________________ My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev" |
|
Back to top |
|
|
C5ace Guru
Joined: 23 Dec 2013 Posts: 474 Location: Brisbane, Australia
|
Posted: Tue Feb 28, 2023 10:09 am Post subject: Re: Zig vs Rust 2023 |
|
|
gso321 wrote: | Which language would you rather see more used in practical code (kernel) in 2023, zig or rust and why? |
Neither, write code correctly by design in C/assembler. _________________ Observation after 30 years working with computers:
All software has known and unknown bugs and vulnerabilities. Especially software written in complex, unstable and object oriented languages such as perl, python, C++, C#, Rust and the likes. |
|
Back to top |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2732
|
Posted: Tue Feb 28, 2023 10:33 am Post subject: |
|
|
fwiw zig is closer to C, generally doesn't make much sense to compare it to rust -- but kernel-wise I guess it'd be easier to integrate with the rest of the C codebase, not that I particularly care to see it used.
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though In case of zig I believe it breaks old code more often than rust right now and haven't really settled down too, there's been talk to slot the compiler because of that. |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4403 Location: Bavaria
|
Posted: Tue Feb 28, 2023 11:00 am Post subject: |
|
|
eccerr0r wrote: | Neither, write code correctly by design in C/assembler. |
++ |
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Tue Feb 28, 2023 12:31 pm Post subject: |
|
|
eccerr0r wrote: | Neither, write code correctly by design in C/assembler. |
That's an oxymoron, a self-contradiction. |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Tue Feb 28, 2023 1:05 pm Post subject: |
|
|
mike155 wrote: | That's an oxymoron, a self-contradiction. |
That's what people who can't write code correctly by design in C and assembly say
------
My choice: neither, obviously, but if I absolutely had to choose one, it would be whichever has a compiler that:
- Targets every architecture that Linux itself currently targets.
- Can be bootstrapped with GCC.
- Builds in less time.
One C and C++ compiler that takes hours to build is enough for me, I want the resulting compiler to be able to build everything
EDIT — Oh, and this:
Ionen wrote: | [...] I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
_________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
Last edited by GDH-gentoo on Tue Feb 28, 2023 2:09 pm; edited 3 times in total |
|
Back to top |
|
|
stefan11111 l33t
Joined: 29 Jan 2023 Posts: 922 Location: Romania
|
Posted: Tue Feb 28, 2023 1:30 pm Post subject: |
|
|
mike155 wrote: | That's an oxymoron, a self-contradiction. |
C allows you to write fast and efficient code. Oo is a mess and just adds needless constraints, which is especially important in performance-critical applications, like kernels. Also, you will need unsafe code in the kernel and in efficient programs. At least Rust is quite efficient. Good luck writing kernels in c++, java or python _________________ My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev" |
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 815
|
Posted: Tue Feb 28, 2023 4:07 pm Post subject: |
|
|
Neither.
I think that especially a kernel should be one language (+ some asm if required for very low level stuff), and rewriting everything to either Zig or Rust doesn't make sense. _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9709 Location: almost Mile High in the USA
|
Posted: Tue Feb 28, 2023 5:25 pm Post subject: |
|
|
Agree with the sentiment for C++ - main reason why I did not include C++ is because kernel/driver software must be optimized to the bone - fast, minimized, and efficient. C++ with object overloading can carry a lot of unforeseen and unneeded overhead that should not be in a kernel or driver, at best they should only be in userland code.
Yes security is an issue. Correct by design is up to the person writing the code. That is not to say if someone has a lint finder to post process C/assembly it shouldn't be run, in fact if there was a way to do this at compile time with static control flow analysis it should be done. The newer gcc's seem to start to be doing this with zillions of warnings popping up on old code so I think this is slowly happening... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Leonardo.b Guru
Joined: 10 Oct 2020 Posts: 302
|
Posted: Tue Feb 28, 2023 5:43 pm Post subject: |
|
|
Which flavour would you rather add to your morning coffe, and why?
|
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2023
|
Posted: Wed Mar 01, 2023 11:51 am Post subject: |
|
|
I'd replace the coffee with a hot dog. Then using mustard makes sense.
See also https://www.redox-os.org/ _________________ Greybeard |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Wed Mar 01, 2023 12:39 pm Post subject: |
|
|
GNU Hurd reborn! With a Rust skin! _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 815
|
Posted: Wed Mar 01, 2023 12:55 pm Post subject: |
|
|
If that keeps them from invading the linux kernel this project makes sense _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
Leonardo.b Guru
Joined: 10 Oct 2020 Posts: 302
|
Posted: Wed Mar 01, 2023 1:22 pm Post subject: |
|
|
Redox OS, I'll try it inside a VM.
Amatorial projects are always funny to play with.
My favourite programming language is C.
I read some books, artichles, programs sources. I don't want to trash everything and move to a "modern" programming language.
"Modernity is the oldest thing in the world."
I did some C++ when I was at university, but I don't like Object Oriented languages in general, I just don't feel natural reasoning in that way.
Rust doesn't attract me. |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Wed Mar 01, 2023 1:42 pm Post subject: |
|
|
Leonardo.b wrote: | I did some C++ when I was at university, but I don't like Object Oriented languages in general [...] |
C++ is object-oriented only if you want it to be _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
stefan11111 l33t
Joined: 29 Jan 2023 Posts: 922 Location: Romania
|
Posted: Wed Mar 01, 2023 1:51 pm Post subject: |
|
|
We learn c++ at school, but only use the "convenience" features, like opening files with fstream, reading and writing with iostream allocating memory with new and passing arguments by reference. For projects, I use c because I see no need for all the oo bloat, especially if I won't use it. Structs should be structs, not classes. Pointers should be pointers, not references. Allocation should be done with malloc and free, not new and delete and especially not with gc and/or placing strict restrictions on pointers/removing them all together because they are "unsafe" (looking at you, java) _________________ My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev" |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4403 Location: Bavaria
|
Posted: Wed Mar 01, 2023 1:57 pm Post subject: |
|
|
GDH-gentoo wrote: | C++ is object-oriented [...] |
With C you can do object-oriented programming also ... look at our Linux kernel ! |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Wed Mar 01, 2023 2:28 pm Post subject: |
|
|
stefan11111 wrote: | [...] especially if I won't use it. | What you don't use, you don't pay for.
stefan11111 wrote: | Structs should be structs, not classes. Pointers should be pointers, not references. Allocation should be done with malloc and free, not new and delete [...] | You can have all (C++ classes that work like C structs are the standard layout classes that are also aggregates).
pietinger wrote: | GDH-gentoo wrote: | C++ is object-oriented [...] |
With C you can do object-oriented programming also ... look at our Linux kernel ! | Of course! Only "inconvenience" is that the compiler won't help you in that case. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
stefan11111 l33t
Joined: 29 Jan 2023 Posts: 922 Location: Romania
|
Posted: Wed Mar 01, 2023 2:51 pm Post subject: |
|
|
GDH-gentoo wrote: | stefan11111 wrote: | [...] especially if I won't use it. | What you don't use, you don't pay for.
stefan11111 wrote: | Structs should be structs, not classes. Pointers should be pointers, not references. Allocation should be done with malloc and free, not new and delete [...] | You can have all (C++ classes that work like C structs are the standard layout classes that are also aggregates).
pietinger wrote: | GDH-gentoo wrote: | C++ is object-oriented [...] |
With C you can do object-oriented programming also ... look at our Linux kernel ! | Of course! Only "inconvenience" is that the compiler won't help you in that case. |
If I write c code with some c++ syntactic sugar, I am better off writing in c in the first place. _________________ My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev" |
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6103 Location: Dallas area
|
Posted: Wed Mar 01, 2023 3:07 pm Post subject: |
|
|
C is a low level language, just a step up from writing in assembeler. *chuckle*
Even before C++ came along, there were OO libraries that were springing up.
But even without an OO lang you can write things in a OO format.
To me C++ is C with a OO layer on top of it.
The problem with many languages, from C++ to go. to rust, etc is that they work well for a subset of real world problems,
but once outside that subset, then writing with these languages can become a chore.
There is no one size fits all language, and that includes C, but C will allow you to build practically anything else on top of it,
it just takes a little effort, some forethought, etc. A lot of languages have started off written in C, until they can self-host. _________________ PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 21856
|
Posted: Wed Mar 01, 2023 4:04 pm Post subject: |
|
|
stefan11111 wrote: | Pointers should be pointers, not references. | References are usually implemented as pointers at runtime, so there is no overhead to using a reference. Using a reference tells the reader that this variable can never be null. stefan11111 wrote: | Allocation should be done with malloc and free, not new and delete | The lack of a C++ counterpart to realloc is annoying, but new/delete serve some value over malloc/free. Among other things, new makes it harder to compute the wrong size when allocating an array. |
|
Back to top |
|
|
|