Transcripción
Extracto de la transcripción automática del vídeo realizada por YouTube.
Mike Lyon starting off with Python for Ruby programmers one thing about the Ruby community that I have always loved is the fact that there's always been an emphasis on learning and an emphasis on not getting religiously hung up on our language or our tools
you know to take the software craftsmanship and apply it and improve what we're doing even if that means at times taking something that we held sacred yesterday and moving away from it so the next like I said the next talk this is mike leone on python
for Ruby then we've gotta talk that's going to be about backbone and NR we've got a third talk that kind of delves into JRuby all important tools all pieces that helped contribute to software development overall and all of which have some kind
of focus on craftsmanship and desire to improve so with that that's going to be the next three talks I would like to introduce Mike he's a founder of pan optic development in Rhode Island so came to us from the east coast not this morning but I'm
going to go ahead and turn the mic over to Mike that was weird turn the mic over to Mike and let him get started with this presentation thank you great thank you alright guys welcome to Python for Ruby programmers first I just like to apologize for the formatting
of this presentation quickly I just switch laptops right before I started so i will post the correct formatting slides online right after this ok so this presentation is going to be fast paced i'm gonna try to teach you guys the basics of python in about
30 minutes but don't worry it's going to be very easy coming from a ruby background first a little bit about me I'm a founder and principal engineer at panoptic development we build web mobile and embedded applications the languages we use our
primarily Ruby JavaScript and of course Python so this gives us a little bit different perspective for most folks we are based in the beautiful state of Rhode Island which is well known for excellent seafood massive political corruption family guy and nothing
else I started doing Ruby professionally in 2006 and then when a specific client application required python I started doing Python in 2010 and basically it's been a great experience I have a new appreciation for the language design decisions with each
programming language and I think I'm a better rubios for it so what we'll cover today we're going to look at a quick example program in both languages we're going to look at 13 language design similarities we'll look at 13 differences we'll
talk for just a few minutes about five different problem domains and how they apply to each language and then I'm going to talk about my feelings which basically means i just get to make all these wild statements and not back them up and not have to prove
anything what we won't cover our details about specific implementations of either of these languages we won't talk really about performance except i'll just say that performance with both tends to be good enough for the problem domains of each
language and that python tends to perform a little better in most cases i won't talk about parallelism or multi-threaded programming in each language because i'm not an expert so i'll just say that the sea implementations of each language do feature
a global interpreter lock so it is difficult to write multi-threaded programs that are performing in the sea implementations and I won't talk about minor syntax differences between the two languages because they're just that they're minor I think
you're going to get the hang of it really quickly and you'll be able to just read this code easily what I'm going to try to convince you with this presentation is that the two languages are very similar and despite some major differences they're
more similar than they are different to your already ready to start writing Python because of your Ruby experience the jump is not a big one learning Python will make you a better rubios and I hopefully will convince you to look into hiring a thon program
even for Ruby programming positions here as a few things I've extracted from the Zen of Python that I think are relevant to this presentation one explicit is better than implicit two flat is better than nested three readability counts for there should
be usually only one obvious way to do something and five namespaces are a great idea let's do more of those so for example let's create a person class in both languages these are my requirements person should have a name and age a person should be
able to greet you the person should know whether it's justin bieber and the person should be able to greet some folks from the google board of directors so let's look at the ruby implementation this is going to be very straightforward you see that
okay all right so you basically have a person class you declare an array of Google directors and that's a constant scoped within that class you have a typical initialized method where you set the name in the age and then you have a few instance methods
the saying the name is in the age is just a simple print statement I consider you Justin Bieber if your name is exactly Justin Bieber and you're exactly 18 years old and then greeting the Google director is just loops through this array of directors and
prints hello for each one now let's look at this in Python okay so you have a person object again you create this google directors constant scoped within the class at the beginning you have an initialize function where you set the name in the age and again
you have these same instance methods you can see in greeting Google directors the loop syntax a little different you're doing this for name in but again it's pretty easy to follow you might also notice a few little differences here you see this self
parameter is littered all over the place you'll see the is justin bieber method explicitly returns and there are a few other minor differences but if we just kind of go back and forth and just visually look at these they're very similar I mean I guess
you'll see that the methods don't have an end they just have a deaf we'll talk more about that in a minute but overall the design is very very similar so let's look at 13 similarities between the languages they are both dynamically typed here's
a quick Python example I can just have a method funk print object which takes some sort of object as a parameter and as long as that object responds to a read method it will work so if I pass in a file I'll get back to file contents another thing that
just like Ruby is pretty much everything as an object you might even argue that it is more consistent than Ruby because even functions are objects more on that later so here's a Python example just like Ruby five plus three is eight but that plus right
there is just syntactic sugar provided by the interpreter there's actually a method that you can call on the integer 5 add you can say five dot add three and you'll get eight back similarly you can call the string method on five and get back five as
a string you'll see these underscores here too because these are built-in methods and that's a convention and Python 3 both languages support arrays so in Ruby it's called an array you can put any kind of object in there and you can access elements
[ ... ]
Nota: se han omitido las otras 3.624 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.