Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Zig vs Rust 2023
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  

Zig vs Rust 2023
Zig
50%
 50%  [ 2 ]
Rust
50%
 50%  [ 2 ]
Total Votes : 4

Author Message
gso321
n00b
n00b


Joined: 02 Jan 2023
Posts: 15

PostPosted: Tue Feb 28, 2023 3:18 am    Post subject: Zig vs Rust 2023 Reply with quote

Which language would you rather see more used in practical code (kernel) in 2023, zig or rust and why?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9709
Location: almost Mile High in the USA

PostPosted: Tue Feb 28, 2023 6:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1445
Location: Germany

PostPosted: Tue Feb 28, 2023 6:30 am    Post subject: Reply with quote

eccerr0r wrote:
Neither, write code correctly by design in C/assembler.

Yes.

Reminds me that a lot of polls or surveys are most of the time subjective
_________________
My personal space
My delta-labs.org snippets do expire

PFL - Portage file list - find which package a file or command belongs to.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54421
Location: 56N 3W

PostPosted: Tue Feb 28, 2023 9:30 am    Post subject: Reply with quote

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
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 922
Location: Romania

PostPosted: Tue Feb 28, 2023 9:32 am    Post subject: Reply with quote

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
View user's profile Send private message
C5ace
Guru
Guru


Joined: 23 Dec 2013
Posts: 474
Location: Brisbane, Australia

PostPosted: Tue Feb 28, 2023 10:09 am    Post subject: Re: Zig vs Rust 2023 Reply with quote

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
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2732

PostPosted: Tue Feb 28, 2023 10:33 am    Post subject: Reply with quote

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
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4403
Location: Bavaria

PostPosted: Tue Feb 28, 2023 11:00 am    Post subject: Reply with quote

eccerr0r wrote:
Neither, write code correctly by design in C/assembler.

++
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Tue Feb 28, 2023 12:31 pm    Post subject: Reply with quote

eccerr0r wrote:
Neither, write code correctly by design in C/assembler.

That's an oxymoron, a self-contradiction. :D
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1569
Location: South America

PostPosted: Tue Feb 28, 2023 1:05 pm    Post subject: Reply with quote

mike155 wrote:
That's an oxymoron, a self-contradiction. :D

That's what people who can't write code correctly by design in C and assembly say :lol:

------

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
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 922
Location: Romania

PostPosted: Tue Feb 28, 2023 1:30 pm    Post subject: Reply with quote

mike155 wrote:
That's an oxymoron, a self-contradiction. :D

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
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 815

PostPosted: Tue Feb 28, 2023 4:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9709
Location: almost Mile High in the USA

PostPosted: Tue Feb 28, 2023 5:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
Leonardo.b
Guru
Guru


Joined: 10 Oct 2020
Posts: 302

PostPosted: Tue Feb 28, 2023 5:43 pm    Post subject: Reply with quote

Which flavour would you rather add to your morning coffe, and why?
  • Salt
  • Mustard
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2023

PostPosted: Wed Mar 01, 2023 11:51 am    Post subject: Reply with quote

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
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1569
Location: South America

PostPosted: Wed Mar 01, 2023 12:39 pm    Post subject: Reply with quote

Goverp wrote:
See also https://www.redox-os.org/

GNU Hurd reborn! With a Rust skin! :D
_________________
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
View user's profile Send private message
pa4wdh
l33t
l33t


Joined: 16 Dec 2005
Posts: 815

PostPosted: Wed Mar 01, 2023 12:55 pm    Post subject: Reply with quote

Goverp wrote:
I'd replace the coffee with a hot dog. Then using mustard makes sense.
See also https://www.redox-os.org/

If that keeps them from invading the linux kernel this project makes sense :wink:
_________________
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
View user's profile Send private message
Leonardo.b
Guru
Guru


Joined: 10 Oct 2020
Posts: 302

PostPosted: Wed Mar 01, 2023 1:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1569
Location: South America

PostPosted: Wed Mar 01, 2023 1:42 pm    Post subject: Reply with quote

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 :wink:
_________________
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
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 922
Location: Romania

PostPosted: Wed Mar 01, 2023 1:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4403
Location: Bavaria

PostPosted: Wed Mar 01, 2023 1:57 pm    Post subject: Reply with quote

GDH-gentoo wrote:
C++ is object-oriented [...] :wink:

With C you can do object-oriented programming also ... look at our Linux kernel ! 8)
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1569
Location: South America

PostPosted: Wed Mar 01, 2023 2:28 pm    Post subject: Reply with quote

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 [...] :wink:

With C you can do object-oriented programming also ... look at our Linux kernel ! 8)
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
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 922
Location: Romania

PostPosted: Wed Mar 01, 2023 2:51 pm    Post subject: Reply with quote

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 [...] :wink:

With C you can do object-oriented programming also ... look at our Linux kernel ! 8)
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
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6103
Location: Dallas area

PostPosted: Wed Mar 01, 2023 3:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21856

PostPosted: Wed Mar 01, 2023 4:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum