4 ms·
I already cited the source of the code: http://shootout.alioth.debian.org/ http://shootout.alioth.debian.org/ Specifically, the Perl version you find suspect
by Goladus 17y ago
I already cited the source of the code: http://shootout.alioth.debian.org/ http://shootout.alioth.debian.org/
Specifically, the Perl version you find suspect can be found here: http://shootout.alioth.debian.org/u32q/benchmark.php?test=binarytrees&lang=perl&id=2 http://shootout.alioth.debian.org/u32q/benchmark.php?test=bi...
And it really was mostly random. I picked lua because I knew some people who used it, and was pretty sure it was a somewhat similar language to Perl in terms of problems its designed to solve, but that I'd never seen it before. I picked binary trees mostly because I was pretty sure both languages would have results for that test.
I wanted to see if it would be easier or harder to read the Lua vs. the Perl. It was easier for me to understand the Lua than the Perl, and I have attempted to explain that.
I don't care if you believe me or not. To anyone who doesn't already program in Perl full time: go to that site and pick random samples of code to read. Read through the various different solutions. Decide for yourself which language is most annoying to deal with.
For the record, here is the lua version of the same function.
local function BottomUpTree(item, depth)
if depth > 0 then
local i = item + item
depth = depth - 1
local left, right = BottomUpTree(i-1, depth), BottomUpTree(i, depth)
return { item, left, right }
else
return { item } -- Faster for LuaJIT: return { item, false }
end
end
- berntb 17y agoTo recap: You wrote the same old point -- the expressibility and some old ugliness make it a bit steeper learning curve for Perl. A troll favorite. You wrote that Perl was one of your two most experienced languages -- but obviously, you're a beginner not doing many hours development/month. Everyone pointed out the standard answers -- this is a small cost in the beginning, learning libraries dwarf this, Perl is easy to use for people knowing C/sh/etc, there are plus/minus with expressibility, etc. Then your second code example is on the wrong side of obfuscation with modifying an array while appending to it -- inside two tight loops!. (Sure, this was some performance test and it was the language's worst case, or something, so it had been rewritten in an attempt to get better speed, but... still, I've seen saner things in obfuscation code.) When this is pointed out, you just claim that it is an accident that you happened to pick this hairy recursive-to-iterative example... I would have given you the benefit of the doubt, if this hadn't been a typical troll subject... But, no.
- Goladus 17y agoAnd yet you refuse to discuss this with me in private, where you cannot accuse me of trolling.
- berntb 17y agoa) You didn't touch my description above. Enough. b) This was the third trolled Perl discussion I read on HN in a row. And trolled in the same boring way. Why would I want to waste more time on language wars?!