Live data from Hacker News

C++ at Google: Here Be Dragons

blog.llvm.org

81–90 of 91 posts

Re: C++ at Google: Here Be Dragons

#81
post #12

When will they enhance it to flag the other error in this line: long kMaxDiskSpace = 10 10<<30 is ten gigs, not thirty gigs.

Doh! Good catch, comment updated. =[ Maybe we do need Clang-for-comments as well as Clang-for-C++ code.... ;]

in that case you should checkout this paper: "iComment: bugs or bad comments" (http://portal.acm.org/citation.cfm?id=1294276 sorry couldnt find an open pdf)

Re: C++ at Google: Here Be Dragons

#82

Earlier quoted context omitted.

the rest of the world is falling in love with the "power" of weak typing systems Really? I'd argue the exact opposite -- with F# and Scala (and some others) on the rise, I think there are plenty of people who are fed up with weak/dynamic typing and want to take advantage of building programs with strong type systems. At the very least, it seems that the programming world is becoming much more polarized. Anecdotally,…

Those in favor of only static typing and those in favor of only dynamic typing are living in the past. Any interesting evolution in programming languages will allow developers to program with and without types / contracts from the same language.

Qi is a lisp-like language with Haskell-style type-checking which can be turned on and off at will:

http://en.wikipedia.org/wiki/Qi_(programming_language)#Type_...

Re: C++ at Google: Here Be Dragons

#83
post #71

Earlier quoted context omitted.

People forget that AOT can only get you so far. JIT not only has all the info the AOT mechanism has, but also has real runtime fact based data, and can do wonders with it.

LLVM isn't really a JIT, and I've never heard of people using it as one for C++. (Also, those that tried to use it as a JIT had lots of problems, like Unladen Swallow).

Rubinius is using it successfully though (I think anyways, does the Ruby community have benchmarking infrastructure?)

Re: C++ at Google: Here Be Dragons

#84
post #71

Earlier quoted context omitted.

LLVM isn't really a JIT, and I've never heard of people using it as one for C++. (Also, those that tried to use it as a JIT had lots of problems, like Unladen Swallow).

Rubinius is using it successfully though (I think anyways, does the Ruby community have benchmarking infrastructure?)

Yes. My impression is that it's the same kinda-sorta successfully as Unladen Swallow - pretty good, but nothing like LuaJIT2, V8 or SpiderMonkey.

Re: C++ at Google: Here Be Dragons

#85
post #27

Earlier quoted context omitted.

I hear you, but I think the rest of the world is actually polarizing to some degree. Perhaps I'm just fickle or a language whore, but I love both the dynamism and freedom of Ruby (et. al.) and the "protect me from doing stupid $#@!" of Scala (et. al.) Although honestly, I don't know that I'd want a language that supported both, if even such a thing were possible. I do see a lot of people getting all hung up on one si…

Why can't we have a language that supports both? I would love to have a language with a scalable type system where I could hack out a quick small prototype with dynamic typing first, and then perhaps layer on static types later where necessary to improve reliability and performance as the program evolves. For example, I would like to be able to declare a variable in all of the following different ways. a value a numb…

It's been a long time, but I believe Ada provides the ability for the first 4 and I would bet you could define the last two in it.

Re: C++ at Google: Here Be Dragons

#86
post #68

Earlier quoted context omitted.

GCC definitely has a warning for 0.5 -> int (likely -Wconversion, but I've not checked). It also has a warning for setting a pointer to "false" (-Wconversion-null). However, turning that warning on in a codebase where every warning breaks the build was challenging because of false positives. We're able to remove false positives and narrow the scope of the warning to just the buggy code in many cases with Clang, and t…

Isn't the real bug in the example where the bool was assigned to the pointer that a pointer was used where it should have been a reference?

Google's C++ style guide discourages the use of references altogether.

Re: C++ at Google: Here Be Dragons

#87
post #45

Earlier quoted context omitted.

People forget that AOT can only get you so far. JIT not only has all the info the AOT mechanism has, but also has real runtime fact based data, and can do wonders with it.

For the sake of argument: What is an example of an optimization that a JIT compiler can make that a AOT compiler cannot? If the developer is able to profile the application on typical end-user workloads, don't profile-guided optimizations provide the same benefit as JIT runtime profiling? Why can't an AOT compiler just consider every path a "hot" path? Last but not least: Got any benchmarks?

A simple example: let program P do a zillion * multiplications, and call the program every hour with argument value zero or one, depending on a coin flip. An AOT compiler would not even know that the program will never be called with other arguments. A JIT compiler could remove all multiplications.

Profile-guided optimizations only work on the next run, and, when used by the developer, do not work for cases where there are widely different usage profiles for a single program. For example, most users would have data sets that fit in memory, but others will have ones that do not.

Re: C++ at Google: Here Be Dragons

#88
post #76

Earlier quoted context omitted.

Library support is aimed squarely at realtime life critical systems. You're more likely to find a library with some sort of safety certification than not. If you're expecting to use the latest web libraries or hadoop you'll be disappointed. However, there is a small collection of oss Ada libraries out there.

I seem to remember there was a pretty interesting web framework written in Ada, Adaweb I think? Anyway, Ada has some other amazingly cool features. The concurrency primitives it offers are very cool, lets you make some much stronger guarantees about the interactions between threads than any other language I've seen. For example, you can define rendezvous sections, which if memory serves, are pieces of code that are g…

There's ada web server (aws) which is neat. Similar idea to the java web kits like jetty. You can even hotplug code during runtime.

You're right about the concurrency. Ada has a bunch of stuff like that built into the language since 1983.

The particularly cool toys I like are SPARK (a formal verifier tool) and stackcheck - tells you exactly how deep in the stack your code can possibly go. (Yes you have to annotate cycles.)

Re: C++ at Google: Here Be Dragons

#89

Earlier quoted context omitted.

GCC definitely has a warning for 0.5 -> int (likely -Wconversion, but I've not checked). It also has a warning for setting a pointer to "false" (-Wconversion-null). However, turning that warning on in a codebase where every warning breaks the build was challenging because of false positives. We're able to remove false positives and narrow the scope of the warning to just the buggy code in many cases with Clang, and t…

When is assigning a pointer to be boolean false intentional and correct?

Done that before...had a variable that was formerly an int:

  int foo = 0;
But got changed into a non-integral type:

  Thing foo = 0;
Turns out Thing had a copy constructor roughly like:

  Thing::Thing(Thing* old)
      : field(old->field)
  {
  }
Needless to say, my program was not very happy.
Post reply on HN