Profile

Photo de couverture
Ralph Corderoy
Ancien lieu de résidence : London, England
2 323 abonnés|93 145 consultations
BioPostsAvis

Stream

Ralph Corderoy

Partagé en mode public  - 
 
Python’s NaN-handling catches people out, as it does in many languages.

    >>> def nan(): return float('nan')
    ...
    >>> n = nan()
    >>> n == n, n == nan(), [n] == [n], [n] == [nan()]
    (False, False, True, False)
    >>> {n: 0, n: 1, nan(): 2, nan(): 3}
    {nan: 1, nan: 2, nan: 3}

IEEE 754 decided NaN would never be seen as equal to itself. Bertrand Meyer¹, creator of the Eiffel programming language² with its design by contract³, argues the IEEE 754 got it wrong and the opposite is more useful, less unexpected, and “least damaging to time-honored assumptions embedded in mathematics”.

1.  https://en.wikipedia.org/wiki/Bertrand_Meyer 2.  https://en.wikipedia.org/wiki/Eiffel_%28programming_language%29 3.  https://en.wikipedia.org/wiki/Design_by_contract
 ·  Traduire
Let me start, dear reader of this blog, by probing your view of equality, and also of assignment. Two questions: Is a value x always equal to itself? (For the seasoned programmers in the audience: I am talking about a value, as in mathematics, not an expression, as in programming, ...
1
Photo du profil de Ralph CorderoyPhoto du profil de Rob ScovellPhoto du profil de Christopher PK SmithiesPhoto du profil de David White
6 commentaires
 
I guess if not-a-number is compared with not-a-number using a numerical comparision then it makes sense for that to be false in some way.
 ·  Traduire
Ajoutez un commentaire...

Ralph Corderoy

Tips and tricks  - 
 
Using an int to track indentation and print itself as the indent when its String() method is called. play.golang.org/p/uY6SW71jjS is a longer example showing a bit more behaviour.
 
Stumbled on this Go code I wrote ages ago. It's an interesting use of the String method. (To see it in action, visit http://play.golang.org/p/MX7eFmtHh_)


// tab indents itself when printed.
type tab int

func (t tab) String() string {
  n := int(t)
  if n > len(tabs) {
    n = len(tabs)
  }
  return tabs[0:n]
}
 ·  Traduire
8
Ajoutez un commentaire...

Ralph Corderoy

Discussion  - 
 
Written in Go, etcd is a distributed locking manager for small amounts of data, e.g. configuration, with handling of node failures. Similar to Google's Chubby, research.google.com/archive/chubby.html, or Apache's Zookeeper. It's just released version 0.1.0. Brandon explains more in the comments of his post.
 
etcd is a distributed key value store we have been working on for CoreOS. It is like Zookeeper but uses REST APIs and is written in Go. Excited to get this first release shipped!

A distributed configuration service is a primitive we are building into CoreOS. Every application stack builds something like this eventually we want there to be an easy default.
etcd is ready for its first release! We just marked v0.1.0 and uploaded binaries for Linux and OSX. These are the major features in this release: Simple: curl'able user facing API (HTTP+JSON); Secure: optional SSL client cert authentication; Fast: benchmarked 1000s of writes/s per instance ...
29
3
Photo du profil de Ralph CorderoyPhoto du profil de Andrea PavoniPhoto du profil de Ash WuPhoto du profil de Krzysztof Wilczynski
3 commentaires
 
+Konstantin Cherkasoff, Yes, Brandon answered what some of the differences were between Doozer and etcd on his post.
 ·  Traduire
Ajoutez un commentaire...

Ralph Corderoy

Show and tell  - 
 
groupcache is implemented in Go and, I thought, sufficiently interesting to warrant its own post.
 
groupcache: Memcached alternative/replacement from its original author

+Brad Fitzpatrick has just given a talk at OSCON 2013 on downloads from Google’s dl.google.com: talks.golang.org/2013/oscon-dl.slide. Its old C++ code was replaced with an all-round better Go implementation.

groupcache is part of that and is now available. It has coordinated cache filling, so on a cache-miss the herd doesn’t thunder. Unlike Memcached, a key’s value is immutable, so no increment, etc. This allows groupcache to replicate sought-after items to processes other than the authoritative source, avoiding a bottleneck of CPU or NIC for very popular items.

#memcached #golang
11
5
Photo du profil de Andrea PavoniPhoto du profil de Julien Etienne
Ajoutez un commentaire...

Ralph Corderoy

Partagé en mode public  - 
 
Cycle-counted bit-banging of video and audio

Heartened by the comments on Jeff Dean’s post, plus.google.com/118227548810368513262/posts/EMzp9NVV6QJ, showing that the skill of low-level optimisation is still valued, I thought I’d dig out Linus Åkesson’s 2011 blog post about his “Bit banger”.

It’s not uncommon to bit-bang audio these days, or even a video signal. Linus does both, and in a very constrained environment. He’s using a 1.6MHz Atmel ATtiny15 microcontroller that has room for a maximum of 512 instructions. RAM’s a bit tight too; 32 bytes. Though “RAM” is a bit of a stretch, those bytes are more accurately described as the register file.

Linus doesn’t shirk from giving detail so I’ll stop re-telling it here, but do look out for his assembly extract. It’s in two columns, video bit-banging instructions are on the left, audio on the right. They have to be interleaved because of the timing constraints. :-)
Lines 0-479 displine: add r6, r10 ; t0 out PORTB, r2 ; t1 adc r7, r11 ; t2 mov r17, r22 ; t3 sbrc r24, 7 ; t4 eor r17, r23 ; t5 out PORTB, r17 ; t6 add r4, r8 ; t7 adc r5, r9 ; t8 brcc 1f ; t9 neg r12 ; t10 1: lsl r20 ; t11 rol r21 ; t12 brvc 1f ; t13 subi r20, 0xfe ; t14 1: in r16, ...
1
Ajoutez un commentaire...

Ralph Corderoy

Partagé en mode public  - 
 
For us plebs that haven’t got a vanity Google+ URL, unlike https://plus.google.com/+AdeOshineye/, the http URL scheme can be abused to add in your desired text: https://plus.google.com/115649437518703495227;Ralph-Corderoy

That’s a ‘path parameter’, defined in http://tools.ietf.org/html/rfc2396#section-3.3 but the superseding RFC 3986 doesn’t make them a formal part of a path. Even so, some web servers strip them out when traversing the path allowing us to add our own commentary to a URL.

That URL above goes to my posts. My boundless vanity would probably prefer the About page but if you open https://plus.google.com/115649437518703495227;Ralph-Corderoy/about you’ll see About is underlined in the navigation but the browser’s location is showing /posts and that’s what’s being displayed. Poor G+ has got a bit confused.

(In case it’s not obvious from the tongue-in-cheek nature of this post, I don’t serious intend anyone to do this. I just thought it an amusing little corner of URLs and shone a little light on it. If I were Google I’d stop ignoring path parameters on G+ quite quickly so your pride will take a fall when they become ‘404 Not found’.)
 ·  Traduire
1
Ajoutez un commentaire...
Dans ses cercles
357 contacts
Dans les cercles de
2 323 contacts
Photo du profil de Girish Lakshminarayana
Photo du profil de Emil Bengtsson
Photo du profil de Cheney Tsai
Photo du profil de Thant Syn Aung
Photo du profil de Fabio Roig
Photo du profil de Gökhan Barış Aker
Photo du profil de Philip Cortes
Photo du profil de Max McDonnell
Photo du profil de Giovanni Lanzani

Ralph Corderoy

Partagé en mode public  - 
 
The Tragedy of the Commons is a well-known theory but I only knew what I’d gleaned from en.wikipedia.org/wiki/The_tragedy_of_the_commons, and suspect I’m not alone. +Tim Harford’s excellent Do You Believe in Sharing? added some interesting snippets, e.g. TotC says “freedom to breed is intolerable”, and contrasts its author’s views against those of Lin Ostrom who had studied long-lasting commons that hadn’t unavoidably descended into ruination. It’s a great read over a five-minute break with your favourite beverage.
3
1
Photo du profil de Victor ChurchillPhoto du profil de Ralph CorderoyPhoto du profil de Andrew Bonello
7 commentaires
 
+Victor Churchill, Thanks for letting me know; that's Wordpress for you. ;-) I expect Wolfe will sort it soon. And welcome to G+!
 ·  Traduire
Ajoutez un commentaire...

Ralph Corderoy

Discussion  - 
 
Python library Twisted has been around a long time, “an event-driven networking engine”. +Guido van Rossum recently learnt and explained some more of its internals as research for Tulip, his reboot of asynchronous I/O for Python. I thought it a "fun" read, highlighting how complex some of this stuff can get, not just for the implementer but for the user that has to comprehend the behaviour, especially when debugging.
 ·  Traduire
Instantly connect to what's most important to you. Follow your friends, experts, favorite celebrities, and breaking news.
11
4
Photo du profil de Marcelo MódoloPhoto du profil de Maxim MoiseevPhoto du profil de Matt DragonPhoto du profil de Yann Guibet (Yann2192)
4 commentaires
 
Gosh, I hate async programming.
 ·  Traduire
Ajoutez un commentaire...

Ralph Corderoy

Discussion  - 
 
Googler +Josh Haberman, works on BigQuery, has come up with a considered couple of issues with Go's design that's blocking him from using it. I thought there might be learned voices here that can better persuade him, perhaps from long experience, than my comment on his post.
 
I just can't get over my discomfort at Go's take on interfaces. In Go you don't explicitly declare that your type implements an interface, you just pass your type to a function expecting the interface and the Go compiler checks that you have method signatures that match the interface.

This lack of an explicit "implements" statement just bugs me so much. Interfaces can have really subtle semantics; without an explicit "implements" declaration it's unclear what (if any) interface and associated semantics you are promising to implement.

For example, I can easily declare two interfaces (I haven't written any real Go, so sorry if I get the details of this wrong):

type Writable1 interface {
  // Returns the number of bytes successfully written,
  // or "0" or on error or EOF.
  Write(data []byte) int
}

type Writable2 interface {
  // Returns the number of bytes successfully written,
  // or "-1" on error or EOF.
  Write(data []byte) int
}

Now there is no type that can implement both interfaces correctly, but any type that attempts to implement one will also (inadvertently) implement the other, and the Go compiler will be happy to let this happen.

Also, if the interface changes the compiler won't warn you about subclasses that need changing unless you compile the code that tries to use that type by its interface.

I really think explicit is better than implicit when it comes to "implements" declarations. This is a big stumbling block for me ever wanting to use Go.
 ·  Traduire
7
1
Photo du profil de Jeff WendlingPhoto du profil de Kevin GillettePhoto du profil de Elazar LeibovichPhoto du profil de george oloo
31 commentaires
 
I think that +Josh Haberman have a very valid point. Everyone answer the concern: "accidentally implementing an interface will cause a bug". A bigger concern is "not declaring implemented interfaces explicitly hamper readability".

If you look at the go/ast package for example, you'll find a "standard" type hierarchy for where "If is a statement" is implemented by having If struct implementing an annotation-only interface.

This indeed makes it harder to read, and harder to understand.

What really bothers me about +Josh Haberman's approach for evaluating programming languages, is the methodology of deciding against a language because it has a single bad feature.

People worked successfully with far worse languages, with tools and methodology to mitigate their shortcoming. IMHO the mere features of the language does not correlate to a productivity boost.

Go features a first class standard library, with a clean API. Go put emphasize on top notch developer tools (which other language implemented a profiler so early, and added standard to the GDB). I personally couldn't care less if some detail is wrong in the language design.
 ·  Traduire
Ajoutez un commentaire...

Ralph Corderoy

Partagé en mode public  - 
 
groupcache: Memcached alternative/replacement from its original author

+Brad Fitzpatrick has just given a talk at OSCON 2013 on downloads from Google’s dl.google.com: talks.golang.org/2013/oscon-dl.slide. Its old C++ code was replaced with an all-round better Go implementation.

groupcache is part of that and is now available. It has coordinated cache filling, so on a cache-miss the herd doesn’t thunder. Unlike Memcached, a key’s value is immutable, so no increment, etc. This allows groupcache to replicate sought-after items to processes other than the authoritative source, avoiding a bottleneck of CPU or NIC for very popular items.

#memcached #golang
4
7
Photo du profil de Ash WuPhoto du profil de Andrea PavoniPhoto du profil de Julien EtiennePhoto du profil de Frederick ROS
 
I'm hoping this improvement spreads further so googlecode.com stops returning 404 for HEAD until a little while after a GET for the same URL has primed its cache. It then works, returning 200, at least for a while. Been like this for a few years now. :-) code.google.com/p/support/issues/detail?id=660
 ·  Traduire
Ajoutez un commentaire...

Ralph Corderoy

Discussion  - 
 
If Go matches my understanding of its ancestors, a select where more than one case can proceed will pick one pseudo-randomly. Is this true, and is it still true in the Playground? I'm suspecting it's effectively nobbled there, perhaps as a side effect of the PRNG always having the same seed.
 ·  Traduire
1
Photo du profil de Reed O'BrienPhoto du profil de David CheneyPhoto du profil de Ralph Corderoy
6 commentaires
 
Cheers +David Cheney. Caching accepted, I can get a select to pick randomly by tweaking the magic value. Seeing about 50/50 between the two channels. http://play.golang.org/p/7Qylg4RF1w
 ·  Traduire
Ajoutez un commentaire...

Ralph Corderoy

Partagé en mode public  - 
 
An interesting post by +Martin Kleppmann showing the internal structure of your id_rsa or id_dsa private SSH keys. He then shows how to switch a passphrase-protected private key from un-stretched MD5 to stretched-with-PBKDF2 using HMAC-SHA1, triple-DES encrypted. Or, in English, it makes brute-force attacks on the passphrase of a stolen private key more difficult. To switch is essentially one openssl(1) command.
 ·  Traduire
Improving the security of your SSH private key files. Ever wondered how those key files in ~/.ssh actually work? How secure are they actually? As you probably do too, I use ssh many times every single day — every git fetch and git push , every deploy, every login to a server.
5
2
Photo du profil de Thomas KeitelPhoto du profil de Nick Devereaux
Ajoutez un commentaire...
Contacts
Dans ses cercles
357 contacts
Dans les cercles de
2 323 contacts
Photo du profil de Girish Lakshminarayana
Photo du profil de Emil Bengtsson
Photo du profil de Cheney Tsai
Photo du profil de Thant Syn Aung
Photo du profil de Fabio Roig
Photo du profil de Gökhan Barış Aker
Photo du profil de Philip Cortes
Photo du profil de Max McDonnell
Photo du profil de Giovanni Lanzani
Parcours professionnel
Profession
Consulting programmer
Informations générales
Sexe
Homme
Histoire
Description
Programmer of the Unix school
Présentation
Unix/C programmer for over twenty years, lots of programming/assembly languages over that time, nowadays C, Python, and ARM.  Performance, problem-solving, and bit-twiddling are particular interests.
Adresses
Carte des endroits où cet utilisateur a vécuCarte des endroits où cet utilisateur a vécuCarte des endroits où cet utilisateur a vécu
Anciens domiciles
London, England - West Sussex, England - Hampshire, England - Dorset, England - Versailles, France
Packed to the rafters with one of just about everything, this is an excellent hardware and ironmongers. Always lots of staff on hand wearing brown overall coats to help. All the nuts and bolts are tucked away in a plethora of little cardboard boxes behind the counter. You go in with an unknown type of widget that needs replacing, they recognise it, get the right box, sift through the different sizes for one to match, wrap it in a little bag, then ask for 37p or some other inconsequential amount. Go in asking for oil for a lock and they'll politely question you and perhaps explain graphite powder would be better. Great place to wander in and browse too. Has its own little bit of parking at the back accessed by the driveway down its side.
• • •
Public - il y a 2 ans
a publié un avis il y a 2 ans
1 avis
Map
Map
Map