HNHacker News
TopNewBestAskShowJobs

cgrubb

237 karma · joined July 5, 2010

Los Angeles
submissionscomments
cgrubb··on Why Use Make
Most systems I use have GNU make 3.81 installed. GNU make 3.81 added the special target .ONESHELL which makes code like the following possible. I'm not sure if it is a good idea, but it does remove the dependency that make has on shell programming.

    .ONESHELL:

    SHELL = /usr/bin/python

    VAR := lorem ipsum

    all:
        @
        import re
        
        n = 3
        
        print('make variable: $(VAR)')
        print('local variable n: {}'.format(n))
        
        rx = re.compile('\d+')
        s = 'foo 17'

        m = rx.search(s)
        if m:
          print('has number: {}'.format(s))
        else:
          print('no number: {}'.format(s))
cgrubb··on A Modern Space Cadet
Great post. Consider the following changes to the Greek mapping to be consistent with Greek keyboards and the "greek" input mode in Emacs:

    q Q: ; :
    w W: ς Σ
    y Y: υ Υ
    u U: θ Θ
    j J: ξ Ξ
    x X: χ Χ
    c C: ψ Ψ
    v V: ω Ω
cgrubb··on The Most Important Social Network: GitHub
Agreed. Long ago I remember trying to get a non-developer to use cvs, which is much less complicated than git. It's not for everybody.
cgrubb··on The Caging of America
Many people reading this will fail to realize that "correctional supervision" includes about 4M who are on probation or parole. Horrible article.
cgrubb··on Advanced programming languages
Yegge wrote that in "Tour de Babel". I don't think it is really true tho.

When I started in 1997 (before Yegge) there was lots of C and Perl but no Lisp, at least not in the central repo. There were restrictions on Perl. The DBAs wouldn't let us use it to insert data in the database. Shel didn't care much for Perl. He might have warmed to it a little bit when he discovered it supported closures; I remember him sending a msg to the software alias about it.

Eric Benson had been a principal at Lucid, though I didn't know it at the time. Once he gave a class to the perlhackers on how to write code. The advice, as I recall, was to put "use strict;" at the top of our scripts and to start every function by shifting all the arguments into local variables. Eric Benson wrote the initial version of the "customer who bought this also bought..." code, and he used Perl, not Lisp. I'm sure he thought about the problem in Lisp terms, tho.

http://sites.google.com/site/steveyegge2/tour-de-babel

cgrubb··on New Twitter Has Become Browser Poison
I've experimented with the new twitter web app on both Chrome and Safari (Mac).

It automatically loads a chunk of data when I scroll to the bottom. The CPU use seems to be proportional to the number of chunks that have been loaded. Initially about 2% and increasing to 50% with 20 chunks.

The new twitter almost unusable because of this. Hoping for a fix soon.

cgrubb··on Jack Dorsey (Square/Twitter): “It’s Really Complex To Make Something Simple.”
If you fail tell your audience you don't have the time to be brief.
cgrubb··on Why the (US) Rich Are Getting Richer
Author's reasons for phenomenon in brief: (1) tax system not progressive enough; (2) govt hard on unions.
cgrubb··on SageMath: Python-based Mathematics. Rock it.
Octave is free and I used MATLAB in school so it made sense to install it. I've never had problems with Octave though I've heard others complain about it. I don't use it that much. For graphics I always use R.

Maybe I should have mentioned Coq in my previous list. I installed it a few days ago. Haven't learned to use it yet.

cgrubb··on SageMath: Python-based Mathematics. Rock it.
The math software I use is Mathematica (Home Ed), Sage, Octave, R, and TeXShop. All open source except for Mathematica.

Mathematica has a few advantages. The input notation can look more like traditional mathematics: adjacency instead of * for multiplication, superscript instead of ^ for exponentiation, fraction notation. I think that cuts down on errors. Variables are symbolic in Mathematica by default. The Mathematica language is something of a defacto standard and WolframAlpha understands it to a certain extent, so you have access for free if you have internet. WolframAlpha mobile gives you CAS on your phone.

That said, an open source version of Mathematica is desirable and Sage should be supported. I keep a table of equivalences at http://hyperpolyglot.org/math to try to lessen the mental burden of using two equivalent products.

cgrubb··on Ask HN: Why do people consider Ruby better than Perl or vice versa?
Switched from Perl to Ruby in 2006. Things I like off the top of my head:

One variable type. This makes references unnecessary. Also, everything that can be stored in a variable is an object.

I can remember the Ruby syntax for defining a class. In Perl I had to look it up every time. Also Perl has two competing class systems.

Methods by default take a fixed number of arguments and there are no implicit conversions between strings and numbers. This catches a lot of errors.

Good Perl practice involves boilerplate such as 'use strict'. I hear about lint tools and such and it makes me think the situation has gotten worse since 2006.

The Ruby Array class and the Enumerable module are good. I've become dependent on methods that aren't as readily available in Perl: include? each_with_index all? any? permutation. Also the intersection and union operators: & and |.

Ruby blocks.

Ruby 1.9 has the Fiber class (rough equivalent to Python generator).

Ruby IO operations throw exceptions when they fail. Hence you don't need the '|| or die "could not open!"' idiom.

cgrubb··on Python vs. Ruby: A Battle to The Death
Ruby overuses []. It is used in Array literals, but it is also an operator (i.e. a method with odd syntax) on several classes: Array, String, Fixnum, Bignum, Proc. In a language with dynamic typing, we should avoid having methods (or operators) with the same name and different function since calling nonexistent methods is how we catch errors.

The [] operator on Proc was new to me. I don't like the [] on Fixnum and Bignum, which is a bit operation: x[y] := (x << y) & 1. Hence my fixes to Ruby would be:

  $ irb
  001> add = lambda {|x,y| x+y}
  => #<Proc:0x0000010089ef30@(irb):1 (lambda)>
   002> add[1,2]
  => 3
  003> 1[2]
  => 0
  004> class Proc; undef_method :[]; end
  => Proc
  005> class Fixnum; undef_method :[]; end
  => Fixnum
  006> class Bignum; undef_method :[]; end
  => Bignum
  007> add[1,2]
  NoMethodError: undefined method `[]' for #<Proc:0x0000010089ef30@(irb):1 (lambda)>
        from (irb):7
        from /usr/local/bin/irb:12:in `<main>'
  008> 1[2]
  NoMethodError: undefined method `[]' for 1:Fixnum
        from (irb):8
        from /usr/local/bin/irb:12:in `<main>'
  009> (100**100)[1]
  NoMethodError: undefined method `[]' for #<Bignum:0x00000101116f50>
        from (irb):9
        from /usr/local/bin/irb:12:in `<main>'
I'm also tempted to remove [] from String, but the usefulness probably outweighs the occasional confusion from thinking a String is an Array.
cgrubb··on TIOBE Programming Community Index for December 2010
The TIOBE index is the homecoming queen at the school for the homely.

If you are going to date one of these girls, also check these out:

http://lang-index.sourceforge.net/

http://www.dataists.com/2010/12/ranking-the-popularity-of-pr...

cgrubb··on The Semicolon Wars
The programming world isn't as balkanized as natural languages. If Tiobe is to believed, the top 20 programming languages account for 85% of "use". By contrast, the native speakers for the top 20 natural languages only have 50% of the world population. Here's a spreadsheet with the data.

  http://j.mp/hiPGXA
Other factors to consider: learning a new programming language requires less than a tenth the effort of learning a natural language (my estimate). That's for people. Getting my laptop to speak a new language is mostly a matter of downloading the interpreter or compiler. Granted the interpreter or compiler has to be initially ported to the architecture or OS. So not only is there less programming language balkanization, but the cost of balkanization is less.
cgrubb··on Python Mode in Emacs
If you highlight the following code with python.el:

  a = 1
  b = 2
a and b will be highlighted in orange. However, in this code they will not:

  a, b = 1, 2
I tried to modify python.el so that variables defined by parallel assignment would get highlighted. I made the following imperfect change to python.el:

  <     ;; If parallel assignment is used, up to four variable names are highlighted.
  <     (,(rx line-start
  <           (zero-or-one (group (1+ (or word ?_))) (0+ space) "," (0+ space))
  <           (zero-or-one (group (1+ (or word ?_))) (0+ space) "," (0+ space))
  <           (zero-or-one (group (1+ (or word ?_))) (0+ space) "," (0+ space))
  <           (group (1+ (or word ?_))) (0+ space) "=")
  <      (1 font-lock-variable-name-face) (2 font-lock-variable-name-face)
  <      (3 font-lock-variable-name-face) (4 font-lock-variable-name-face))
  ---
  >     (,(rx line-start (group (1+ (or word ?_))) (0+ space) "=")
  >      (1 font-lock-variable-name-face))
The change is imperfect because it only highlights up to 4 variables created by parallel assignment. It does not work for this code:

  a, b, c, d, e = 1, 2, 3, 4, 5
If anybody is good enough with Emacs Lisp to handle the general case I would be interested to see it.
cgrubb··on Can you name the Programming Language if You Know The Creators?
Wikipedia's attribution of the work that took place in late 1959 on COBOL to Grace Hopper is incorrect. Note that it was made anonymously by someone who was fixing obvious vandalism. See

  http://en.wikipedia.org/w/index.php?title=COBOL&action=historysubmit&diff=283228831&oldid=283200503
I will summarize what I think is the correct story. I have "The Early History of COBOL" by Jean Sammet, 1978, which can be downloaded from http://portal.acm.org/citation.cfm?id=808378 for $15. Sammet was on the short-range design committee which did the work that Wikipedia mentions occurring in late 1959. I also have a photocopy of the April 1960 CODASYL report on COBOL which I acquired from the Charles Babbage Institute.

There was a meeting of various people at the University of Pennsylvania in April 1959. They thought a "machine independent" language for data processing could and should be developed and they suggested that the Department of Defense lead the effort. In May 1959 there was a meeting at the Pentagon which outlined high level goals for the language. It also said that the existing languages FLOW-MATIC and AIMACO as well as the specified but unimplemented language COMTRAN should be studied to determine what is wrong and right with them. The May 1959 meeting also established a short-range committee, an intermediate-range committee, and a long-range committee to develop the language. The long-range committee would never actually meet. There was also an executive committee for coordinating the other committees. Grace Hopper was appointed as an advisor to the executive committee, but the executive committee was political in nature and wasn't involved in design.

Most of the design work for COBOL was done by the short-range committee, which met from June through December 1959. These people served on the short-range committee:

Col. Alfred Asch, Robert Barton, Howard Bromberg, William Carter, Ben Cheydleur, Miss Deborah Davidson, Norman Discount, William Finley, Charles Gaudette, Roy Goldfinger, Dan Goldstein, Mrs. Mary K. Hawes, Duane Hedges, Mrs. Frances E. Holberton, Miss Sue Knapp, Karl Kozarsky, Roy Nutt, William Logan, Rex McWilliams, Vernon Reeves, Gerald Rosenkrantz, Miss Jean E. Sammet, William Seldon, Edward Somers, Mrs. Nora Taylor, Miss Gertrude Tierney, Capt. Erwin Vernon, J..H. Wegstein (Chairman)

After the short-range committee dissolved, work was carried on by the intermediate-range committee at a slower pace. The following individuals are mentioned as participating in the intermediate-range committee (though Sammet thinks this list may be incomplete):

A. Eugene Smith (Chairman), Lester Calkins, Gregory Dillon, Roy Goldfinger, Jack Jones, William Keating, Colonel Gerald Lerner, Robert Rossheim

As for the influence of FLOW-MATIC on COBOL, I am not aware of any FLOW-MATIC manuals that are available online, unfortunately. Sammet's article lists 5 influences of FLOW-MATIC on COBOL, however. It also lists 6 influences of COMTRAN on COBOL. Sammet says the FLOW-MATIC influences are

1) It worked! 2) Full data-names unlike FORTRAN (though limited to 12 characters in length) 3) It used full English words for commands 4) It used less than a full machine world for each data item. 5) It separated data description and commands.

cgrubb··on Can you name the Programming Language if You Know The Creators?
Grace Hopper invented FLOW-MATIC. She wasn't even on the COBOL design committee.

If I were to choose a single inventor for Scheme, I would have chosen Sussman, not Steele.

← PreviousPage 3 of 3