问:
How to better integrate a unix development environment into Windows
I'm mostly a Windows user but I do most of my development (essentially web development) using unix tools and software. I've been going back and forth between using a dedicated lubuntu virtual machine on Virtualbox and using some tools directly in windows (msgit, python, django), but none of these approaches is entirely satisfactory.

I'd like to hear of ways other devs use to better integrate a unix workflow into windows. For instance tighter integration between a linux and vm and windows. The vagrant demo showed how a VM could work off of a windows project folder and I found that nice. I'd like to hear of other tools and tips that would help mimic the workflow one can find on OS X (of course I understand that it cannot be as tightly integrated on Windows as it doesn't have the same unix underpinnings).

PS: I have tried cygwin as well

EDIT for clarifications about What I find lacking (thanks to axblount for pointing that out) :
unix tools like msys et al do not work as well as their native unic counterparts. Many scripts, installers require further configuration or do not work at all. For instance getting virtualenvwrapper to work is not very straightforward.
virtualbox: ideally I would like to use windows software (photoshop, sublime text 2) seamlessly with linux. I mostly use a FTP client atm to move over files edited on the windows side which is a tedious process.

SUMMARY:
It seems there are no established solutions. As a temporary solution I will probably try to use the native versions of frameworks and libraries through the windows command line when possible and switch to a tool like vagrant for incompatible programs.

MORE INFO FROM REPLIES AND COMMENTS:
The case-sensitivy issue seems to work against windows as pointed out by @GlenPeterson

答:
Most of your development (essentially web development) use unix tools and software.

You have tested different alternatives to use those tools in Windows but as of now, you haven't found one that works as well as the real thing.

Then you should really consider migrating yourself to Linux as your desktop OS, and virtualize Windows for everything else.

Believe me, you will not regret it. Your desktop will be faster, more secure, no-virus and you will have all the tools you need for your development projects.

EDIT:

Accommodating for a great comment from @GlenPeterson:

If you are deploying to Unix/Linux then you should be working on a case-sensitive OS.  Windows' case-insentiveness can cause you problems someday.


问:
Exception Handling Frequency/Log Detail
I am working on a fairly complex .NET application that interacts with another application. Many single-line statements are possible culprits for throwing an Exception and there is often nothing I can do to check the state before executing them to prevent these Exceptions.

The question is, based on best practices and seasoned experience, how frequently should I lace my code with try/catch blocks? I've listed three examples below, but I'm open to any advice.

I'm really hoping to get some pros/cons of various approaches. I can certainly come up with some of my own (greater log granularity for the O-C approach, better performance for the Monolithic approach), so I'm looking for experience over opinion.

EDIT: I should add that this application is a batch program. The only "recovery" necessary in most cases is to log the error, clean up gracefully, and quit. So this could be seen to be as much a question of log granularity as exception handling. In my mind's eye I can imagine good reasons for both, so I'm looking for some general advice to help me find an appropriate balance.

Monolitich Approach

```<code>class Program{
    public static void Main(){
        try{
            Step1();
            Step2();
            Step3();
        } catch (Exception e) {
            Log(e);
        } finally {
            CleanUp();
        }
    }

    public static void Step1(){
        ExternalApp.Dangerous1();
        ExternalApp.Dangerous2();
    }

    public static void Step2(){
        ExternalApp.Dangerous3();
        ExternalApp.Dangerous4();
    }

    public static void Step3(){
        ExternalApp.Dangerous5();
        ExternalApp.Dangerous6();
    }
}
</code>```

Delegated Approach

```<code>class Program{
    public static void Main(){
        try{
            Step1();
            Step2();
            Step3();
        } finally {
            CleanUp();
        }
    }

    public static void Step1(){
        try{
            ExternalApp.Dangerous1();
            ExternalApp.Dangerous2();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step2(){
        try{
            ExternalApp.Dangerous3();
            ExternalApp.Dangerous4();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step3(){
        try{
            ExternalApp.Dangerous5();
            ExternalApp.Dangerous6();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }
}
</code>```

Obsessive-Compulsive Approach

```<code>class Program{
    public static void Main(){
        try{
            Step1();
            Step2();
            Step3();
        } finally {
            CleanUp();
        }
    }

    public static void Step1(){
        try{
            ExternalApp.Dangerous1();
        } catch (Exception e) {
            Log(e);
            throw;
        }
        try{
            ExternalApp.Dangerous2();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step2(){
        try{
            ExternalApp.Dangerous3();
        } catch (Exception e) {
            Log(e);
            throw;
        }
        try{
            ExternalApp.Dangerous4();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step3(){
        try{
            ExternalApp.Dangerous5();
        } catch (Exception e) {
            Log(e);
            throw;
        }
        try{
            ExternalApp.Dangerous6();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }
}
</code>```

Other approaches welcomed and encouraged. Above are examples only.

答: Catch at the granularity that is meaningful to your application. If you are not going to take a different action for a different exception source, then there is no need to break those things apart.</p>

ContentLicense: CC BY-SA 3.0

Title: Exception Handling Frequency/Log Detail


答:
I favor approach one.

The exceptions are going to go up the call stack to the try/catch block in the main method, and get logged there anyway.

Don't catch in your step methods unless you can handle each exception locally somehow.

Title: Exception Handling Frequency/Log Detail

Body:
I am working on a fairly complex .NET application that interacts with another application. Many single-line statements are possible culprits for throwing an Exception and there is often nothing I can do to check the state before executing them to prevent these Exceptions.

The question is, based on best practices and seasoned experience, how frequently should I lace my code with try/catch blocks? I've listed three examples below, but I'm open to any advice.

I'm really hoping to get some pros/cons of various approaches. I can certainly come up with some of my own (greater log granularity for the O-C approach, better performance for the Monolithic approach), so I'm looking for experience over opinion.

EDIT: I should add that this application is a batch program. The only "recovery" necessary in most cases is to log the error, clean up gracefully, and quit. So this could be seen to be as much a question of log granularity as exception handling. In my mind's eye I can imagine good reasons for both, so I'm looking for some general advice to help me find an appropriate balance.

Monolitich Approach

```<code>class Program{
    public static void Main(){
        try{
            Step1();
            Step2();
            Step3();
        } catch (Exception e) {
            Log(e);
        } finally {
            CleanUp();
        }
    }

    public static void Step1(){
        ExternalApp.Dangerous1();
        ExternalApp.Dangerous2();
    }

    public static void Step2(){
        ExternalApp.Dangerous3();
        ExternalApp.Dangerous4();
    }

    public static void Step3(){
        ExternalApp.Dangerous5();
        ExternalApp.Dangerous6();
    }
}
</code>```

Delegated Approach

```<code>class Program{
    public static void Main(){
        try{
            Step1();
            Step2();
            Step3();
        } finally {
            CleanUp();
        }
    }

    public static void Step1(){
        try{
            ExternalApp.Dangerous1();
            ExternalApp.Dangerous2();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step2(){
        try{
            ExternalApp.Dangerous3();
            ExternalApp.Dangerous4();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step3(){
        try{
            ExternalApp.Dangerous5();
            ExternalApp.Dangerous6();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }
}
</code>```

Obsessive-Compulsive Approach

```<code>class Program{
    public static void Main(){
        try{
            Step1();
            Step2();
            Step3();
        } finally {
            CleanUp();
        }
    }

    public static void Step1(){
        try{
            ExternalApp.Dangerous1();
        } catch (Exception e) {
            Log(e);
            throw;
        }
        try{
            ExternalApp.Dangerous2();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step2(){
        try{
            ExternalApp.Dangerous3();
        } catch (Exception e) {
            Log(e);
            throw;
        }
        try{
            ExternalApp.Dangerous4();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }

    public static void Step3(){
        try{
            ExternalApp.Dangerous5();
        } catch (Exception e) {
            Log(e);
            throw;
        }
        try{
            ExternalApp.Dangerous6();
        } catch (Exception e) {
            Log(e);
            throw;
        }
    }
}
</code>```

Other approaches welcomed and encouraged. Above are examples only.


问:
Vim key mappings / plugin XCode?
I'm a developer who mostly does web stuff in ruby and C#.

I'd like to start tinkering with iOS and Mac development.

Over the last few month i've been trying to get fluent in one set of key bindings (vi / vim because it just feels right).

I have the awesome ViEmu installed for visual studio on windows which gives me a ton of the vim awesomeness side by side with visual studio power toys.

Is there anything like this for xcode?

I know I could set up MacVim as the default editor, but I'm not too interested in this as it means losing all of xcode's cocoa awareness.

The other option of course would be to go for the lowest common denominator and switch to emacs (as the mac keybindings are based massively on emacs) but let's not think about that for too long. :P

答: I just cloned the git repository xVim and ran the build in Xcode (as the instructions say), and it works like a champ.   Right now, it has a limited keyset, but has what I need for now.   And you get to look at the source code to learn how to write an XCode Plugin and work with Objective-C</p>

Title: Vim key mappings / plugin XCode?


答:
Ask yourself why exception syntax was invented when it's perfectly possible to handle unexpected conditions without them.  In C, all code looks like your obsessive-compulsive approach, except for instead of a try/catch block, the return value of the function indicates success or failure.

The reason exceptions were invented is to allow code to look like your monolithic approach.  It's much cleaner, follows the DRY principle, and it's easier to have people write the lower layers without imposing strict rules on exception handling in every single function.  That should be your default mode of operation, and you should only also catch exceptions at the lower layers if you can actually recover from the error, not just report it.

Title: Exception Handling Frequency/Log Detail


问:
WCF an Entity Framework connection
I have a 100+ users on a Silverlight application that uses WCF and entity framework.

Everyone has their own database and here comes my problem.

How do I make sure that only the user gets access to his database via WCF. Do I have to send the connectionstring every time I make a call to the service, or?

答:
Sending the connection string to the service would not be a good idea. The caller should really have no idea if there is one database or one million (unless you are building something truly odd, like a database front end, along the lines of phpMyAdmin).

On the Entity Framework side of things, you can change the connection when your context is created. So, for example:

    public class EFContext : DbContext
    {
        public EntityFrameworkSession()
            : base(DetermineConnection(), true)
       {
       }

       private static DbConnection DetermineConnection()
       {
           // create an ADO.NET connection here based on your criteria
       }
    }
```

Which would leave open the connection of how to store/retrieve the connection. There are a few ways to handle this, beginning with the simplest (storing multiple connection strings in your web.config and pulling the one that applies to the current user) to more  sophisticated methods (like putting all of your connection strings in an encrypted database).

Being the paranoid type, I would be more likely to do the latter.

The method that makes sense for authenticating a user (and, thereby having the information to determine which database connection to use) is mostly dependent on your setup. Some good links on setting this up with WCF would include:

http://msdn.microsoft.com/en-us/library/ff647503.aspx

http://msdn.microsoft.com/en-us/library/bb386582(v=vs.100).aspx

Since you are using WCF, I would use Active Directory if it is at all feasible. Windows authentication tends to play very nicely with .NET security.

Title: WCF an Entity Framework connection

Body:
Sending the connection string to the service would not be a good idea. The caller should really have no idea if there is one database or one million (unless you are building something truly odd, like a database front end, along the lines of phpMyAdmin).

On the Entity Framework side of things, you can change the connection when your context is created. So, for example:

    public class EFContext : DbContext
    {
        public EntityFrameworkSession()
            : base(DetermineConnection(), true)
       {
       }

       private static DbConnection DetermineConnection()
       {
           // create an ADO.NET connection here based on your criteria
       }
    }

Which would leave open the connection of how to store/retrieve the connection. There are a few ways to handle this, beginning with the simplest (storing multiple connection strings in your web.config and pulling the one that applies to the current user) to more  sophisticated methods (like putting all of your connection strings in an encrypted database).

Being the paranoid type, I would be more likely to do the latter.

The method that makes sense for authenticating a user (and, thereby having the information to determine which database connection to use) is mostly dependent on your setup. Some good links on setting this up with WCF would include:

http://msdn.microsoft.com/en-us/library/ff647503.aspx

http://msdn.microsoft.com/en-us/library/bb386582(v=vs.100).aspx

Since you are using WCF, I would use Active Directory if it is at all feasible. Windows authentication tends to play very nicely with .NET security.


问:
Visual C++, CMap object save to blob column
I have a MFC CMap object, each object stores 160K~ entries of long data. I need to store it on Oracle SQL. We decided to save it as a blob. Since we do not want to make additional table, we also thought about saving it as local file, with the SQL column pointing to that file.  We would prefer to just keep it as blob on the server and clear the table every couple of weeks.

The table has a sequential key as ID, and 2 column of time. I need to add the blob column in order to store on every row that CMap.

Can you recommend a guide to do this approach (read/write Map to blob or maybe a clob)? Thanks.

答:
I do not think this is a great approach:

For starters Oracle BLOB/CLOB handling in the ODBC and MFC classes is
not great and can be subject to some non-trivial rules (e.g. The LOB
columns must be last in the select statement, positional updates are
not always possible).

Secondly, by hiding it all in the blob you
lose ability to easily query content (e.g find only the records that
have the "sample value" in the map), reorganize into a different
form.

Thirdly, if the content of the BLOB references other DB
items, you can miss out on validation and ability to maintain the
integrity if the referenced data changes.

It is difficult to see a downside in just normalizing the data and storing it in the separate, referenced table. You can even assemble it into a BLOB later with a stored procedure, if that is a requirement.


问:
Ideal "intermediate" file format to use for structured/styled text?
I have files that I want to make available in an variety of formats:

HTML

PDF

EPUB

Plain Text (maybe)

Most of the files will be sourced in doc, docx, or rtf format, so that needs to be considered.

So I need some kind of format that converts well from docx, doc, and rtf and has plenty of libraries for converting into PDF, EPUB, HTML etc. Ideally libraries in Python, but Java is also okay.

答:
"doc" and "rtf" can be easily converted to "docx" using MS Word. "docx" can be can be converted to PDF, EPUB, HTML or plain text either by Word's buildin converters, or by third party tools.

Here is a link telling you more about a clean Word->HTML conversion: http://webdesign.about.com/od/beginningtutorials/qt/doc-to-html.htm

For Word->EPUB a simple google search will reveal you some free online converters and some commercial tools.

If, for what reasons ever, you don't like that solution and want a more "vendor neutral" intermediate format, then use docbook. But don't expect that this will increase the overall quality of the results, since every additional step in the conversion chain will most probably add some additional data loss.


问:
How Visual Studio could help to avoid duplicating code?
I work within a team of developers. Everyone is making their changes without carrying too much if the same thing is already implemented in the codebase. This leads to classes constantly growing and to severe duplication.

I want to add line items to class definitions from which a developer could judge what this class has.

Would it help?

How to do it in Visual Studio?

If it wouldn't help, what would be the better alternative to encourage the developers to check if something exists before implementing it?

答:
It sounds like you are already in the situation, so I would suggest:

Use the new feature in Visual Studio 2012 called Code Clone Detection.

Enter all the identical and the top 25% of similar into the backlog.

Make the folks creating the duplicates clean it up.

Do this a few times and people will start to realize they need to be more careful.

If you don't have Ultimate or Premium edition then look at CodeRush or Resharper they have similar features.


问:
Does NASA license the software that it develops?
NASA provides a visualization software called Panoply. There is a Credits and Acknowledgments page that acknowledges and lists the licenses of software dependencies, but provides no information about its own license.

I have looked at other software produced by NASA, including the source code for GISS and can not find any information about a licence.

The closest information that I can find is in the FAQ for the global climate model EdGCM Global that says the code is in the "public domain"

is it standard practice at NASA to release code into the public domain?

are there exceptions?

Can I assume that Panoply is public domain and can be used without restriction other than than those imposed by licenses of software dependencies?

Is the absence of specific permission to reuse the code a concern (this issue was raised in the answer to a separate question)

How common is this practice across government agencies?

答:
tl;dr - NASA software is not public domain.

NASA releases some software under the NOSA. A great deal of NASA software is classified or restricted to NASA staff. The source code for the GISS GCM Model E requires that you be internal to NASA to access it. The Johnson Space Center has a complete list of the various levels of control over licenses.


问:
Why it is necessary to to test my iPhone app on actual iPhone device
I developed one application for iPhone and now I want it on App Store. So many my iOS geek friends told me to test it on actual device i.e. on iPhone.

So I wonder that why it is necessary to to test my iPhone app on actual iPhone device though they (Apple) have given "simulator" which is near about same as my device?

答:
Because you are not going to have a lot of users walking around with a simulator in their pocket.

EDIT:
Whenever you're testing your app on a simulator (or emulator), you're using a fake device that cannot be, by definition, a 100% accurate representation of the real thing.
An emulator might be more accurate than a simulator, but there will still be differences. The only 100% accurate emulator is the device itself.

Designing, testing, optimizing code on a simulator results in an application that is finely tweaked to optimally work on a.. simulator. Your users will not have simulators, though; you're targeting the wrong device. A very similar one; but not the very same device that your users will use.

This can lead to several kind of issues. Severe issues like bugs, crashes are certainly your top priority. But there are others; such as ergonomics. Try to hold the Simulator in your hand. Just try. UI elements are rendered on a different screen, with possibly different color rendering, and certainly different dimensions (a problem exacerbated by the beautiful retina displays, not entirely solved by also using a retina macbook, for instance).
Are those exquisite shades of gray equally distinguishable on a device in the sun?

Subtle differences in speed, and different sensor emulation (or lack thereof), can sometimes dramatically alter the experience.

If your application relies on internet connectivity, there is no way for you to switch between LTE, 3G, EDGE or GPRS, to test different scenarios, or even test different carriers.

Are you going to support jailbroken devices? Perhaps you aren't, but if you are, you're probably willing to test your app with one. Or, if you aren't, are you confident that you're detecting a jailbroken environment?

Is the iPad game you're developing on the simulator equally usable when a user is holding its weight and using her fingers to play?
Are unintended multiple touches able to break your app, something that you weren't able to anticipate in the safe single-touch (or symmetric double-touch) simulator environment?

Would you be comfortable boarding a plane commanded by a pilot who has never actually left the ground?

The bottom line is: before shipping, please do use the same device that your users are going to use. None of them is going to use a Simulator.


问:
How do you use blank lines in your code?
There has been a few remarks about white space already in discussion about curly braces placements.

I myself tend to sprinkle my code with blank lines in an attempt to segregate things that go together in "logical" groups and hopefully make it easier for the next person to come by to read the code I just produced.

In fact, I would say I structure my code like I write: I make paragraphs, no longer than a few lines (definitely shorter than 10), and try to make each paragraph self-contained.

For example:

in a class, I will group methods that go together, while separating them by a blank line from the next group.

if I need to write a comment I'll usually put a blank line before the comment

in a method, I make one paragraph per step of the process

All in all, I rarely have more than 4/5 lines clustered together, meaning a very sparse code.

I don't consider all this white space a waste because I actually use it to structure the code (as I use the indentation in fact), and therefore I feel it worth the screen estate it takes.

For example:

```<code>for (int i = 0; i < 10; ++i)
{
    if (i % 3 == 0) continue;

    array[i] += 2;
}
</code>```

I consider than the two statements have clear distinct purposes and thus deserve to be separated to make it obvious.

So, how do you actually use (or not) blank lines in code ?

答: I don't always write software, but when I do, I use blank lines for clarity.</p>

ContentLicense: CC BY-SA 2.5


问:
Bump version before kicking off new development or when tagging a release, which is better?
Some projects bump version before kicking off a new development, while the other projects  bump version when tagging a release.

Which approach is better?

If version number not changed at the start of new phase, the developers may forget to change it and simply release the program.

If version number changed before tagging release, then 2 the version numbers (tag and Makefile/AssemblyInfo.cs) do not match.

git describe may give you v1.2.3.4-15-g1234567 if current revision is after v1.2.3.4, but you have already changed the files to have v1.2.3.5

答:
When using four-segment version numbers like .NET assemblies have, I prefer using a version control tag to set the first three segments, then the fourth segment is the number of commits since that tag.

For example, a version gets tagged "v1.2.3". If git-describe returns "v1.2.3-4-g1a2b3c4", then when built that assembly gets versioned as 1.2.3.4.

If a tag is later applied to that version, then git-describe will return "v1.2.4" instead, which represents version 1.2.4.0. The next commit would then be 1.2.4.1.

The benefits I find from this system are:

Every commit automatically increments the version number.

A version can be  made a ".0" release by simply tagging it.

Though not perfect, this system works with DVCS because it counts the number of commits since the most recent tag.


问:
Is it important to know C/C++ for Android development?
Is it possible to use only Java (without C++ /NDK) for building good, fast, beautiful Android apps (including 3D development)?

When I look for Android developer position requirements (vacancies), I see that knowledge of C/C++/NDK is very important. Some companies even require to build their test tasks using only C++ (OpenGL).

答: It works perfectly when modifying for C/C++ code, but when java code is modified it does not automatically rebuild it. Java modifications are not send to emulator or device.</p>


问:
Is modern C++ replacing C#? Is Microsoft pushing developers to adopt C++?
I hear about modern C++ popularity and some talks about migrating back to C++ from C# or other C-like languages.

I know about C++11 features but I would like to hear your experiences, especially from developers who migrated from C# to C++.

More importantly, does Microsoft push developers to use C++? If yes, why?

答:
C++ still have Header files, flexible preprocessors (#define), ... such stuffs some people considered these features 'evil' or 'difficult to manage'.

C#, on the other hand, use metadata, no need to write and maintain header files.

About Microsoft adding more features to C++: Not a wondering matter.

Every C++ compiler is adding more features, including C++11 features. gcc is also.


问:
How can I improve my application's memory use?
I am writing a C# application, and can see the memory usage increasing as the running time of the application increases.

Are there any tools or techniques I could monitor my application's memory use, identify memory leaks and generally improve my application's memory use?

答:
The following resources may help you

For Tool

.NET Memory Profiler
As good as monitoring the memory is by itself, you're probably thinking of memory profiling to identify leaks or stale objects.

.NET Memory Profiling
This tool helped me to solve many different issues related to memory management in C# .Net application I have to work with.

Tool Mentor This tool describes how to use Rational Purify
to profile and improve memory usage in a managed code application.
This tool mentor is applicable for use with systems running the
Microsoft .NET Framework on Microsoft Windows.

VMMap It is a clever tool that gives you a picture of what is
taking up the memory in a running process.

ANTS Memory Profiler This tool finds memory leaks and optimize memory usage
in your .NET application.

For Concepts &Techniques

Understanding Visual Studio (2010) memory consumption.


问:
What are options for 3rd Party Centralized Software Settings Management?
I am an architect in an enterprise looking to build a SaaS solution.  Our products are distributed over many different deployable containers,  Web Services, Web UI's, etc.

I am looking for some open-source or 3rd party software solution to manage the settings of our application.  These would be similar to the settings you might find in Word or Eclipse or Visual Studio.  The settings would control various behaviors and features of the product. (Probably not settings like which database to connect to but more like, should I show line numbers on the page or not by default..).  Ideally, we would be able to store values for different dimensions (by tenant, by user, by application environment... )

Because we have so many different deployables, I am looking for a centralized solution that can provide a web service that each of the deployables can get their individual settings from.

Does anyone know of a centralized service providing this sort of features or give me some help in searching for an alternative to rolling our own?

答:
We use the database itself for this.

We have a table where every record has a "Last Updated" datetime field for the settings stored in the record (updated using a trigger).

Our apps check the datetime field for whichever settings they're interested in and if it's more recent than the value they have in memory, the settings are reloaded and the in-memory datetime updated.

Works for many different apps checking 1 or more groups of settings.


问:
What triggered the popularity of lambda functions in modern mainstream programming languages?
In the last few years anonymous functions (AKA lambda functions) have become a very popular language construct and almost every major / mainstream programming language has introduced them or is planned to introduce them in an upcoming revision of the standard.

Yet, anonymous functions are a very old and very well-known concept in Mathematics and Computer Science (invented by the mathematician Alonzo Church around 1936, and used by the Lisp programming language since 1958, see e.g. here).

So why didn't today's mainstream programming languages (many of which originated 15 to 20 years ago) support lambda functions from the very beginning and only introduced them later?

And what triggered the massive adoption of anonymous functions in the last few years? Is there some specific event, new requirement or programming technique that started this phenomenon?

IMPORTANT NOTE

The focus of this question is the introduction of anonymous functions in modern, main-stream (and therefore, maybe with a few exceptions, non functional) languages.
Also, note that anonymous functions (blocks) are present in Smalltalk, which is not a functional language, and that normal named functions have been present even in procedural languages like C and Pascal for a long time.

Please do not overgeneralize your answers by speaking about "the adoption of the functional paradigm and its benefits", because this is not the topic of the question.

答:
There's certainly a noticeable trend towards functional programming, or at least certain aspects of it. Some of the popular languages that at some point adopted anonymous functions are C++ (C++11), PHP (PHP 5.3.0), C# (C# v2.0), Delphi (since 2009), Objective C (blocks) while Java 8 will bring support for lambdas to the language . And there are popular languages that are generally not considered functional but supported anonymous functions from the start, or at least early on, the shining example being JavaScript.

As with all trends, trying to look for a single event that sparked them is probably a waste of time, it's usually a combination of factors, most of which aren't quantifiable. Practical Common Lisp, published in 2005, may have played an important role in bringing new attention to Lisp as a practical language, as for quite some time Lisp was mostly a language you'd meet in an academic setting, or very specific niche markets. JavaScript's popularity may have also played an important role in bringing new attention to anonymous functions, as munificent explains in his answer.

Other than the adoption of functional concepts from multi-purpose languages, there's also a noticeable shift towards functional (or mostly functional) languages. Languages like Erlang (1986), Haskell (1990), OCaml (1996), Scala (2003), F# (2005), Clojure (2007), and even domain specific languages like R (1993) seem to have gained a strong following strongly after they were introduced. The general trend has brought new attention to older functional languages, like Scheme (1975), and obviously Common Lisp.

I think the single more important event is the adoption of functional programming in the industry. I have absolutely no idea why that didn't use to be the case, but it seems to me that at some point during the early and mid 90s functional programming started to find it's place in the industry, starting (perhaps) with Erlang's proliferation in telecommunications and Haskell's adoption in aerospace and hardware design.

Joel Spolsky has written a very interesting blog post, The Perils of JavaSchools, where he argues against the (then) trend of universities to favour Java over other, perhaps more difficult to learn languages. Although the blog post has little to do with functional programming, it identifies a key issue:

Therein lies the debate. Years of whinging by lazy CS undergrads like me, combined with complaints from industry about how few CS majors are graduating from American universities, have taken a toll, and in the last decade a large number of otherwise perfectly good schools have gone 100% Java. It's hip, the recruiters who use "grep" to evaluate resumes seem to like it, and, best of all, there's nothing hard enough about Java to really weed out the programmers without the part of the brain that does pointers or recursion, so the drop-out rates are lower, and the computer science departments have more students, and bigger budgets, and all is well.

I still remember how much I hated Lisp, when I first met her during my college years. It's definitely a harsh mistress, and it's not a language where you can be immediately productive (well, at least I couldn't). Compared to Lisp, Haskell (for example) is a lot friendlier, you can be productive without that much effort and without feeling like a complete idiot, and that might also be an important factor in the shift towards functional programming.

All in all, this is a good thing. Several multi-purpose languages are adopting concepts of paradigm that might have seemed arcane to most of their users before, and the gap between the main paradigms is narrowing.

Related questions:

Functional Programming on the rise?

Why isn't functional programming more popular in the industry? Does it catch on now?

Why hasn't functional programming taken over yet?

Further reading:

Why are functional programming languages, especially Common Lisp and Lisp dialect Clojure, making a comeback in popularity?

Functional Programming: What caused the rise in popularity of functional programming?

Can Your Programming Language Do This?

Why functional programming? Why Haskell?


问:
Commercial product using a GPL OS
we are planning to create a commercial product. The product consists of some MCUs and a small computer (we are developing on a Raspberry Pi at the moment).

The computer needs an operating system as we would like keep things like WLAN and booting as simple as possible.  We created some software that runs on this computer (node.js application).

The most operating systems like Arch Linux are licensed under the GPL.

The product we would sell contains the computer with pre-installed OS and software. This system operates as a central access point to MCU devices and is able to control them.

We use other's software in our product. We do not modify their source code. The product (the computer part) consists of a computer, an OS and software we create.

How does the use of an OS affect our own code (licence)?

Is there a possibility of avoiding GPL for our own code? eg.
shipping the software separated?

Are there any effects to other components of our product, eg. the
MCU part?

The node.js application delivers a WebApp to the client where it is
executed. Are there any effects (As we would like to sell parts of
the code as an additional App on the App Stores)?

I know we make use of the work of the community and i respect this. The problem is: The software alone is kind of useless without the MCU devices. I do not expect a legal advice.

答:
How does the use of an OS affect our own code (licence)?

GPL doesn't really stop you from distributing any software -directly or derived. So you handing over an Arch Linux CD to someone (even if you bill that person for it) - doesn't really violates anything.

Are there any effects to other components of our product, eg. the MCU
  part?

Secondly, if you are billing for hardware - you are only licensing for use and not for design, it is certainly fine - unless under GPLv3 you are adding restriction of usage. Hence, OS or any other software products doesn't impose restrictions on any hardware distribution. Software merely says it requires hardware of specifications or more.

Is there a possibility of avoiding GPL for our own code? eg. shipping
  the software seperated?

That's not quite needed I guess. However, it is important to understand that even if you ship a certain software separately, GPL (and its variants like LGPL) works on dependency. So billing separately or bundled has no difference on GPL applicability. (I will dwell more on this below.)

The node.js application delivers a WebApp to the client where it is
  executed. Are there any effects (As we would like to sell parts of the
  code as an additional App on the App Stores)?

Node.js is NOT GPL. From this: https://github.com/joyent/node/blob/master/LICENSE - but I might have overlooked something.

As long as you don't modify any software product and use it as is, you can distribute it freely (even if you are charging money to customer). If you modify existing software product and if the customer asks for the modified code - you have to handover your modification code. If your code is black box is independent of other GPL products - you can keep it closed as well.

If you feel, there is a lot of commercial value you are deriving while getting free of charge software - you might consider donating those author, but it doesn't mean you cann't use the product.

Title: Commercial product using a GPL OS


答:
Configuration management is a space by itself and such a DB is often called CMDB.

CMDB, quite often doesn't have to be relational DB. What i can recall most effectively will be OneCMBD - but see if that fits your need.

There are many solutions and some open source solutions such as a few that you can find here: http://linuxaria.com/article/6-cmdb-open-source?lang=en

Title: What are options for 3rd Party Centralized Software Settings Management?

Body:
I am an architect in an enterprise looking to build a SaaS solution.  Our products are distributed over many different deployable containers,  Web Services, Web UI's, etc.

I am looking for some open-source or 3rd party software solution to manage the settings of our application.  These would be similar to the settings you might find in Word or Eclipse or Visual Studio.  The settings would control various behaviors and features of the product. (Probably not settings like which database to connect to but more like, should I show line numbers on the page or not by default..).  Ideally, we would be able to store values for different dimensions (by tenant, by user, by application environment... )

Because we have so many different deployables, I am looking for a centralized solution that can provide a web service that each of the deployables can get their individual settings from.

Does anyone know of a centralized service providing this sort of features or give me some help in searching for an alternative to rolling our own?


答:
As Yannis pointed out, there are a number of factors that have influenced the adoption of high-order functions in languages that were previously without. One of the important items he only touched lightly on is the proliferation of multi-core processors and, with that, the desire for more parallel and concurrent processing.

The map/filter/reduce style of functional programming is very friendly to parallelization, allowing the programmer to easily make use of multiple cores, without writing any explicit threading code.

As Giorgio notes, there is more to functional programming than just high-order functions. Functions, plus a map/filter/reduce programming pattern, and immutability are the core of functional programming. Together these things make for powerful tools of parallel and concurrent programming. Thankfully, many languages already support some notion of immutability, and, even if they don't, programmers can treat things as immutable allowing the libraries and compiler to create and manage asynchronous or parallel operations.

Adding high-order functions to a language is an important step to simplifying concurrent programming.

Update

I'll add a couple more detailed examples in order to address the concerns Loki noted.

Consider the following C# code which traverses a collection of widgets, creating a new list of widget prices.

```<code>List<float> widgetPrices;
    float salesTax = RetrieveLocalSalesTax();
foreach( Widget w in widgets ) {
    widgetPrices.Add( CalculateWidgetPrice( w, salesTax ) );
}
</code>```

For a large collection of widgets, or a computationally intensive CalculateWidgetPrice(Widget) method, this loop would not make good use of any available cores. To do the price calculations on different cores would require the programmer to explicitly create and manage threads, passing work around, and collecting the results together.

Consider a solution once high-order functions have been added to C#:

```<code>var widgetPrices = widgets.Select( w=> CalculateWidgetPrice( w, salesTax ) );
</code>```

The foreach loop has been moved into the Select method, hiding its implementation details. All that remains to the programmer is to tell Select what function to apply to each element. This would allow the Select implementation to run the calculations in parellel, handling all the synchronization and thread management concerns without the programmer's involvement.

But, of course, Select does not do it's work in parallel. That's where immutability comes in. The implementation of Select does not know that the provided function (CalculateWidgets above) does not have side effects. The function could change the state of the program outside the view of Select and its synchronization, breaking everything. For example, in this case the value of salesTax could be changed in error. Pure functional languages provide immutability, so the Select (map) function can know for sure that no state is changing.

C# addresses this by providing PLINQ as an alternative to Linq. That would look like:

```<code>var widgetPrices = widgets.AsParallel().Select(w => CalculateWidgetPrice( w, salesTax) );
</code>```

Which makes full use of all the cores of your system without explicit management of those cores.

Title: What triggered the popularity of lambda functions in modern mainstream programming languages?

Body:
In the last few years anonymous functions (AKA lambda functions) have become a very popular language construct and almost every major / mainstream programming language has introduced them or is planned to introduce them in an upcoming revision of the standard.

Yet, anonymous functions are a very old and very well-known concept in Mathematics and Computer Science (invented by the mathematician Alonzo Church around 1936, and used by the Lisp programming language since 1958, see e.g. here).

So why didn't today's mainstream programming languages (many of which originated 15 to 20 years ago) support lambda functions from the very beginning and only introduced them later?

And what triggered the massive adoption of anonymous functions in the last few years? Is there some specific event, new requirement or programming technique that started this phenomenon?

IMPORTANT NOTE

The focus of this question is the introduction of anonymous functions in modern, main-stream (and therefore, maybe with a few exceptions, non functional) languages.
Also, note that anonymous functions (blocks) are present in Smalltalk, which is not a functional language, and that normal named functions have been present even in procedural languages like C and Pascal for a long time.

Please do not overgeneralize your answers by speaking about "the adoption of the functional paradigm and its benefits", because this is not the topic of the question.

Body:
As Yannis pointed out, there are a number of factors that have influenced the adoption of high-order functions in languages that were previously without. One of the important items he only touched lightly on is the proliferation of multi-core processors and, with that, the desire for more parallel and concurrent processing.

The map/filter/reduce style of functional programming is very friendly to parallelization, allowing the programmer to easily make use of multiple cores, without writing any explicit threading code.

As Giorgio notes, there is more to functional programming than just high-order functions. Functions, plus a map/filter/reduce programming pattern, and immutability are the core of functional programming. Together these things make for powerful tools of parallel and concurrent programming. Thankfully, many languages already support some notion of immutability, and, even if they don't, programmers can treat things as immutable allowing the libraries and compiler to create and manage asynchronous or parallel operations.

Adding high-order functions to a language is an important step to simplifying concurrent programming.

Update

I'll add a couple more detailed examples in order to address the concerns Loki noted.

Consider the following C# code which traverses a collection of widgets, creating a new list of widget prices.

List<float> widgetPrices;
    float salesTax = RetrieveLocalSalesTax();
foreach( Widget w in widgets ) {
    widgetPrices.Add( CalculateWidgetPrice( w, salesTax ) );
}

For a large collection of widgets, or a computationally intensive CalculateWidgetPrice(Widget) method, this loop would not make good use of any available cores. To do the price calculations on different cores would require the programmer to explicitly create and manage threads, passing work around, and collecting the results together.

Consider a solution once high-order functions have been added to C#:

var widgetPrices = widgets.Select( w=> CalculateWidgetPrice( w, salesTax ) );

The foreach loop has been moved into the Select method, hiding its implementation details. All that remains to the programmer is to tell Select what function to apply to each element. This would allow the Select implementation to run the calculations in parellel, handling all the synchronization and thread management concerns without the programmer's involvement.

But, of course, Select does not do it's work in parallel. That's where immutability comes in. The implementation of Select does not know that the provided function (CalculateWidgets above) does not have side effects. The function could change the state of the program outside the view of Select and its synchronization, breaking everything. For example, in this case the value of salesTax could be changed in error. Pure functional languages provide immutability, so the Select (map) function can know for sure that no state is changing.

C# addresses this by providing PLINQ as an alternative to Linq. That would look like:

var widgetPrices = widgets.AsParallel().Select(w => CalculateWidgetPrice( w, salesTax) );

Which makes full use of all the cores of your system without explicit management of those cores.


答:
It's free software, subject to the constraints of the third party software upon which Panoply depends. From http://gcmd.nasa.gov/records/NASA_GISS_Panoply.html
(you'll have to click on the "Click to view more" under "Use Constraints" to see the license):

Scope of License. Subject to all the terms and conditions of this license and of the individual licenses of any third-party libraries, NASA Goddard Institute for Space Studies grants the user royalty-free, nonexclusive, nontransferable, and worldwide rights to reproduce, modify, reverse engineer, and distribute the Panoply software package, herein referred to as the Product.

Conditions and Limitations of Use. Neither the U.S. Government, nor any agency or employee thereof, makes any warranties, expressed or implied, with respect to the Product provided under this License, including but not limited to the implied warranties or merchantability and fitness for any particular purpose.

Liability. In no event shall the U.S. Government, nor any agency or employee thereof, be liable for any direct, indirect, or consequential damages flowing from the use of the Product provided under this License.

Non-Assignment. Neither this License nor any rights granted hereunder are transferable or assignable without the explicit prior written consent of NASA Goddard Institute for Space Studies.

Names and Logos. User shall not substitute its name or logo in identification of the Product.

Export of technology. User shall comply with all U.S. laws and regulations restricting the export of the Product to other countries.

Title: Does NASA license the software that it develops?

Body:
NASA provides a visualization software called Panoply. There is a Credits and Acknowledgments page that acknowledges and lists the licenses of software dependencies, but provides no information about its own license.

I have looked at other software produced by NASA, including the source code for GISS and can not find any information about a licence.

The closest information that I can find is in the FAQ for the global climate model EdGCM Global that says the code is in the "public domain"

is it standard practice at NASA to release code into the public domain?

are there exceptions?

Can I assume that Panoply is public domain and can be used without restriction other than than those imposed by licenses of software dependencies?

Is the absence of specific permission to reuse the code a concern (this issue was raised in the answer to a separate question)

How common is this practice across government agencies?


问:
Can python and php work together?
I am having a mobile app created for ios. The developers built the app in php. The app requires an algorithm so I found another programmer to develop it. The algorithm programmer built the algorithm in python. The developers refuse to finish the app because they say it won't work with python, while the programmer insist it will. The programmer says put the algorithm in its on server and connect then over http. Will this work and I'd so how risky is it to future problems? </p>

答:
Will this work and I'd so how risky is it to future problems?

Yes it will work, and how risky it is depends on how good your implementation is. This is perfectly acceptable if done correctly. I have successfully integrated PHP and C, when PHP was simply too slow to do certain niche tasks in real time (IIRC, PHP is 7 times slower than its C counterpart).

The best implementation is to ignore the fact they are PHP/Python specifically, and just treat them as two separate languages.

Now, you need to pick some 'standard' way of interacting. HTTP is probably the easiest: everyone has a web server setup already so it's just a matter of putting the script online.

From here, you need to get away from the fact they are PHP/Python still and design your API without knowing that. For example, imagine you had a calculator:

```<code><?php
print '<answer>' . ($_GET['one'] + $_GET['two']) . '</answer>';
?>
</code>```

Then your API would be http://location/script.php?one=5&two=7. This is perfectly acceptable: the user of the API expects an answer within an <answer> tag (my example is a lazy mans XML, purely as a demonstration, but I think you should look into outputting JSON). This, is not:

```<code><?php
print eval($_GET['expr']);
?>
</code>```

Since your API would be http://location/script.php?expr=5+7. Even though it would result in the same answer (and, ignoring any major security flaws), the caller needs to know the implementation details of PHP (eval is a PHP function which will just evaluate its input as real PHP code). If they did 2^3, is that 2 xor 3 or 2 * 2 * 2 (2 to the power 3). This is a bad design: your inputs should be independent of the language your API is implemented in. On top of this, how do we distinguish between an error message and an answer? No magic "if the response is not a number", please.

Python side - you just need to make sure HTTP requests fail gracefully. If you can't connect to your script, perhaps try again, and if that fails, give up with a nice error message asking them to try again later. Don't just display them a Python stack trace.

You should also document your API as well as possible - this will save you a lot of time down the line. Say what each of the inputs should be, what ranges they should fall in, and give some good examples of how to use it.

API side - you should also try to fail quickly if something is wrong. If a variable is missing, incomplete, or invalid, print a message and exit as the first thing you do. Do not just run with the values, and then let them get back a PHP error message (remember, they should not know or care what language your API is implemented in), but should get a nice friendly You didn't give me a 'two' variable. What do you want me to add 'one' to?.

Title: Can python and php work together?

Body:
Will this work and I'd so how risky is it to future problems?

Yes it will work, and how risky it is depends on how good your implementation is. This is perfectly acceptable if done correctly. I have successfully integrated PHP and C, when PHP was simply too slow to do certain niche tasks in real time (IIRC, PHP is 7 times slower than its C counterpart).

The best implementation is to ignore the fact they are PHP/Python specifically, and just treat them as two separate languages.

Now, you need to pick some 'standard' way of interacting. HTTP is probably the easiest: everyone has a web server setup already so it's just a matter of putting the script online.

From here, you need to get away from the fact they are PHP/Python still and design your API without knowing that. For example, imagine you had a calculator:

<?php
print '<answer>' . ($_GET['one'] + $_GET['two']) . '</answer>';
?>

Then your API would be http://location/script.php?one=5&two=7. This is perfectly acceptable: the user of the API expects an answer within an <answer> tag (my example is a lazy mans XML, purely as a demonstration, but I think you should look into outputting JSON). This, is not:

<?php
print eval($_GET['expr']);
?>

Since your API would be http://location/script.php?expr=5+7. Even though it would result in the same answer (and, ignoring any major security flaws), the caller needs to know the implementation details of PHP (eval is a PHP function which will just evaluate its input as real PHP code). If they did 2^3, is that 2 xor 3 or 2 * 2 * 2 (2 to the power 3). This is a bad design: your inputs should be independent of the language your API is implemented in. On top of this, how do we distinguish between an error message and an answer? No magic "if the response is not a number", please.

Python side - you just need to make sure HTTP requests fail gracefully. If you can't connect to your script, perhaps try again, and if that fails, give up with a nice error message asking them to try again later. Don't just display them a Python stack trace.

You should also document your API as well as possible - this will save you a lot of time down the line. Say what each of the inputs should be, what ranges they should fall in, and give some good examples of how to use it.

API side - you should also try to fail quickly if something is wrong. If a variable is missing, incomplete, or invalid, print a message and exit as the first thing you do. Do not just run with the values, and then let them get back a PHP error message (remember, they should not know or care what language your API is implemented in), but should get a nice friendly You didn't give me a 'two' variable. What do you want me to add 'one' to?.


问:
Functional Methods on Collections
I'm learning Scala and am a little bewildered by all the methods (higher-order functions) available on the collections.  Which ones produce more results than the original collection, which ones produce less, and which are most appropriate for a given problem?  Though I'm studying Scala, I think this would pertain to most modern functional languages (Clojure, Haskell) and also to Java 8 which introduces these methods on Java collections.

Specifically, right now I'm wondering about map with filter vs. fold/reduce.  I was delighted that using foldRight() can yield the same result as a map(...).filter(...) with only one traversal of the underlying collection.  But a friend pointed out that foldRight() may force sequential processing while map() is friendlier to being processed by multiple processors in parallel.  Maybe this is why mapReduce() is so popular?

More generally, I'm still sometimes surprised when I chain several of these methods together to get back a List(List()) or to pass a List(List()) and get back just a List().  For instance, when would I use:

```<code>collection.map(a => a.map(b => ...))
</code>```

vs.

```<code>collection.map(a => ...).map(b => ...)
</code>```

The for/yield command does nothing to help this confusion.  Am I asking about the difference between a "fold" and "unfold" operation?

Am I trying to jam too many questions into one?  I think there may be an underlying concept that, if I understood it, might answer all these questions, or at least tie the answers together.

答:
Concerning the operations that produce an output smaller than their input, a common mistake concerns map itself. By intuition, map takes each of the input elements, computes a transformation of this element, and places the result on the output, so that input and output have the same size.

In fact, in Scala, a map of a set (let's say, of integers) is a set. So applying a predicate (that is, a boolean function) establishing if the integer is odd or even, the result will be a set of booleans. Therefore the only possible output sizes are 0, 1 and 2, whatever the input size is.

```<code>val a = Set(1,2,3,4,5)
a.map(_ % 2 == 0)
res0: scala.collection.immutable.Set[Boolean] = Set(false, true)
</code>```

Note that is a Scala convention. For instance, in Python, a map of a set is a list containing the same number of elements than the original set.

Title: Functional Methods on Collections

Body:
Concerning the operations that produce an output smaller than their input, a common mistake concerns map itself. By intuition, map takes each of the input elements, computes a transformation of this element, and places the result on the output, so that input and output have the same size.

In fact, in Scala, a map of a set (let's say, of integers) is a set. So applying a predicate (that is, a boolean function) establishing if the integer is odd or even, the result will be a set of booleans. Therefore the only possible output sizes are 0, 1 and 2, whatever the input size is.

val a = Set(1,2,3,4,5)
a.map(_ % 2 == 0)
res0: scala.collection.immutable.Set[Boolean] = Set(false, true)

Note that is a Scala convention. For instance, in Python, a map of a set is a list containing the same number of elements than the original set.


答:
The main reason for version number is there so that when a bug is discovered you are able to debug using the actual version of the source code that the error actually happened in (thus discover the real reason for the bug).

It does not matter what versioning scheme you use as long as the user of your produce can communicate to the developer enough information so that the developer can achieve this goal.

Other reasons for versioning are for marketing and help (sometimes legal) teams.

These teams have their own priority's for versioning.

Help

Wants an easy way to determine compatibility and features and potentially stability (see Linux Odd/Even number scheme).

Marketing

Wants a bigger number each time (preferably above 2)

Legal

Wants to make sure you have all features committed to before increasing the number.

In all cases the scheme used is unimportant. As long as you are consistent (or have easily available highly detailed documentation on changes in meaning).

Title: Bump version before kicking off new development or when tagging a release, which is better?

Body:
Some projects bump version before kicking off a new development, while the other projects  bump version when tagging a release.

Which approach is better?

If version number not changed at the start of new phase, the developers may forget to change it and simply release the program.

If version number changed before tagging release, then 2 the version numbers (tag and Makefile/AssemblyInfo.cs) do not match.

git describe may give you v1.2.3.4-15-g1234567 if current revision is after v1.2.3.4, but you have already changed the files to have v1.2.3.5


问:
Which platform to choose, Java or .NET?
I am working in a private bank, a leading mid size bank in local market. We are going to create our core banking solution. Existing solution has been developed on Java using IBM Visual Age 4.0.

It is very important to discuss architecture first, we have currently more than 350 branches working in standalone mode, and it means they are working in self contained environment. They have their own database server (IBM DB2 9.7) and they are communicating with other branches via sockets to send and receive data.

Having experience of .NET for more than 5 years I am trying to convince my superiors to choose .NET platform, but they are reluctant and unwilling. It is my job to encourage them for choosing best available platform to create large scale enterprise application.

In simple word, we are going to create a very large scale enterprise financial application, a centralize and integrated which connects all branch networks plus having scalable, solid architecture that easily evolve over time.

I want professional people to comment on above scenarios. Which platform to choose .NET or Java? Our all resource is currently working in Java, we have homogeneous environment (no Linux, no Mac and no UNIX).

Any idea, any thoughts, any points technical or non-technical i.e. administrative or management point of view will be really appreciated.

答:
In my Opinion .NET Platform is the best one because by using Java Platform it will take more time to learn and code the program

Example

Java Platform is treated as a"Sea" while the .NET Platform is treated as a "River".

Title: Which platform to choose, Java or .NET?


答:
I think its interesting how much the popularity of functional programming has paralleled the growth and proliferation of Javascript. Javascript has a lot of radical features along the functional programming spectrum that at the time  of its creation (1995) were not very popular among mainstream programming languages (C++/Java). It was injected suddenly into the mainstream as the only client-side web programming language. Suddenly a lot of programmers simply had to know Javascript and therefore you had to know something of functional programming language features.

I wonder how popular functional languages/features would be if it had not been for the sudden rise of Javascript.


问:
What package name to choose for a small, open-source Java project?
I'd like to publish a small open-source library in Java. I wonder what package name should I choose? I'm not a company and I don't have a domain that I could use as the basis for naming the package according to the naming conventions. Still I'd like to somehow follow the naming conventions to prevent an accidental conflict and to keep things standard.</p>

答: Why not make use of your surname? Something like pudlak.project_name.


问:
The Art of Computer Programming - To read or not to read?
There are lots of books about programming out there, and it seems Code Complete is pretty much at the top of most people's list of "must-read programming books", but what about The Art of Computer Programming by Donald Knuth?  I'm a busy person, between work and a young family I don't have a ton of free time, so I have to be picky about how I use it.

I'm wondering - has anybody here read 'TAOCP'?  If so, is it worth making time to read or would some other book or more on-the-side programming like pet projects or contributing to open source be a better use of my time in terms of professional development?

DISCLAIMER - For those of you who sport "Knuth is my homeboy" t-shirts, don't get me wrong - I want to read it, but I'm just wondering if it should be right at the top of my priority list or if something else should come first.

答:
It's not something most people will want to sit down and read cover-to-cover, no.  It is an incredibly invaluable reference, and it's certainly good to pick it up, pick an interesting section, read over it, and do some exercises.  But the encyclopedia comparisons made above are pretty apt... it's big, extensive, and detailed.  And some of the "exercises" are research problems that might take years to solve.

If you just want a better knowledge of low-level algorithms, it might be better to start with the Robert Sedgewick books (eg, "Algorithms in C," "Algorithms in Java," etc.).


问:
Which numeral systems are useful in computer science?
I am wondering which numeral system different programmers are using, or would use if their language has support for them. As an example, in C++ we can use:

Octal by prefixing with 0 (e.g. 0377)

Decimal by default (e.g. 255)

Hexadecimal by prefixing with 0x (e.g. 0xff)

When working with bitmask, I am using hexadecimal but would sometimes want to be able to express binary numbers directly. I know some programming language support it with 0b syntax (e.g. 0b11111111).

Is there any other numeric system useful in some computer science domain (e.g. cryptography, codecs, 3D graphics, etc)?

答:
http://en.wikipedia.org/wiki/List_of_numeral_systems

Minutes and seconds use base60, base64 encoding uses base64 (doh), radian angles use Pi as base, us stocks used to have weird fractions instead of decimals, dates have irregular base (different amount of days in month) and so on.

In general - any system can prove useful under certain conditions, but most often than not it is dictated by domain traditions.


答:
I think the reason is the increasing prevalence of concurrent and distributed programming, where the core of object oriented programming (encapsulating changing state with objects) no longer applies. In the case of a distributed system, because there is no shared state (and software abstractions of that concept are leaky) and in the case of a concurrent system, because properly synchronizing access to shared state has been proven cumbersome and error-prone. That is, one of the key benefits of object oriented programming no longer applies for many programs, making the object oriented paradigm far less helpful that it used to be.

In contrast, the functional paradigm does not use mutable state. Any experience we gained with functional paradigms and pattern is therefore more immediately transferrable to concurrent and distributed computation. And rather than reinvent the wheel, the industry now borrows those patterns and language features to address its need.


问:
Why are source control systems still mostly backed with files?
It seems that more source control systems still use files as the means of storing the version data.  Vault and TFS use Sql Server as their data store, which I would think would be better for data consistency as well as speed.

So why is it that SVN, I believe GIT, CVS, etc still use the file system as essentially a database,  (I ask this question as we had our SVN server just corrupt itself during a normal commit) instead of using actual database software (MSSQL, Oracle, Postgre, etc)?

EDIT:  I think another way of asking my question is "why do VCS developers roll their own structured data storage system instead of using an exisiting one?"

答:
As far as I've seen in many offerings it seems that files are "good enough" for the job, something reasonable, taking into account that at the end of the day VCSes output is also files.

There are many companies that offer a RDBMS back end with a svn/git/etc interface, so what you are asking for basically exists already.


问:
How effectively "sell" a good design in large meetings
Many times I have witnessed a sad tragedy.  Here's what happens:

A team design review for a new project.

I see a simple design that has quite a few holes.

I casually mention the holes and ways to avoid them.

The warnings are ignored with comments like "that 'never' happen in real life"

Eventually the things that "will 'never' happen" happen

An emergency team design review for a broken project.

So what do I do?  Copping the "I told you so" attitude is not going to win friends and influence people.  Sometimes years go by and the comments from step 3 are forgotten anyway.  I definitely don't want to be the annoying pest reminding the world of the gotchas.  I often sit back and watch the Titanic sail off to Europe.

It's frustrating to see bad designs move forward.  It's also frustrating that I can't seem to convince others of the pending peril of the current path.  I do worst on team meetings where everyone has different ways of understanding different terms.  Also, egos tend to win of reason and thought.  I'm looking for good tactics to convince groups people to use some new and complicated ideas.

答:
How to get your idea(s) implemented

First in meetings refer to problems as challenges. You fix problems, you overcome challenges. Challenges are good things, problems are not.

Start slow and use this technique on one single challenge at a time. Next time you want your boss to adopt one of your ideas do the following:

Develop three similar but different approaches

Tell your boss you need his help with something

Explain that you are not sure which of the three methods is the best course of action for solving the problem

Ask Him/Her to help you choose one of the three

1. This is extremely powerful. What you are doing is providing choices not an ultimatum. Ultimatums more often then not get shot down because it's not their idea and there is only one option.

2. Your use of words is very key here. "I need your help".

3. Let the boss choose "A", "B", or "C". In fact let the boss create option "D" by pulling out sections from "A", "B" and "C". What you are doing is letting your boss make a choice.

At this point you could care less what option he chooses, because they are all your ideas. He will think he's actually solving the problem because you let the decision becomes his.


答:
TL;DR: Few version control systems use a database because it isn't necessary.

As a question for a question answer, why wouldn't they?  What benefits do "real" database systems offer over a file system in this context?

Consider that revision control is mostly keeping track of a little metadata and a lot of text diffs.  Text is not stored in databases more efficiently, and indexability of the contents isn't going to be a factor.

Lets presume that Git (for argument's sake) used a BDB or SQLite DB for its back-end to store data.  What would be more reliable about that?  Anything that could corrupt simple files can also corrupt the database (since that's also a simple file with a more complex encoding).

From the programmer paradigm of not optimizing unless its necessary, if the revision control system is fast enough and works reliably enough, why change the entire design to use a more complex system?

Title: Why are source control systems still mostly backed with files?

Body:
It seems that more source control systems still use files as the means of storing the version data.  Vault and TFS use Sql Server as their data store, which I would think would be better for data consistency as well as speed.

So why is it that SVN, I believe GIT, CVS, etc still use the file system as essentially a database,  (I ask this question as we had our SVN server just corrupt itself during a normal commit) instead of using actual database software (MSSQL, Oracle, Postgre, etc)?

EDIT:  I think another way of asking my question is "why do VCS developers roll their own structured data storage system instead of using an exisiting one?"


答: If you don't have a domain name, you can still use that naming convention and name it (org\com\net\whatever).projectname. The package name doesn't necessarily need to be the domain name you expect the project to be found at, although it does make things easier. Some projects end up moving domains and don't have their package names renamed for compatibility reasons.

Title: What package name to choose for a small, open-source Java project?

Body: I'd like to publish a small open-source library in Java. I wonder what package name should I choose? I'm not a company and I don't have a domain that I could use as the basis for naming the package according to the naming conventions. Still I'd like to somehow follow the naming conventions to prevent an accidental conflict and to keep things standard.</p>


答:
I agree with many of the answers here, but what's interesting is that when I learned about lambdas and jumped on them, it wasn't for any of the reasons others have mentioned.

In many cases, lambda functions simply improve readability of your code. Before lambdas when you call a method that accepted a function pointer (or function, or delegate), you had to define the body of that function somewhere else, so when you had "foreach" construct, your reader would have to jump to a different part of the code to see just what exactly you were planning to do with each element.

If the body of the function that processes elements is only few lines of, I would use an anonymous function because now when you are reading code, functionality remains unchanged, but the reader doesn't have to jump back and forth, the entire implementation is right there in front of him.

Many of the functional programming techniques and parallelization could be achieved without anonymous functions; just declare a regular one and pass a reference to that whenever you need to. But with lambdas ease of writing code and ease of reading code is greatly improved.


问:
Why it is necessary to to test my iPhone app on actual iPhone device
I developed one application for iPhone and now I want it on App Store. So many my iOS geek friends told me to test it on actual device i.e. on iPhone.

So I wonder that why it is necessary to to test my iPhone app on actual iPhone device though they (Apple) have given "simulator" which is near about same as my device?

答:
While it's been mentioned that hardware's performance is generally worse, it must be noted that this is not the case with OpenGL ES. The simulator implements it in software so it is not uncommon, to notice huge performance increase while running on the device itself.

Moreover, there are some minor differences between the software and hardware implementations of Open GL ES, e.g. shader precision hints might have different outputs.


答:
JavaScript and DOM event handlers meant that millions of programmers had to learn at least a little bit about first class functions in order to do any interactivity on the web.

From there, it's a relatively short step to anonymous functions. Because JavaScript doesn't close over this, it also strongly encourages you to learn about closures too. And then you're golden: you understand anonymous first class functions that close over enclosing lexical scopes.

Once you're comfortable with it, you want it in every language you use.


问:
Should you promise to deliver a feature that you aren't sure if its implementable?
In an article from HN, I came across the following advice:

Always tell your customer/user "yes", even if you're not sure. 90% of
  the time, you'll find a way to do it. 10% of the time, you'll go back
  and apologize. Small price to pay for major personal growth

But I've always thought that one should do a feasibility analysis before making any kind of promises to a customer/user, so that they aren't misled at any point. At what circumstances, then, should the above advice applicable?

答:
Playing devil's advocate

Being of an analytical mindset, technical folks can tend assume that their performance primarily will be judged based on a scorecard of completed vs committed requests, but in practice, it's not as cut and dried.

Before development even begins, customers start to form opinions on a team's performance based on their level of confidence and willingness to commit.

Part of the reason for this is that customers can have a difficult time assessing whether a contractor's hesitation to commit is due to the sheer difficulty of the request or lack of ability of the contractor.

As there are no absolute criteria for measuring difficulty of a request, often what is more important to the customer is trust that the contractor is giving 100% effort, rather than whether 90% or 100% of the requests are met.

Suppose the customer has to choose between two scenarios:

Contractor A:

Confident they can deliver on all requests

Result: 90% of requests delivered

Customer is pleased that the contractor gave 100% effort

Customer perceives that the uncompleted requests were due to unforeseen issues, which probably outside of the contractors control

Contractor B:

Commits to delivering on 90% of the requests. Not confident they can deliver on the remaining 10%

Result: 90% of requests delivered

Customer is disappointed that the contractor didn't try to complete the other 10% of its requests

Customer assumes that the uncompleted 10% of requests were due to either lack of effort or ability of the contractor

In both scenarios, the same number of requests were delivered; however, the customer felt that the "overcommitting" Contractor A was giving 100% effort and used this to validate that the remaining requests truly were difficult, to Contractor A's credit.

On the flip side, the customer felt like Contractor B wasn't giving 100% effort and its inability to complete all of the requests was either due to Contractor B's lack of effort or ability.

Disclaimer: I am not advocating overcommitment as a strategy; this is just an observation of a possible real world situation in which overcommitment might have positive results.


问:
Why is CSS3 doing animations?
Like what the title says, why are there animations in CSS3?

With basis from the "rule" of separation of concerns, HTML is the content, CSS is the style, and JavaScript is the interactive component. And by interactivity, one can conclude that anything moving due to any interaction, user or non-user triggered should be covered by JavaScript, not CSS.

So why did they make CSS3 capable of doing animations? Doesn't it breach the rule, which is separation of concerns? Is there anything I missed that makes animations qualified to be classified as styles rather than interaction?

答:
There are two reasons:

If an animation can be standardized and handled natively by the browser's rendering engine, it's way cheaper (performance wise) than doing it in JavaScript.

As mentioned in the comments, the animations/transitions are mainly about style, not so much behavior (at least the set that's covered by CSS functionality), so it's not such a huge deal with respect to seperation of concerns.

Seperation of concerns is nice, but putting animations in CSS makes more sense than putting it into HTML, and is more performant than doing it in JavaScript (you could as JS apis, but CSS does graceful fallback a whole lot better.

Title: Why is CSS3 doing animations?


答:
Actually svn used to use BDB for repositories. This was eventually gotten rid of because it was prone to breakage.

Another VCS that currently uses a DB (SQLite) is fossil. It also integrates a bug tracker.

My guess at the real reason is that VCSes work with lots of files. Filesystems are just another kind of database (hierarchical, focused on CLOB/BLOB storage efficiency). Normal databases don't handle that well because there's no reason to -- filesystems already exist.


问:
Need suggestion for Mutiple Windows application design
This was previously posted in StackOverflow, I just moved to here...

I am using VS2008, MVVM, WPF, Prism to make a mutiple window CRM Application.

I am using MidWinow in my MainWindow, I want

Any ViewModel would able to make request to MainWindow to create/add/close MidChildWindow, ChildWindow(from WPF Toolkit), Window (the Window type).

ViewModel can get the DialogResult from the ChildWindow its excutes.

MainWindow have control on all opened window types.

Here is my current approach:

I made Dictionary of each of the windows type and stores them into MainWindow class.

For 1, i.e in a CustomerInformationView, its CustomerInformationViewModel can execute EditCommand and use EventAggregator to tell MainWindow to open a new ChildWindow.

CustomerInformationViewModel:

```<code>CustomerEditView ceView = new CustomerEditView ();
CustomerEditViewModel ceViewModel = CustomerEditViewModel ();
ceView.DataContext = ceViewModel;
ChildWindow cWindow = new ChildWindow();
cWindow.Content = ceView;
MainWindow.EvntAggregator.GetEvent<NewWindowEvent>().Publish(new WindowEventArgs(ceViewModel.ViewModeGUID, cWindow ));
cWindow.Show();
</code>```

Notice that all my ViewModel will generates a Guid for help identifies the ChildWindow from MainWindow's dictionary. Since I will only be using 1 View 1 ViewModel for every Window.

For 2. In CustomerInformationViewModel I can get DialogResult by OnClosing event from ChildWindow, in CustomerEditViewModel can use Guid to tell MainWindow to close the ChildWindow.

Here is little question and problems:

Is it good idea to use Guid here? Or should I use HashKey from ChildWindow?

My MainWindows contains windows reference collections.  So whenever window close, it will get notifies to remove from the collection by OnClosing event.  But all the Windows itself doesn't know about its associated Guid, so when I remove it, I have to search for every KeyValuePair to compares...

I still kind of feel wrong associate ViewModel's Guid for ChildWindow, it would make more sense if ChildWindow has it own ID then ViewModel associate with it...

But most important, is there any better approach on this design? How can I improve this better?

答:
Instead of trying to use a Guid or HashKey, you might find it easier to actually use a reference to the ChildWindow objects.

Also, in order to prevent memory leaks, while not having to worry about handling events, you can use a weak reference to the object so that the garbage collector can still reclaim the resources used by the object once it's no longer referenced anywhere.

I've found the folliwing .NET classes to be pretty handy when working with weak references:

WeakReference Class

ConditionalWeakTable <TKey, TValue> Class

Also, you can have each ChildWindow set it's own DataContext to the
appropriate ViewModel, either declaratively within the XAML, or in the code-behind.

Edit

Also, I thought I should clarify that if you use a collection of WeakReference's to keep track of each window, you won't need to manually remove the reference from the collection whenever a window is closed. You can simply close your window (either from the code-behind, or anywhere else) & forget about it - the GC will still automatically deallocate the necessary resources.


答:
I would say it's because the primary data structure of a version control system is a DAG, which maps to databases very poorly.  A lot of the data is also content addressable, which also maps to databases very poorly.

Data integrity isn't the only concern of a VCS, they are also concerned with version history integrity, which databases aren't very good at.  In other words, when you retrieve a version, you not only need to make sure that version has no current flaws, but also that nothing in its entire history has been surreptitiously altered.

VCS are also a consumer product in addition to an enterprise product.  People use them in small, one-man hobby projects.  If you add the hassle of installing and configuring a database server, you are going to alienate much of that part of the market.  I'm guessing you don't see a lot of Vault and TFS installations at home.  It's the same reason spreadsheets and word processors don't use databases.

Also, this is more a reason for DVCS, but not using a database makes it extremely portable.  I can copy my source tree onto a thumb drive and reuse it on any machine, without having to configure a database server process.

As far as corrupting during commits, VCS uses the exact same techniques as databases to prevent simultaneous access, make transactions atomic, etc.  Corruptions in both are very rare, but they do happen.  For all intents and purposes, a VCS data store is a database.


问:
Reading and conditionally updating N rows, where N > 100,000 for DNA Sequence processing
I have a proof of concept application that uses Azure tables to associate DNA sequences to "something".

Table 1 is the master table.  It uniquely lists every DNA sequence.  The PK is a load balanced hash of the RK.  The RK is the unique encoded value of the DNA sequence.

Additional tables are created per subject.  The PK is a load balanced hash, and the RK is the unique value of the DNA sequence.  Assume that the quantity of RKs here is many order of magnitudes smaller than the Master table.  Each subject has a list of N DNA sequences that have one reference in the Master table, where N is > 100,000.

It is possible for many tables to reference the same DNA sequence, but in this case only one entry will be present in the Master table.

My Azure dilemma:

I need to lock the reference in the Master table as I work with the data.  I need to handle timeouts, and prevent other threads from overwriting my data as one C# thread is working with the information.  Other threads need to realise that this is locked, and move onto other unlocked records and do the work.

Ideally I'd like to get some progress report of how my computation is going, and have the option to cancel the process (and unwind the locks).

Question

What is the best approach for this?

I'm looking at these code snippets for inspiration:

Link

https://stackoverflow.com/q/4535740/328397

答:
While I've not worked with Azure, only on-premise SQL Server, it seems like this is really a matter of asynchronous data access/concurrency.

Why not simply have each thread keep track in a centralized location (e.g. another table) which set of data it's working with. Then, subsequent threads can ignore any records that are already "checked out" to another thread. Once the thread is finished working with the data it has "checked out", it would then remove the record from the centralized location.

Also, you could include the UTC timestamp of when the record was "checked out", so that if something where to fail or otherwise timeout, then the "check out" record (i.e. the lock) could be cleared by the next thread, or even a seperate worker process.

ContentLicense: CC BY-SA 4.0


问:
Best design for a "Command Executer" class
Sorry for the vague title, I couldn't think of a way to condense the question.

I am building an application that will run as a background service and intermittently collect data about the system its running on. A second Android controller application will query the system over tcp/ip for statistics about the system.

Currently, the background service has a tcp listener class that reads/writes bytes from a socket. When data is received, it raises an event to notify the service. The service takes the bytes, feeds them into a command parser to figure out what is being requested, and then passes the parsed command to a command executer class. When the service receives a "query statistics" command, it should return statistics over the tcp/ip connection.

Currently, all of these classes are fully decoupled from each other. But in order for the command executer to return statistics, it will obviously need access to the socket somehow. For reasons I can't completely articulate, it feels wrong for the command executer to have a direct reference to the socket. I'm looking for strategies and/or design patterns I can use to return data over the socket while keeping the classes decoupled, if this is possible.

Hopefully this makes sense, please let me know if I can include any info that would make the question easier to understand.

答:
Perhaps implementing a message queue between whatever is responsible for the TCP/IP connection & your parser class would provide a nice, clean way to fully decouple everything.

Plus, you'd have the added bonus of any network communication issues not having to be handled by your parser class. It could just add messages to the queue and forget about them - nice separation of concerns. :-)


答:
I'm firmly in the camp of folks that feel that every developer should make the investment in getting the books at some point (and it's getting easier now that it looks like they are being reprinted in paperback) but on the same token, I would also be hard pressed to believe that someone would sit down and read them all from cover to cover.

The best approach to them - if you don't have a commute to work where you have free time to sit and read - is to read enough of them to know where to find things in them and then to read a full chapter when ever you find yourself using them as reference books for a given problem. With Google and Stack Overflow it's not as common to be reaching for reference books, but in some cases you may find that the books provide some insight that you would have to send some extra time looking for on the internet.

Title: The Art of Computer Programming - To read or not to read?

Body:
There are lots of books about programming out there, and it seems Code Complete is pretty much at the top of most people's list of "must-read programming books", but what about The Art of Computer Programming by Donald Knuth?  I'm a busy person, between work and a young family I don't have a ton of free time, so I have to be picky about how I use it.

I'm wondering - has anybody here read 'TAOCP'?  If so, is it worth making time to read or would some other book or more on-the-side programming like pet projects or contributing to open source be a better use of my time in terms of professional development?

DISCLAIMER - For those of you who sport "Knuth is my homeboy" t-shirts, don't get me wrong - I want to read it, but I'm just wondering if it should be right at the top of my priority list or if something else should come first.


答: Ok, so this is what I've gone with for now. Any critiques are welcome. Basically I just modified the command executer to return a response object if a response is required, else null. That way the executer does not need any knowledge of where the response is going. The service mediator that sits between the socket and the rest of the classes checks if the response is null and if not, encodes it and ships it back over the tcp/ip connection.

Title: Best design for a "Command Executer" class

Body:
Sorry for the vague title, I couldn't think of a way to condense the question.

I am building an application that will run as a background service and intermittently collect data about the system its running on. A second Android controller application will query the system over tcp/ip for statistics about the system.

Currently, the background service has a tcp listener class that reads/writes bytes from a socket. When data is received, it raises an event to notify the service. The service takes the bytes, feeds them into a command parser to figure out what is being requested, and then passes the parsed command to a command executer class. When the service receives a "query statistics" command, it should return statistics over the tcp/ip connection.

Currently, all of these classes are fully decoupled from each other. But in order for the command executer to return statistics, it will obviously need access to the socket somehow. For reasons I can't completely articulate, it feels wrong for the command executer to have a direct reference to the socket. I'm looking for strategies and/or design patterns I can use to return data over the socket while keeping the classes decoupled, if this is possible.

Hopefully this makes sense, please let me know if I can include any info that would make the question easier to understand.


问:
Is it legal to take the icon/graphic file found online to use in software project?
For example, like this icon website: http://www.iconspedia.com/

There is a lot icon there, (I just can't draw myself, I am not good at it.....), I wonder if is OK to use them in my software project?

Will the type of project make difference?

i.e Open Source Application, Commercial Application, Free Download Application?

答:
The type of project makes a difference as does the terms of the site you got the image from. Some sites do not allow for usage of images without paid licensing, some without attribution, and some are entirely free, local country of origin's laws aside. It can also depend on the project. Some are available for use in applications made by students for educational, noncommercial purposes. Others are available only for commercial applications. It all depends on the photos or pictures in question.

In the case of Iconspedia, each icon has a listing for what license applies to it. It appears most are non-commercial usage only from a cursory perusal.


答:
Free icons does imply they are free to use.

The FAQ says to check the license agreement in each individual pack, some may require crediting the artis or be under creative commons or similar.

Unfortunately most of the licenses use rather uncertain phrases - like free for "non-commercial use" or "free for personal use". It's very difficult to decide exactly what these mean - which is why licenses like the GPL contain a lot of text and some very carefully chosen words.

But if this is just for a project for yourself that you aren't selling it seems that mot of these sets would be fine.

Title: Is it legal to take the icon/graphic file found online to use in software project?

Body:
For example, like this icon website: http://www.iconspedia.com/

There is a lot icon there, (I just can't draw myself, I am not good at it.....), I wonder if is OK to use them in my software project?

Will the type of project make difference?

i.e Open Source Application, Commercial Application, Free Download Application?


问:
Releasing Mobile Application under multiple platforms, same time or?
I've always had this idea circling around until I am facing this issue.

We made an android app, it is ready, but we are planning to release the same app on iOS and possibly Windows Phone;

Now, should we just release the Android app and promise the clients that the iOS version is coming soon (create anticipation before release)

or delay the release until the iOS version is ready?

Same applies if we have a premium and free version, should we release the free version and promise that the better premium is coming soon, or release them both the same time?

EDIT: as requested, the APP is a social APP, it depends on people's activity to succeed, and the manpower is the same, we made the iOS version, but to compile it we are waiting for the company to get us better Mac Machines (will be in a  week for most)

答:
On free / premium, it depends. If the free version is fully usable and is going to improve the user's life a lot, it might be worth getting the free version out there and building some hype. If the free version isn't that great, and it's just a gateway drug to the premium version then making them wait for the premium risks their moving off it and never coming back.

As to Android/iOS, it's not so much that it depends as I can think of a huge advantage and a huge disadvantage to either decision and you need to balance them off and consider which is most important to you.

If you release them together then you'll get combined hype, which is always good. People using the Android version will talk about it in earshot of people using the iOS version. That can only be good for you.

BUT it means that, if you have any bugs, you've got twice as many people clammering for a fix and twice as much negative press. In that sense, it might be worth getting the Android free version out quickly and calling it a Beta or EAP release.