Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Pattern



  A String is not an Error

I decided to write a little article to discourage an unfortunately common pattern in Node.JS modules (and browser JavaScript, to a lesser extent) that can boil down to these two examples: // A:function myFunction () {  if (somethingWrong) {    throw 'This is my error'  }  return allGood;} and // B: async Node.JS-style callback with signature `fn(err, …)`function myFunction (callback) {  doSomethingAsync(function () {    // …    if (...

   JavaScript,Node.js,String,Error object     2011-12-23 08:00:32

  How Integers Should Work (In Systems Programming Languages)

My last post outlined some of the possibilities for integer semantics in programming languages, and asked which option was correct. This post contains my answers. Just to be clear: I want practical solutions, but I’m not very interested by historical issues or backwards compatibility with any existing language, and particularly not with C and C++. We’ll start with: Premise 1: Operations on default integer types return the mathematically correct result or else trap. This is th...

   Number,Algorithm,System,Embedded system     2011-12-05 12:48:41

  Macro vs. Micro Optimisation

So there's recently been a bit of hype about another Colebourne article: http://blog.joda.org/2011/11/real-life-scala-feedback-from-yammer.html I'd like to respond to a few points he makes. First - You should evaluate Scala and pay attention to its benefits and flaws before adopting it.  Yes, there are flaws to Scala.   Working at typesafe makes you more aware of some of them.  We're actively working to reduce/minimize/get rid of these.   In my opinion, the negat...

   Optimization,Performance,Micro,Macro,Software     2011-11-30 12:04:25

  When and How to Use the Go Channel

Go’s concise structure and powerful native library enable us to hit the ground running easily. It is more efficient than Java or Python when implementing the same functions, especially its concurrent programming, which is very handy and widely admired due to its goroutine and channel. goroutine and channel has much to dig into, and let’s start with channel, which I used to consider narrowly as a message queue to transfer data between gorouti...

   GOLANG,CONTEXT,CHANNEL     2022-09-17 23:06:36

  Python Performance Tips, Part 1

To read the Zen of Python, type import this in your Python interpreter. A sharp reader new to Python will notice the word “interpreter”, and realize that Python is another scripting language. “It must be slow!” No question about it: Python program does not run as fast or efficiently as compiled languages. Even Python advocates will tell you performance is the area that Python is not good for. However, YouTube has proven Python is capable of serving 40 million videos...

   Python,Performance,Efficiency,Tips     2012-02-14 10:50:22

  JavaScript Attack/Defend

As developers and designers we work hard to build visually attractive, fast and easy to maintain applications. Our goals are to make sure the applications we build stick to users and keep them coming back for more. Security is not always at the forefront of our minds. No one intentionally builds insecure software but often a lack of security knowledge leads developers to build vulnerabilities into their applications. In this article we are going to examine two web security attacks, how they are ...

   JavaScript,Attack,Defend,Security,Cross site     2011-10-13 13:09:11

  insertAdjacentHTML() Enables Faster HTML Snippet Injection

In Firefox 8, we’ve added support for insertAdjacentHTML(). It’s an ancient feature of Internet Explorer that has recently been formalized in HTML5 and then spun out into the DOM Parsing specification. The bad news is that Firefox is the last major browser to implement this feature. The good news is that since other major browsers implement it already, you can start using it unconditionally as soon as the Firefox 8 update has been rolled out to users.Basic Usage...

   InsertAjacentHTML,Firefox,HTML5,DOM     2011-11-10 10:52:00

  Translating math into code with examples in Java, Racket, Haskell and Python

Discrete mathematical structures form the foundation of computer science.These structures are so universal that most research papers in the theory of computation, programming languages and formal methods present concepts in terms of discrete mathematics rather than code.The underlying assumption is that the reader will know how to translate these structures into a faithful implementation as a working program.A lack of material explaining this translation frustrates outsiders.What deepens that fr...

   Math,Algorithms,Formula,Program,Python     2011-11-14 08:43:15

  It’s Not China; It’s Efficiency That Is Killing Our Jobs

The majority of wealth is now concentrated at the top of the social ladder. This is particularly true in the US, and the gap is widening every year. This, I believe, is because of efficiency, not China. Today the best ideas can efficiently and quickly propagate worldwide, and everyone can efficiently find them and buy them. This makes the owners of these ideas filthy rich, and those ideas that are not the best, can hardly survive. It’s not just transfer of information that is fast; wealth...

   China,Efficiency,Job,Opportunity,Wealth     2011-10-23 11:43:18

  Efficiency of code execution

If you want to optimize your program codes, you need to find their Hotspot, i.e, the codes which are executed most frequently. If you can optimize this portion of codes a bit, you may gain much improvement of your code efficiency. Here I give you three examples about efficiency of code execution.1. PHP's Getter and Setter (From Reddit)This example a quite simple, you can skip it if you want.Consider the code below, we can find it's slower when we use Getter/Setter method to read a member variabl...

   Code, Efficiency,Analysis,Trick     2012-07-13 10:59:21