Thursday, April 18, 2013

Your Daily digest for Tech Geek`s Tools, Tips, Tricks and Tutorials

Tech Geek`s Tools, Tips, Tricks and Tutorials
Pipes Output
System Monitoring Policy
Apr 19th 2013, 07:00

It is essential that an organization’s critical computer/networking systems and services are properly monitored so that staff can be made aware of and respond to problems and trends.

YouTube Wins Against Viacom Again
Apr 18th 2013, 23:54

NewYorkCountryLawyer writes "Once again YouTube has defeated Viacom and other members of the content cartel; once again the Court has held that the Digital Millennium Copyright Act actually does mean what it says. YouTube had won the case earlier, at the district court level, but the US Court of Appeals for the Second Circuit, although ruling in YouTube's favor on all of the general principles at stake, felt that there were several factual issues involving some of the videos and remanded to the lower court for a cleanup of those loose ends. Now, the lower court — Judge Louis L. Stanton to be exact — has resolved all of the remaining issues in YouTube's favor, in a 24-page opinion. Among other things Judge Stanton concluded that YouTube had not had knowledge or awareness of any specific infringement, been 'willfully blind' to any specific infringement, induced its users to commit copyright infringement, interacted with its users to a point where it might be said to have participated in their infringements, or manually selected or delivered videos to its syndication partners. Nevertheless, 5 will get you 10 that the content maximalists will appeal once again."

Share on Google+

Read more of this story at Slashdot.



Kobo CEO Says Not Selling Washing Machines Key To Overtaking Amazon
Apr 18th 2013, 23:10

DavidGilbert99 writes "Kobo, the Canadian-based ebook company is number two in the market, behind the behemoth that is Amazon. So what does the CEO Michael Serbinis think is the one thing which will allow them to overtake the e-commerce giant? 'We don't sell any washing machines, we don't sell radios. We are not focused on the next server farm to offer data services. It is a question of focus.' Serbinis goes on to tell IBTimes UK: 'From an organization standpoint at Kobo, this is all we do. Everyone at Kobo, all we focus on is creating a great experience for book-lovers.'"

Share on Google+

Read more of this story at Slashdot.



To Connect People Securely, Tor Project Seeks New Bridges
Apr 18th 2013, 22:26

An anonymous reader links to an article at Ars explaining the dropping inventory of bridges available to users of the Tor project's encrypted messaging system. They're looking for more bridges, but that doesn't necessarily mean buying new hardware per se. From the article: "After campaigning successfully last year to get more volunteers to run obfuscated Tor bridges to support users in Iran trying to evade state monitoring, the network has lost most of those bridges, according to a message to the Tor relays mailing list by Tor volunteer George Kadiankakis. 'Most of those bridges are down, and fresh ones are needed more than ever,' [Tor volunteer George] Kadiankakis wrote in an e-mail, 'since obfuscated bridges are the only way for people to access Tor in some areas of the world (like China, Iran, and Syria).' For those who want to donate bridges to the Tor network, the easiest route is to use Tor Cloud, an Amazon Web Service Elastic Compute Cloud image created by the Tor Project that allows people to leverage Amazon's free usage tier to deploy a bridge."

Share on Google+

Read more of this story at Slashdot.



Google Leak Hints At an Android Game Center With Multiplayer Support
Apr 18th 2013, 21:42

An anonymous reader writes "Google appears to be preparing the launch of a game center for Android with an unknown name. It looks like the new hub will sport a slew of features, including multiplayer support, in-game chat, lobbies, leaderboards, and achievements. The leaked information come to us courtesy of Android Police, which amusingly stumbled on the details by tearing apart the apk file for MyGlass, the Google Glass companion app that launched earlier this week. The feature list was hidden within, though it's not clear if this was done on purpose to build hype or entirely by accident." While on the topic of Google-branded Android hardware speculation, this wishlist at The Full Signal makes some feature-list pleas for the rumored Nexus 5.

Share on Google+

Read more of this story at Slashdot.



A Critique of the Boston Bombing News Coverage (Video)
Apr 18th 2013, 21:00

David Coursey has spent a lot of his life as a journalist, specializing in IT coverage for most of it. He's written for ZDNet and eWeek, Forbes, and other well-known publications, and has had his stories linked from Slashdot more than a few times over the years. What he is not as well known for is his expertise as an EMT, a field he has been in as both a volunteer and professional since the rocks in California (where he lives) were still soft enough that the Flintstones used them as pillows. He and I were chatting on Facebook yesterday, and I realized that David's views on media coverage of the recent Boston Marathon bombings might be worth sharing. Do you think what he's saying is valid? Do you agree or disagree with him? Or some of each?

Share on Google+

Read more of this story at Slashdot.



Kepler-62 Has 2 Good Candidate Planets In the Search for Life
Apr 18th 2013, 20:18

astroengine writes "About 1,200 light-years from Earth, five planets are circling around sun-like star Kepler-62, two of which are fortuitously positioned for water, if any exists, to remain liquid on their surfaces — a condition believed to be necessary for life. The discovery, made by scientists using NASA's planet-hunting Kepler space telescope, is the strongest evidence yet for more than one Earth-sized planet existing in a star's so-called 'habitable' zone. 'We're particularly delighted to find that there are two planets in the habitable zone,' lead Kepler scientist William Borucki, with NASA's Ames Research Center in California, told Discovery News. 'It sort of doubles our chances of finding that Earth we'd all like to find. When you think about Earth and Mars, if Mars had been a bit larger, if Jupiter hadn't been so close, we'd again have two planets in the habitable zone and maybe we'd have a place to go,' he said." There's also a third planet believed to be a good candidate for hosting water.

Share on Google+

Read more of this story at Slashdot.



Debian 7.0 ('Wheezy') Release Planned For 1st Weekend in May
Apr 18th 2013, 19:37

An anonymous reader writes with this good news from the Debian developers who have been working hard to release the next version of the distro: "We now have a target date of the weekend of 4th/5th May for the release. We have checked with core teams, and this seems to be acceptable for everyone. This means we are able to begin the final preparations for a release of Debian 7.0 — 'Wheezy'. The intention is only to lift the date if something really critical pops up that is not possible to handle as an errata, or if we end up technically unable to release that weekend (e.g. a required machine crashes or d-i explodes in a giant ball of fire). Every other RC fix that does not make it in time will be r1 material. Please be sure to contact us about the RC fixes you would like included in the point release!" Of particular interest to casual users, from the list of changes in 7.0: "Debian wheezy comes with full-featured libav (formerly ffmpeg) libraries and frontends, including e.g. mplayer, mencoder, vlc and transcode. Additional codec support is provided e.g. through lame for MP3 audio encoding, xvidcore for MPEG-4 ASP video encoding, x264 for H.264/MPEG-4 AVC video encoding, vo-aacenc for AAC audio encoding and opencore-amr and vo-amrwbenc for Adaptive Multi-Rate Narrowband and Wideband encoding and decoding, respectively. For most use cases, installation of packages from third-party repositories should not be necessary anymore. The times of crippled multimedia support in Debian are finally over!"

Share on Google+

Read more of this story at Slashdot.



Iron Man 3 To Debut As a 4DX Film In Japan
Apr 18th 2013, 18:55

adeelarshad82 writes "Marvel's Iron Man 3 will debut in select Japanese theaters later this month employing the 4DX system for the first time. Developed by South Korea's largest movie chain operator, the CJ Group, 4DX-equipped theaters deliver smells, seat motions, and additional effects such as strobe lights and fog, all in sync with events as they appear on the screen. Beyond South Korea, this full immersion approach to cinema is already in operation in countries such as Israel, Mexico, Brazil, and China."

Share on Google+

Read more of this story at Slashdot.



CISPA Passes US House, Despite Privacy Shortcomings and Promised Veto
Apr 18th 2013, 18:13

An anonymous reader writes with a story at the Daily Dot: "Despite the protests of Internet privacy advocates, the controversial Cyber Intelligence Sharing and Protection Act (CISPA) passed the House of Representatives Thursday. The vote was 288-127. ... CISPA saw a handful of minor amendments soon before passage. A representative for the EFF told the Daily Dot that while they were still analyzing the specifics, none of the actual changes to the bill addressed their core criticisms. ... But also as was the case the year before, on Tuesday the Obama administration issued a promise to veto the bill if it reaches the president’s desk without significant changes." Techdirt has a short report on the vote, too — and probably more cutting commentary soon to follow.

Share on Google+

Read more of this story at Slashdot.



Most Projects On GitHub Aren't Open Source Licensed
Apr 18th 2013, 17:32

PCM2 writes "Kids these days just don't care about open source. That's the conclusion of the Software Freedom Law Center's Aaron Williamson, who analyzed some 1.7 million projects on GitHub and found that only about 15% of them had a clearly identifiable license in their top-level directories. And of the projects that did have licenses, the vast majority preferred permissive licenses such as the MIT, BSD, or Apache licenses, rather than the GPL. Has the younger generation given up on ideas like copyleft and Free Software? And if so, what can be done about it?" Not having an identifiable license is one thing, but it seems quite a stretch to say that choosing a permissive open source license is "not caring"; horses for courses.

Share on Google+

Read more of this story at Slashdot.



Interviews: Ask Freeman Dyson What You Will
Apr 18th 2013, 16:50

Famous for his work in math, astronomy, nuclear engineering, and theoretical physics, Freeman Dyson has left his mark on almost every scientific discipline. He's won countless awards, and written numerous books on a wide range of topics both scientific and philosophical. One of his biggest contributions to science was the unification of the three versions of quantum electrodynamics invented by Feynman, Schwinger and Tomonaga. 10 years after moving to the U.S. he started working on the Orion Project, which sought to create a spacecraft with a nuclear propulsion system. STNG exposed the idea of a Dyson sphere to the masses, and his hypothetical plan for making a comet habitable with the help of genetically-engineered plants is a personal favorite. Mr. Dyson has graciously agreed give us a bit of his time in order to answer your questions. As usual, ask as many as you'd like, but please, one question per post.

Share on Google+

Read more of this story at Slashdot.



In Iceland, Tap Cellphones To Avoid Incest
Apr 18th 2013, 16:29

Kozar_The_Malignant writes "Students at the University of Iceland have written an Android app that helps you avoid dating your cousins. The app accesses the Icelandic national genealogical database that contains information on all living citizens and their ancestors going back 1,100 years. Tapping two phones together will bring up an alert if you share a common grandparent." Just one of the consequences of having a population small enough (and well documented enough) to have a well-known genetic makeup.

Share on Google+

Read more of this story at Slashdot.



LinkedIn Invites Gone Wild: How To Keep Close With Exes and Strangers
Apr 18th 2013, 16:07

sholto writes "An aggressive expansion strategy by LinkedIn has backfired spectacularly amid accusations of identity fraud. Users complained the social network sent unrequested invites from their accounts to contacts and complete strangers, often with embarrassing results. One man claimed LinkedIn sent an invite from his account to an ex-girlfriend he broke up with 12 years ago who had moved state, changed her surname and her email address. ... 'This ex-girlfriend's Linked in profile has exactly ONE contact, ME. My wife keeps getting messages asking 'would you like to link to (her)? You have 1 contact in common!,' wrote Michael Caputo, a literary agent from Massachussetts."

Share on Google+

Read more of this story at Slashdot.



Twitter Launches the World's Umpteenth Online Music Site
Apr 18th 2013, 15:26

Nerval's Lobster writes "Twitter is plunging into the online music game. Twitter Music (or "Twitter #music," in the company's own rendering) uses Twitter activity such as Tweets and engagement "to detect and surface the most popular tracks and emerging artists," according to an April 18 posting on Twitter's official blog. Songs on the app derive from three sources: iTunes, Spotify, or Rdio. And yes, Twitter is big, but its victory is by no means assured: other IT giants have entered the same market only to watch highly-publicized projects wither away, doomed by some combination of audience apathy and implementation issues. Take Apple's Ping, for example: launched in September 2010 as part of an iTunes update, the ambitious social-networking and music-recommendation engine immediately ran into a number of problems, including a lack of Facebook integration (despite Steve Jobs' assurances to the contrary) and widespread reports of spam and fake accounts. Can Twitter's effort stand out, or will it just be lost in all the noise?"

Share on Google+

Read more of this story at Slashdot.

Twitter Launches the World's Upteenth Online Music Site
Apr 18th 2013, 15:26

Nerval's Lobster writes "Twitter is plunging into the online music game. Twitter Music (or "Twitter #music," in the company's own rendering) uses Twitter activity such as Tweets and engagement "to detect and surface the most popular tracks and emerging artists," according to an April 18 posting on Twitter's official blog. Songs on the app derive from three sources: iTunes, Spotify, or Rdio. And yes, Twitter is big, but its victory is by no means assured: other IT giants have entered the same market only to watch highly-publicized projects wither away, doomed by some combination of audience apathy and implementation issues. Take Apple's Ping, for example: launched in September 2010 as part of an iTunes update, the ambitious social-networking and music-recommendation engine immediately ran into a number of problems, including a lack of Facebook integration (despite Steve Jobs' assurances to the contrary) and widespread reports of spam and fake accounts. Can Twitter's effort stand out, or will it just be lost in all the noise?"

Share on Google+

Read more of this story at Slashdot.



Google Forbids Advertising On Glass
Apr 18th 2013, 14:45

An anonymous reader writes "Contrary to widespread thought, Google Glass will not be an advertising platform: 'Google Inc has lately told app developers that they are not allowed to present ads to Google Glass users and they are also not permitted to sell users' personal and private information for the fulfillment of advertising needs. The internet company has explicitly and openly said that the Glass platform should and must be clean and clear of any ads whatsoever, because the technology is designed to facilitate internet browsing and other related activities, therefore, the featured podium cannot be used to advertise products as it will cause the user experience to diminish.' Seems like Google is going for hardware-only revenue on this one." You're not supposed to resell the Glass hardware, either.

Share on Google+

Read more of this story at Slashdot.



HP To Package Leap Motion Sensor Into — Not Just With — Some Devices
Apr 18th 2013, 14:02

cylonlover writes "It hasn't even been released yet but the Leap Motion could already be considered something of a success – at least with PC manufacturers. Following in the footsteps of Asus, who announced in January that it would bundle the 3D motion controller with some of its PCs, the world's biggest PC manufacturer has joined the gesture control party. But HP has gone one step further, promising to build the Leap Motion technology into some future HP devices." (See this video for scenes of users scrabbling with their hands in empty air, and get ready for more of it.)

Share on Google+

Read more of this story at Slashdot.



Demand for Kopi Luwak May Be Threatening Wildlife
Apr 18th 2013, 14:02

Damien1972 writes "Popularization of the world's strangest coffee may be imperiling a a suite of small mammals in Indonesia, according to a new study in Small Carnivore Conservation. The coffee, known as kopi luwak (kopi for coffee and luwak for the civet), is made from whole coffee beans that have passed through the gut of the animal. The coffee is apparently noted for its distinct taste, though some have argued it is little more than novelty. Now, this burgeoning kopi luwak industry is creating 'civet farms,' whereby civets are captured from the wild and kept in cages to eat and crap out coffee beans."

Share on Google+

Read more of this story at Slashdot.



Prof. Stephen Hawking: Great Scientist, Bad Gambler
Apr 18th 2013, 13:24

astroengine writes "World-renowned physicist Stephen Hawking has announced that he was likely wrong about his view that the Higgs boson doesn't exist — an outcome he doesn't find very exciting — conceding that he lost a $100 wager. Speaking at the Beckman Auditorium in Caltech, Pasadena, Calif., on Tuesday (April 16), the British physicist gave a public lecture on 'The Origins of the Universe,' summarizing new revelations in modern astrophysics and cosmology. After the lecture, Caltech physicist and colleague John Preskill commented on Hawking's fondness for placing bets when faced with conflicts of physics ideas. Hawking lost a famous wager to Preskill in 2004 in a debate over whether or not black holes destroy information (theory suggests they do not, opposing Hawking's argument). 'To love Stephen Hawking is to not always agree with Stephen Hawking,' Preskill quipped. 'He's usually right, but he's not always right. Sometimes we haven't been able to resolve our differences and we've resorted to making bets it's sad to say that although Stephen Hawking is without doubt a great scientist, he's a bad gambler.'"

Share on Google+

Read more of this story at Slashdot.



Bitfloor Indefinitely Suspends Bitcoin Trading
Apr 18th 2013, 13:00

PerformanceDude writes "Bitfloor (a New York-based online exchange for Bitcoin) yesterday made the following announcement on their website: I am sorry to announce that due to circumstances outside of our control BitFloor must cease all trading operations indefinitely. Unfortunately, our US bank account is scheduled to be closed and we can no longer provide the same level of USD deposits and withdrawals as we have in the past. As such, I have made the decision to halt operations and return all funds. Over the next days we will be working with all clients to ensure that everyone receives their funds. Please be patient as we process your request. Roman — bitfloor.com" According to the company's Twitter account, money should be returned to users' bank accounts shortly.

Share on Google+

Read more of this story at Slashdot.

Bifloor Indefinitely Suspends Bitcoin Trading
Apr 18th 2013, 13:00

PerformanceDude writes "Bitfloor (a New York-based online exchange for Bitcoin) yesterday made the following announcement on their website: I am sorry to announce that due to circumstances outside of our control BitFloor must cease all trading operations indefinitely. Unfortunately, our US bank account is scheduled to be closed and we can no longer provide the same level of USD deposits and withdrawals as we have in the past. As such, I have made the decision to halt operations and return all funds. Over the next days we will be working with all clients to ensure that everyone receives their funds. Please be patient as we process your request. Roman — bitfloor.com" According to the company's Twitter account, money should be returned to users' bank accounts shortly.

Share on Google+

Read more of this story at Slashdot.



Google Breathes New Life Into EU's Cookie Law
Apr 18th 2013, 12:43

First time accepted submitter Trajan Przybylski writes "Google has just implemented new changes to its search pages in order to comply with the EU's Cookie Law, which aims to improve user privacy. Google is now showing a conspicuous banner with information about its use of cookies to all EU visitors accessing the site. This is despite the legislation attracting strong words of criticism from web developers, who believe the regulation to be harmful to the economy while offering no real improvement to online privacy and security problems. Google's move comes only 3 months after online activists announced the Cookie Law to be "dead" and is likely to reignite the heated debate about the controversial legislation."

Share on Google+

Read more of this story at Slashdot.



Businesses Moving From Amazon's Cloud To Build Their Own
Apr 18th 2013, 12:05

itwbennett writes "There are rumblings around this week's OpenStack conference that companies are moving away from AWS, ready to ditch their training wheels and build their own private clouds. Inbound marketing services company HubSpot is the latest to announce that it's shifting workloads off AWS, citing problems with 'zombie servers,' unused servers that the company was paying for. Others that are leaving point to 'business issues,' like tightening the reins on developers who turned to the cloud without permission."

Share on Google+

Read more of this story at Slashdot.



Businesses Moving From Amazon's Cloud To Build Their Own
Apr 18th 2013, 12:05

itwbennett writes "There are rumblings around this week's OpenStack conference that companies are moving away from AWS, ready to ditch their training wheels and build their own private clouds. Inbound marketing services company HubSpot is the latest to announce that it's shifting workloads off AWS, citing problems with 'zombie servers,' unused servers that the company was paying for. Others that are leaving point to 'business issues,' like tightening the reins on developers who turned to the cloud without permission."

Share on Google+

Read more of this story at Slashdot.



Weak, Strong, Static And Dynamic: An Introduction To Programming Type Systems
Apr 18th 2013, 09:36


  

Static typing is great because it keeps you out of trouble. Dynamic typing is great because it gets out of your way and lets you get your work done faster. The debate between strongly and dynamically typed languages rages on, but understanding the issue starts with weak typing and languages such as C.

C treats everything like a number. A character like a or 7 or % is the number of the ASCII symbol representing it; "true" and "false" are just 1 and 0.

C defines variables with types such as int for integer and char for character, but that just defines how much memory to use. To access the variable and print it out, I need to know the type.

  int a = 1;  printf("The number is %i\n", a);    char z = 'z';  printf("The character is %c\n", z);  

When I run this program, it shows this:

The number is 1  The character is z  

The printf function needs a hint from us to know how to format the variable. If I give the wrong hint…

  char z = 'z';  printf("The character is %i\n", z);  

… then I get this:

  The character is 122  

C doesn't know whether z is a character or an integer; it has a weak type.

Weak typing is fast because there's no overhead of remembering the different types, but it leads to some nasty bugs. There's no way to format the z if you don't know its type ahead of time. Imagine accessing a variable and getting the number 1229799107. The number could be the result of a mathematical calculation (1,229,799,107), the cost of a government program ($1.2 billion) or a date (Saturday, 20 December 2008). When all you have is the number, there's no way to know that it's really the code for the letters in my name: zack.

So far, we've just covered weak typing. "Weak versus strong" and "static versus dynamic" are often spoken of synonymously, but they each describe a different phase of the same problem. They're also politicized, with the words carrying an implied value judgment. "Weak versus strong" makes one of them sound a lot better than the other, while "static vs. dynamic" makes one sound stodgy and the other exciting.


(Image: Cris)

These two terms are used interchangeably, but they describe the difference between the way a language defines types and how it figures them out when the program runs. For example:

Weak with no typing Assembly languages don't provide any way of specifying or checking types at all. Everything is just a number.
Weak static typing C lets you define object types as structures, but it doesn't do much to enforce or remember them. C automatically convert between many types. C++ and Objective-C go further with the definitions but still don't enforce the resulting types.
Strong static typing Java forces you to define all types and checks them with a virtual machine.
Strong dynamic typing Python, JavaScript and Ruby dynamically infer the types of objects, instead of forcing you to define them, and then enforce those types when the program runs in the interpreter. All dynamically typed languages need a strong typing system at runtime or else they won't be able to resolve the object types.
Weak dynamic typing Dynamically inferred types don't work in a weakly typed language because there aren't any types to infer.

No programming language fits any of these definitions 100%. Java is considered one of the most static languages, but it implemented a comprehensive reflection API that lets you change classes at runtime, thus resembling more dynamic languages. This feature allows the Java Virtual Machine to support very dynamic languages such as Groovy.

Functional programming languages such as Lisp, Erlang and Haskell blur the lines even more.

Usually when people argue about the merits of strong versus weak programming languages, they really mean the varying degrees of weak, strong, static and dynamic philosophies in every language.

Weak Static Languages: C, C++ And Objective-C

These next programming languages use a subset of C's functionality and strict guidelines to improve the loose nature of the language. C++ and Objective-C compile into the same bytes as C, but they use the compiler to restrict the code you can write.

In C++ and Objective-C, our number (1229799107) has a meaning. I can define it as a string of characters and make sure that no one uses it as a currency or a date. The compiler enforces its proper use.

Static typing supports objects with sets of functionality that always work in a well-defined way. Now I can create a Person object and make sure the getName function always returns the string of someone's name.

  class Person {      public:          string getName() {              return "zack";          }  };  

Now I can call my object like this:

  Person p;  printf("The name is %s\n", p.getName().c_str());  

Static typing goes a long way to avoid the bugs of weakly typed languages by adding more constraints in the compiler, but it can't check anything when the program is running because a C++ or Objective-C program is just like C code when it runs. Both languages also leave the option of mixing weakly typed C code with static typed C++ or Objective-C to bypass all of the type checking.

Java goes a step beyond that, adding type checking when the code runs in a virtual machine.

Strong Static Languages: Java

C++ offers some stricter ways of using C; Java makes sure you use them. Java needs everything to be defined so that you know at all times what type of object you have, which functions that object has and whether you're calling them properly.

Java also stopped supporting C code and other ways of getting out of static typing.

The Person object looks almost the same in Java:

  public class Person {      public String getName() {          return "zack";      }  }  

I get the name by creating a new object and calling the getName function, like this:

  public class Main {      public static void main (String args[]) {          Person person = new Person();          System.out.println("The name is " + person.getName());      }  }  

This code creates a new Person object, assigns it to a variable named person, calls the getName function and prints out the value.

If I try to assign my person variable to a different type, such as a character or integer, then the Java compiler will show an error that these types are incompatible. If I was calling a separate API that had changed since I compiled, then the Java runtime would still find the type error.

Java doesn't allow code outside of a class. It's a major reason why people complain that Java forces you to write too much boilerplate.

The popularity of Java and its strong adherence to strong typing made a huge impact on the programming landscape. Strong typing advocates lauded Java for fixing the cracks in C++. But many programmers found Java overly prescriptive and rigid. They wanted a fast way to write code without all of the extra definition of Java.

Strong Dynamic Languages: JavaScript, Python, Ruby And Many More

In JavaScript, I define a variable with the keyword var, instead of a type like int or char. I don't know the type of this variable and I don't need to until I actually want to access it.

I can define an object in JavaScript with the getName function.

  var person = {      getName: function() {          return 'zack';      }  };    alert('The name is ' + person.getName());  

Now I have an object named person, and it has a function named getName. If I call person.getName(), it will result in zack.

I declared person as a var, and I can reassign it to anything.

  var person = {      getName: function() {          return 'zack';      }  };    person = 5;    alert('The name is ' + person.getName());  

This code creates a variable named person and assigns it to an object with a getPerson function, but then it reassigns that variable to the number 5. When this code runs, the result is TypeError: Object 5 has no method 'getName'. JavaScript says that the object 5 doesn't have a function named getName. In Java, this error would come up during compilation, but JavaScript makes you wait for runtime.

I can also change the type of the object based on the conditions of the program.

  var person = {      getName: function() {          return 'zack';      }  };    if (new Date().getMinutes() > 29) {      person = 5;  }    alert('The name is ' + person.getName());  

Now this code will work at 9:15 but will fail at 9:30. Java would call this a type error, but it's fine in JavaScript.

The most popular form of dynamic typing is called "duck typing" because the code looks at the object during runtime to determine the type — and if it walks like a duck and quacks like a duck, then it must be a duck.

Duck typing enables you to redefine any object in the middle of the program. It can start as a duck and turn into a swan or goose.

  var person = {      getName: function() {          return 'zack';      }  };    person['getBirthday'] = function() {      return 'July 18th';  };    alert('The name is ' + person.getName() + ' ' +         'and the birthday is ' + person.getBirthday());  

At any point, I can change the nature of my Person object to add the new getBirthday function or to remove existing functionality. Java won't allow that because you can't check object types when they're always changing. Dynamically redefining objects gives you a lot of power, for good and bad.

C shows errors when the program runs. C++, Objective-C and Java use the compiler to catch errors at compile time. JavaScript pushes those errors back to the runtime of the application. That's why supporters of strong typing hate JavaScript so much: it seems like a big step backward. They're always looking for JavaScript alternatives.

Which Is Better?

I'm looking for a program to parse XML, find a particular element, make a change and save the file. On a team of Java programmers, I wrote the code in the dynamic language Python.

import sys  import string  from xml.dom.minidom import parse    dom = parse(sys.argv[1])    for node in dom.getElementsByTagName('property'):      attr = node.attributes['name'];      if attr.value == 'my value':          node.childNodes[0] = dom.createTextNode('my new value');    file = open(sys.argv[1], 'w');  file.write(dom.toxml('UTF-8'));  file.close();  

This program finds every property node with the name my value and sets the contents to my new value. I define the variables dom for my XML document, node for each node of XML that I find, and attr for the attribute. Python doesn't even require the keyword var, and it doesn't know that node has childNodes or that attr has value until I call it.

To change an XML file in Java, I would write a new class, open an input stream, call the DOM parser, traverse the tree, call the right methods on the right elements, and write the file out to an output stream. I could simplify some of those calls with a library, but I'd still have the overhead of defining my static types. All of the extra definition of objects and variables could easily take a hundred lines. Python takes 14.

Dynamic code is generally shorter than static code because it needs less description of what the code is going to do. This program would be shorter in Python than in C++ and shorter in Ruby than in Objective-C.

So, which is better?

The static programmer says: The dynamic programmer says:
"Static typing catches bugs with the compiler and keeps you out of trouble." "Static typing only catches some bugs, and you can't trust the compiler to do your testing."
"Static languages are easier to read because they're more explicit about what the code does." "Dynamic languages are easier to read because you write less code."
"At least I know that the code compiles." "Just because the code compiles doesn't mean it runs."
"I trust the static typing to make sure my team writes good code." "The compiler doesn't stop you from writing bad code."
"Debugging an unknown object is impossible." "Debugging overly complex object hierarchies is unbearable."
"Compiler bugs happen at midmorning in my office; runtime bugs happen at midnight for my customers." "There's no replacement for testing, and unit tests find more issues than the compiler ever could."

Static typing made our Person object easier to understand. We defined a Person with a name and agreed about which fields mattered ahead of time. Establishing everything clearly makes our Person easier to debug but harder to change.

What happens when someone in our application needs a second email address? In a static language, we'd need to redefine the object so that everyone has two email addresses, even though most people don't. Add in a birthday, favorite color and a few more items and every Person will have twice as many fields as they need.

Dynamic languages make this problem much easier. We can add a second email field to one Person without adding it to everyone. Now, each object has only the fields it needs. A static language could handle this with a generic map of values, but then you're fighting the static environment to write dynamic code. C programmers spent years tearing their hair out over errors in type conversions, corrupt values, and the terrible bugs that come from small typos. They've been burnt by weak typing, and dynamic typing looks weak.

Dynamic programmers spent years banging their heads over the rigidity of static languages, and they crave the freedom to make the languages do what they want.

I've seen static code get overly complex and become impossible to follow. Try debugging an enterprise JavaBean or understanding all of the details of generics in Java. I've seen dynamic code turn into a giant mound of unmaintainable spaghetti. Look at the myriad of terrible JavaScript programs before jQuery. Node.js does some amazing things, but I can't look at it without traumatic flashbacks of horrible JavaScript that I've debugged.

Conclusion

There's no clear conclusion. Dynamically typed languages are popular now. The pendulum will swing back and forth many times in the coming years. The only solution is flexibility. Learn to work in each environment and you'll work well with any team.

Image credits of image on front page: Alexflx54

(al) (ea)


© Zack Grossbart for Smashing Magazine, 2013.

Low Levels of Toxic Gas Found To Encourage Plant Growth
Apr 18th 2013, 09:20

olsmeister writes "Hydrogen Sulfide is a toxic, flammable, foul-smelling gas that some theorize may have been at least partially responsible for some of Earth's mass extinctions, including the Permian-Triassic event, which killed well over half of the species on the planet. Now, thanks to a fortuitous accident, doctoral student at the University of Washington seems to have discovered that very low doses of the gas seems to greatly enhance plant growth, causing plants to germinate more quickly and grow larger. The finding could have far reaching implications for both food and biofuel production."

Share on Google+

Read more of this story at Slashdot.



A Simple JavaScript Library for Themable FPS Meter
Apr 18th 2013, 07:10

Advertise here via BSA

FPSMeter is a simple JavaScript library for sexy, fast, and themable FPS meter. It can measure frames per second, number of milliseconds between frames, and number of milliseconds it takes to render one frame when using the .tickStart() method.

FPSMeter supports multiple instances on one page, has show/hide methods that also pause the meter rendering, and color heatmaps that make themes even more pretty. It is released under MIT License.

fpsmeter

Requirements: JavaScript Framework
Demo: http://darsa.in/fpsmeter/
License: MIT License

Sponsors

Professional Web Icons for Your Websites and Applications

Interactive Playground for Snippets of CSS & HTML
Apr 18th 2013, 07:01

Advertise here via BSA

Dabblet is an interactive playground for quickly testing snippets of CSS and HTML code. It uses -prefix-free, so that you won’t have to add any prefixes in your CSS code. You can save your work in Github gists, embed it in other websites and share it with others.

It currently only supports modern versions of Chrome, Safari and Firefox. All posted code belongs to the poster and no license is enforced. Dabblet itself is open source software and is distributed under a NPOSL-3.0 license. you can fork dabblet on github as well.

dabblet

Requirements: -
Demo: http://dabblet.com/
License: NPOSL-3.0 License

Sponsors

Professional Web Icons for Your Websites and Applications

Joomla 3.x. How to change Google Map coordinates
Mar 5th 2013, 13:34

Our Support team is ready to present you a new tutorial that will show you how to change Google Map coordinates in Joomla 3.x templates.

PrestaShop 1.5.x. How to move your website from one domain to another
Mar 1st 2013, 11:38

This tutorial will show you how to move your PrestaShop 1.5.x website from one domain to another.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions