News for hackers. Stuff that matters.
Re:Why I Write Games in C by RaitoBezarius on Saturday January 09, 2016 @04:04AM (#10870585)
What about Rust?
Re:Why I Write Games in C by dunkelheit on Saturday January 09, 2016 @04:44AM (#10870674)
Maybe in ten years. Great thing about old mature technology such as C is that all gotchas have been tripped over innumerable times and are all well known and codified. Meanwhile new exciting technology like Rust contains unknown number of bugs like http://www.wabbo.org/blog/2014/22aug_on_bananas.html, undiscovered antipatterns and subtleties.

My comment is not meant to bash Rust, on the contrary it is very promising and the fact that it is used to write Servo is likely to significantly speed up its maturation. But as author notes, if you are developing a project under a deadline you don't have time for bugs you didn't cause yourself. So old boring technology is the way to go.

Re:Why I Write Games in C by Rusky on Saturday January 09, 2016 @12:12PM (#10871965)
That bug was almost a year before Rust 1.0 was released. At this point, Rust is being used in production outside of Servo- for example Dropbox is even using it for their core data storage code.

It's certainly not as old-and-boring stable as C, but it's a lot closer than you'd think.

Re:Why I Write Games in C by dunkelheit on Saturday January 09, 2016 @02:33PM (#10872500)
And that bug was less than a 1.5 years before now. And Rust is at version 1.5 now. And all changelog entries since version 1.0 (which was released 8 months ago) mention "multiple bugfixes". Of course, that's all subjective, but for me these facts all scream "rapid pace of development, expect multiple annoyances and a couple of major bugs for your particular use case".

Dropbox is using Rust in production? Great news! But I'll wait when a thousand of organizations use Rust in production before advocating its use in my own organization. Also, judging by this comment: https://www.reddit.com/r/programming/comments/3w8dgn/announc... they had incredible rapport with the language core team. That is a luxury not every team using Rust is going to have.

Still, great news. I guess I must implement some kind of little personal project in Rust and in the process help iron out a few more quirks.

Re:Why I Write Games in C by steveklabnik on Saturday January 09, 2016 @03:40PM (#10872779)
As a member of that core team, I would expect that we will pay just as much attention to any company that plans on using Rust in production. We're very interested in supporting companies using Rust, and making sure t works well.
Re:Why I Write Games in C by melted on Sunday January 10, 2016 @04:31AM (#10874790)
That doesn't inspire a ton of faith in Dropbox, TBH.
Re:Why I Write Games in C by Rusky on Monday January 11, 2016 @11:12AM (#10881242)
So which is it? It's impossible for anything new to be stable so Rust automatically reflects badly on Dropbox? Maybe take a look at how well Dropbox is doing and let that reflect on Rust.
Re:Why I Write Games in C by AndyKelley on Saturday January 09, 2016 @04:31AM (#10870649)
I like Rust, but sometimes it is pretty difficult to convince the compiler that one's code is safe. And this does not mean that the compiler is preventing unsafety; there are many safe programs that the compiler rejects.

Also, the OP said that compile time was a priority, and compiling Rust code is closer to C++ speed than C.

Re:Why I Write Games in C by Manishearth on Saturday January 09, 2016 @05:21AM (#10870749)
> there are many safe programs that the compiler rejects

It's often less about being safe currently and more about being resilient to breaking after further changes in code. I've worked with some C++ codebases that rely on complicated invariants to be safe (so the code looks safe now), and stuff breaks down when certain changes are made. Programming with a C++11 style greatly reduces but does not eliminate this.

It takes a while to get a hang of this, but once you figure out the "Rust way" of moving data/references around you tend to hit these errors very rarely. Of course, this takes time to learn which you may not have :)

But yes, there are things which Rust could improve upon here, like nonlexical scopes and SEME regions. Which may come soon.

Re:Why I Write Games in C by pcwalton on Saturday January 09, 2016 @01:29PM (#10872259)
> And this does not mean that the compiler is preventing unsafety; there are many safe programs that the compiler rejects.

Two nits:

1. The compiler does prevent safety problems. It just happens to rule out some safe programs while doing so. (Although I think this is a bit of a misconception, because with the aliasing rules being used for optimization many things that the Rust compiler rejects that people think are safe are actually not.)

2. You can describe any type system this way. That doesn't mean we don't like type systems.

Re:Why I Write Games in C by Jach on Saturday January 09, 2016 @07:40PM (#10873577)
I think game programmers don't like type systems -- or rather, they prefer the minimal typing necessary for speed improvements and their ability to simplify basic static analysis (with tools or in their heads). I don't blame them, games are a lot of work even for relatively simple things, and to get anything done at a reasonable pace you just need to be able to churn out lots of code that compiles on the first try, and when it doesn't the mistakes should be easy to fix and minimize the time you're spending fighting with the type system (C++ templates come to mind as they're often avoided in games no small reason being the cryptic error messages they can produce). There might be an argument of familiarity, that eventually if they used Rust or Haskell enough it would all come to them as easy as C, but then well known Haskell promoters say things like "if you're using the type system right your code will never compile on the first time."
Re:Why I Write Games in C by tome on Sunday January 10, 2016 @03:55AM (#10874714)
> the mistakes should be easy to fix and minimize the time you're spending fighting with the type system

In Haskell you don't fight the type system. It fights your bugs.

[Yes, yes, this isn't an absolute truth, but it is a relative truth when the point of reference is C++'s, or even Java's, type system.]

Re:Why I Write Games in C by pcwalton on Saturday January 09, 2016 @09:49PM (#10873918)
Well, it's the classic static versus dynamic typing debate, and the costs and benefits of each approach are well known at this point.

In general, I think memory safety and data race freedom speed you up other than for small throwaway programs, because memory issues are so awful to debug (even with things like Valgrind).

Re:Why I Write Games in C by pdpi on Saturday January 09, 2016 @05:08AM (#10870721)
There are many valid programs that static typing rejects, too. Question is whether the trade off is worth it (and the answer isn't the same for everybody)
Re:Why I Write Games in C by alkonaut on Saturday January 09, 2016 @04:18AM (#10870616)
Exactly. Compilation times and young age might be an issue, but if the guy likes C and Go, then why not Rust?

The reason people might want to avoid it can be the same as "Why not D". The answer to that is that it doesn't offer enough over C and C++, which is where Rust is different, and why I think Rust will be huge.

Re:Why I Write Games in C by kodr on Saturday January 09, 2016 @04:07AM (#10870593)
my thought. is there enough support for OpenGL? I know you can use stuff from C in Rust, so it could be a solution.
Re:Why I Write Games in C by mden on Saturday January 09, 2016 @04:26AM (#10870635)
There's also https://github.com/tomaka/glium which seems very promising.
Re:Why I Write Games in C by pcwalton on Saturday January 09, 2016 @01:26PM (#10872249)
> my thought. is there enough support for OpenGL? I know you can use stuff from C in Rust, so it could be a solution.

glium is arguably the best idiomatic OpenGL binding in any language anywhere.

I program in OpenGL with Rust every day as part of my job these days.

Re:Why I Write Games in C by pandaman on Saturday January 09, 2016 @04:29AM (#10870643)
Is Rust available on consoles? (AFAIK, no) Is it going to be around? (Who can tell?)
Re:Why I Write Games in C by Manishearth on Saturday January 09, 2016 @04:55AM (#10870695)
Re:Why I Write Games in C by pandaman on Saturday January 09, 2016 @05:14AM (#10870731)
And for any console other than PSX emulator you can place a SFF PC on a console and run Rust on it (as an added bonus you will get a better API than writing hex numbers into registers).
Re:Why I Write Games in C by douche on Saturday January 09, 2016 @09:42AM (#10871375)
Who cares? Consoles are dead after this generation.
Re:Why I Write Games in C by s_kilk on Saturday January 09, 2016 @10:02AM (#10871435)
Why? Do you have any evidence to back up this claim?

On the contrary, it seems both the Xbox One and PS4 are doing a roaring trade, with gaming overtaking Hollywood in terms of market size and revenue

Re:Why I Write Games in C by clouddrover on Saturday January 09, 2016 @04:54PM (#10873045)
I'm not sure sure about a roaring trade. Games consoles are niche platforms. Look at the numbers: http://www.vgchartz.com/

The global life to date figures are 12.4 million Wii Us sold since November, 2012. 19.2 million Xbox Ones and 35.3 million PS4 sold since November, 2013.

Contrast that with PC shipments, where 70 million in one quarter is considered a bad result: http://betanews.com/2015/10/09/pc-shipments-decline-in-windo...

Or contrast it with the iPad's quarterly sales: http://www.statista.com/statistics/269915/global-apple-ipad-...

In FY2014 Apple sold 250 million iOS devices: http://www.geeky-gadgets.com/apple-to-sell-its-billionth-ios...

Add in Android phones and tablets and the games consoles are dwarfed in comparison, even the 3DS which has sold the most of the current games console generation.

Re:Why I Write Games in C by pandaman on Saturday January 09, 2016 @05:08PM (#10873096)
People do not buy PCs, iOS devices and Android phones just to play games. In fact, many people do not play games on these devices at all. E.g. Steam is probably going to be found on any PC that is used for games yet there are just 125M accounts since September 2003[1]. And even if somebody plays a game on a cellphone - they usually do not pay for it [2].

1. https://en.wikipedia.org/wiki/Steam_(software)

2. http://recode.net/2014/02/26/a-long-tail-of-whales-half-of-m...

Re:Why I Write Games in C by clouddrover on Saturday January 09, 2016 @05:28PM (#10873149)
From the Wikipedia page that's 125 million currently active users. They define an active account as one which has been used in the last 90 days. 125 million active users is about double the combined lifetime sales of the Wii U, XBox One and the PS4, which demonstrates my point.

It doesn't matter if an individual does or doesn't pay for a game on their phone. What matters is revenue. Worldwide iOS and Android games revenue has outgrown consoles: http://fortune.com/2015/01/15/mobile-console-game-revenues-2...

Re:Why I Write Games in C by pandaman on Saturday January 09, 2016 @05:54PM (#10873213)
I don't think you quite understand what is written on wiki page. There is no "currently" active users, there are just 125M active users according to Valve's definition of owning a product OR being logged in the last 90 days [1]. So the actual number of gaming PCs is less (I, for example, have two active accounts since I play PC games so rarely that I've lost credentials for the account I've created for Half-Life 2 and had to create a new one when somebody has given me a free game, not to mention incentives to have multiple accounts to collect badges and stuff) and is quite comparable to the numbers of a single platform in the previous gen consoles, which is so far is surpassed by the current when you compare sales relative to the launch.

>It doesn't matter if an individual does or doesn't pay for a game on their phone. What matters is revenue. Worldwide iOS and Android games revenue has outgrown consoles: http://fortune.com/2015/01/15/mobile-console-game-revenues-2....

Do you have any better source than a mobile analytics firm speculation? I for one have no clue where to get console game sales and where that firm got them is a mystery.

1. https://en.wikipedia.org/wiki/Steam_(software)#cite_note-12

Re:Why I Write Games in C by clouddrover on Saturday January 09, 2016 @06:40PM (#10873358)
Sure. Mobile is the biggest segment of the video games market and growing: https://www.superdataresearch.com/blog/global-games-market-2...

Tencent is the biggest video game company in the world by revenue: http://www.newzoo.com/free/rankings/top-25-companies-by-game...

There are more mobile gamers in China than there are people in America: https://www.techinasia.com/china-mobile-gamers-america-peopl...

Games consoles aren't competitive with that scale.

Re:Why I Write Games in C by pandaman on Saturday January 09, 2016 @06:51PM (#10873407)
I don't see comparable numbers here either, but if you want to believe this - good for you. I don't see anybody contemplating buying, say, Call of Duty game or saving money to buy magic mushrooms in some mobile game so, frankly, I don't even understand what are you comparing. My main objection was comparing total numbers of devices capable to play some kind of games vs dedicated gaming hardware, which, I hope we have sorted out.
Re:Why I Write Games in C by clouddrover on Saturday January 09, 2016 @07:28PM (#10873548)
Not really. I don't know what you're objecting to. The trend worldwide is away from console platforms. Look at the shift happening in the Canadian video game industry:

http://mobilesyrup.com/2015/11/22/mobile-game-revenue-will-s...

http://theesa.ca/wp-content/uploads/2015/11/ESAC_2015_Bookle...

Console game revenues down by 32% since 2013, mobile game revenues up by 20%. Mobile games on trend to overtake console games and investment is being directed to mobile studios and titles. Don't take it personally, it's just how it is.

Re:Why I Write Games in C by pandaman on Saturday January 09, 2016 @07:43PM (#10873587)
The trend in the current generation is strongest so far (at least for Sony) http://www.ign.com/articles/2014/11/14/playstation-4-continu... and even for MS it's pretty good from what I remember. I am guessing all the analysts making these predictions are looking at Nintendo, which had been in decline since 1990s and only caught one lucky break with Wii. It's being back to its normal state will look like a declining trend only for somebody who learned about game consoles when Wii came out.

Doing trends for mobile games over short periods of time is entertaining but I am old enough to remember the same trend building that led to Zynga's IPO, social games were to kill console games before mobile games in the good old times of 2010-2011.

Re:Why I Write Games in C by clouddrover on Saturday January 09, 2016 @08:24PM (#10873695)
That compares games consoles to themselves and not to the broader video game industry. 35.3 million PS4s isn't even one tenth of just the iOS ecosystem, which is why mobile is the biggest video game segment and growing.
Re:Why I Write Games in C by Narishma on Saturday January 09, 2016 @10:56AM (#10871645)
They were dead after the last generation too. And the one before it as well.