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

Pages: 1-

Python 2 or 3?

Name: Opi 2013-06-23 10:03

I'm not sure whether I should focus on learning Python 3.3 or Python 2.7. What's your opinion on the matter?
(I don't want Andru's advice)

Name: Anonymous 2013-06-23 10:06

Learn and use only 2.7 of course. The Python community needs even more incompatible, deprecated code.

Name: Anonymous 2013-06-23 10:11

Clojure.

Name: Opi 2013-06-23 10:13

That's what I thought, but some books such as learn python the hard way insist on using 2.7.
Thanks for your advice.

Name: Anonymous 2013-06-23 12:53

Fuck that, learn Perl 6 instead.

Name: Opi 2013-06-23 13:14

I'd like to learn Perl 6 too, but I haven't seen anything ever written in Perl. Do you really think it's better than Python or is it just your prefered scripting language out here?

Name: Anonymous 2013-06-23 15:02

...

Name: Opi 2013-06-23 16:30

Could any of you fags answer me?

Name: Anonymous 2013-06-23 16:42

>>8
Django is still stuck in Python 2.x last I saw, so learn that shit if jobs are what you care for.

Name: Anonymous 2013-06-23 16:44

Learn Ruby.

Name: Anonymous 2013-06-23 16:47

>>8
Your question is like any of these:
Which is better, ranch dressing or italian?
Which is a better choice for a storm, a water-proof jacket or an umbrela?
Which is a better murder weapon, an axe or an ice-pick?
Which is a faster car, a mercedes or a bmw?
Which is a better place for abducting children, an elementary school or a city park?

The choices are too similar for one to better than the other. The ideal choice will be due to circumstance.

Name: Anonymous 2013-06-23 17:38

Go with python 3. I'm sick of seeing languages stuck in a perpetual time lock just because nobody can be arsed to upgrade.

Name: Anonymous 2013-06-23 21:13

I don't really care about jobs, I don't study cs, I'm teaching myself some programming because there are too many idiots who don't know how to program on this planet.

Thanks for the advice, kind of wanted to go on Django next but I guess I could go straight to Ruby and RoR.
Python 2.7 looked very unattractive to me, looked like the ugly bastard child of C and Ruby, so I'll stick with 3.3 for now.

Name: Opi 2013-06-23 21:13

>>13
That was me btw

Name: Anonymous 2013-06-23 22:49

Learn Scheme

Name: Anonymous 2013-06-24 1:20

>>11
Ranch, umbrella, ax, BMW, city park.

Name: Anonymous 2013-06-24 1:30

>>16
The next I time I see someone driving a BMW with an ax and umbrella eating a salad with ranch at a city park, I'm killing them before they harm any children.

Name: Opi 2013-06-24 12:37

Actually 3.3 sucks too. I'm learning Ruby instead I guess. It just looks like the better choice.

Or is perl actually better? What do you think?

Name: Anonymous 2013-06-24 13:09

>>18
Ruby is the best one of them but it's also generally slightly slower no matter what the VM it runs on. If a small performance gain is more important than the programmer's pleasure and productivity, then choose Python.
And Perl is an old piece of garbage that the Perl guys unsuccessfully try to revive by adding more bloat and incomprehensible garbage.

Name: Opi 2013-06-24 13:35

>>19

Okay that clears things up, thanks a lot!

Name: Anonymous 2013-06-24 14:15

>>20
Ruby also has a syntax unfamiliar to many. It borrows a lot from Smalltalk, a classic OOP language. And OOP is the best in Ruby. For instance, you can redefine all classes, even the built-in ones. You can customize how every object responds to messages, you can easily send some code to an object or a class to evaluate, etc. Lots of niceties, but Ruby ain't gonna be a performance champion anytime soon.
Python on the other hand has a more C-like syntax but with a lot of its own ugliness like "self." everywhere and __bullshit__. It also has a lot of little language quirks and inconsistencies. For instance, an empty string evaluates to false while a non-empty string evaluates to true so you have to constantly keep that in mind. In Ruby everything just evaluates to true except nil and false.

Name: Anonymous 2013-06-24 14:20

Here's a piece that shows some examples of how Ruby syntax is more consistent and generally pleasant.
http://eradman.com/posts/ruby-python.html

Name: Anonymous 2013-06-24 14:21

>>21
you can redefine all classes, even the built-in ones.
leading to bad design choices and spaghetti code.

Name: Anonymous 2013-06-24 14:29

>>23
Leading to more powerful metaprogramming, more elegant DSLs, more overall flexibility and extensibility.

Name: Anonymous 2013-06-24 15:12

>>24
Leading to more powerful metaprogramming, more elegant DSLs, more overall flexibility and extensibility.
Redefining global variables has nothing to do with metaprogramming/DSLs/flexibility/extensibility. And it is less elegant than segmentation fault.



Here's why one should be wise regarding Ruby:
- Ruby, like most other badly designed languages, does not require variables to be declared, as (let (x 123) ...) in Lisp or int x = 123 in C/C++, leading to ugly scoping problems, where you have to disambiguate visibility at every reference, using $, @ and @@ prefixes. Worser: if you want a variable private to a block, you need to pick an unique variable name, holding the entire symbol table in your head. Ruby introduces new variables by just parsing their assignments, meaning "a = a" or "a = 1 if false; a" wont raise an error. Ruby can't detect even a trivial typo - it will produce a program, which will continue working for hours until it reaches the typo. Local and global scopes are unintuitive. Certain operations (like regular expression operator) create implicit local variables for even more confusion.
- Ruby indulges obfuscation: Ruby has no keyword/optional arguments, so you'll have to use hash parameters as a substitute. This is an idiom that comes from Perl. Ugly, Perl-looking code, like proc {|obj, *args| obj.send(self, *args)} or (0..127).each { |n| p n.chr }, considered beautiful. Another confusing Perl borrowing are postfix `if` and `while` (line = file.readline while line != "needle" if valid line) and quirky variable names (partially due to naive environment design): @instance_var, @@class_var, CONSTANT_VAR, $global_var, :sym, &proc, $~[1], $!, $>, $@, $&, $+, $0, $~, $’, $`, $:, $., $* and $?. If A is [1,2,3] and B is [10,20,30], then A+B is [1,2,3,10,20,30], when you probably wanted [11,22,33]. If `a` and `b` are undefined, then "a = b" produces error, but "a = a" gives `nil`.
- Faulty syntax: Ruby's YACC grammar (ruby-grammar-yacc.bnf is 900 lines) is bigger than Haskell (HaskellParser.y is 650 lines) and C++ (CxxGrammar.y is 700 lines), and that is a lot, considering that Lisp's YACC file is just about 10 lines. Ruby cant distinguishing a method call from an operator: "a +b" can be both "a(+b)" and "a + b" - remove the space to the left of "+" or add a space to the right of "+", and it will be parsed as an addition. Same with "puts s *10", which is parsed as puts(s(*10)). Ruby's expressions terminate by a newline and you have to implicitly state that the expression is not over, using trailing + or \. That makes it easy to make a dumb syntactic mistake by forgetting to continue line. It also encourages putting everything onto a single line, producing messy looking code. A good amount of your code will consist of "begin end begin begin end end..." noise.
- Slow: JIT-compiling implementations exist, but they're still slow and incomplete, due to Ruby's complexity and bad design, which make Ruby difficult to optimize compared to other dynamic languages, like Lisp. For example, Ruby has to accommodate for somebody in another thread changing the definition of a class spontaneously, forcing compiler to be very conservative. Compiler hints, like `int X` from C/C++ or `declare (int X)` from Lisp, arent possible either.
- Ruby's GC is a naive mark-and-sweep implementation, which stores the mark bit directly inside objects, a GC cycle will thus result in all objects being written to, making their memory pages `dirty` and Ruby's speed proportional to the number of allocated objects. Ruby simply was not designed to support hundred thousand objects allocation per second. Unfortunately, that’s exactly what frameworks like Ruby on Rails do. The more objects you allocate, the more time you "lose" at code execution. For instance something as simple as 100.times{ ‘foo’ } allocates 100 string objects, because strings are mutable and therefore each version requires its own copy. A simple Ruby on Rails 'hello world' already uses around 332000 objects.
- OOP: Matz had a bit too much of the "OOP is the light and the way" philosophy in him, in effect Ruby doesn't have stand-alone functions and Ruby's blocks can't be used in exactly the same way as usual closures. Even high-order functions are attached to objects and produce verbose code: "names.map { |name| name.upcase }", instead of simple "map upcase names".
- Non-othogonal: {|bar| bar.foo}, proc {|bar| bar.foo}, lambda {|bar| bar.foo}, def baz(bar) bar.foo end - all copy the same functionality, where Lisp gets along with only `lambda`. Some Ruby's features duplicate each other: print "Hello", puts "Hello",  $stdout<<"Hello", printf "Hello", p "Hello", write "Hello" and putc "Hello" -- all output text to stdout; there is also sprintf, which duplicates functionality of printf and string splicing. begin/do/then/end, {} and `:` also play role in bloating syntax, however, in some cases, precedence issues cause do/end and {} to act differently ({} binds more tightly than a do/end). More bloat comes from || and `or`, which serve the same purpose.
- Ruby as a language supports continuations via callcc keyword. Ruby's callcc is incredibly slow, implemented via stack copying. JRuby and IronRuby don't have continuations at all, and it's quite unlikely they will ever get them. There were also support breaches in mainline Ruby, where Ruby 1.9 has not supported continuations for a while. If you want your code to be portable, I'd suggest not using Ruby.
- Ruby was created "because there was no good scripting language that could handle Japanese text". Today it's mostly Rails hype and no outstanding feature, that makes the language, like the brevity of APL or simplicity and macros of Lisp. "There is some truth in the claim that Ruby doesn’t really give us anything that wasn’t there long ago in Lisp and Smalltalk, but they weren’t bad languages." -- Matthew Huntbach

Name: MEAT 2013-06-24 15:20

Name: Anonymous 2013-06-24 15:20

>>25
Go fuck yourself, Goldenbraun.

Name: Anonymous 2013-06-24 15:22

>>27
Shalom, Hymie!

Name: >>28 2013-06-24 15:27

Name: Anonymous 2013-06-24 15:47

Guido a shit. Enjoy your Dropbox and its 100 MB resident size.

2.7 is the only viable choice since all the implementations worth anything support just that.

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