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

SEARCH KEYWORD -- Assignment



  Five-minute Multimethods in Python

So what are multimethods? I'll give you my own definition, as I've come to understand them: a function that has multiple versions, distinguished by the type of the arguments. (Some people go beyond this and also allow versions distinguished by the value of the arguments; I'm not addressing this here.) As a very simple example, let's suppose we have a function that we want to define for two ints, two floats, or two strings. Of course, we could define it as follows: def foo(a, b): if...

   Python,Multimethod,Argument list,Version,Overloadding     2011-12-07 08:41:03

  Recursive class initialization in Java

When a Java class is referenced and initialized, it has to go through the loading and linking first. Once the loading and linking complete successfully. The class will be initialized. The static variables and constant variables will be initialized during this process. Once the class is initialized, it is ready for use. If when class A is initialized and it is referencing a class B, the class B will also get initialized. But what will happen if class B is referencing class A as well? This is call...

   Java,JVM,class initialization,static final     2015-04-15 21:04:29

  Restore mocked variables in GoLang unit test

One of the guarding principles of writing unit test is that there should be no real external calls for dependant services. Unit test should run by its own and can run without issues on any environment including local, build, test environment. This indicates there should be some mock responses whenever an external call is needed so that different unit test scenarios can be covered. How can this be done in GoLang? In GoLang, anything can be assigned to a variable even including functions. A variab...

   GOLANG,UNIT TEST,MOCK FUNCTION,RESTORE MOCK     2021-12-10 20:43:00

  Some tips for writing proper emails

Email is now becoming one necessity of working. We may receive hundreds of emails everyday, they may from our colleagues, friends or clients. We need to exchange ideas, arrange meetings , asking for help etc though email in our work. A proper email can help us achieve what we want to achieve. Here we share some tips for writing a proper email.At the beginning of an email : Thank the reader is a good way to start the email, thank the reader may make the reader feel happy, especially when you ask ...

   EMAIL,TIP,FORMAT,TEMPLATE     2012-07-02 12:26:32

  The Go Pointer Magic

Go is a language with the pointer type, by which we can Pass pointer into a function and update value in-place. Add methods to a struct as (* T) A, which is different from (T) A(). However, the pointer is type-safe in Go, meaning that there are such restrictions of the pointer. Different types of pointers are unconvertible. Pointer type cannot be used for calculation. Pointer types cannot be compared, either == nor !=. No mutual assignment between different pointer-...

   GOLANG,POINTER,UNSAFE     2021-10-03 02:18:57

  Function Pointers in C are Underrated

The function pointer in C is, in my opinion, one of the most ignored gems of the language. It’s the kind of feature you rarely need, and then suddenly, one day, you find yourself in dire need of it, as evidenced by the real-life use-case below. If you don’t know what a function pointer is in the first place, here’s the meat of it: it gives you the ability to pass a function around like a normal variable. If you know Python / Ruby / Lisp, you might know it by the name...

   C,Pointer,Analysis     2012-03-24 05:23:09

  Understand unsafe in GoLang

Before going to understand unsafe package in GoLang, the first thing needs to talk about is the pointer in GoLang. If you have a background of C language, you must know what pointer means and its usage. With pointer, you are free to operate any data at memory level which means you have great power, but this means that you have great responsibility as well. That's why it might be considered unsafe in lots of cases. Take a look at a simple example of doubling an integer. package main import "fmt"...

   GOLANG,UNSAFE,ZERO-COPY     2020-03-14 23:18:00

  How to read Haskell like Python

Have you ever been in the situation where you need to quickly understand what a piece of code in some unfamiliar language does? If the language looks a lot like what you’re comfortable with, you can usually guess what large amounts of the code does; even if you may not be completely familiar how all the language features work.For Haskell, this is a little more difficult, since Haskell syntax looks very different from traditional languages. But there's no really deep difference here; you j...

   Haskell,Python,Format,Like,Similarity     2011-11-15 08:45:39

  IE ActiveX(”htmlfile”) Transport, Part II

In my last post I discussed using the ActiveX(”htmlfile”) technique to provide a usable streaming transport in Internet Explorer. The solution I provided will work, but since writing the last article I’ve made significant progress in understanding why IE behaves the way it does with respect to the streaming transport. The previous solution amounted to creating an array of messages, pushing messages on that array from the htmlfile iframe, and popping messages off of the array i...

   IE,Http,Streaming,htmlfile,Transport,Act     2011-09-05 04:07:02

  Why Dynamic Programming Languages Are Slow

In a statically typed language, the compiler knows the data-type of a variable and how to represent that. In a dynamically-typed language, it has to keep flag describing the actual type of the value of the variable, and the program has to perform a data-dependent branch on that value each time it manipulates a variable.  It also has to look up all methods and operators on it. The knock-on effect of this on branching and data locality is lethal to general purpose runtime performance. T...

   Dynamic language,Slow,Analysis     2012-03-26 15:33:11