[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: rust-social-wide.jpg (133 KB, 2048x1024)
133 KB
133 KB JPG
Without all the shitposting, is it worth it? Or is there any better alternative right now?
>>
>>91109213
Yes it's good and there is nothing better in the area it specializes in.
If you are doing systems programming and can use Rust, you mostly likely should.
>>
File: 1665128091346627.png (237 KB, 1027x1342)
237 KB
237 KB PNG
>>91109213
>Rust
>>
>>91109213
Whether there are better alternatives depends on what you're prioritizing. But yes, Rust is worth it.

>>91109317
Are you just posting this image so we can get another good 50 posts of stupid arguing about how complex the implementation of printf is when compared to Rust's format macros? Because we've had this argument too many fucking times.
>>
>>91109353
>printf
>complex
>>
Rust (pronouns: shit/programming/language)
>>
>>91109377

Just a tad
https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf.c;h=fc370e8cbc4e9652a2ed377b1c6f2324f15b1bf9;hb=3321010338384ecdc6633a8b032bb0ed6aa9b19a
>>
File: 1660065017311645.jpg (37 KB, 512x512)
37 KB
37 KB JPG
>>91109353
>using macros to format text
>>
>>91109213
nah. rust is shit and go is the shit nowadays
>>
>>91109472
Why not? It lets the job get done at compile time.
>>
>>91109213
It's better than c and c devs are just mad that they wasted their entire career (4 months) learning c for the performance
>>
File: 1667785474933490.png (282 KB, 634x650)
282 KB
282 KB PNG
>>91109550
>inlining string formatting code in every binary
>>
>>91109417
>literally 1000 lines of macros
as expected of glibc
>>
>>91109575
Rust macros are not like C macros. C macros are simple text cut and paste, and thus are equivalent to inlined procedures. In Rust, the format string is actually processed at compile time. The only thing that gets pasted into the code is the creation of a data structure.
>>
>>91109266
>muh system programming
there is no such thing as "system programming". there is a boomer programming by programmers who stuck in 80's software mentality

you can write a driver in python and it would work just fine
>>
File: 1664005120473181.jpg (23 KB, 400x386)
23 KB
23 KB JPG
>>91109680
>comparing toy language made yesterday to a language from last century
>>
>>91109715
You're the one who implied it was inlining. Meaning your understanding of macros was limited to languages that just use macros for inlining (i.e. C)
>>
File: 1666299987237009.jpg (237 KB, 853x1000)
237 KB
237 KB JPG
>>91109758
>your understanding of macros was limited to languages that just use macros for inlining (i.e. C)
yeah it's only natural because those languages are taught everywhere, you can't graduate without learning them
where do they teach rust? in discord grooming groups? kek
>>
File: vfprintf-internal.c.jpg (3.24 MB, 3192x9601)
3.24 MB
3.24 MB JPG
>>91109377
>>91109317
>>
>>91109213
There is no better alternative for the things it's best at. But that's not everything.
If you don't need libraries it doesn't have, you don't need to support more obscure platforms, you do need the efficiency or low-level control, then it's great.
>>
I'm having fun with it. Wife keeps making programming sock jokes though.
>>
>>91109213
It's a great language, easy to start learning, great documentation, sane and human readable error messages, memory safe, good dependencies manager.
Really the only "bad" thing about it is that it's still a kinda young language but that's also one of its strength.
>>
>>91110026
this is compiled and shipped with the OS though
>>
>>91109266
>>91109353
>>91109571
>>91110032
>>91110067
>>91110147
2 shekels have been deposited to your account
>>
>>91110005
C is taught everywhere, but it is not the only language with macros. Lisp and its derivatives, for instance, have very powerful macro systems. These languages are sometimes taught at the university level, although quite frankly, only an idiot would limit themselves to the languages they are taught. You are expected to learn a wide variety of technologies on your own in order to succeed in a software development career. Most Rust programmers learned in this way. They opened up the language manual in their web browser, studied it, made some example programs, and integrated it into their projects as soon as they understood it enough. The Discord communities are just there to ask questions if you need it.
>>
replaced every other language i use. probably the closest to a silver bullet language that you can get.
>web services
check
>network packet manipulation tools
check
>ide/editor
check
>my experimental small indie video game
check

by far the best part though is it sends /pol/lacks into a complete chimpout because they are compelled to think about other people's genitalia, or something equally unstable. i personally have never given a single fuck about what sex or gender the person who programs the tools i use identifies as..
>>
>>91110167
Nah, I don't support trannies so they wouldn't pay me.
>>
>>91109680
the only difference is that by default C lacks introspection of code, but it's trivial to write C source generator with same capabilities as rust macros
>>
>>91110243

>the only difference is that by default C lacks introspection of code
That's a pretty fucking big difference. C macros cannot do anything with their arguments except fucking paste it. Meanwhile, Rust can analyze the fucking AST.
>>
>>91110243
Procedural macros maybe, but the declarative macros do some subtle things in order to be hygienic. That'd be hard to replicate.
And being non-standard also kills it, or at least ensure it's used ten times less than it would be otherwise.

>>91110302
>Rust can analyze the fucking AST
Procedural macros only get the token stream. I'm sure you can obtain a C lexer somewhere.
>>
>>91110364

>I'm sure you can obtain a C lexer somewhere.
But you cannot run it in a C macro. C macros cannot perform compile time computation.
>>
>>91109213
The people who code on it never heard about the circular buffer.
>>
>>91110399
Yeah, so you add your own preprocessor before the compiler. Even make should be able to manage that.
>>
>>91110460
At that point, you're actually not writing C. C's macros are considered a part of the language, but a custom macro system that adds new features is not really an apples to apples comparison. At that point, you might as well use a different language entirely. And what do you know, Rust has great macros in the language standard.
>>
>>91110547
Think through this. What are the benefits of sticking to C?
- You already know the language
- It's supported by every platform out there
- You've got tooling that works with it
- You can use C libraries
These benefits are mostly kept if you bolt on your own macro system. You need to learn a little more but you don't need to revise your fundamental understanding at all. You can keep using special snowflake compilers. Some of your tooling will degrade but libraries aren't affected at all.
Rust is a whole different language with loads to learn, it doesn't have C's platform support because no other language does, it only has some of the same tooling, and while it can use C libraries you need a decent amount of glue.
"You might as well use a different language entirely" is just silly, you're way overstating your case.
>>
>>91110192
>replaced every other language i use. probably the closest to a silver bullet language that you can get.
>>web services
Meh. I a web service in Rust and it works fine, it doesn't break down when I update node or anything like that. But it took me significantly longer to develop using Rust and making any change to it takes way more effort. Even something as simple as adding another database connector or integrating different rest api takes order of magnitude more work than doing the same in node.
I would and do use Rust for all the other things you've listed, but I don't think I will ever write web stuff in Rust again. Too much work for little gain.

>>91110440
https://doc.rust-lang.org/std/collections/vec_deque/index.html

>>91110364
>Procedural macros maybe, but the declarative macros do some subtle things in order to be hygienic
The opposite is true. Declarative macros can be somewhat emulated in C. But procedural macros are way beyond C capabilities. You will never make something like serde in C, it's just impossible with simple text-replace macros.

>>91110692
The only advantage of C you've listed is support for niche platforms. If you are not targeting some weird architecture, every thing you've listed applies to Rust as well, assuming you know it already.
>>
>>91109317
Haven't they fix this yet?
>>
shitty hipster lang, c++ does it better without the gorillion compiler/llvm bugs and the dumb arbitrary limitations.
>>
>>91109213
Btfo's C & c++. Take the bussy pill.
>>
>>91110818
What is there to fix?
>>
>>91110796
>You will never make something like serde in C, it's just impossible with simple text-replace macros.
Sure sure but the post I replied to wasn't talking about simple text-replace macros, I'm pretty sure we're talking about full-blown external preprocessors.
>If you are not targeting some weird architecture, every thing you've listed applies to Rust as well
Rust doesn't have all the same tooling I'm pretty sure, and like I said, using C libraries is not as trivial. You can do it, I've done it, but there's a reason C libraries tend to be wrapped inside two layers of crates.
>assuming you know it already
That's an enormous assumption. I can't imagine it holds for most of the people who'd consider writing bespoke C macros.
>>
>>91109213
>is it worth it?
are you writing an OS or browser?
then no
>>
File: Trannyjak.png (374 KB, 529x637)
374 KB
374 KB PNG
>>91110877
>What is there to fix?
>>
>>91110692

>You already know the language
I also already know Rust. It wasn't that hard to learn.
>It's supported by every platform out there
I have a laptop with Ubuntu on it, a desktop with Windows 10 on it, and a phone with Android on it. Rust runs on all three. What platforms am I supposed to be using that Rust doesn't run on?
>You've got tooling that works with it
Same with Rust.
>You can use C libraries
...Also same with Rust. Every C library worth using has a Rust library that wraps it. And there are plenty of other native Rust libraries that are just fucking good.

Also, all of the benefits you mentioned would equally have worked with C++. You could have used this as an excuse to make the case for C++ over Rust. Except C++ has a functioning template system that, while it lacks the ability to read ASTs, is nonetheless turing complete and provides sufficient metaprogramming capabilities that C could only dream of having. But somehow, despite knowing all of these benefits applied to C++, you still thought "we should double down and recommend people write their own custom macro processor so they can use C".

For what it's worth, the reason I prefer Rust over C++ is primarily because of the tooling. Everything that sucks about C tooling applies equally to C++. But as a language, C++ is at least decent. C is hot garbage and writing your own custom macro system for it is putting lipstick on a pig.
>>
>>91110151
So is rust on kernel 6.1+
>>
File: 1664591595183258.jpg (122 KB, 1800x1474)
122 KB
122 KB JPG
>>91111008
>rust standard library is shipped with a kernel
kek
>>
>>91110933
>Rust doesn't have all the same tooling I'm pretty sure
Depends on what you need. For example Rust has package manager and C doesn't. Rust can generate one uniform documentation for your whole project and all of its dependencies, in one consistent form. C also has some tools that Rust doesn't have.
For all the years I have been working with Rust I didn't find any tool that I would be missing. Even nice debugging integrated into IDE(clion) works just fine.

>C libraries is not as trivial. You can do it, I've done it, but there's a reason C libraries tend to be wrapped inside two layers of crates.
Why two? From my experience every wrapper is just a single crate that has some codegen and some safe abstraction over it. I wrote some wrappers myself and really had no issues with that, other than the fact that some people think header-only libraries are a good idea for some reason and C compilers can't actually compile them. I had to add blank .c files that only include the .h files to actually be able to compiler them, this is pants-on-head retarded of C if you ask me
>>
File: 1660420618169276.png (317 KB, 542x674)
317 KB
317 KB PNG
>>91109317
>i::cant::take::it::anymore
>>
>>91109213
>can't women
>can't GUI
>can't 32 bit
>can't standard
>can't even linked list
It's not ready yet
>>
>>91110992
>you still thought "we should double down and recommend people write their own custom macro processor so they can use C"
No? I was arguing against doing that, but then someone else said there was literally zero reason to ever do that and zero reason not to switch to Rust, and I thought that went too far. I'm not saying to double down, I'm saying that it doesn't make sense for literally everyone to switch to Rust immediately.
>What platforms am I supposed to be using that Rust doesn't run on?
Embedded platforms, mainly. I don't do embedded work myself but from what I hear Rust ranges from poorly supported to basically infeasible because of missing architecture support or assumptions about hardware properties or safety models. (TDMA is mentioned sometimes as something Rust isn't equipped to model.)
>Every C library worth using has a Rust library that wraps it.
That can't possibly be true unless your standards are very high indeed. And e.g. GUI toolkits are notoriously wonky to use in Rust even though wrappers do exist.
>And there are plenty of other native Rust libraries that are just fucking good.
There are, but not for everything. I often have to write my own libraries or submit patches to existing libraries.

>>91111034
>Why two? From my experience every wrapper is just a single crate that has some codegen and some safe abstraction over it.
The usual pattern I see is a -sys thread with pure bindings and then a Rustified wrapper on top of that.
>>
>>91110992
DESU higher level C++ templete metaprogramming is a bitch to write, read and godawful to debug, a rust macro is much more approachable
>>
>>91109213
I use C and C++ at work. In my field everyone is a C fanatic and I am some of the few who likes C++.
The other day we talk about RUST and I feel the C fanatic is most likely to make the hop to RUST than C++... So now I'm learning RUST in the hope we can move on into something more modern.
Also, the rust book is realy good!
>>
>>91109213
>it's another no-programmer journalists rent free hate rust thread
get a life already you losers. We know you don't program and trannies live rent free in your head.
>>
>>91111918
I hate trannies, but men make great shit.
>>
Transgender language.
Very very bad for the future of white men.
>>
File: 20230125_063603.png (11 KB, 800x400)
11 KB
11 KB PNG
>>91112710
Wrong. It's kept us on top.
>>
>>91110364
>declarative macros
declarative macros is just DSL on top of procedural macros
>>
>>91112710
never seen a transnigger in public tho
>>
File: 1673297489489886.gif (1.64 MB, 221x244)
1.64 MB
1.64 MB GIF
>>91109711
>driver in python
>>
>>91109213
>as a C++ replacement
sure but Carbon is going to try to compete in that area, guess we will see which one is successful.
>as C but more type safe with modern features
no idea what would this give me that Ada doesn't already.
I'm not sure if it needs to exist.
>>
>>91109213
it's ok, at least it's an improvement over sepples. whether it's worth it or not depends on what you want to use it for and your experience with systems programming. don't listen to the shills saying it's an easy language and it's perfect for every possible task, that's bullshit. the learning curve is somewhat steep, especially if you have no experience with c/cpp, and while you certainly can use it for many things it's not necessarily great outside of its domain. if you're planning to write large pieces of parallel software that needs to run in real-time learn rust, if you're planning to write anything else other languages might serve your needs better
>>
>>91113647
>Carbon
it's barely a POC at this point and it will take at least a year to even get an alpha toolchain to compile it. by the time a stable version comes out (and assuming google doesn't kill it before it does)
rust will have grown even more so the only way carbon can survive is that the language and cpp interop tools are so good it makes adding it to cpp codebases a no-brainer
>>
>>91113865
Rust development seems pretty slow right now, but yes Carbon should have started a while ago, if it did Rust really would have no reason to exist. To me only time will tell if rust is developed enough before Carbon becomes actually useful.
>>
>>91113647
>Carbon is going to try to compete in that area, guess we will see which one is successful.
Why are you talking about things you have no idea about?
Carbon is not C++ replacement. Carbon is only supposed to assist in dealing with preexisting C++ codebases. It literally tells you to use Rust instead if possible in the FAQ.
>>
>>91113647
>no idea what would this give me that Ada doesn't already.
>I'm not sure if it needs to exist.
Ada guarantees are much weaker than Rust's. And ada is not moden by any means, it lacks in pretty much everything you would expect from modern programming language, and despite being much older has way less libraries than Rust.
>>
While Rust has many benefits, there are also some downsides to the language:

Steep learning curve: Rust's syntax and concepts can be difficult to understand for new programmers, particularly those with experience in languages like Python or JavaScript. It's also relatively unique compared to other popular languages, which can make it hard for developers to adopt.

Verbosity: Rust's syntax can be verbose, which can make it difficult to write concise code. The error messages it generates can also be difficult to understand, especially for new users.

Limited ecosystem: While Rust's ecosystem is growing, it still has a smaller ecosystem than some other popular languages such as Python or JavaScript, which can make it more difficult to find libraries or frameworks for certain tasks.

LimitedIDE support: Rust's IDE support is not as good as some of the other languages, which can make it difficult to write and debug code.

Lack of generics: Rust does not support generics in the same way as other languages such as Java or C#. While Rust has a powerful macro system, some developers may find it more difficult to write generic code.

Limited use cases: Rust is not suitable for every use case, it's primarily used for systems-level programming, and it may not be the best choice for web development, data processing or machine learning tasks.

Overall, Rust is a powerful and efficient language, but it has a steeper learning curve and some limitations that can make it difficult to use for certain tasks. It's important to weigh the benefits and downsides of Rust before deciding to use it for a specific project.
>>
>>91113647
Carbon is merely a maintenance language. It isn't meant to be used for new projects.
>>
>>91114101
based bot poster
>>
File: 1673966557463551.png (284 KB, 475x356)
284 KB
284 KB PNG
>>91109711
>>91109266
>>
>>91114101
The first actually substantive critique of Rust ITT. Well done.
>>
It is worth using Rust if your task is related to system programming and security including building operating systems, device drivers, low level libraries with a C ABI Application Binary Interface. But Rust is not a suitable replacement for C++ when dealing with game programming, computer graphics or scientific computing since Rust lacks mature game engines, numerical computing libraries and also lacks support for MPI message passing interface and OpenMP, that allows making loops parallel with just preprocessor annotations.
>>
>>91114182
Sadly I didn't write it. I primed chatgpt to write it. >>91114249 was spot on.
>>
>>91114199

By that I meant >>91114149
>>
>>91114191
I wrote a game engine in Rust and wouldn't use anything else. It works perfectly for that use case. Nalgebra is more than enough for an engine and vulkano is good for graphics.
But it's true it doesn't have any mature game engine. It's not a good idea to use language like that for game logic anyway.

>>91114199
Chatgpt is more intelligent than cniles then. I am not surprised.
>>
>>91114246
I am not a cnile, I just acknowledge that Rust ecosystem is still not mature as C++ and Fortran ones. If you use Rust, you will have trouble hiring developers and also may have to write bindings to other C or C++ supporting libraries or rewrite the dependencies in Rust. But I hope Rust gain more traction and adoption.
>>
>>91114459
Oh yeah that's why I agreed with the bot reply.
I am not calling you cinile, just the people shitposting who can't make any reasonable argument against Rust. Rust not being as mature as these two is definitely a real thing to be considered when choosing a language for a project.
>>
>>91113249
>NOO I MUST WRITE DRIVERS IN C OR ELSE...
the 50 years old premature optimizatoor
>>
>>91109317
So what's the problem?



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.