Has anyone seen this blog?

Thanks for the clarification the use of #= and =# about comments.

Good suggestion. I will update the blog accordingly.

Fixed typo.

My counting is naively basic.

$ find . -type f -name '*.scm' | xargs wc -l |grep total
  8219 total
$ find . -type f -name '*.[ch]' | xargs wc -l |grep total
  68808 total
$ find . -type f -name '*.[cpp]' | xargs wc -l |grep total
  54126 total
$ find . -type f -name '*.*lsp*' | xargs wc -l |grep total
 2286 total

Thanks for stepping in to set things right!

I tried the following code and it ends up with 68 lines of native instructions. That’s very good compared to the 500+ instructions that the original blog claimed.

@code_native Formatting.printfmt("{1:>4s} {2:.2f}", "abc", 12)

I don’t quite understand, however, why it could be so much simpler in C. I just copied the instructions from that blog below. It almost seems that the it does nothing except calling another function (see the jmp instruction at the end).

f:
.LFB23:
	.cfi_startproc
	movq	%rsi, %r8
	movl	$.LC0, %ecx
	movq	$-1, %rdx
	movl	$1, %esi
	movl	$1, %eax
	jmp	__sprintf_chk
	.cfi_endproc

I have reproduced this on my mac. It turns into 21 lines of instructions:

$ cat test.c
#include <stdio.h>

void f(char *buffer, const char *a, double b) {
  sprintf(buffer, "this is a %s %g", a, b);
}

$ gcc -g -c -o test.o test.c
$ objdump -d -S test.o

test.o:	file format Mach-O 64-bit x86-64

Disassembly of section __TEXT,__text:
_f:
; void f(char *buffer, const char *a, double b) {
       0:	55 	pushq	%rbp
       1:	48 89 e5 	movq	%rsp, %rbp
       4:	48 83 ec 20 	subq	$32, %rsp
       8:	31 c0 	xorl	%eax, %eax
       a:	48 8d 0d 33 00 00 00 	leaq	51(%rip), %rcx
      11:	48 c7 c2 ff ff ff ff 	movq	$-1, %rdx
      18:	48 89 7d f8 	movq	%rdi, -8(%rbp)
      1c:	48 89 75 f0 	movq	%rsi, -16(%rbp)
      20:	f2 0f 11 45 e8 	movsd	%xmm0, -24(%rbp)
; sprintf(buffer, "this is a %s %g", a, b);
      25:	48 8b 7d f8 	movq	-8(%rbp), %rdi
      29:	4c 8b 45 f0 	movq	-16(%rbp), %r8
      2d:	f2 0f 10 45 e8 	movsd	-24(%rbp), %xmm0
      32:	89 c6 	movl	%eax, %esi
      34:	b0 01 	movb	$1, %al
      36:	e8 00 00 00 00 	callq	0 <_f+0x3B>
; }
      3b:	89 45 e4 	movl	%eax, -28(%rbp)
      3e:	48 83 c4 20 	addq	$32, %rsp
      42:	5d 	popq	%rbp
      43:	c3 	retq

Update: added assembly code compiled from sprintf C code.

can you please provide a link? I can’t find it.

No, with Hacker News you want to search for it otherwise it removes upvotes if they all come from the same link. Just search for Julia and sort by date.

Done. For convenience, here is a link to search results for this item at Hacker News. To see the upvote arrow, click on the “ points” or “[y] comments” links under the title. Please let me know if using this link will remove upvotes; if so I’ll delete it.

But if we want it to climb up Google’s page rankings I think it needs to be cross-posted a lot more. Any suggestions for other sites can we post it on?

EDIT: Added instructions for how to find the upvote arrow.

FWIW, github also gives some percentages and a nice visualization:

They seem to use the Linguist library (see here).

1 Like

If it hits Hacker News’ front page, it will be cross posted a ton. We need to make sure it gets enough votes quick enough to do this.

Something is killing the ranking since it got up to 30 points but still isn’t seen near the front pages… probably needs some comments too.

Done

It looks like longer comments give points - not sure exactly how their ranking works, but I upvoted it, and that gave a point, and then made a long comment, and that gave another point (or it could be, that only the first comment by a person gives a point)

I suspect it’s the latter

I assume time might be the penalizer (compare point to time ratio of articles in the top 30). I’d guess we’d need about 200 votes given that the post is about 15 hours old. But I might as well be wrong here.

EDIT: The article below boils down to

Score = (P-1) / (T+2)^G

where,
P = points of an item (and -1 is to negate submitters vote)
T = time since submission (in hours)
G = Gravity, defaults to 1.8 in news.arc

While Hacker News is read by many people, I think the ultimate goal is to make this rebuttal show up in search engines. For that, mentioning it in blogs etc may work.

I ended up using cloc to count lines of code so it’s more accurate. I also had the wrong stats previously (silly mistake for not checking out the branch properly so the previous stats were from master instead.)

Stats from Julia release-0.6 branch below. I intentionally include specific languages to avoid noises e.g. there are many single-file language stat from the microbenchmarks. I will update my blog shortly.

$ cloc --out=/tmp/julia-cloc-subset.txt --include-lang=Julia,C,C++,Scheme,Lisp,"C/C++ Header" .

$ cat /tmp/julia-cloc-subset.txt 
github.com/AlDanial/cloc v 1.74  T=10.90 s (66.3 files/s, 28974.0 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Julia                          556          27690          16987         175147
C                               86           4292           4316          41455
C++                             21           1529           2356          18491
C/C++ Header                    43           1393           1578          10748
Scheme                          11            566            669           6369
Lisp                             6            288             97           1901
-------------------------------------------------------------------------------
SUM:                           723          35758          26003         254111
-------------------------------------------------------------------------------

You should fix that column about Lisp, those are just Scheme (FemtoLisp) files, FemtoLisp accepts both *.scm and *.lsp for source files, and if you look at the files themselves, you will see:

14:00 $ more compiler.lsp
; -*- scheme -*-

i.e. they are tagged as being Scheme.

Backgroud

Small thing, but as it is in a headline I thought I mention it.

Good point… although Jeff Bezanson calls it a scheme-liked lisp implementation. Do we call it scheme, lisp, or somewhere in between? :wink:

https://github.com/JeffBezanson/femtolisp

It’s closer to Scheme than other dialects of Lisp (I believe Jeff studied under Gerald Sussman - who was also one of the 3 professors on the panel when he defended his Ph.D. thesis)
Lisp’s are basically balls of mud anyway :grinning:

I’ve updated my blog and just called it Femtolisp, which should be the most accurate description.

3 Likes