Live data from Hacker News

Why is C faster than Java: git vs JGit

marc.info

21–30 of 106 posts

Re: Why is C faster than Java: git vs JGit

#21

So why do they write and use jgit at google instead of just git?

As they wrote at the end of the article:

"But, JGit performs reasonably well; well enough that we use internally at Google as a git server."

He is not advocating to never use Java. He is just pointing out some things that may or may not be important when choosing a language to write a program.

Re: Why is C faster than Java: git vs JGit

#23
All the points are valid but they are peculiar to Java, not to all managed high-level languages. C#/.NET, for example, have unsigned types, value-type arrays and structs, memory mapped files and specialized collections.

As an example, the C# port of Sqlite is sometimes faster than the C version on queries, although updates are slower, despite Sqlite is a highly optimized C library.

EDIT: link http://code.google.com/p/csharp-sqlite/wiki/Benchmarks

Re: Why is C faster than Java: git vs JGit

#24

I almost skipped this link; I assumed it was typical borring blog noise. It's not. This is an insightful post from the git mailing list which shows some of the real limitations that a top tier developer hits when trying to write Java code as fast as neatly optimized C code. Definitely worth reading.

Actually, it also makes me want to get into another project in C again.

Re: Why is C faster than Java: git vs JGit

#25
post #23

All the points are valid but they are peculiar to Java, not to all managed high-level languages. C#/.NET, for example, have unsigned types, value-type arrays and structs, memory mapped files and specialized collections. As an example, the C# port of Sqlite is sometimes faster than the C version on queries, although updates are slower, despite Sqlite is a highly optimized C library. EDIT: link http://code.google.com/p…

It's also worth pointing out that the C# port of SQlite omits using certain C mechanisms (like pointers) in favor of passing copies of byte arrays around. You'd expect this to make it slower, but in many cases, it doesn't! (C# supports pointers, but the port doesn't use them so that it'll work in limited environments like Silverlight)

Re: Why is C faster than Java: git vs JGit

#26

So why do they write and use jgit at google instead of just git?

There is a few things that require jgit: a while back, I found a really nice library (I'd look it up, but am on 3G on a train) that let you use Amazon S3 as a git remote. The author had just written some bridge code between jgit and an AWS library. Works suprisingly well, you just have to remember to use `jgit push` rather than `git push`.

Re: Why is C faster than Java: git vs JGit

#27
post #23

All the points are valid but they are peculiar to Java, not to all managed high-level languages. C#/.NET, for example, have unsigned types, value-type arrays and structs, memory mapped files and specialized collections. As an example, the C# port of Sqlite is sometimes faster than the C version on queries, although updates are slower, despite Sqlite is a highly optimized C library. EDIT: link http://code.google.com/p…

It's also worth pointing out that the C# port of SQlite omits using certain C mechanisms (like pointers) in favor of passing copies of byte arrays around. You'd expect this to make it slower, but in many cases, it doesn't! (C# supports pointers, but the port doesn't use them so that it'll work in limited environments like Silverlight)

The .NET runtime is well optimized for that sort of thing, as it needed to be for F#.

Re: Why is C faster than Java: git vs JGit

#28
post #7

I find it kind of interesting that in Haskell, which is arguably even higher level than Java, most of these optimisations are eminently possible.. EDIT: This obviously came across a bit as language fanboyism, so I guess I should mention that the language features that let you do many of them let you shoot yourself in the foot just as easily as you can in C, and you can certainly argue that with a strong FFI you might…

I've heard the argument before that in need, one can use a FFI to optimize bottlenecks in high-level code, but I've never understood.

Won't using a high-level language incur an omnipresent speed slump? And even if a bottleneck exists, how would using a FFI remedy crucial problems in the language, like the absence of unsigned types or that all types are boxed. The types will have to be unboxed anyway, so whether that happens in foreign code or in the interpreter/JIT code won't matter.

Post reply on HN