123 points · by ksec · 3y ago · 107 comments
My language brings all the devs to the yard
And they’re like, it’s better than yours
Damn right, it’s better than yours
I can teach you, but I have to charge
https://www.youtube.com/watch?v=aVQEbD3NyDwHah, this sounds like it fits in the Nerdcore genre. Might need to go and listen to something by MC Frontalot because of nostalgia now. I've also heard some humorous tech songs by Dylan Beattie in the past (though his conference talks are even better).
Edit: As for the languages, it seems like there's still a lot of elitism, gatekeeping and bikeshedding going on, which was something that was spoken of in DevTernity 2022 as well (in addition to coupling in codebases and architecture being a big theme this year). Sure, sometimes one language might be superior to another, but for most purposes many of the popular (or even niche) languages can be good investments and just generally good enough.
> No more CPU time
> I run KILL DASH NINE
> And your process is mine
Reminds me of this.
I think you know the answer. We can be a selfish and narcissistic creature and we often show our worst side on the internet since there are no repercussions. It's not as bad on HN but its definitely there.
I do see many shortcomings of C, I see a lot of advantages of Rust. It is always a game of trade offs. Safety/correctness, speed of development, performance of applications. It all depends on many factors, familiarity being one of them.
Lately I am thinking if it is possible to write in a subset of Rust, that would essentially be C-with-Borrow-Checker. Not using most of stdlib and very limited set of libraries. I also look at all those Better-C languages and do hope for their maturity: Zig, Odin, Hare etc.
Where's the trade-off? If the result is buggy crap and/or a security nightmare it makes no difference whether it was "fast to develop".
Saying something like that is like saying that you could build houses much faster if you just didn't have to follow any safety regulations. If you would try that in the real world you would end up in jail sooner or later. But in the virtual world of software people really seem to think that such an "argument" is valid.
I'm eagerly looking forward to the EU finally (and hopefully soon!) removing the liability exceptions that are still in place for software. It's in the working. Than software products would fall under the same liability laws than any other products, and vendors going to be finally full responsible for what they ship to customers. The whole "I don't care about safety and correctness because there are no consequences" madness would come to a very abrupt end in case vendors would be liable and could end up in court easy for shipping subpar products that were manufactured not adhering to state of the art practices.
> […] performance of applications.
Rust and C are the same in this regard. So no "trade-offs" here.
In my opinion:
- Rust is more productive than C
- Rust is easier than C, once you get past the initial bump
And it's not my opinion, it's just fact that Rust has practically the same performance as C.
I say this as someone who is currently actively maintaining embedded firmware with 10,000+ lines of C. It will be my last significant C project.
Rust macros are a disaster.
The whole kerfuffle around async and what had to be put into the compiler shows that Rust features don't compose well and don't allow the language to extend to unhandled cases cleanly (see: Pin).
#![nostd] still doesn't handle alternate memory allocators all that well.
My wishlist is C with just a bit of the Rust borrow checking and safety. I suspect that Zig or D will be able to get 80% of Rust's safety while only gaining 10% of Rust's complexity.
Not really. Those are very rare and only happens when someone asking for alternative or make claims that something only Rust can do.
>And say "why not Rust".
The unwritten rule of HN:
You do not question or criticise The Rusted Holy Grail and the Riscy Silver Bullet.
You forgot the Holy D Cup.
In other words don't be asshole to other people, unless you want them to stir drama. And if you are, make sure you have some decent ammo to back those claims.
There are objectively better programming languages than others. Like there are objectively better vehicles than others…
The blind Rust fanboyism reached crazy levels by now; and Zig isn't a bad language. (It's actually even quite nice for what it is). But there are very valid rational reasons to prefer one over the other.
Zig is a new language that repeats 50 year old mistakes. That's a very valid reason to criticize it. No memory safety is a big NO in the year 2022! Over 70% of all software malfunctions—and what's even more important, almost 100% of all severe security issues—are a direct result of missing memory safety. Even this one prominent stubborn and arrogant C dude realized that memory safety is an absolute requirement for a new language. That's saying a lot!
Still I recommend Zig to C die-hards. Because it's a slight improvement, and those folks will stick to C anyway otherwise.
But anybody who isn't married to C, and is still mentally flexible enough, should look for a better language instead.
As there are not much C contenders, especially safe and modern ones, the most valid choice right now in that field is Rust. Love it or hate it. It's like that. (And this does not change even in the light of the fact that Rust is currently overpraised by a large margin, and for a lot of "rewrite it in Rust" projects just using a GC language would be a more sane approach. Also there a niches where C can't be replaced by anything for the time being. But that are quite small niches, and they will likely become even smaller over time).
Second. Regarding using C, how would you react if someone told you: "I prefer driving cars with seatbelts and airbags removed. I like the speed you get from the reduced mass." Me, I'm not gonna try to convince you. I just don't want to drive with you.
Third people like their tribes. Insulting some language is bound to cause some members of said languages to retort. See discussion about D and Rust.
> D also has a @nogc mode, but it feels like giving up on 60% of the language’s power.
Without the GC, D has exactly the same 'power' as Zig have..
I feel that the poster is a bit misleading: he chose Zig instead of D because Zig, being newer, is more fashionable, not because of an imaginary technical reason.
If there's a technical reason, it's not written in the article.
If you disable GC in D, and end up with something equivalent to Zig, then why not use Zig?
- Multiple production-ready compilers. (Zig does not claim to be production-ready yet.) https://wiki.dlang.org/Compilers
- A more stable API. (Zig's authors rightly expect it to change before 1.0.)
- A package manager (dub) and repository: https://code.dlang.org/ (Zig will get support for these but doesn't even have an HTTP client needed to back package fetching yet.)
- An HTTP server and client with SSL/TLS support. (Zig is too new to have these, although community libs are starting to spring up to fill the gaps.)
- Better documentation, including a very accessible tour at https://tour.dlang.org/ and books such as http://erdani.org/tdpl/.
Zig may get all of these in time but D had quite the head start. D is a good language and I wish it got more attention.
99% of the D ecosystem uses the GC. You probably can't use most of it if you put @nogc on main.
99% of the D ecosystem of docs and articles assumes using the GC. You're going to struggle learning how to build something without it. You are kind of on your own.
Also @nogc only was added in 2014, it's not that old.
So given that, I honestly doubt that @nogc is much more mature than Zig, and is probably more difficult to learn how to use in practice, given that it's not a normal thing to do.
D always looked nice conceptually. But the syntax!
Most likely I would use it actively if it wouldn't look like C.
The type annotations are "on the wrong side". Type inference is barely-there (`auto` is a joke). It's littered with superfluous braces and semicolons.
I would really love it if they would change the syntax, and the result would look more like the new syntax in Scala 3.
Maybe. But could as well be the GC stigma being too strong. It isn't without reason that there's a post on official blog named "don't fear the reaper."
It's the community around D, the micro design decisions. If everything online presupposes you're using garbage collection most of the time, if everything in the language also makes that supposition sure possible to still go against the grain but it does feel like you're going against the grain.
Feel and community support is as important as anything else in a language decision.
> Zig is a programming language, but it also ships with a package manager
Which is not true:
https://github.com/ziglang/zig/issues/943
> Zig has no macros and no metaprogramming
Literally from Zig's homepage (https://ziglang.org/):
"Comptime - a fresh approach to metaprogramming"
The rest of the arguments are very weak in my opinion.
I created https://github.com/ziglang/www.ziglang.org/pull/228 let's see if it gets accepted :)
It is, at least, more battle tested.
Extensions shine brightest on CPU bound workloads by doing away with a lot of the intermediate Object allocs/frees. The gains tend to not be worth the investment in IO bound settings.
This doesn’t mean Rails won’t benefit from extensions.
That would be an interesting tale, especially in light of helix / ruru / magnus (why so many?) (and I don't know how they compare to pyo3 in terms of ease of use).
I can see it if they used "raw" rb_sys though, that seems... not much of an improvement over C unless the API is really small and you can quickly bail out to safe Rust: https://briankung.dev/2022/02/02/writing-a-rust-gem-from-scr...
https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-comp...
It has a bunch of macros that are rather straightforward to use
The key part. It wasn't possible to write Ruby extensions in Zig until a few weeks back. Now you can.
> I have a story of rewriting part of our production code as Rust extension, which turned out to be 3-4 times faster, but we ditched it anyway, because maintenance cost would be too high.
My solution to this problem is to stick with C. Your code won't get obsolete. Most people are still using C99, and not much has changed in 20 years, even in recent versions.
Ultimately we need to recognise that for some people, language is a core part of their identity. At that point criticising “their” language hurts them. If we’re talking to someone who feels this way, it’s best to politely say “is that so?” and gently disengage.
I know it’s tempting to think that we could show them just one compelling data point that will change their minds. But that’s not any more possible than convincing someone to stop believing in religion by pointing out factual inconsistencies in scripture. If you tell a committed Christian that Jesus couldn’t have been born in 0AD because Herod died in 4BC and the census they were travelling for happened in 7AD … is that going to make them reconsider everything about their religion? No, they’ll dismiss this as a minor issue that can be worked around. Same with $language programmers.
1 - https://msrc-blog.microsoft.com/2019/07/16/a-proactive-appro...
2 - https://www.chromium.org/Home/chromium-security/memory-safet...
3 - https://security.googleblog.com/2022/12/memory-safe-language...
Many of us still like C because it is inherently simple. That doesn't mean that it's good. It just means that we value simple and will take some (a lot!) of bad to keep the simple.
When others try to pawn off complex languages like Rust as alternatives because they solve C problems, they are not really listening. From my perspective the pushback is really about 2 groups having diametrically opposite values.
1 values purity and perfection, 1 values simplicity. These two groups are never going to see eye to eye.
opposite is also true "those who think C is inherently not good [...]"
> Any data backed study from Microsoft [1] or Google [2], [3] will be dismissed as Big Tech hiring mediocre programmers.
They aren't being dismissed, but criticized when used to promote other languages.
Those studies are partial and about a different topic.
They are are about bugs in millions lines of code bloated products, written in C++. Not counting the actual implementation "bugs", like the browser X leaking details about users to make fingerprinting easier and then sell ads.
You know why those companies are worried about memory safety and nothing else?
Because it's the way people can circumvent the so called "features" and "protections" they implement.
Here we are talking about Ruby extensions in C, which is a completely different domain, involving completely different tradeoffs.
The author confess he's not a great Rust programmer yet, so probably using Rust over a language he knows better, just because Google said it, it's not the best of choices.
Just think about the fact that the Ruby interpreter itself is written in C.
Think about the fact that a bug in path traversal or input sanitization is at least an order of magnitude easier to exploit and usually more dangerous than a double free.
> If you tell a committed Christian that Jesus couldn’t have been born in 0AD because Herod died in 4BC and the census they were travelling for happened in 7AD
as a non believer, that is the least problematic issue about Christianity.
dates are conventions, we are not actually leaving in 2022, would you change your calendar because dating is completely made up?
also: Jesus does not exists nor can do anything for you, C does.
A) Has a clear specification (none of that "the implementation is the specification" shenanigans). B) Is not manually memory managed (that's what we're trying to avoid by getting away from C). C) Is not garbage collected (that's what we're trying to avoid by writing C). D) Compiles to native code for if not all, at least most of the platforms that C supports.
...now I wonder which languages match that description, C++ with RAII and maybe SPARK?
I view ruby ecosystem as totally different philosophy system anti-ethical to many others seen in the engineering realm.
This may be my personal poorly-educated view, but I cannot shake it. Most of the good engineering practices are based on the orthogonal cartesian view of the world, where ego of the creator wants to believe the that all the corner-cases will be ultimately handled. And we just need time to add this or that component. That leads to increasing complexity and it is a vicious circle because all the abstractions are leaky. While in the ruby community, I don't see above described philosophy to be as strong as it is in other language ecosystems.
Thank you!
And unfortunately, I don't think I can "describe it in detail" as that's what the ego wants. That's the whole point, the ego wants to hear the details and then argue with the details.
Details often times make a lot of sense, while the end result does not.
The U.S. Tax Code is 6,871 pages. When you include the federal tax regulations and the official tax guidance, the number of pages raises to approximately 75,000.
Every single word has to be there, because it is solving some corner case.
Imagine, a json parsing library 50k LOC in C++ that can be cross compiled on most of the platforms.
Every single LOC (line of code) needs to be there.
These are creations of the ego (and orthogonal cartesian view). That's the dominant ideology in our world, it works very very well.
PS: Everybody knows, you could just parse your little json with `strnstr()`, and somehow we believe that amending cmake anytime it breaks is more meaningful than having spaghetti code calling strnstr that just magically works.
https://github.com/ziglang/zig/wiki/Community#discord-englis....
GitHub's code search beta is a good way to find out how other people are doing things with Zig, if you have access to it. For example:
https://cs.github.com/?scopeName=All+repos&scope=&q=http+pat...
Some less-known walkthroughs for those new to Zig but comfortable in other languages:
- A half-hour to learn Zig: https://gist.github.com/ityonemo/769532c2017ed9143f3571e5ac1...
- Zig Crash Course: https://ikrima.dev/dev-notes/zig/zig-crash-course/
You can also see how other people have solved problems you might have:
Note that improvements from GitHub Code Search have been integrated into the main website, which means you can do something like this:
https://github.com/search?q=lang%3AZig%20%2F%22https%3F%3A%5...
For too long, I too have been bothered by amazing writers not having RSS. So, I ended up hacking my own reader, that can parse almost any page and turn it into a stream of logical items. It is interesting how many web resources lack efficient delivery mechanism.