elfs: (Default)
[personal profile] elfs
I once famously said "Python is Perl for grown-ups."

If that's true, then Ruby is the hot 20-something firecracker chick of your programming mid-life crisis. You've got nothing in common but damn the interfacing is great. It's so different.

Maturity is getting over it and coming back to the stable reliability and maintainability of Python once more.

Date: 2008-08-26 05:09 pm (UTC)
From: [identity profile] en-ki.livejournal.com
What do you call writing Perl in Python?

I'm not sure...

Date: 2008-08-26 05:28 pm (UTC)
From: [identity profile] danlyke.livejournal.com
You can write BASIC in any language, but I'm not sure you can write Perl in Python.

And I say this as a user of Perl who, intellectually, likes the cleanliness of Python, but who can't maintain a relationship with it 'cause I use Perl for all the one-off stuff and find that getting back into Python for the big stuff takes longer than just expanding the Perl.

I know Perl's going to break my heart, that I'm going to get to a stage in the relationship where I want something deeper and more meaningful, but Python just takes so much commitment up-front...

Date: 2008-08-26 06:29 pm (UTC)
From: [identity profile] en-ki.livejournal.com
I assure you that I am staring right at some Perl-written-in-Python, and I must assume that someone had to write it.

Date: 2008-08-26 06:54 pm (UTC)
From: [identity profile] elfs.livejournal.com
I've been looking at Ruby code all day that was written by kindergartners. This chunk converts a python array into a chunk of static javascript code:

Ruby:
  
cmd += 'var types = new Array('
count = 0
types.each do |type|
  if count == 0
    cmd += "\"%(type)s\""
    count += 1
  else
    cmd += ",\"%(type)s\""
  end
end


Python:
cmd += 'var types = new Array(%s);' % string.join(['"%s"' % i for i in types], ", ")


Who the Hell writes array assemblies with sentinels like that? Ruby programmers from Windows, that's who! (Although if there's one thing I miss from Perl, it's the qq{} operators.)

Date: 2008-08-26 07:58 pm (UTC)
From: [identity profile] en-ki.livejournal.com
Of course.

cmd << 'var types = new Array(#{types.join(',')})'

is much too concise. Thank Turing for imperative programming!

(Isn't qq{} the same as %q{}? I haven't yet missed anything from Perl in Ruby other than tail-call elimination.)

Date: 2008-08-26 08:17 pm (UTC)
From: [identity profile] elfs.livejournal.com
I miss them in python. The ''' ''' operator isn't nearly as much fun. And it's nice to see someone understands his language of choice, although your construct isn't quite what mine does.

Date: 2008-08-26 10:32 pm (UTC)
From: [identity profile] en-ki.livejournal.com
Ah yeah, I suppose new Array("#{types.join('","'}") would do better. I blame eyeball spasms!

(And at that point the Python version is starting to look nicer even to me. List comprehensions and % go together pretty well.)

Date: 2008-08-26 10:43 pm (UTC)
From: [identity profile] en-ki.livejournal.com
OMFG, I just found that code. It burns! I blame Java.

Date: 2008-08-26 10:52 pm (UTC)
From: [identity profile] cadetstar.livejournal.com
If it's a simple string array that just needs to be broken up with commas, it's pretty simple:

cmd += "var types = new Array(#{types.join(',')})"

-Michael

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 30th, 2025 11:27 am
Powered by Dreamwidth Studios