log4j, for JavaLanguage, is the JakartaProject's logging system for Java. It straps onto your class hierarchy and enables hierarchical logging, keyed by the usual set of levels and module names.
Log4r is a RubyLanguage clone:
So they both apparently solve exactly same problem in exactly the same way.
log4j's src folder has 31,764 lines of code.
log4r's src folder has 2,071 lines of code.
Some criticism on this comparison by Remon van Vliet: As per Java convention, the Java version has the lowest level API reference documentation included in its source code which, obviously adds quite a few newlines (an odd measurement of verbosity to begin with but hey). It also happened to be properly spaced and indented code. Now I took the liberty of browsing through the code of the Ruby equivalent you mentioned and it has none of that (as in, hardly any comments and horribly formatted code). Since both are more a matter of taste/style I don't see its relevance anyway. I'm pretty sure a similar amount of input went into both versions (code + docs).
another item to compare would be development time. I [PhlIp] am a RubyLanguage zealot, yet the super-terse style of other zealots makes me postal. Yet if the language indeed permitted a super short development time, _despite_ its terse style, then...
another item to compare would be development time...
It's very difficult to compare development time for a library which has been developed over a period of time in one language, and one which is a copy of said library. For the redevelopment in Ruby, its bound to go faster, because you're copying the analysis (and ideas, etc). This isn't to say that RubyLanguage isn't a faster development environment, but that this situation is not a good one for comparison. -- MatthewFarwell
Try "another item to compare would be development time, despite the faster language's crappy indenting!
As per Java convention, the Java version has the lowest level API reference documentation included in its source code which, obviously adds quite a few newlines
Hmm. This:
require 'find' total_lines = real_lines = 0 Find.find("src") do |file| next unless file =~ /\.java$/ File.open(file) do |fh| source = fh.read total_lines += source.count "\n" source.gsub!(/\/\*.*?\*\//m, "") source.gsub!(/\/\/[^\n]*/, "") real_lines += source.split("\n").grep(/[^\s]/).size end end print "Total lines: #{total_lines}\n" print "Real lines: #{real_lines}\n"yields:
[jfelice@untamo logging-log4j-1.2.13]$ ruby slime.rb Total lines: 31802 Real lines: 15331So it seems that comments do not account for the order of magnitude difference. (This is without removing blank lines or comments from log4r *snicker*).
Update: Forgot to match newlines. *sigh* Now only 7 times larger.
See also LogForJava LogForRuby PatternsForLoggingDiagnosticMessages
Topical in MayZeroSix