サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
2024年ランキング
patshaughnessy.net
If I was learning to read English as a foreign language, I would need something simple to get started. (from The Remarkable Story of Chicken Little, 1840) The best way to learn a new programming language, just like a human language, is from example. To learn how to write code you first need to read someone else’s code. But who is the best person to learn from? Which code should we read? Where shou
Rust's new async/await feature makes it easy to stop and start asynchronous tasks (from: Wikimedia Commons) Imagine if you had a text file containing thousands of URLs: $ cat urls.txt https://example.com/1.html https://example.com/2.html https://example.com/3.html etc... https://example.com/99999.html https://example.com/100000.html …and you needed to download all of those HTML pages efficiently.
Learning something new every day is exercise for your mind. (source: Jeremy Bowcock via Wikimedia Commons) As software developers we’re paid to be professional learners. People hire us (or should hire us) for what we are capable of learning, not for what we already know. To stay in shape and keep up with our peers we need to practice by learning something new every day. We need to get daily exerci
This is an excerpt from the second chapter of an eBook I’m writing this Summer called “Ruby Under a Microscope.” My goal is to teach you how Ruby works internally without assuming you know anything about the C programming language. If you’re interested in Ruby internals you can sign up here and I’ll send you an email when the eBook is finished. I also posted one entire chapter in May, and an excer
Writing assembly language is something best left for the experts. To write code that runs directly on your microprocessor you need to know how memory segmentation works, what the intended use of each register is, how codes executes in real and protected modes and much, much more. And, of course, modern compilers will usually produce faster, more optimized code than you ever could, without making a
Running the Crystal compiler on your Ruby code is like asking a second doctor for their opinion. When it comes to your health, you don’t hesitate to get a second opinion. Doctors don’t always agree, and a second doctor’s appointment is always time well spent when it comes to staying healthy. But what about your code? A code review is similar to going to see a doctor: Someone examines your code, lo
Reading the Postgres source code is like attending a free Computer Science lecture, complete with working examples. Aside from saving and retrieving data, the primary feature of a relational database is the ability to execute join queries, to relate data in one table with data from another. While many developers are turning to NoSQL solutions, joining one set of data values with another remains on
It can be hard to open the Strong Parameters door and let permitted values into your Rails 4 app. Last week I banged my head against the wall for a few hours trying to figure out how to whitelist input values for my Rails 4 app using the Strong Parameters feature. Calling permit when you have a simple attributes hash for a single new object is straightforward, but figuring out how to call permit f
First published in 1870, 20,000 Leagues Under the Sea describes an underwater adventure that takes place onboard a submarine called the “Nautilus.” This is the first of a series of four posts based on a presentation I did at the Barcelona Ruby Conference called “20,000 Leagues Under ActiveRecord.” (posts: two three four and video). Let me start with a question: How many of you have actually read 2
Ruby represents small integers using Fixnum and large integers using Bignum. Most of us don’t use Ruby to perform complex calculations for science, engineering or cryptography applications; instead, we might turn to R, Matlab or some other programming language or tool for that sort of thing. When we calculate values using Ruby, it’s often to process simple values while generating a web page using
Note: This post is based on a presentation I just did at RuPy in Budapest. Instead of just posting my slides I thought it would be more useful if I wrote it down as a blog post while it’s still fresh in my mind. I’ll post the video link here when the RuPy folks have it online. FYI I’m planning to do a similar presentation at RubyConf, except I’ll remove the Python info, and instead compare how GC
Both the Ruby and Python garbage collectors handle old and young objects differently. Last week I wrote up the my first half of my notes from a presentation I did at RuPy called “Visualizing Garbage Collection in Ruby and Python.” I explained how standard Ruby (also known as Matz’s Ruby Interpreter or MRI) uses a garbage collection (GC) algorithm called mark and sweep, the same basic algorithm dev
Note: This post is based on a presentation I just did at RuPy in Budapest. Instead of just posting my slides I thought it would be more useful if I wrote it down as a blog post while it’s still fresh in my mind. You can also watch the video recording of the presentation. FYI I’m planning to do a similar presentation at RubyConf, except I’ll remove the Python info, and instead compare how GC works
Note: I co-wrote this article with Chris Salzberg, an Canadian Rubyist living in Japan who attended RubyKaigi. RubyKaigi is the largest Ruby conference in Japan, Ruby’s home country. It was started in 2006 as a Japanese-only conference; that year David Heinemeier Hansson was the only non-Japanese presenter. But gradually year by year RubyKaigi gained more and more foreign attendees and content. Th
How many times do you think Ruby allocates memory for the “Lorem ipsum...” string while running this code snippet? str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit" str2 = str ...or what about while running this snippet? str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit" str2 = String.new(str) ...and this one? str = "Lorem ipsum dolor sit amet, consectetur adipisicing
Lazy enumeration isn’t magic; it’s just a matter of hard work Ruby 2.0’s new lazy enumerator feature seems like magic. In case you haven’t tried it yet, it allows you to iterate over an infinite series of values and take just the values you want. It brings the functional programming concept of lazy evaluation to Ruby - at least for enumerations. For example, in Ruby 1.9 and earlier you would run i
Last year I wrote a post about how the core team optimized Ruby to process shorter strings faster than longer strings. I found that Ruby strings containing 23 or fewer characters are much faster. Why am I bringing this up again now? Well, it turns out this isn’t a single optimization that the core team has added for short strings. Instead, they’ve used the same technique in many other places as we
Reading Ruby’s C source code can be as easy as reading your own Ruby code Last week I discussed how Ruby’s C source code uses macros to access data values. I explained that this “MRI Idiom” can make Ruby’s source a bit confusing for C programmers to read, but at the same time can make it easier to follow for Ruby developers who aren’t experienced with C. Today I want to continue this series and ta
Don’t be afraid of reading Ruby’s C source code. If you’re a Ruby developer, it can be a lot of fun to see how things work “under the hood,” and studying Ruby internals can give you a deeper understanding of what Ruby really is and how to use it. A good way to get started looking at Ruby’s source code, to get a “lay of the land,” would be to watch Peter Cooper and I walk through some code in a scr
Many of the ideas behind Ruby’s object model were developed for Smalltalk in the 1970s. A couple weeks ago an article by Ernie Miller got me interested in how class variables work in Ruby. After doing a bit of research, I found that class variables have been a perennial source of confusion. In fact, John Nunemaker wrote an article called Class and Instance Variables In Ruby way back in 2006 that s
My eBook build process and some PDF, EPUB and MOBI tips In case you missed it, last month I self-published an eBook about Ruby internals called Ruby Under a Microscope. To date I’ve sold over 600 copies - thanks everyone! I’ve never written anything so ambitious before, and I’m grateful for your support. I hope it’s been a fun read, and that you come away with a better appreciation for the amazing
Everyone knows that Ruby is a powerful language. Its dynamic nature allows you to concisely write the code you need to actually solve a problem instead of burying yourself under mountains of boilerplate. You don't have to fight it; you just get to enjoy the ride. But how is the magic created? And can you trust it? After all, MRI is written in C - a statically typed, compiled language which is pret
This is the last of a series of free excerpts from an eBook I’m writing called Ruby Under a Microscope. I plan to finish the book and make it available for purchase and download from this web site before RubyConf 2012 on Nov. 1. You can still sign up here, if you haven’t already, to receive an email when the book is finished. I plan send that one, single email message out to everyone before Novemb
In my eBook I’ll explore Ruby internals using an experimental approach. Update: I just setup an email sign up form - if you give me your email address I'll send you one - count ’em - one email messsage when the eBook is finished. You may have noticed I haven’t been blogging here for a while; instead I’ve been working on a new eBook about Ruby language internals. I find this topic fascinating! In f
According to Wikipedia, Oniguruma means “Devil’s Chariot” in Japanese We’re all familiar with regular expressions; they are “the developer’s swiss army knife.” Whatever sort of information you need to find, whatever sort of text you need to parse, there’s always a way to do it using a regular expression search. In fact, you’ve probably been using regular expressions for much longer than you have b
More than a web framework, Sinatra is an elegant, stylish Ruby program we can all learn from We all know Sinatra as a lightweight alternative to Rails. I find using it is a real pleasure. Sinatra’s helper methods, template support and routing provide just enough to get a simple web site running quickly, but then immediately get out of your way. Years after it was introduced Sinatra remains one of
While not very glamorous, Bitmap Marking Garbage Collection is a dramatic, creative innovation! You may have heard last week how Innokenty Mihailov’s great Enumerable::Lazy feature was accepted into the Ruby 2.0 code base. But you may not have heard about an even more significant change that was merged into Ruby 2.0 in January: a new algorithm for garbage collection called “Bitmap Marking.” The de
Where does my javascript code go? Backbone, JST and the Rails 3.1 asset pipeline One of the best things about the Rails framework is that each project looks the same: Every Rails developer knows to look in “app/models” for the model classes, “app/controllers” for the controller classes, etc. When you start a new project all of this is setup for you, and if you’re a new developer assigned to an ex
次のページ
このページを最初にブックマークしてみませんか?
『Pat Shaughnessy』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く