News for hackers. Stuff that matters.
Re:The cost of forsaking C by dreta on Wednesday October 05, 2016 @07:22AM (#12642942)
There’s a lot of problems with C, like the fact you have to break out of case statements, or string concatenation, or overuse of the static keyword. These are actual problems, which C++ doesn’t even begin to try and solve, instead introducing useless features and bloat. C is still one of the few popular languages that allows you to talk to the machine directly. It’s a language that doesn’t rely on hidden run-time logic, or hidden implementation costs. It doesn’t enforce any particular programming style on you, and lets you do anything a process is capable of doing.

Software engineers these days are so lost in abstractions and design patterns that they forget that at the end of the day a program is just data, and a set of operations that transform that data. There’s huge value in writing code that does everything explicitly from top to bottom, both from a readability, and from a debugability standpoint. Instead, these days, software is designed using UML diagrams and OOP concepts while pretending that objects are ideas that float in some abstract disconnected space. All in the name of concepts envisioned by people who write books instead of programming, and who never saw even a glimpse of a problem you’re trying to solve.

Languages like C will never become obsolete. There’s always a new frontier of hardware that needs fast, tailored software. Few years ago that was phones, and watches, next it might be tiny implants. Anybody who thinks languages like C is obsolete should ask themselves “why was my Comodore64 more responsive than a PC i bought in 2016?”, or "why is my dual-core Android smartphone with 1GB of RAM barely usable after a year”. Modern languages and programming practices have this amazing ability to completely negate the massive progress hardware has made.

Re:The cost of forsaking C by 0xcde4c3db on Wednesday October 05, 2016 @09:30AM (#12643591)
> “why was my Comodore64 more responsive than a PC i bought in 2016?”

Not because of C; that's for sure. The two biggest reasons are:

1) Your Commodore 64 is doing at least a couple orders of magnitude less actual work. This has less to do with language choice than it does with a programmer who is fully in touch with the problem to be solved and can identify unnecessary work to eliminate.

2) Your Commodore 64 is effectively designed in a way that prioritizes latency over throughput. Pipelines and buffers are small-to-nonexistent. When you read the joystick port, you sample the state of that joystick at that very microsecond; you're not asking one microcontroller to ask another microcontroller to start thinking about sending the input it sampled 10 milliseconds ago. The worst-case latency from changing the video data to seeing it on screen is measured in lines, not frames (assuming a low-latency display like a dumb CRT). Virtually nothing is asynchronous. Systems aren't built that way anymore because we want to be able to push massive amounts of data through subsystems that can't all run in lockstep to one fast master clock, and that means lots of buffering and burst transfers.

Re:The cost of forsaking C by dreta on Wednesday October 05, 2016 @10:10AM (#12643922)
I don't understand why you guys hang on the fact C64 wasn't coded in C. I never said it was. I talk about C-like languages, so low-level, with little to no overhead.

I understand that computers worked differently back then, and that software usually had full control over the machine, but please, don't talk to me about buffering, etc. when we're talking 6502 versus an i7, or an A8. I understand that input and output aren’t instant these days, but that’s an order of tens to hundreds milliseconds of delay. It doesn’t explain why Visual Studio takes tens of seconds to compile “Hello, World!” on a 16 core processor. Or why your Chrome tab eats 600MB of RAM.

Since you want to talk about buffering and built-in input delay, here’s a comparison of text editor performance:

https://pavelfatin.com/typing-with-pleasure/#windows

Re:The cost of forsaking C by 0xcde4c3db on Wednesday October 05, 2016 @07:50PM (#12648989)
I guess what I'm getting at -- and could have communicated better -- is that this approach of "buffer/queue/cache/defer everything because it's faster right now, never mind that we might have to stall and flush the pipeline all at once later" has worked its way up the stack, with the worst-case stall growing in magnitude as the path cascades through progressively more layers and bigger buffers (cf. bufferbloat in networks [1]). Among other issues, it fools people into thinking that expensive operations are cheap. I think that pattern is far more responsible than language-imposed overhead for the weird quasi-random delays that are seen in modern systems. You can certainly connect this to popular idioms and some standard library facilities in some higher-level languages, but I think that connection is largely a historical accident rather than having much to do with the languages themselves.

[1] https://en.wikipedia.org/wiki/Bufferbloat

Re:The cost of forsaking C by Avshalom on Wednesday October 05, 2016 @07:45AM (#12643027)
>>Few years ago that was phones,

ObjC and Java

>>Anybody who thinks languages like C is obsolete should ask themselves “why was my Comodore64

Assembly and Basic.

Re:The cost of forsaking C by mikejmoffitt on Wednesday October 05, 2016 @08:08AM (#12643119)
Surely Basic is not responsible for the Commodore being responsive. Java was a total dog on phones for a long time, too.
Re:The cost of forsaking C by Avshalom on Wednesday October 05, 2016 @08:23AM (#12643163)
Well C wasn't responsible for the Commodore either. And whether Java was a dog or not, thats what people went with, from your SIM card to JavaME snake games to Dalvik/ART. People looked at these resource constrained environments and went "yeah lets use Java".

ETA: it's probably worth put scare quotes around "resource constrained" when talking about Android and IOS but phones were dreta's example.

Re:The cost of forsaking C by marrs on Wednesday October 05, 2016 @10:04AM (#12643866)
and promptly went out of business when the iPhone showed up
Re:The cost of forsaking C by Avshalom on Wednesday October 05, 2016 @10:49AM (#12644251)
a phone that launched full of ObjC and Javascript with a SIM card running Java...
Re:The cost of forsaking C by marrs on Tuesday October 11, 2016 @06:16AM (#12682932)
ObjC is a native language and a direct descendent of C, and powered the phone's built-in apps. JS was provided for 3rd party developers, who incidentally rejected it. I wasn't aware of the SIM card running Java. I guess Java was good enough for that job since I never noticed any performance issues with the iPhone, unlike my Palm Pre which was plagued with them, and had a terrible battery life.
Re:The cost of forsaking C by e12e on Wednesday October 05, 2016 @11:49AM (#12644879)
I still remember the load times for Last Ninja - I'd prefer an ssd any day.
Re:The cost of forsaking C by dottrap on Wednesday October 05, 2016 @05:26PM (#12648044)
>>>Few years ago that was phones,

> ObjC and Java

To defend the parent's point, Objective-C is a pure superset of C. And there are quite a few frameworks on the Apple platforms that are pure C (not Obj-C), e.g. CoreGraphics, CoreAudio, ImageIO, OpenGL, etc.

Re:The cost of forsaking C by fredsanford on Wednesday October 05, 2016 @08:06AM (#12643106)
Take a look at the useless features and bloat in this video. Modern C++ isn't what you think it is.

https://www.youtube.com/watch?v=zBkNBP00wJE

Re:The cost of forsaking C by inDigiNeous on Wednesday October 05, 2016 @08:19AM (#12643154)
That's a great talk that really shows that with modern C++ you can do some really nice optimizations and code minimizations, but it seems to require a discipline that can require a lot of thinking in the complex world of C++, to find those methods that for example Jason is talking about here.

Was pretty eye opening video to see that, that some of those complex looking instructions with a modern optimizing compiler can be surprisingly neatly optimized away.

Re:The cost of forsaking C by fredsanford on Wednesday October 05, 2016 @08:28AM (#12643192)
I think discipline is a keyword here. It feels to me like being a professional means a fair amount of discipline should be required. Unless you're the nephew's uncle in law of the founders sister that knows VB and is "pretty good with compooturz" or the like.
Re:The cost of forsaking C by dreta on Wednesday October 05, 2016 @08:18AM (#12643149)
Could’ve easily written that in plain C. All the usage of C++ concepts like templates did, was made him write more code than necessary, and made the code harder to understand.
Re:The cost of forsaking C by marchelzo on Wednesday October 05, 2016 @12:58PM (#12645603)
I agree completely. I couldn't believe it when he made that Frame struct and completely abused RAII just to execute some code at the beginning and end of a block. The only really big wins were the wrappers for writing to different memory locations, all of which could have been implemented in C using macros or inline functions.
Re:The cost of forsaking C by fredsanford on Wednesday October 05, 2016 @08:31AM (#12643203)
You're not worth the effort.
Re:The cost of forsaking C by dreta on Wednesday October 05, 2016 @08:47AM (#12643315)
If i’m missing something obvious, please explain to me how using any of the C++ concepts made the code any better.

You have to keep in mind that this is a very simple piece of software. I wager you that using things like templates made the code unnecessarily harder to understand. I’ll also wager that by using templates he made the code harder to scale, since any remotely complex template, just like an overused base class, eventually becomes a set of special cases, or a set of specialised templates which defeats their purpose in the first place, and makes your code a nightmare to step through.

This is a typical example presented in a talk. It doesn’t reflect any large real-world software, where complex language solutions (useful ones, not the ones in C++) could actually benefit the programmer.

Re:The cost of forsaking C by GFK_of_xmaspast on Wednesday October 05, 2016 @08:24AM (#12643171)
I used a c64 for many years in my youth, and "responsive" is not at all the way I remember it. Have you forgotten things like "the loading times from the 1541" and "geos"? (for example: https://www.youtube.com/watch?v=qpX6TIa3U1o and warning: soundtrack)
Re:The cost of forsaking C by retro64 on Wednesday October 05, 2016 @11:43AM (#12644816)
Whoa now friend. The 1541 is a computer onto itself. The slow loading was because of Commodore’s desire to keep backwards compatibility with the VIC-20 drive, which used a buggy 6522 chip, not because the 64 couldn’t go faster.

BTW, if you want to run GEOS faster, get an REU and let the DMA transfer fun begin. This is 2016 after all; you must keep up with the times :)