What is the difference between procedural programming and functional programming?

I’ve read the Wikipedia articles for both procedural programming and functional programming, but I’m still slightly confused. Could someone boil it down to the core?

via glossary – What is the difference between procedural programming and functional programming? – Stack Overflow.

A functional language (ideally) allows you to write a mathematical function, i.e. a function that takes n arguments and returns a value. If the program is executed, this function is evaluated.

A procedural language, on the other hand, performs a series of sequential steps, where the functional program would be nested. There’s a way of transforming sequential logic into functional logic called continuation passing style.

As a consequence, a purely functional program always yields the same value for an input, and the order of evaluation is not well-defined; which means that uncertain values like user input or random values are hard to model in purely functional languages.

The Plane Crash That Gave Americans GPS

The U.S. had already launched into orbit almost a dozen satellites that could help locate its military craft, on land, in the air, or on the sea. But the use of the system was restricted. (It was meant, for instance, to help powerful weapons hit their targets—it wasn’t the sort of tool governments usually want to make publicly available.) Now, Reagan said, as soon as the next iteration of the GPS system was working, it would be available for free.

It took more than $10 billion and until over 10 years for the second version of the U.S.’s GPS system to come fully online. But in 1995, as promised, it was available to private companies for consumer applications. Sort of. The government had built in some protection for itself—”selective availability,” which reserved access to the best, most precise signals for the U.S. military (and anyone it chose to share that power with).

via The Plane Crash That Gave Americans GPS – The Atlantic.

One wi-fi hotspot for every 150 people, says study

Over the next four years, global hotspot numbers will grow to more than 340 million, the equivalent of one wi-fi hotspot for every 20 people on earth, the research finds.

via BBC News – One wi-fi hotspot for every 150 people, says study.

“At the moment you have to have a separate log-in for every hotspot and ultimately the winning providers are those that will offer the easier access experience,” she said.

Top Open-Source Static Site Generators

The typical CMS driven website works by building each page on-demand, fetching content from a database and running it through a template engine. This means each page is assembled from templates and content on each request to the server.

For most sites this is completely unnecessary overhead and only ads complexity, performance problems and security issues. After all, by far the most websites only change when the content authors or their design team makes changes.

A Static Site Generator takes a different approach and generate all the pages of the website once when there’s actually changes to the site. This means there’s no moving parts in the deployed website. Caching gets much easier, performance goes up and static sites are far more secure.

via Top Open-Source Static Site Generators – StaticGen.

Archiving command history in Linux

#!/bin/bash
 umask 077
 max_lines=10000
 linecount=$(wc -l < ~/.bash_history)
 if (($linecount > $max_lines)); then
         prune_lines=$(($linecount - $max_lines))
         head -$prune_lines ~/.bash_history >> ~/.bash_history.archive \
                && sed -e "1,${prune_lines}d"  ~/.bash_history > ~/.bash_history.tmp$$ \
                && mv ~/.bash_history.tmp$$ ~/.bash_history
 fi

via BashFAQ/088 – Greg’s Wiki.

I needed to manage shell command history in a formal fashion in order to turn repeated sequences into scripts without having to type them in again.  I also wanted a  record of packages installed and in what order.   The history of commands is contained in .bash_history file which is read once when a terminal opens.   Running set -o vi allows for history commands to be recalled using standard vi commands.  The above script can be run as a user level cron job to periodically prune the top so many commands and place them into an archive.

The bash statements below set history size and make it so a command will be written to the history file immediately and not simply when a terminal closes.   These should be placed in .bashrc or whatever file executes when a new terminal opens.

HISTFILESIZE=400000000
HISTSIZE=10000
PROMPT_COMMAND="history -a"
export HISTSIZE PROMPT_COMMAND

shopt -s histappend

The Internet Dodges Another Bullet With Wget Flaw

“It was found that wget was susceptible to a symlink attack which could create arbitrary files, directories or symbolic links and set their permissions when retrieving a directory recursively through FTP,” developer Vasyl Kaigorodov wrote in a Red Hat Bugzilla comment. –

via The Internet Dodges Another Bullet With Wget Flaw.

Wget is a linux command that allows a shell script to download a web page and store it to a file.  This bug pertains to using a URL to do File Transfer Protocol (FTP) and not HTTP which is what wget was designed for.  Here are a couple more snippets of this bug.

“Random bug found by accident, but the implication is that the FTP server can overwrite your entire filesystem,” Moore tweeted to eWEEK.

Don’t use wget for ftp.  Don’t run wget with root permissions.

So just to recap here, Wget is on nearly every Linux server in the world, and it had a flaw that could have enabled anyone to overwrite directories on a server. That’s very serious.

You should only use wget for http downloads.  This doesn’t sound like one of those Internet Dodges a Bullet problems.

Things You Should Never Do, Part I – Joel on Software

There’s a subtle reason that programmers always want to throw away the code and start over. The reason is that they think the old code is a mess. And here is the interesting observation: they are probably wrong. The reason that they think the old code is a mess is because of a cardinal, fundamental law of programming:

It’s harder to read code than to write it.

via Things You Should Never Do, Part I – Joel on Software.

Each of these bugs took weeks of real-world usage before they were found. The programmer might have spent a couple of days reproducing the bug in the lab and fixing it. If it’s like a lot of bugs, the fix might be one line of code, or it might even be a couple of characters, but a lot of work and time went into those two characters.

When you throw away code and start from scratch, you are throwing away all that knowledge. All those collected bug fixes. Years of programming work.

The Soaring Financial Cost of Blocking Pirate Sites

But these 36 new sites to be blocked on copyright grounds are potentially just the tip of a quite enormous iceberg now that blocking on trademark grounds is being permitted.

Richemont has identified approximately 239,000 sites potentially infringing on their trademarks, 46,000 of which have been confirmed as infringing and are waiting for enforcement action.

via The Soaring Financial Cost of Blocking Pirate Sites | TorrentFreak.

IBM Is Not A Tech Company

IBM’s revenues are declining because there’s a big shift going on in the way companies are buying tech. Instead of buying their own software and hardware for their own data centers, then hiring expensive consultants to stitch it all together, they are renting that technology, which is often hosted elsewhere. That’s called “cloud computing.”

All the big tech firms are shifting from the old way of selling stuff to this new way with varying degrees of success: SAP, Oracle, Microsoft, Dell, HP and IBM are all getting into the cloud.

via Mark Cuban: IBM Is Not A Tech Company – Business Insider.