Do not know who made this, but this is awesome example of pictograms for programming paradigms. Want pictograms for categories.
Dynamic type system
Dynamic type system: ES6 almost LISP (Scheme)
Given the fact that ES6 has dynamic type system, higher order functions (e.g. functions which can accept and/or return other function), tail call optimisation (TCO
), brings ES6 to level of LISP (Scheme).
First time this idea was suggested by Douglas Crockford. But Crockford suggested it when there was no TCO
in standard.
With TCO
and fat arrow
(=>
) ES6 become closer to LISP (in some aspects) e.g. you can take SICP and implement all examples using ES6. Yay!
Side note: there exist variations of LISP with static type system, but historically LISP was dynamically typed.
Next time you will think something is impossible, take some time to reconsider
History repeating: public fear
I wanted to compare public fear of GMO with public fear of vaccination in early periods of smallpox vaccine development. But it appears that it wasn’t so irrational fear: there were death accidents and other negative consequences in early stages of research. My initial purpose was to show, that fear of GMO is irrational, but my approach was wrong.
I’m trying to be scientific and objective. Still sometimes I fail and use logic fallacies. Errare humanum est.
This meant to be series of “history repeating” posts: to show recurring patterns in history.
The word is about, there’s something evolving,
whatever may come, the world keeps revolving.
They say the next big thing is here,
that the revolution’s near,
but to me it seems quite clear
that it’s all just a little bit of history repeating
In the early empirical days of vaccination, before Louis Pasteur's work on establishing the germ theory and Lister's on antisepsis and asepsis, there was considerable cross-infection
Source: <a href=https://en.wikipedia.org/wiki/Smallpox_vaccine>Wikipedia</a>
Anti-GMO organization exploits public fear to fight with genetic engineering
In case of smallpox vaccination, experimentation was done before there was strong scientific theory developed. There were errors. So caricature by James Gillray depicting the early controversy surrounding Jenner’s vaccination theory had some ground behind it. While anti GMO-poster simply using public fear without any background or research.
See also:
Two big schools of Object-Oriented Programming
TL;DR There is no one “canonical” definition of OOP. There are at least two of them. From my POV there are two big definitions, which deserves separate names. I named them after biggest advocates. Those two definition have some differences and some commonalities.
I was about to get into another argue on OOP on the internet. I decided to do some research on the subject. I found more than one definition of OOP. Some of the definitions are variations of the same “tune”, some are useless. On my opinion there are two main directions of thoughts in this domain, which from two schools of OOP. School as in school of thought. The same way as there were philosophical schools in ancient Greece. The same way there are two schools of OOP:
- Alan Kay’s school or message focused
- Bjarne Stroustrup’s school or class focused or “PolymorphismEncapsulationInheritance” in terms of c2
I must emphasize that this article is not about what is best way to do OOP, because such discussion will lead to holy war. Instead purpose of this article is to help to recognize the fact that there are two ways to think about OOP. I believe this will help to build more constructive discussions about OOP. Next time you will start discussion on OOP or OOP vs
About names
I choose Alan Kay and Bjarne Stroustrup as founders of schools, because they are big advocates of OOP and authors of first OOP languages of each school correspondingly. I’m aware that there are arguments on which programming language is the first OOP language and who invented OOP. See history section.
Kay's school
Stroustrup's school
TL;DR Describing typical problems with ruby function arguments. How I solved them with a gem. What other options are.
Ruby syntax
keyword arguments
Ruby 2.0 introduced first-class support for keyword arguments:
def foo(bar: 'default')
puts bar
end
foo # => 'default'
foo(bar: 'baz') # => 'baz'
Programming mantras
What is programming mantra? This is small advice or rule of thumb that should help write better code. Lets see some examples
- Less code is better
- Prefer composition over inheritance
- Don’t repeat yourself (DRY)
Sometime developers forget what is the purpose of mantras and start follow them blindly without giving a thought on what they actually doing.
Your aim as a developer write good code, not follow mantras. Mantras suppose to help you, not to make decisions instead of you.
Good code:
- does what it is suppose to do
- is readable and maintainable (in one row, because they are the sides of the same coin)
Here is the story from Sandi Metz which explains how DRY mantra can get you into bad position.
Duplication is far cheaper than the wrong abstraction.
See also: Too DRY - The Grep Test.
The future is already here — it's just not very evenly distributed.
There are only two hard things in Computer Science: cache invalidation and naming things.
This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
You gotta do what you gotta do
Ruby decorators
Good overview of decorator options for ruby listed in thoughtbot article
The simplest implementation is:
class Decorator < SimpleDelegator
def self.wrap(collection)
collection.map do |obj|
new obj
end
end
# to mimic draper
# Be aware that draper does some magic to implement it,
# so this will not work exactly the same as draper
# https://github.com/drapergem/draper/blob/master/lib/draper/view_context.rb
def h
ActionController::Base.helpers
end
end
class WorkerDecorator < Decorator
end
See also this article.
Draper
Draper is de facto choice for Rails projects. But be aware that there are some issues with it:
Cells
Cells is part of trailblazer project, which tries to bring “a high-level architecture for web applications”.
Rails: fighting N+1 query problem
This problem is well known and have been solved 1000 times before. But most articles on rails and N+1
problem address mostly includes
function. There are actually some more techniques (much simpler, but not obvious to fight this problem). I want to list them all.
Responsive big bold text
There are existing solutions for creating responsive big bold text. Most reliable so far are JS based.
JS
- big-ideas-text. No jQuery!
- fitText (32 sloc). Use this plugin on your fluid or responsive layout to achieve scalable headlines that fill the width of a parent element.
- TextTailor (165 sloc). Responsive text to fill the height of the parent element or ellipse it when it doesn’t fit.
- slabText (207 sloc). jQuery plugin for producing big, bold & responsive headlines. Implementation of slabtype alogorithm
- BigText (248 sloc). jQuery plugin, calculates the font-size and word-spacing needed to match a line of text to a specific width.
- hatchshow.js. jQuery plugin
If you take a look in source code, you will notice it is not complicated code. But all of them depend on jQuery. So it will introduce ~50kb of JS dependency for such simple functionality. Possible solution of this problem:
- use lighter jQuery alternative
- implement same functionality without jQuery dependency
- implement using Houdini (when it will be ready)
Paint for Mac OS
What’s the closest equivalent to paint.net (which I love!) on Mac?
— Jeff Atwood (@codinghorror) May 29, 2016
I believe all new Mac users have been asking the same question. This is just super strange that there is no simple, free image editor for Mac OS. Here is roundup of all options.