News for hackers. Stuff that matters.
Re:Why I’m Using C by rvz on Friday March 13, 2020 @09:13AM (#22566974)
> Why on earth would someone would pick C to start a new project in 2020?

Please ask yourself this before writing any code (For a cross-platform game).

By just reading this, I thought to myself if I were to write a cross-platform game in 2020, Is C necessary to accomplish this? Perhaps anything C can do, surely Rust can do it safer and arguably better.

Re:Why I’m Using C by Touche on Friday March 13, 2020 @09:49AM (#22567205)
People need to stop acting like Rust is flawless. There are real issues that make it not an ideal choice in some situations (notably embedded). Issues include:

1. Rust is very slow to compile. This is bad when rapid iteration is important.

2. Rust is a complex language. It wants to replace C++, not C, and gladly adopts features™ and the complexity that comes with that.

Re:Why I’m Using C by msla on Friday March 13, 2020 @12:54PM (#22568841)
> Rust is a complex language. It wants to replace C++, not C, and gladly adopts features™ and the complexity that comes with that.

This is a good point. I wonder if the trend of saying C/C++ is to blame; that is, people see C, think C/C++, and then are incapable of realizing that C is, in fact, its own language, and not merely "C++ Jr." or C++ with some features removed.

There's a hole in the modern language world, from what I can see: We lack a simple, mid-level language which incorporates modern knowledge about language design, where by mid-level I mean that all resources (other than stack, perhaps) are managed by hand but it's reasonably simple to write cross-platform code.

Re:Why I’m Using C by timw4mail on Friday March 13, 2020 @09:16AM (#22567000)
The biggest advantage C has over Rust is the sheer breadth of platforms. As a developer, I would always prefer Rust over C, if possible, but sometimes C is more realistic.

In most cases, C would only be more practical on obscure or outdated hardware, though.

Re:Why I’m Using C by worldsayshi on Friday March 13, 2020 @09:34AM (#22567111)
I fear that we are slowly moving towards a situation where our underlying technology stack is written in languages that a diminishing number of people have seniority in.

96% of the Linux kernel is written in C (https://github.com/torvalds/linux).

Re:Why I’m Using C by otachack on Friday March 13, 2020 @11:30AM (#22568033)
Would be nice to get a survey of current Linux kernel maintainer demographics (age) and see where we're at. Can be good data for a call to arms and potential company backing via charitable funds.
Re:Why I’m Using C by mroche on Friday March 13, 2020 @10:38AM (#22567567)
The GitHub counters are not always accurate. 97.3% (if going by C (imp+header) and Assembly) of the kernel is written in C, with the rest being written in Assembly. Everything else is config files, scripts, tests, or docs. GitHub reports C++ and Objective-C; those are just .h header files.

Update: Got to my system so I could actually look at available files accurately:

  C Implementation (.c): 28269
  C Header (.h): 20250
  Asm (.S): 1323
Edits: Update section and removing "100% in C" and "5 sources files of assembly"
Re:Why I’m Using C by clarry on Friday March 13, 2020 @11:01AM (#22567768)
Eh, find -iname '*.s' in kernel source tree finds more than a thousand files and half a million lines in them.
Re:Why I’m Using C by mroche on Friday March 13, 2020 @11:21AM (#22567951)
I wasn't at my system when I wrote that and just checked (5 is way off the mark there). Should have followed my own advice and not used GitHub's counters :P

The counter reports 1.2%, but if you click on that to show Assembly files it only reported 5 code results (it's not actually showing all Assembly, so you then have to click on "Unix Assembly" on the side).

Re:Why I’m Using C by jkoudys on Friday March 13, 2020 @09:30AM (#22567085)
Pretty easy to integrate C libs as unsafe calls with rust's FFI. You're definitely in for an uphill battle if you have to manage a bunch of decade+ old makefiles with hundreds of special flags for each platform under the Cargo ecosystem, though.
Re:Why I’m Using C by paulddraper on Friday March 13, 2020 @09:41AM (#22567155)
Console toolkits are almost entirely C/C++. E.g. Wii [1]

That's not to say you couldn't cobble together a solution with enough elbow grease and FFI, but the cure may be worse than the disease.

[1] https://wiibrew.org/wiki/List_of_development_tools

Re:Why I’m Using C by ogoffart on Friday March 13, 2020 @09:33AM (#22567105)
Ask yourself if his criteria applies to you:

> Reliability

While C is indeed a winner for obscure platforms, many language gets you perfectly covered for a "cross-platform" game.

> Performance

You can get equally good performance in Rust and C++.

> Simplicity

As he says, simplicity does not mean easy nor intuitive. Then it is a matter of opinion why simplicity should be a good thing. Personally, I prefer a complex but easier to use language than a simple but difficult to use language.

Re:Why I’m Using C by glouwbug on Friday March 13, 2020 @11:01AM (#22567772)
I've spent the last 2 years writing an age of empires 2 clone in C:

github.com/glouw/openempires

and my time spent with C has really just been manually implementing min heaps, circular buffers, ad hoc vectors, and a tier 1 dummy garbage collector.

All this stuff is readily available in C++, and I could have saved hundreds of hours by just using C++.

But, to one benefit, since I did all this work myself, I understand the machine better, and my compilation times are orders of magnitude faster than what I would have had if I chose C++. Additionly, since so few calls are even being made to the C standard library, the majority of the code exists in text, and easily inlines across all translations units with link time optimization. With C++, as except for templated library code, the majority of link time optimizations go to waste as calls to the standard library are binary linked.