News for hackers. Stuff that matters.
Re:24-core CPU and I can’t move my mouse by andrepd on Monday July 10, 2017 @07:49AM (#14735062)
Are you serious? You want to make a product: a Web browser. What technology are you going to choose? The one that makes your browser fast but gives you more work, or the one that makes your browser slower but makes compilation less of a nuisance to you? It's mind boggling that some would openly say that, hey, who cares about performance that much, these compilation times bother me, the developer. On a browser of all things! Would you be okay with your browser being 2x or 3x slower?
Re:24-core CPU and I can’t move my mouse by gizmo on Monday July 10, 2017 @08:24AM (#14735252)
False dilemma. You can have both. It's okay if a fully optimized release mode binary takes a bit longer to compile, but compiling a few million lines of code for a debug build shouldn't take more than a second or two.

Also consider the leverage factor. Improvements to the compiler benefit all users of the programming language, so it's worthwhile to invest in high quality compilers.

Re:24-core CPU and I can’t move my mouse by striking on Monday July 10, 2017 @10:16AM (#14736100)
In what language can we have both?

Yes, we can use caching compilers (https://wiki.archlinux.org/index.php/ccache) to speed up builds with few changes. We can lower optimization levels (although that barely gives you an increase in compile speed compared to the runtime speed you lose and the fact that it makes your program do slightly different things).

There's no slider from "pessimum" to "optimum". You need to do wildly different things to optimize past this point for compile speed. Erlang hot-reload and at-runtime-code-gen from other langs come to mind. But that will almost definitely slow down your program because of the new infrastructure your code has to deal with.

I have observed that there can be a nice balance with Java and the auto-reloading tools that are available for it. But I am unaware of their limitations and how a web browser might trigger those limitations.

Re:24-core CPU and I can’t move my mouse by CyberDildonics on Monday July 10, 2017 @12:20PM (#14737304)
D is a language where you can have both. C++ architected correctly can get much closer though. Much larger compilation units are a start. After that, realizing that modularity comes from data formats and protocols means you can start to think about minimal coupling between pieces. I think dynamic libraries for development are very under utilized.
Re:24-core CPU and I can’t move my mouse by marcosdumay on Monday July 10, 2017 @02:13PM (#14738330)
Besides those people already pointed (and Haskell - yep, the always slow GHC can do that), there's no reason C++ couldn't have both (except from large templates).
Re:24-core CPU and I can’t move my mouse by Shorel on Monday July 10, 2017 @01:49PM (#14738145)
> In what language can we have both?

D has very fast compilation times compared with C++.

Rust is another option.

Re:24-core CPU and I can’t move my mouse by twic on Monday July 10, 2017 @04:30PM (#14739358)
Rust doesn't compile very quickly at the moment. Helpfully, there's a live thread about the matter on r/rust [1]. Broadly speaking, it's about the same as C++. Some aspects are faster, some slower. Points worth noting (from that thread and elsewhere):

* Everything up to and including typechecking (and borrowchecking) takes a third to a half of the time, with lowering from there to a binary taking the rest of the time; that means (a) you can get a 2-3x speedup if you only need to check the code is compilable, and (b) overall speed isn't likely to improve a lot unless LLVM gets a lot faster.

* Rust doesn't currently do good incremental compilation, so there are potential big wins for day-to-day use there.

* There is a mad plan to do debug builds (unoptimised, fast, for minute-to-minute development) using a different compiler backend, Cretonne [2]. If that ever happens, it could be much, much faster.

[1] https://www.reddit.com/r/rust/comments/6m97hl/how_do_typical...

[2] https://internals.rust-lang.org/t/possible-alternative-compi...

Re:24-core CPU and I can’t move my mouse by p0nce on Monday July 10, 2017 @12:06PM (#14737152)
> In what language can we have both?

Have you actively tried to find one?

Re:24-core CPU and I can’t move my mouse by zeusk on Monday July 10, 2017 @10:20AM (#14736135)
> You can have both. It's okay if a fully optimized release mode binary takes a bit longer to compile, but compiling a few million lines of code for a debug build shouldn't take more than a second or two.

> You can have both.

Pretty bold claim, without proof.

Re:24-core CPU and I can’t move my mouse by gizmo on Monday July 10, 2017 @10:42AM (#14736339)
It's not difficult to spit out machine code at a high pace. TCC is one example given by the grandparent, but it's certainly not the only fast compiler out there. Languages like Turbo Pascal were designed for rapid single-pass compilation, way back in the 80s.

A million lines of code represents an AST with a few million nodes in it, which compiles to a binary of a few megabytes. To do this we have computers with a dozen cores running at 4ghz each, 100GB of memory and blazingly fast SSD drives.

It's easy to forget, but computers themselves aren't slow. The software we write is just inefficient.

Re:24-core CPU and I can’t move my mouse by sqeaky on Monday July 10, 2017 @11:46AM (#14736980)
What you are saying is that it is possible in theory, but no one has done it yet. So in some future were someone rewrites all C++ compilers to not be so slow then we won't need to compromise.

Most C++ devs have to work with tools that currently exist and so we are stuck with what the compiler devs give us. Believe it or not C++ compiler devs are pretty smart people and have largely optimized it as much as possible without a language redesign.

That language redesign is in the works with modules, but the dust hasn't settled yet, so that is also a discussion for the future. In the mean time no other language delivers the performance C++ does right now. So if I want to ship product right now the very real dilemma is fast product with slow builds (and a bunch of tools for dealing with that) with C++ or use some other language for a faster compiler and a slower product.

Then there is Rust, but that is another whole can of worms and not in use in most shops yet (Just switching to something has a huge cost).

Re:24-core CPU and I can’t move my mouse by gizmo on Monday July 10, 2017 @12:18PM (#14737281)
C++ is a language that's incredibly hard to compile efficiently and incrementally, because it suffers from header file explosion (among other things) and as you mentioned it has no working module system.

C compiles a _lot_ faster than C++, so that's always an option. And as other people have pointed out, you can get C++ code to compile much more quickly by being very disciplined about what features you use and how your code is laid out.

So I agree that if you want to ship something right now all your options have significant downsides. I think software engineers as an industry don't take tooling nearly as seriously as they should. Tools are performance amplifiers and we currently waste a staggering number of manhours working with poorly designed, unreliable, poorly documented and agonizingly slow tools.

Re:24-core CPU and I can’t move my mouse by msla on Monday July 10, 2017 @12:57PM (#14737646)
Tell me, how do you do mutual recursion in a single-pass define-before-use compiler?
Re:24-core CPU and I can’t move my mouse by jfoutz on Monday July 10, 2017 @01:15PM (#14737816)
Single pass generally means one crack at each compilation unit. it's ok to keep a list of unresolved forward references and go back and inject (fix-up) the address once it's known. I mean, that would still count as a single pass. If they're not in the same file, the linker does it.
Re:24-core CPU and I can’t move my mouse by ruste on Monday July 10, 2017 @01:35PM (#14738023)
Easy, stack trampoline (or skyscraper a la cheney on the m.t.a)
Re:24-core CPU and I can’t move my mouse by Dylan16807 on Monday July 10, 2017 @02:10PM (#14738295)
Are we speaking in a general sense here? Because the root of this is headers needing to be compiled with (almost) every use in C++. We could get rid of that while maintaining the same functionality. It's not a very bold claim unless there's a requirement of "no significant language changes"
Re:24-core CPU and I can’t move my mouse by andrepd on Monday July 10, 2017 @10:38AM (#14736302)
Then show me how, please.
Re:24-core CPU and I can’t move my mouse by astrodust on Monday July 10, 2017 @10:47AM (#14736400)
Turbo Pascal.
Re:24-core CPU and I can’t move my mouse by mpweiher on Monday July 10, 2017 @01:16PM (#14737825)
Yes, I am totally serious.

Where did I write "who cares about performance"? And why do you think any of what I said is going to cost 2x-3x performance? Performance has been either a major part of or simply my entire job for most of my career, and I usually make projects I run into at least an order of magnitude faster. For example by switching a project from pure C to Objective-C. Or ditching SQLite despite the fact that it's super-optimized. Or by turning a 12+ machine distributed system into a single JAR running on a single box.

The Web browser and WWW were invented on a NeXT with Objective-C. It wasn't just a browser, but also an editor. In ~5KLOC written in a couple of months by a single person. NCSA Mosaic took a team of 5 a year and was 100KLOC in C++. No editing. So pure code-size is also a problem. And of course these days code size has a significant performance impact all by itself, but also 20x the code in C++ is going to take a significantly longer time to compile.

In terms of performance, the myth that you need to use something like C++ for the entire project is just that: a myth. First, the entire codebase doesn't need to have the same performance levels, a lot of code is pretty cold and won't have measurable impact on performance, especially if you have good/hi-perf components to interact with. See 97:3 and "The End of Optimizing Compilers". Or my "BookLightning" imposition program, which has its core imposition routine written in Objective-Smalltalk, probably one of the slowest languages currently in existence. Yet it beats Apple's CoreGraphics (written in C and heavily optimized) at the similar task of n-up printing by orders of magnitude.

Second, time lost waiting for the compiler is not "convenience", it is productivity. If you get done more quickly, you have more time to spend on optimizing the parts of the program that really matter, and thoughtful optimization tends to have a much larger impact on performance than thoughtless performance. The idea that this is purely a language thing is naive. See, for example, https://www.youtube.com/watch?v=kHG_zw75SjE

Third, you don't need to have C++ style compilers and features to have a language that has fast code, see for example Turbo Pascal mentioned in other comments. When TP came out, we had a Pascal compiler running on our PDP-11 that used something like 4-5 passes and took ages to compile code. TP was essentially instantaneous, so fast that our CS teacher just kept hitting that compile key just for the joy of watching it do its thing. It also produced really fast code.

Re:24-core CPU and I can’t move my mouse by andrepd on Monday July 10, 2017 @04:54PM (#14739571)
Point taken, but my point was more about pragmatism. We know it's possible to have a fast compiler that generates fast code (indeed every time this is discussed someone brings up TP). But it's no use talking about a 30 year old compiler or about how the first WWW browser was superbly written. What I mean is I'm not talking about possible, I'm talking about feasible now. If I want to write a performance critical project right now what tool(s) should I use? The answer is most likely C++.
Re:24-core CPU and I can’t move my mouse by quotemstr on Monday July 10, 2017 @01:19PM (#14737868)
Furthermore, using a "slow" language for big parts of the code can make the whole project faster: size matters as an input into performance. A compact bytecode executed by a small interpreter thrashes the cache and memory hierarchy a lot less than tons and tons of ahead-of-time-compiled native code.

Use high-level interpreted languages to make your life easier, but also use them to make the page cache's life easier.

Re:24-core CPU and I can’t move my mouse by pjmlp on Monday July 10, 2017 @01:33PM (#14738000)
A good example of the architectures you are describing are Android and UWP.

Although the lower levels are written in a mix of C and C++, the OS Frameworks are explicitly designed for Java, C# and VB.NET.

Trying to use C or C++ for anything more than moving pixels or audio around is a world of pain.

The Android team even dropped the idea of using C++ APIs on Brillo and instead brought the Android stack, with ability to write user space drivers in Java (!).

Re:24-core CPU and I can’t move my mouse by bluGill on Monday July 10, 2017 @10:15AM (#14736092)
> Would you be okay with your browser being 2x or 3x slower?

No, I will switch to firefox or something. I'm a user, I don't care how hard it is for developers I can about my workflow which is using a browser on various machines, some of which are very slow.

Re:24-core CPU and I can’t move my mouse by hinkley on Monday July 10, 2017 @12:13PM (#14737225)
Tired developers make more mistakes. Rushed developers cut corners.

A faster compiler isn't just some frivolity. It's a power tool. A force multiplier.

Re:24-core CPU and I can’t move my mouse by reaperducer on Monday July 10, 2017 @12:27PM (#14737381)
Of the developers I've met recently, this wouldn't surprise me at all. The world revolves around them. Not the product. Not the user. Not the company. They are a "developer" or worse, an "engineer" and can do no wrong.
Re:24-core CPU and I can’t move my mouse by dilap on Monday July 10, 2017 @11:50AM (#14737010)
Jai, though unreleased and in development, is an language that explicitly aims to have extremely good runtime and compile-time performance.
Re:24-core CPU and I can’t move my mouse by ash on Monday July 10, 2017 @08:28AM (#14735283)
Why not fast browser and fast compilation at the same time?
Re:24-core CPU and I can’t move my mouse by sp332 on Monday July 10, 2017 @10:14AM (#14736079)
This might be theoretically possible, but I don't think it's been done yet. All the fast browsers so far take a while to build.
Re:24-core CPU and I can’t move my mouse by gsnedders on Monday July 10, 2017 @02:12PM (#14738324)
It's worthwhile to note that Blink (v. the whole of Chromium) has had its build time quintuple in the past four years or so, and its starting point was far slower than Presto (which may or may not qualify as "fast" in people's books, depending on what features you care about).
Re:24-core CPU and I can’t move my mouse by andrepd on Monday July 10, 2017 @10:38AM (#14736299)
Show me how, then.
Re:24-core CPU and I can’t move my mouse by ash on Tuesday July 11, 2017 @03:27AM (#14742216)
I didn't say I know how to do it. And I didn't say it's easy. Yes, currently we have fast browser and slow compilation. Just let's not assume situation can't be improved at all.