[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] [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

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: bruh.jpg (116 KB, 1050x891)
116 KB
116 KB JPG
In C:
#include "raylib.h"

int main(void)
{
InitWindow(800, 450, "basic window");

while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}

CloseWindow();

return 0;
}


In Rust:
use macroquad::prelude::*;

#[macroquad::main("BasicShapes")]
async fn main() {
loop {
clear_background(RED);

draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);
draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);

draw_text("IT WORKS!", 20.0, 20.0, 30.0, DARKGRAY);

next_frame().await
}
}
>>
If they were normal they'd use C, maybe with __counted_by.
>>
I use some rust programs and they're all pretty solid, so I gave it a try, everyone says it's difficult to learn and a pain, but holy shit I was not expecting it to be such a mess. Usually I can learn a language just by reading code to understand the syntax, and then reading about the new features, but rust does everything different, it's constantly calling methods and enums and shit you have to memorize.
I followed some tutorials from their website and they didn't teach me how to make a fucking if statement. If the user needs to read your whole book to learn how to make a calculator maybe your language sucks.
>>
>>108413263
kys
Your idiocy makes real C programmers look bad.
>>
>>108413341
Rust is js for systems programming.
>>
>>108413263
This is how Rust people create a simple window btw:
https://github.com/rust-windowing/winit/blob/master/winit/examples/window.rs
>>
>>108413341
if is not a statement. it wasn't a statement since before C. it being a statement is a C-ism.
>>
File: waaaa.png (234 KB, 920x1062)
234 KB
234 KB PNG
>>108413472
>OMG an example has both boilerplate AND comments
>>
>>108413263
>neither example does the same thing
>rust one gives you a real coroutine as well with explicit yielding til next frame.
idk the rust one looks better anon.
>>
>>108413733
hm. I guess they only use the continuation for dealing with web wasm bullshit.
>>
File: satania_laugh.gif (344 KB, 500x491)
344 KB
344 KB GIF
I find it quite funny that Raylib was your choice for example C code, considering Raylib is easily one of the the cleanest C code bases out there, everything else is infinitely more niggerlicious.
Meanwhile the Rust code is readable and in terms of cleanliness, it is par for the course.
>>
>main(void)
>readable
kys cniles
>>
>>108413263
>>108413357
>>108413733
>>108414003
I know that this thread was probably made by a Rust slavewhore, but macroquad probably wasn't the best pick for shilling, TBQHWY.

https://www.reddit.com/r/rust_gamedev/comments/1pc9wyv/macroquad_after_2_years_of_mostly_fulltime_rust/
https://github.com/not-fl3/macroquad/issues/333
>fn get_context() -> &'static mut is unsound #333
>>
>>108413263
now show bevy
>>
>>108414220
>opens bevy tutorial
>tutorial starts with teaching entity component system
this shit is wack, yo
>>
>>108414220
>gayme engine
lol
do vello
>>
>>108413472
and these people shit on java
>>
>>108414355
ever tried creating a window in win32 or anything else?
>>
>>108414188
>that issue 333
damn. kek. a lot of people also don't realize just how bad a lot of software is out there as well. dealing with global mutable state really makes you realize how bad UNIX/Windows really is.
>>
>>108414565
STFU Rust slavewhore.
>>
File: 1724880038967486.png (127 KB, 1712x2852)
127 KB
127 KB PNG
cnile nocoders get upset, or at least feign being upset, about the most trivial things. What is their goal?
>>
>>108416503
No one asked you. Quit yapping, Rust slavewhore.
>>
>>108413689
https://en.cppreference.com/w/c/language/if.html

if is a statement you larping retard.
>>
>>108413263
>) \n {
Into the trash
>>
>>108413341
I'm sorry to say this, but you may have a terminal case of retardation.
>>
>>108413341
skill issue
>>
>>108417590
is this a /g/eet bait attempt, or are you literally illiterate who thinks seepeepee reference holds universal truths?
>>
>>108413341
>>108417607
>>108417615
STFU, samefag Rust slavewhore. Explain the intricacies of pinning, unsafe and the worst of async. Pro-tip, you can't, even the language designers are still trying to understand unsafe and remove inherent unsoundness and type system bugs from the language.
>>
File: javascript.png (129 KB, 1086x705)
129 KB
129 KB PNG
>>108417656
Most languages are the same.
>>
>>108417690
#letrec fact n = if n = 0 then 1 else n * fact(n-1);;
fact = - : (int -> int)

take a guess how old the code above is. then imagine if that same code is written with a language that has similar semantics, but with C-like syntax.
>>
>>108413989
i have noticed a strong propensity for this particular .gif to be attached to retarded posts
>>
File: file.png (96 KB, 612x482)
96 KB
96 KB PNG
>>108417734
I bet not as old as pic rel. If statements being statements and not expressions goes back a very long time.
Not that it makes much of a difference anyway. If statements aren't big, and there's always ternaries.
int fact(int n) {
if (n == 0) return 1;
else return n * fact(n-1);
}
int fact2(int n) {
return n == 0 ? 1 : n * fact2(n-1);
}
>>
>>108413263
I like how "cooooders" can't even tell that these are two completely different results. There's nothing to compare since nothing in common.
>>
>>108417937
Basically everyone on this thread has pointed that out, desu.
>>
>>108417951
I don't scroll past first like 5 posts in such coooooding threads.
>>
>>108417734
imagine thinking an early ML of all things is representative of programming
>>
>>108417734
ocaml is gay
which means rust is gay
>>
File: giphy.gif (2.13 MB, 480x480)
2.13 MB
2.13 MB GIF
>>
>>108413341
Rust was designed with vibe coding in mind
>>
>>108417835
>>108419394
the LLM answer(s) failed you.
this code is from at least as early as ML (1973). and having the same semantics means "if" is an expression so no return is needed on each branch. so a language with actual similar semantics and C-like syntax could look like:
int fact(int n) {
return if (n == 0) 1 else n * fact(n-1);
}


but that return still breaks the expressive semantic nature of the language, so, more correctly, it would be:

int fact(int n) {
if (n == 0) 1 else n * fact(n-1)
}


now. there are reasons (too long to cover here, and i'm almost finished with my number 2) for changing this syntax in a couple of ways so you get something like:

fn fact(n: int) -> int {
if n == 0 { 1 } else { n * fact(n-1) }
}


(single line blocks without {} should be avoided even in C because it has been a huge pitfall that caused egregious bugs)
if you think C-isms are the default, the OG of programming if you may, then you can think of this as a generalization of ?: that goes beyond mere trivial bool switching.
>>
File: 1773875847688538.jpg (299 KB, 828x775)
299 KB
299 KB JPG
Omg that rust syntax
Hell no
Stay away from me rustrannies
>>
>>108413341
>Usually I can learn a language just by reading code to understand the syntax, and then reading about the new features, but rust does everything different
This is a good thing. Stop guessing, read the book
>I followed some tutorials from their website and they didn't teach me how to make a fucking if statement
Chapter 3.5 of the book - control flow, "if" is the first thing explained.
>If the user needs to read your whole book to learn how to make a calculator maybe your language sucks.
If is literally the exact same as in other languages, bar brackets being optional and it being an expression, which you can completely ignore by not opting in by skipping the last brace, which if you are a beginner you won't even know you can do.

Forcing new users into actually learning the language instead guessing shit and being wrong half the time is a net benefit. Maybe the fact that you can't make an if and don't know where to find how to make it should be a hit to stop being lazy and learn properly. It's just called "the book", it's not actually book length
>>
File: fufufu.jpg (60 KB, 1360x768)
60 KB
60 KB JPG
>>108417783
>no argument
i accept your concession tranny
>>
>>108417675
People explained all of these to you fifty thousand times, you just don't accept the answers because you believe there's some magic inherent difficulty in eg. pinning and not that it's an easy concept to explain, but hard to apply
>>
>>108420229
Retarded Rust slavewhore, how come you are this stupid and duplicitous? Explain it to the language designers and fix Rust and rustc for them then, since they can't figure it out.
>>
>>108413263
>macroquad
literally what?
never heard of that and what you posted seems more like a library issue than a rust issue.
>>
>>108413341
filters jeet, i love rust.
I agree that it's harder to learn but it's imo a good thing, once you master it though there are not a lot of languages that are more productive than it.
>>
>>108420341
>citation needed
>>
>>108420484
Rust slavewhore who eats ass, shit and cum all day, you already know this to be true, since it only requires a modicum of research or time spent with Rust. Neck yourself.
>>
>>108420482
Indians use Rust as well, including in Google's Fuchsia.
But it's true that Rust is harder to learn, since not even its language designers and compiler writers can figure it out.
>>
>>108419758
>implying an LLM would ever write C code like that
>this code is from at least as early as ML (1973)
C was invented in 1972, and the picture I posted of "if" being a statement not an expression is from the original version of fortran in 1958, so which do you really think came first? Fortran 66 even got full if statements with control flow, and it also predates ML.
>>
>>108413263
testing:
<code>
Some code
</code>
>>
>>108413263
testing some more
test code
>>
>>108420902
>conditionals in assembly are not statements
atheists btfo!
https://www.youtube.com/watch?v=WcE0mvWNpqQ
>>
>>108413263
Rust does not fly !!!

Seems to me it never will!
>>
>>108420801
so none?
I accept your concession jared.
>>
>>108413472
Simple window creation is just 3 lines in this snippet. The rest is for event loop and cross platform support. This code can even run on wasm.

I would love to see what language can do all of that in less LoC.
>>
>>108419687
There was no vibe coding 10 years ago. You must be 18 years or older to use this website, zoom zoom.
>>
>>108421285
Nice try, the world did not exist before 2019
>>
>>108421123
The only one conceding is you, Rust slavewhore, as you just did. Gobble some more shit and cum as you are currently doing.
>>
>>108421408
message to operator: congratulations on the bot update. we missed you. nice dictionary updates too.
>>
>>108421507
Is that a projecting admission? Either way, neck yourself, Rust slavewhore.
>>
File: REAL_WORLD_HASKAL.png (346 KB, 599x335)
346 KB
346 KB PNG
>>108413263
I'm old enough to have been programming in 2008-2009. I remember Haskell. I remember all the hype for Haskell. Rust is the modern Haskell, mark my words. It's the same stupid conversation.

>LOOK AT HOW ELEGANT THIS CURATED CODE SAMPLE IS
That's cool, why does none of the library code look like this?
>IT'S NEAR C PERFORMANCE
Yes if you write unsafe code that looks like fucking dogshit
>THE TYPE SYSTEM MAKES YOUR CODE PERFECT ON THE FIRST TRY
Except for all the cases where it doesn't
>YOU DON'T HAVE TO WORRY ABOUT UNSAFE MEMORY MANAGEMENT
Fine until lazy evaluation/borrow checker does unpredictable things and I need that "low level performance" you advertise
>GORILLIONS OF COMPANIES ARE ALREADY USING HASKELL/RUST
Okay, which ones? * produces list of like 27 with 4 dead domains 10 random one-off teams at a company like Amazon with thousands of developers *
>DYNAMIC LANGUAGES HAVE BEEN EVOLVED OUT
ML languages with a Hindley–Milner type system have existed for over 50 years, and I distinctly remember when webshits were jerking off over how much quicker than can develop in Ruby and Python. Tech hasn't changed, the hype has.
>YOU GOTTA BUILD SOMETHING IN IT
I did, and it made simple shit excessively complicated
>OH YEAH WELL BASED ON MY EXTENSIVE EXPERIENCE DOING A TO DO LIST IN IT THAT NOBODY USES, IT'S EASY

The only "uncommon" languages actually worth using in production are Common Lisp and Erlang. I've seen nothing out of Rust that isn't a big political circlejerk.
>>
>>108413263
Learning Rust felt a bit similar to learning Haskell.
> do babby tutorials and toy programs: neat and clean
> do real projects: time to spam 'unsafe' and shit weird macros everywhere to do anything
>>
>>108421706
You are wrong on pretty much every level.
People have been saying that Rust is very similar to Haskell from the start. It mostly comes from people who never heard about Ocaml but this isn't that far from truth anyway.

>why does none of the library code look
Except, it does. I don't know about the particular library OP used, but if HALs for microcontrollers can look nice and readable, I don't see why any other problem couldn't be solved like that. #[cfg] really helps a ton compared to analogous C++ code using preprocessor macros for example.

>Yes if you write unsafe code that looks like
Except it doesn't. Unsafe doesn't change anything about syntax or semantics, except for allowing you to call unsafe functions and dereference pointers.

>Except for all the cases where it doesn't
But it does. The powerful type system with explicit lifetimes can elegantly express a lot of stuff about your code. For example you can use traits to describe how particular type can behave in multi threaded context, or for example who holds ownership over some physical peripheral. All of these leveraging cleverly designed type system, and not some ugly hidden library runtime code.

>Fine until lazy evaluation/borrow checker does unpredictable things...
Rust doesn't have the same problems as Haskell with unpredictable evaluation order. When you are using iterators they still are evaluated sequentially as you'd expect, they are only lazy while you are still composing them to express whatever logic you need. Order of evaluation of subexpressions is strictly defined in Rust too.

>Okay, which ones?
Google, Microsoft, Apple, Amazon, Meta, Cloudflare, pretty much every big player uses it in production.

>DYNAMIC LANGUAGES HAVE BEEN EVOLVED OUT
No one said so. Dynamic languages have different niche than static compiled languages like Rust, C and so.

>I've seen nothing out of Rust that isn't a big political circlejerk.
Your post has been processed by Rust code in order to end up here.
>>
>>108421839
Git gud.
If entire GPU driver can be written with only couple of unsafe blocks, you should be able to write your program with close to none.
>>
>>108421986
I appreciate the thorough response to my shitposting, but you've missed the forest for the trees. My post is 90% social commentary.
>People have been saying that Rust is very similar to Haskell from the start. It mostly comes from people who never heard about Ocaml [...]
I've used Haskell, ML, OCaml, Rust, etc. My point is not that Haskell is the same language, it's that the hype train and social dynamics around Rust are extremely similar. It's a fringe language with a rabid fanbase eager to shoehorn the language everywhere without evaluating merit or producing results.
>But it does. The powerful type system [...]
Strong type systems (not just static) help catch a certain class of errors, and algebraic data types and other niceties are useful. However, the belief that a type system is a panacea for code is a religious belief, not a technical one.
>Rust doesn't have the same problems as Haskell with unpredictable evaluation order.
You have missed my point. Haskell had problems with performance-constrained code because of lazy evaluation. Rust suffers at the bleeding edge of performance because of the borrow checker. There is a reason mission-critical realtime systems are not (yet) being written in Rust.
>Google, Microsoft, Apple, Amazon, Meta, Cloudflare, pretty much every big player uses it in production.
Yeah they use it in production, and Meta uses OCaml in production. My point still stands that niche use in a one-off project where the strengths of the language shine does not make the language great for general purpose work.
>No one said so.
Should you have the misfortune to peruse Hacker News etc., you will find much of your community screeching about how dynamic languages are unusable and rushing to bolt type systems onto other languages.
>>
>>108422089
>Haskell is the same language, it's that the hype train and social dynamics around Rust are extremely similar.
Except, it isn't. Haskell is an academic language that focuses on formalism and category theory stuff. Rust was never meant to be of any use for that. Rust has always meant to be just a practical language that takes good ideas from other languages and combines them into a modern, practical language. Although lifetimes turned out to be quite innovative, everything else about it is just taken from various other language.

>Strong type systems (not just static) help catch a certain class of errors,
And the point of Rust type system is to minimize surface for most common class of errors, memory errors. It does quite a good job at it and that's why every corporation is so interested in it.

>Haskell had problems with performance-constrained code because of lazy evaluation.
That's why there was a lot of effort put into Rust compiler to make that zero-cost. Most of the time you can do a lot of FP style maps, filters, folds, etc and they often compile to about as good(or sometimes even better) assembly than explicit loops.

>Rust suffers at the bleeding edge of performance because of the borrow checker.
Borrow checker is evaluated entirely during compilation, it's a form of static analysis. It doesn't add any runtime code.

>There is a reason mission-critical realtime systems are not (yet) being written in Rust.
That's not performance. People use Ada for mission critical code and it's often much slower than C or Rust.
This mostly comes down to inertia, lack of certified toolchains and such.

>My point still stands that niche use in a one-off project where the strengths of the language shine does not make the language great for general purpose work.
Rust is in the kernels, in Cloudflare proxy, in android, these are pretty flagship projects of these companies.

>you will find much of your community
/g/ is my community
>>
>>108413263
And it takes 60 GB in Cargo to compile it.
>>
>>108421706
>>108421986
>>108422089
>>108422289
nice llm samefsgging
>>
>>108422365
>anything longer than 3 sentence is an LLM
You need to kill yourself immediately, thank you for your attention to this matter.
>>
>>108422289
>Except, it isn't.
You intentionally clipped the quote to argue a strawman. Typical Rust troon.
>>
>>108422470
completely wrong, you should kill yourself, i shouldn't, and you know it, faggot
>>
>>108422485
I clipped the quote because I ran into character limit, desu.
>>
>>108422565
Your mom's gay. What about that, tough guy?
>>
>>108413341
>I followed some tutorials from their website and they didn't teach me how to make a fucking if statement.
https://doc.rust-lang.org/book/ch03-05-control-flow.html
it's in the very beginning
>>
>>108422580
are you a tranny? Neck yourself, faggot



[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.