real, use rust and zig
every time i run into an issue with rust and i’m like “ah man it’s so annoying the language doesn’t have this feature” i go write the same thing in c++ or kotlin or something, and then i realize why i hardly touch anything other than rust or f#…
the lack of (generic) variadics, overloading, proper specialization, etc. in rust gets really annoying sometimes but it’s an issue solvable with macros and/or weird trait manipulation (feels hacky but it’s whatever).
For great justice, you must
use rust and zig
All your codebase are belong to us.
Computers are so fast now, we should just write everything in BASIC anyway
Welcome to the world of JavaScript
I enjoy the selection bias in the comments for these sorts of posts. >_< There’s a few people saying “I kinda like C”, a few saying “use Python instead”, and a whole lot saying “Rust is my lord and savior”. Completely disjoint from the real world usage of the languages for whatever practical, pragmatic, or ideological measures they are used for.
This is why the post and the thread are so funny (assuming people are being intentionally funny)
I know barely anything about programming languages and only ask as a fan, what are the real world usages of languages and what are their practical, pragmatic, or ideological measures that they are used for?
I guess by real world usage I mean what proportion of code is being made with them. You should be skeptical of their accuracy, but there are measures for that. Like there is this one: https://www.tiobe.com/tiobe-index/, but it describes it’s methodology as being about popularity based on articles, news, and other such things. Github publishes a very different chart as does RedMonk. Rust barely shows up on these charts, but Rust fans are very enthusiastic in threads like this. I like Rust well enough, but I also find the over-enthusiasm amusing.
By practical/pragmatic I mean the ability to target a lot of hardware with C. Sometimes the tooling is crap, but it’s very universal. Being built on LLVM Rust can go onto plenty of hardware too, but it’s probably not the tooling given to you by a platform vendor. It’s also been around for a long time, so using Rust would mean a rewrite. Sometimes C is simply the choice. As for ideologically: Rust solves some pretty nasty programming issues, but sometimes I think it’s fans over-estimate the percentage of real world problems it actually solves while ignoring that Rust can be more expensive to write. (shrug) Sometimes there’s no such thing as a silver bullet.
Does anyone even know what Windows is written in?
Well, you know those claims that Java runs on 18 trillion devices? How do you think they got there, hmmmmm?
deleted by creator
On the other hand, C# is great
witchcraft
Makes sense
C or C++ usually
yeah but which craft?
Originally Windows was written in assembly and ran on top of DOS, but since Windows 2000 and XP, it’s been exclusively running on the NT kernel, which is written primarily in C, with some C++ in there as well.
The actual userspace is mostly C++ and C#.
deleted by creator
True! Their embrace of Rust is certainly heartening to see.
Let’s just hope they don’t follow it up with the other two E’s in their typical playbook.
Please do go ahead and name the last open standard that Microsoft intentionally destroyed.
EEE is the fucking boogeyman on Lemmy. You just mention it’s name and a bunch of nerds shit their pants and upvote.
I did upvote… but my pants are pristine
2002?
Unless I’m missing something, the most recent example there is from 2002 which, to my own horror, was more than 20 years ago.
Atom died about 13 months ago.
Just because they’re in a relative lull in the desktop space doesn’t mean they’ve stopped.
There may be good examples out there, but I’d argue Atom isn’t one of them. VS Code was clearly intended to be a spiritual successor with MS branding IMO, it is a fork of Atom, and it is equally open source (MIT license).
Atom usage dropped off dramatically in favour of VS Code or the fully open source VS Codium, there’s no point in Github writing it’s own code editor when it’s hosting a much more popular, more powerful, and equally open source editor in one of its repos.
Github had been funding development of Atom until MS bought them, put Atom on maintenance mode for 4 years, then killed it.
And basically the entirety of dotnet 6 forward is spans. It’s all spans. All the way down.
deleted by creator
deleted by creator
Search for leak in sudo’s changelog: https://www.sudo.ws/releases/changelog/
Leaks aren’t usually security critical though, and I’ve never heard of sudo triggering the OOM killer.
Also, no general purpose language that I’m aware of can guarantee a lack of memory leaks.
Especially since sudo is generally quite short lived. Unless it is leaking a significant amount of memory waiting for authentication that never comes it is insignificant. It would actually be pretty easy to argue that
sudo
just shouldn’t free memory at all. This would be better for security (all pointers live forever) and possibly faster as upon exec the kernel can just wipe all state rather than havingfree
carefully account for the releases.no general purposd language can guarantee a lack of memory leaks
You’re going to summon every Rust enthusiast on the platform
I am myself a crustacean, and we crabs know that lack of memory leaks is not one of the guarantees of safe rust.
crab_with_glowing_eyes.jpg
Look up function pointer types to make this language seem even more insane
Imagine having anyone tell you how to access your memory.
C is okay with good tooling. I wish it was possible to mix C and Rust code in the same project. I could be wrong but last I looked C code will have to sit outside in a library or something and called externally from Rust.
my controller may be old, but i only pay 20 thousands eurodogs for a board support pckage ,per user per ip per nation per year. I dont even pay for their eclipse ide! C is the laand of free fuck yeah! My debug partner is compatible with only 200 euro per flexcable. Don`t tell em my debrugs parnter is not oem spec🐵.
I really like C because I can just get to the heart of an action and make it happen without much surrounding code.
I could make classes and blah blah blah if I want to make a large, complex program but I’d rather write several small, simple to grok programs which pass information around so each program can do its one simple thing, quickly and easily. Chain the small programs together with bash or something, and bingo, you’ve got a modular high speed system.
I’m not a programmer, actually a mechanical engineer. But the Unix philosophy of simple, modular tools is great, provided one properly checks and sanitizes inputs.
What you’re describing sounds like Python. Not really C’s strong suit.
If you haven’t checked it out yet, you certainly should!
I agree with your main point. Python does a great job of replacing lots of tiny, chained scripts. Simple API calls with wget or curl have a place, but can spiral out of control quickly if you need to introduce any grain of control like with pagination, as an example.
Maintaining one Python app (or “script”) can still adhere to the unix philosophy of simplicity but can bend some rules as far as monolithic design is concerned if you aren’t careful.
It all boils down to whether you are introducing complexity or reducing it, IMHO.
I’m not suggesting replacing the small programs with one mega Python script, I meant that even C is not a good language for that either.
If you’re chaining a bunch of stuff together through your shell environment anyway, you’re not using the low level benefits of C, so you’re just punishing yourself with having to implement everything by hand every time! Python is amazing because the syntax is clear and readable and the standard library has nearly everything you’d need if you’re not building a large application.
However since most of these things are going to be one-liners then yeah you may want to just put them in one script!
I’m supporting embedded devices, and I like the performance of C. I’ve used python, it’s meh. At least you don’t have to compile it.
Aha on embedded not much choice there. It’s what keeps C alive and relevant for sure
Rust is starting to show up in embedded. And micropython, though that obviously has some limitations.
Totally, but I’m not aware of anyone using either properly in a truly production environment. Both are more on the hobbyist or tinkering side, or in the Linux space anyway where you can already just do anything.
(From what I’ve seen? Would be thrilled to see examples!)
I really like Micropython too. I made a “game” that communicates state between multiple boards over wifi in almost no time compared to how long it would take in C++.
That sounds a lot more like functional programming languages / frameworks
I feel like such a fool
Fools haven’t even written it well! Translated:
STOP WRITING
-
MEMORY WAS NEVER SUPPOSED TO BE AESSED DIRETLY
-
YEARS OF PROGRAMMING yet STILL ODE IS STILL WRITTEN with memory vulnerabilities
-
Wanted to aess memory diretly anyway? We had a tool for that: It was alled “ASSEMBLY”
-
“Yes please give me NULL of something. Please give me *&* of it” - Statements dreamed up by the utterly deranged
LOOK at what Programmers have been demanding your Respet for all this time, with all of the omputers we built for them
(These are REAL programs, written by REAL Programmers):
??? ??? ???
They have played us for absolute fools
what does this omment even say??? i ant see it
Took me too long to understand this, you unt.
Oh ome one now, an you not be suh a nit piker for one?
Respet earned.
LUV ‘ODE
LUV LINUX
‘ATE WINDOWS
‘ATE ‘LOSED SOURCE
SIMPLE AS
Thank
-
deleted by creator
But what if I want a union struct to quickly interpret floats as ints and vice versa! I need my C hacks!
You can’t, C have strict aliasing.
… Which compilers don’t consistently enforce, much like most undefined behavior in C.
How to enforce undefined behavior?
By refusing to compile any code that has undefined behavior. This is what rust’s compiler does, and is simply not possible for a C compiler to do.
To put it another way:
Strict aliasing is an invariant that C compilers assume you as a developer will not violate, and use that assumption to make optimization choices that, if you as the developer have failed to follow the strict aliasing rules, could lead to undefined behavior. So it’s a variant that the compiler expects, but doesn’t enforce at compile time.
I guess it is possible to just disable all such optimizations to get a C compiler that doesn’t create UB just because strict aliasing rules were broken, but there are still many ways that you can trigger UB in C, while safe rust that compiles successfully theoretically has no UB at all.
Strict aliasing exists not for optimization, but for type alignment. You may need more space on stack to save uint32_t than uint8_t[5] because former has 32-bit alignment.
Either way, this is a rule that you as a human are required to follow, and if you fail the compiler is allowed to do anything, including killing your cat.
It’s not a rule that the compiler enforces by failing to build code with undefined behavior.
That is a fundamental, and extremely important, difference between C and rust.
Also, C compilers do make optimization decisions by assuming that you as a human programmer have followed these strict aliasing rules.
https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8
Has a few examples where code runs “properly” without optimizations but “improperly” with optimizations.
I put “improperly” in quotes because the C spec says that a compiler can do whatever it wants if you as a human invoke undefined behavior. Safe rust does not have undefined behavior, because if you write code which would invoke UB, rustc will refuse to build it.
Compiler knows what is undefined behaviour better than all lemmy experts
Or if your pulling 4 byte data from an AtoD converter and it’s ordered 2, 3, 0, 1 for a fixed point value that you need to convert to a standard float at an extremely high rate or else the ring buffer will fill and you’ll start losing data.
That code review was a good time.
It’s actually nonstandard. Use memcpy
Well it is standard. The standard says that it is undefined behaviour. But I guess you are right that some compilers have non-standard options to make it not undefined behaviour.
🦀