RubyConf 2015

Creando un editor de texto con Ruby

Colin Fulton  · 


HTML (pincha para descargar)


Código de la presentación

Puedes acceder al código fuente utilizado en esta presentación en el siguiente enlace:


Extracto de la transcripción automática del vídeo realizada por YouTube.

alrighty everyone so it looks like we can go ahead and get started um so my name is Colin Fulton I'm a front-end architect and accessibility specialist at the University of Michigan library so I work on making our websites better for people with disability

isn't also better for people because currently our websites aren't very good if you're a human or if you're a nonhuman is where you do computer so my first question is who loves their text editor okay okay when talking to people who aren't

computer programmers they really didn't understand why it is someone could give an impassioned talk about text editors but wikipedia shows that we're really serious about text editors so much so that our debates about text editors get their own Wikipedia

pages second question has anyone tried to make their own tech center anyone and there is at least one person in the audience who's tried okay there are a couple of you it's a really special experience and as you develop it you start to realize why

most people would avoid doing this now the reason why I got into text editors is a long story which will summarize this way I wanted to make my own website because I do a lot of artwork and so I need to present my art and because i work as a computer programmer

i thought i'll build my own CMS can't be that hard as I'm developing my own CMS to do things I then think well maybe I can develop my own web framework is that I can learn about how to build web frameworks and after working on that for a bit then

figured that well I don't really like any of the HTML tempting languages are out there so maybe I'll develop my own and I don't know that much about parser alexr theory so maybe I'll try to do that and at the end of this really long yak shaving

expedition I decided well you know i'm spending all my time and text editors and i don't really know how to write one of those so why don't i spend some time trying to write the perfect text editor and so far that's been the end of my long

yak shaving expedition but this talk is not going to be about showing off the text sarah they've been working on one it isn't completed yet because i don't believe in rushing personal projects like this i prefer to take rich hickies approach where

he took a year to think about how he was going to construct his perfect programming language as opposed to javascript were they developed in two weeks and then no just let everything go from there so in summary what this talk is going to be is first we're

going to travel through time and look at tech centers throughout history if any are old unix graybeards out there and you've been using Ed's since day one then you can just sort of snooze through this bit but for the rest of us is really interesting

to look at where our text editors come from then we're going to talk about the philosophy of tools why why is it the development tools look the way they do and why are the U is for development tools so different from the U is that we create and for example

all the web commerce products that a lot of us spend our days producing and finally we're gonna spend some time building a time machine most text editors have a time machine in it as well as a number of other features so we're going to spend some time

building up these various features in addition to all three of these subjects we're also going to spend time doing some other things also if these slides ever get too hard to read just shout at me and I can make them a little bit easier to read by change

of the colors of something much uglier so just let me know if any of the code gets too hard to read so first semantics a text editor is different than an IDE an IDE is a big powerful program with lots of features in it it has a debugger it has a let's

flip that that better okay an ID has a debugger in it it has a number of development tools along the sides it has a bunch of wizards that pop up to show you how to do refactorings and it usually has a very small very poor quality text editor inside of it that

you actually manipulate the strings with a text editor on the other hand is a program which you simply use for editing strings notepad is probably the prototypical text editor that a lot of people think of when they think of a really basic text editor and

it's not that much different than vim or emacs it's just a very simple way of manipulating strings it's just that in this case it doesn't give you very many tools for doing that so let's go back to the dawn of time there weren't any

computers and everything wasn't interesting so let's give forward a number of years to when computers were invented uh you didn't have screens and keyboards for quite a long time instead you have key punch machines where you fill in a bunch of

punch cards and you would type in what various commands you would want to or characters you want to put in and it would punch holes in the text cards and if you wanted to undo anything you'd have to load in a new punch card and then type everything in

again these were sort of primitive line editors in that you could reorder all the lines of your code really easily especially if you dropped all the punch cards and they went scattering across the floor this was not a very great way to work which is why eventually

people started hooking up teletype machines to their computers teletype machines are machines which have sort of a typewriter with a long print tape that just continuously can print things out you would type in the characters that you wanted to transmit the

computer those get transmitted the computer and the computer would transmit back to the teletype machine what to output and this is why our command line interfaces look the way they do today you couldn't go back and edit things that have been written before

because they were actually being written on a piece of paper and so the way that command-line interfaces work and still work to this day as you type in a command it then shows that command on the paper the screen prints it out then prints out the response

of what the computer did and then it gives you another command prompt to type in the next thing eventually dumb terminals were created that did the exact same thing only have a screen so instead of wasting paper could just print things out on the screen and

this is how a lot of early important computer development happened this is how unix happen this was how the C programming language was created with with these dumb terminals eventually over time they got smarter and you could fully refresh the entire screen

and you could get sort of primitive txt space user interfaces like them or emacs that actually rewrite the whole screen as opposed to doing everything literally but we'll get into that a little bit so what a text editors look like back in the early days

a really good example is tico tico was a very popular text editor written in the 1960s of MIT which had a very very intricate and complete command language it had if statements and loops in all sorts of different ways to manipulate files and manipulate text

each individual command was only one character long so that you could very easily type things in very quickly without having to deal with the horrible paying up having to type in commands which were you know two or three or even five characters long because

God forbid you have to type in more than one character the problem with having a really powerful command language that people are going to want to write really complicated macros and they did and since each command was only one character long you ended up

with programs like this this is a valid tico program it's an interpreter for a programming language and because there are children in the audience I won't say what programming language but if you go on Wikipedia this interpreter is there and you can

look in giggle at the fact that this is actually a rather complicated working piece of code now unix is the operating system which a lot of the work that we do is based on and a lot of the development tools that we use this day were developed in UNIX and indeed

with Linux now running most servers UNIX is still kind of the standard that we all operated on now the first editor in UNIX that really got popular in the one in that indeed most of UNIX was written in is an editor called ed it is a very simple editor thus

the very short name very few people use it today because it's rather limited in its capabilities and using it as kind of an exercise in frustration you really had to know what you're doing if we load up ed and we load an example file into it the first

thing it does is it prints out how many bytes are in that particular file which is really useful to someone probably back in the 1960s but today it seems a little bit weird that this number randomly pops up now we're allowed to enter a command if we enter

in 42 what Ed's going to do is it's going to operate on the line 42 and we didn't give it anything to do so it just returns that line and tells us what's on that particular line of the file now let's say we want to look at more than one

line of the file which I know is a really crazy idea ed actually would allow you to do that if you typed in a comma between two numbers that would give you a range of lines to operate on and of course if we run that it only returns one line because ed only

returns the last line that it operated on if you actually want to look at multiple lines you would have to insert a command like p or n at the end of your command and then that would allow you to see what was at the end of the vine and on this file if we run

this killer command it will give us a question mark which is super useful because what does that mean I don't know actually I do know that means that Ed encountered an error and obviously it is explaining to us that we got an error with the simplest means

necessary a question mark and then we have to enter another command ask what on earth was that error that you just gave me and now it will tell us oh it's an invalid address error you asked for a line that didn't exist and so obviously I'm going

[ ... ]

Nota: se han omitido las otras 5.097 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.