Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

Python vs Ruby holy war thread

Name: Christy McJesus !DcbLlAZi7U 2005-04-12 13:11

Last week I learned Python. It's not perfect but it's pretty damn cool.
This week I'm starting on Ruby. I've just encountered blocks and I would approve if someone would answer this: are blocks merely an ugly kludge because the author did not know about lambda expressions, or can they do something lambdas can't?

Name: Anonymous 2005-04-12 15:54

for this to answer truthfully, i first need to know what python lambdas can do ruby blocks can't.

Name: Anonymous 2005-04-12 16:50

>>2
then don't answer

Name: Christy McJesus !DcbLlAZi7U 2005-04-12 18:26

>>2

Lambda expressions implement Church's lambda calculus. As with any good feature they're ripped straight out of Lisp. From what I can tell blocks seem to produce a similar result only more ugly.

After I posted this blatant attempt to produce drama, I checked around on that ever useful resource: Google. Seems a bunch of people I never heard of agree with me.

Name: Anonymous 2005-04-12 19:25

I doubt that blocks can do more than lambda expressions. If they could do more, no turning machine could implement them.

Name: Anonymous 2005-04-13 4:23

I don't like the |name| notation for block arguments. It looks somewhat like an absolute value but has no place there. :(

Name: Christy McJesus !DcbLlAZi7U 2005-04-13 5:18

>>6
That's what got me. The whole idea of passing arguments into blocks seems semantically weird to me; the fact that it needs it's own special syntax should set off warning bells.

Actually this morning I thought of one way the two are different: lambda expressions may only be composed of expressions. In blocks you're allowed statements.

Not techically a limitation if you're coding in a clean, functional style, but I can see how it could be inconvenient. However if you do need to pass a more complicated function you can still do it the "normal" way by just giving it a name.

Next question: you use the "yield" statement to execute a block in ruby. Does this mean you can't have more than one block as a parameter to a ruby function? If so that's a limitation right there.

Name: Anonymous 2005-04-13 7:42

It looks somewhat like an absolute value but has no place there
the notation comes from smalltalk, where |variable| denotes a local variable afaik.

Does this mean you can't have more than one block as a parameter to a ruby function?
seems like it, though i haven't bothered much with research. i consider blocks syntactic sugar:

open "file" do |file_obj|
puts file_obj.read
end
instead of, say,
open("file", proc {|f| puts f.read})
or something. of course, there may be more to it but if you really want to find out, ask on the ruby-ml or search the archives: http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml
ruby/tk objects for example evaluate blocks in the instance's context which i found fairly convenient.
lf = TkLabelFrame.new(top_frame) do text "labelframe" end

if you *do* want to pass more than that, you can still use lambdas. they're called "proc" (or it's synonym "lambda") in ruby-speak.
blafunc = proc {|x,y,z| puts x,y,z; puts "hello"} # { ... } can be replaced with do ... end
blafunc.call "x", "y", "z"
process_file(file, proc {|f| somecode()}, another_proc_obj)
essentially the same as in python/lisp i assume.

Name: Anonymous 2005-04-13 11:53

Python has 2000 attack 1000 defense, but ruby has 1000 attack 1200 defense and Ruby Beam Erementar Flush!  Combine this with Shining White Ultimate Combine and you will counter anything! 

Name: Christy McJesus !DcbLlAZi7U 2005-04-13 11:59

>>9
Gotcha, thanks.

Name: Anonymous 2005-04-17 1:39

new python version is getting rid of lambda in favour of nested functions.

... lol

Name: Christy McJesus !DcbLlAZi7U 2005-04-17 14:35

>>11

Yeah I noticed that. Guido is a fucking fucker.

I've also been finding Python's class system is really annoying, especially when compared to Ruby's. I'm starting to feel Ruby is gonna be the way to go for me, especially with all the commotion Rails is causing.>>11

Name: Anonymous 2005-04-17 16:32

Just try this:
Python: [ x**2 for x in xrange(100000) if x % 2 == 0]
Ruby: (1..100_000).select { |x| x % 2 == 0 }.map { |x| x**2 }

RUBY WINS! Python is ten times slower!

Name: Anonymous 2005-04-17 16:36

Seriously, you can store blocks in variables and give multiple blocks to a function. There is no real difference with lambda functions in functionnal programming, I guess the creator just wanted to be original or try a different syntax.

>>8
lambda, procs and Blocks are the same thing in Ruby!

Name: Anonymous 2005-04-18 1:26

lambda functions are anonymous functions that are restricted to one line. what the fuck is so great about that?

Name: Christy McJesus !DcbLlAZi7U 2005-04-18 8:49

>>15
Please learn Lisp.

>>14
I know this, it just seems weird, and not in a good way. It's like matz was too object obsessed to allow for functions, as opposed to methods, and invented the idea of blocks to serve the exact same purpose except with a weird syntax and they're not called functions. Wrapping a block in a lambda/proc lets you call it just like a function, so why not make it a function in the first place?

Seriously it's just a little niggle, but you notice such things more when the rest of the language is so well designed.

Name: Anonymous 2005-04-19 10:06

>>16
Blocks were copied from Smalltalk. Ruby is pretty much a mix of Smalltalk and Perl.

Name: Christy McJesus !DcbLlAZi7U 2005-04-19 17:42

>>17
o rly.
I knew the object system is lifted straight from smalltalk, and I'm pretty impressed with it to be honest.

Name: Anonymous 2005-05-10 8:07

Please learn Lisp.

You can't compare Python's lambda to Lisp's becasue there are no let blocks. So assignments are pretty much impossible, which restricts lambda blocks a lot.

Name: Christy McJesus !DcbLlAZi7U 2005-05-10 12:00

>>19
Not forgetting that Python relies on statements instead of making everything an expression, which is hardly a difficult feat. Yes you're right, Python's lambdas are pretty much crippled. But the lambda calculus, when implemented properly in a real language, is very powerful. Which is why I suggested that the good sir >>15 should learn lisp :-)

Name: Anonymous 2005-05-14 6:10

apparently python wants blocks now?
http://www.python.org/peps/pep-0340.html

Name: Christy McJesus !DcbLlAZi7U 2005-05-14 11:24

aw nuts

Name: EYERYS 2005-05-27 10:36

>>11
Guido is a fucker in this respect, there'll be a lot of outcry if Guido actually removes lambdas. So I don't think he'll do it. Lambdas were a compromise in the first place and Guido doesn't like them so he wants 'em gone.

>>19
lambda is all you need!

This does "assignment":

rsplit = lambda S, I=' ', C=-1: (lambda L: len(L) == 1 and L or L.extend(map(lambda L: L.pop(), (L,)*(len(L)-1))) or L)((lambda L: L.insert(0, I.join(L.pop(0))) or L)((lambda L: L[0].reverse() or L)((lambda L: L.insert(0, L.pop(0).split(I)) or L)((lambda L: L.insert(0, L.pop()) or L)(I.join((lambda L: L.reverse() or L)(list(S.split(I)))).split(I, C))))))

See http://en.wikipedia.org/wiki/Lambda_calculus

>>21
notice that this pep was rejected

Name: Christy McJesus !DcbLlAZi7U 2005-05-29 14:15

So, anyone know how to subclass Integer in Ruby?

Name: Anonymous 2005-06-04 11:03

So, anyone know how to write maintainable code? :P

Name: Christy McJesus !DcbLlAZi7U 2005-06-04 12:11

>>25
Only in Perl.

lol.

Name: Anonymous 2005-06-04 18:05

why sublass it :O?

Name: Anonymous 2005-06-05 10:59

>>27

Because it's kewl and witty

Name: Christy McJesus !DcbLlAZi7U 2005-06-05 11:08

Because I should be able to. I'm told ZOMG EVERYTHING IS AN OBJECT YOU CAN SUBCLASS EVERYTHING EVEN BUILT IN TYPES but when I try to subclass Integer it doen't work :(

Name: Anonymous 2005-06-06 6:20

You need to make Integer WANT to be subclassed.

Name: Anonymous 2005-06-06 19:19

>>30 Dressed like that? It's pretty clear what Integer WANTS. ;)

Name: Anonymous 2005-06-08 21:34

It should be a bug then

Integers are not treated the same way as other objects. A normal object is reference to a structure or something, but integers are not.

Name: Anonymous 2005-06-09 4:27

>>32
I don't disagree if that's what the language specification says, but... Why on holy Earth do you want to make an integer a reference to a structure!?!?

No wonder why crapware is that slow.

Name: Christy McJesus !DcbLlAZi7U 2005-06-09 7:51

>>32
That's true, but the language semantics are supposed to hide the fact that numbers are done at machine level.

Name: Anonymous 2005-06-09 12:04

>>34
They could make a special option, --with-real-integers, which would wrap all basic types so you can subclass them, at the cost of 15% slower programs. I personally wouldn't use it.

Name: Christy McJesus !DcbLlAZi7U 2005-06-09 14:32

>>35

What do you mean? We're not talking about Java btw. Ruby Integers are objects, with methods. Which is why I want subclassage :(

Name: Anonymous 2005-06-09 14:49

I think there are 2 types of integers. Smallints and Bigints or something. Don't remember the names. You could probably subclass bigints.

Name: Christy McJesus !DcbLlAZi7U 2005-06-09 15:46

There's Fixnum and Bignum, and Integer switches between them as necessary, for great justice.

Name: Anonymous 2005-06-09 20:43

>>36
Oh, I see. I knew we were talking about Ruby, which I don't know, but you said that so I assumed it had to be like Java.

Name: Anonymous 2005-06-09 23:58

>>38
Are you sure that there is an Integer class at all?

I don't have Ruby with me now, but I don't think you can wrap up Fixnum and Bignum in one Integer class.

Name: Anonymous 2005-06-10 0:07

>>40
lol disregard that. I just installed ruby.

But I can still speculate that the problem is because Integer wraps up Fixnum and Bignum.

Name: abez !XWEgiX8ArQ 2005-06-20 16:59

When there is Perl and Ruby, why do you need python?

Name: Anonymous 2005-06-20 20:31

because Guido brainwashed everybody

Name: Anonymous 2005-06-21 4:07

I took a look at the most popular scripting languages, here's what I thought of them:

- Perl: Nice and powerful, but write-once, so it's not that good for large applications.
- PHP: Perl's syntax fixed, less useful stuff, but the very best for web apps due to productivity and the ability to accomodate both basic and real programmers to get stuff done, and working good.
- Ruby: Unnecessarily cOOmplex. Looks like I'll create an ActionCreator object to create an Ignore action implementing the DoStuff interface, and send a doThis message to it.
- Python: Looking good. On second thoughts, I love the fact you're forced to indent your code. I'm tired of reading noob code.

I went for Perl at first, but quickly switched over to PHP because I'm getting paid to do stuff, not to brag at what I'm using. I'll learn Python as soon as I can, it looked good too.

Name: abez !XWEgiX8ArQ 2005-06-21 4:16

If you haven't use packages, objects or classes in Perl you should be careful of the assertions you make about its suitability for large applications.

Name: Christy McJesus !DcbLlAZi7U 2005-06-21 4:29

>> Ruby: Unnecessarily cOOmplex. Looks like I'll create an ActionCreator object to create an Ignore action implementing the DoStuff interface, and send a doThis message to it.

You sure do like assuming all OO is like Java don't you.
Java is not a good example of OO - get over it.

Name: Anonymous 2005-06-21 7:22

ruby is awesome no wonder why japaneses are dominating the
lenguage, beyond abstract, a lot of one liners, of course
its a one man lenguage, but being it a very abstract lenguage
it offers a lot of quick weird ways for doing things.

doing 10 things with one line is plain fucking awesome.

for me u are just noobs, if you dont see the power of ruby
(not as an all purpose lenguage of course)

wonderful tool ruby is
yoda spoke, bitches

Name: Christy McJesus !DcbLlAZi7U 2005-06-21 8:49

>>47
Are you trying to be ironic?

Name: Anonymous 2005-06-21 10:16 (sage)

It's hard to tell if that's a GNAA troll, thinly veiled sarcasm or an idiot zealot. Voting sarcasm.

Name: Anonymous 2005-06-30 3:25

Gotta agree, Python is superior.

Name: Anonymous 2007-06-12 13:00 ID:KavDlsHL

Oops, did I just bump a two year old thread?

Name: Anonymous 2007-06-12 14:43 ID:Heaven

Is this some kind of ``let's see who can age more threads from the fucking Bronze Age'' contest? Suddenly, the front page is almost filled with ancient threads.

Name: Christy McJesus !DcbLlAZi7U 2007-06-12 15:31 ID:kwsgqf6u

I lovehate it when I start reading a post, think "lol what a tard", continue reading, think "hmm this seems familiar", then notice the name field and it's me from back when I was a tripfag.

Name: Anonymous 2007-06-12 15:36 ID:Heaven

>>53
So, what are you using nowadays?

Name: Anonymous 2007-06-12 16:30 ID:sBRpG7Qi

>>54

HE ACHIEVED SATORI A YEAR BACK AND IS NOW EXCLUSIVELY USING MOVITZ, THE X86 LISP MACHINE.

Name: Anonymous 2007-06-12 16:31 ID:Heaven

WHOOPS, SAGE, FORGOT, ETC.

Name: Christy McJesus !DcbLlAZi7U 2007-06-12 17:50 ID:kwsgqf6u

>>54
Well since then I decided that Ruby was indeed superior to Python, then went and fapped over Smalltalk, later tried to get back into Scheme again but was forced to admit that however beautiful it is I'll never use it for anything more than toys.

Now I'm having insane amounts of fun with Haskell. It's a bit syntaxful for someone used to Lisp and code generators are a pain to write when you're not dealing in sexps, but apart from that it's pure win.

Name: Eleo 2007-06-12 17:58 ID:Uz0m3D6+

You guys always have conversations that are way over my head.  How come every time I come to this board it seems like I know so little?

Name: Anonymous 2007-06-12 19:05 ID:Q3MUZOzz

>>1
Mostly a matter of syntax. Ruby's syntax sucks, but its feature set is somewhere in the middle of "pretty fucking similar" and "exactly the same" as Python, at least for today's Python.

WTF, now I realize I'm replying to McJesus from a very long time ago. I remember him, but he hasn't been around, or he stopped being a name/tripfag. After reading >>53 , I'm glad to find he's still around, though he has become a Haskellfag ;__;

I miss the old times, when you achieved satori with LISP.

Name: Christy McJesus !DcbLlAZi7U 2007-06-13 4:37 ID:5+ZmFjYn

>>59
Hay buddy. Yeah I joined the Anonymous hoard awhile back after finally accepting that it's the right way. But it's nice to revisit old times by using my old tripcode. Thanks >>51 for giving me this opportunity to relive my faggy past.

Oh and I still love Lisp, I just find Haskell more suitable for getting Real Work Done (TM)

Name: Anonymous 2007-06-13 4:41 ID:YRDwhzuo

In Soviet Russia, Integer Subclasses YOU!!

Name: Anonymous 2007-06-13 4:54 ID:KbX2kcpU

>>58
I learnt most of what I know thanks to fags mentioning in here in /prog. Believe it or not, this troll board proved to be more useful than years of uni for me.

Name: Anonymous 2007-06-13 6:40 ID:qsCeF0U5

>>62
We should start giving out EXPERT PROGRAMMER degrees, with a variety of majors such as haskellfaggotry.

Name: Anonymous 2007-08-23 10:17 ID:vIk9pSAb

>>62
Same here, I never would've got into Haskell if it weren't for this shithole board. Ha!

Name: Anonymous 2007-08-23 13:40 ID:aWsRvRfT

Ruby sucks dick.

Use smalltalk. It is consistent and works great.

Name: Anonymous 2007-08-23 13:50 ID:Heaven

>>65
It's too old

Name: Anonymous 2007-08-23 15:16 ID:A7XNCo1c

>>66
Yes, everything long-lived is bad. Like Lisp, the worst language ever (ONE WORD, THE FORCED OPTIONAL INDENTATION OF THE SOURCE CODE).

Name: Anonymous 2007-08-23 15:20 ID:Heaven

>>67
Yes, a good example

Name: Anonymous 2007-08-23 15:24 ID:A7XNCo1c

>>68
I know.

Name: Anonymous 2007-08-23 15:33 ID:Heaven

>>68,69

same EXPERT

Name: Anonymous 2007-08-23 15:42 ID:A7XNCo1c

>>70
No.

Name: PYTHON EXPART PRORGAMER 2007-08-23 17:41 ID:4VZXY//J

>>13
Python has map(), come back when you've rewritten it properly

Anyways, Ruby kinda sucks (imo), mostly because of its inane Perl syntax, ZOMG EVERYTHING IS AN OBJECT FAP FAP FAP, and slowness.

Name: Anonymous 2007-08-23 17:42 ID:ddfbgKd/

>>72
you are an idiot

Name: Anonymous 2007-08-23 21:11 ID:Jo0tR8AD

>>73
no hes an expart

Name: Anonymous 2007-08-25 0:32 ID:Heaven

Use smalltalk, problem solved

Name: fusianasan 2008-04-28 20:27

If this doesn't work, Shii is a nigger.

Name: Anonymous 2008-08-16 10:57

Name: Anonymous 2008-09-09 16:04

don't mind me, just passing by.

Name: Anonymous 2011-02-04 18:04

Name: Anonymous 2012-10-30 8:27

L I S P

Name: Anonymous 2012-12-01 17:10

???? ???????????????? ????????????????????????????

Name: Anonymous 2013-07-24 11:41

check em

Name: Anonymous 2013-07-24 14:43

>>83
???? ???????????????? ????????????????????????????
How was this ever achieved?

Does does not even help:
http://answers.yahoo.com/question/index?qid=20120111015030AApAtHK
http://en.wikipedia.org/wiki/List_of_Unicode_characters
http://en.wikipedia.org/wiki/Combining_character

Any ideas?

Name: Anonymous 2013-07-24 19:27

???? ???????????????? ????????????????????????????

Name: Anonymous 2013-07-25 6:59

>>85
???? ???????????????? ???????????????? ????????????????

Name: Anonymous 2013-07-25 7:22

>>85
Any ideas?
Download the document and read the fucking hexdump for 100% success????

Name: Anonymous 2013-07-25 8:42

>>85
???????????????? ???????????????????????????????????????????? ???????????????? ???????????? ???????????????????? ???????????? ???????????????????????????????? ????????????????????????.

Name: Anonymous 2013-07-25 10:38

>>87-89
So there is a unicode flag for this that are not documented. I which I learn of a source I can learn more off, than reading the hexdump to get an idea.

Name: Anonymous 2013-07-25 11:28

ASCII is faster, simpler and more portable. Unicode is a useless(most of codepoints are never used), slow and complex mix of technologies depending on huge fonts and support libraries. Unicode is the bloatware of text.

Name: Anonymous 2013-07-25 11:36

マジで
でジマ
マジでジマ

Name: Anonymous 2013-07-25 14:04

>>15

A lambda expression is a structure with one operator, apply. It can be defined as a triple(context, args, body) or in a typed language as quadruple (type, context, args, body).  The context contains a snapshot of the scope at creation. The arguments are the declared arguments, these are labels x,y,z. Thus a lambda function \x.x + 1 can be represented as: ({}, x, x + 1). Executing a lambda function is done by evaluating. This is substituting the variables in the body until it has shrunk to only one term. This is called evaluation and is done by the apply operator:


apply (\x -> x + 1) 1
substitute x with 1
(1 + 1)
2


Lambda calculus is a powerful model for computation, it is equally power as a Turing machine. This is shown in the research on the SKI calculus.


Many more interesting properties arise in lambda calculus.


Fun fact: A lambda expression doesn't have to be exactly one line.

Name: Anonymous 2013-07-25 16:39

>>93

Shalom Hymnie!

Name: Anonymous 2013-07-25 18:09

>>94
That makes no sense Nikita

Don't change these.
Name: Email:
Entire Thread Thread List