问:
Is it possible to create and distribute an app for the BlackBerry Playbook that doesn't go into App World?
My company is looking to create an app that we'll use internally on several (about 20) BlackBerry Playbooks. We don't want it to be put up on App World because it's just an internal application. I'm wondering if there are any:

Costs involved with this outside of paying a programmer to develop it - i.e. Are there any license fees, deployment fees, etc.

License issues involved with deploying the app to multiple Playbooks without deploying it to App World

Limitations on functionality of the app

Other things we should be taking into consideration

If it matters, the app will be collecting information and downloading it to a computer via USB.

答:
Unfortunately the PlayBook, unlike other BlackBerry devices, doesn't directly support applications that aren't released through the AppWorld.

There are a couple of ways around that.

You could put every device in developer mode and then connect via cable directly to the development machine and deploy the application.  For a very small number of devices this is probably acceptably simple.  For a larger number this isn't very practical.

You can sideload apps onto the playbook by connecting the device via USB cable and using a few simple tools.  This blog post explains it: http://limetrip.blogspot.com/2011/09/how-to-install-angrybirdsbar-apps-to.html

The above method works but you still need to physically connect every device to a PC.  There's an application that's been developed called LocalBar that allows you to sideload BAR file directly from the PlayBook.  However, the LocalBar app itself requires sideloading first.  There are instructions here as well as a download link: http://limetrip.blogspot.com/2011/11/download-local-bar-app-for-free-install.html

Costs: in either case (development mode or sideloading) none, except the manual labour involved for each of the devices.

License issues: developer mode is completely fair game and doesn't break any licenses.  It's a pain though because you'll need to create a developer certificate for every device.  That's not hard, but multiply any of this by 20 and it's a hassle.  I'm not sure about the license issues related to sideloading.  It should be fine, as long as it's your own app.

Limitations: none (as far as I know)


问:
What should we provide to a dev team hired to complete a new project?
We are wanting to have developers build an in-house payroll and time sheet application using symfony2/doctrine2.

We are simply at conceptual stage at this point and this will be our first time and getting developers to build an application for our company. Hence, it is very important to us that we provide the most valid and important information to what will be our new developer team.

What documents or tools should we provide to the new team to maximize the odds of success with the project and help the developers be productive from day dot?

答:
Give them the autonomy to choose what they think is the right technology stack.

Give them each a really nice 30" monitor and at least one other decent sized monitor. I used to laugh at the whole large monitor thing until I actually got one. Wow, what a difference it makes! It's so much better than two or three more modest displays IMO. Give them decent computers, keyboards and mice.

Give them any other software tools and libraries they ask for. Give them a dedicaded machine for builds and automated tests.

ContentLicense: CC BY-SA 3.0


问:
Is there a canonical book on Android Development?
I am getting into Android Development and want a book to help fill in some of the gaps.

Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on Android Development? What about that book makes it special?

答:
Assuming you're familiar with Java, I highly suggest checking out "Beginning Android 3" By Mark Murphy

I'm a beginner myself, and this book has helped immensely.


答: There is so much information out there, the best way to start probably isn't by reading a book. In my opinion the best way to start is to go to the Android Developer website.  They explain how to do virtually everything.  Look through the sample projects and make sure you can get them up and running.  Once you have done this and have a higher level understanding of Android and java, then it might be time to look at a book such as The Busy Coder's Guide to Advanced Android Development depending on what you are looking to do with Android.</p>

Title: Is there a canonical book on Android Development?

Body:
I am getting into Android Development and want a book to help fill in some of the gaps.

Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on Android Development? What about that book makes it special?


答: Professional Android 2 Application Development is the book that I used to learn Android. The first 4 chapters provide a general overview of the development environment and the basic features every program contains. From there, pick and choose chapters based on your project idea.</p>


问:
Filling a scene with cubes
I am trying to design a solution for simulating gaseous fluids in confined areas, I am using naiver-stokes equations for fluid dynamics but since it only covers incompressible fluids like liquid, i needed to find a way to simulate compression

Recently, I came up with the solution which is, creating a field storing pressure data for each volumetric partition and I thought it would be a good idea to construct this field as a composition of cubes where each cube has homogeneous pressure value within itself.

I tried to inflate a cube from a point and create other cubes from its surfaces recursively minding the collision with surfaces inside that scene, but this algorithm fails because there are lots of detailed cases involving complex holes and notches on the object. Is there a better way to construct this field?

答:
A recursive "fill" should work for any shape no matter how complex. Unless a single cube is to big to fit in the hole.

What are the cases where it fails?

Title: Filling a scene with cubes


问:
How can I inspire engineers to positively conduct telephone interviews
Our (mid-size) company (with 150 employees) has witnessed considerable growth since last year, and as a result we have been conducting lots of interviews to hire more and more engineers to bring new projects in motion.

To begin with, following is our interview process

Screening resume by HR

Telephone technical interview (conducted by senior engg)

Final technical + HR interview (conducted by team-lead/PM)

After some analysis we found that telephone interviews are not really becoming effective, due to which we are not able to find good number of engineers in final interview. My analysis revealed that engineers don't consider interviewing as important/serious activity, since it's internal and non-billable. Also I see that engineers don't find it really prestigious to carry a label of "interviewer" (at-least telephone interviewer). We do have  set of good experienced engineers in company who can take any interview very effectively, but since number of telephonic interviews is large, this pool is not sufficient. Hence we try to use other engineers as well.

What can be done to inspire engineers to conduct telephone interviews seriously and positively (not treating this as mundane job)?

[Update-2011/12/28]

Thanks for sharing your valuable opinions. It really helped me to look at problem from variety of different angles. Alongside I was discussing issues with few colleagues as well and I personally feel that there is no single silver bullet for such issue. I will need to think recruitment process as a whole unit and plan to improve different areas/stages in it.

答:
People like to feel important.

If you want them to take interviewing more seriously, you need to convince your interviewers that this is a pivotal and important role.  They are the gatekeepers for the next generation of employees in your company.  This is clearly an important job, and it shouldn't be hard to sell it as such.  If you give your interviewers a deserved sense of importance towards this responsibility, they will likely try to do it to their best ability.

Example pitch: "Since you have shown yourself to be a valuable asset to this company and you have a keen eye for quality, I could use your help in hiring the best employees.  Would you be willing to lend your help in conducting phone interviews with applicants?" Ok, maybe that's a little exaggerated but you get the idea.

In essence, don't just dish it to your employees as an extra responsibility.

Hype it up.

OwnerDisplayName: FutureProof


问:
How to implement Continuous Delivery with Java webapp?
I've been reading about Continuous Delivery and it sounds awesome to automate the deployment process. I've been reading about possibilities how to do this with Java Webapps, but usually it ends up with CI server or maven plugin deploying to Tomcat WITHOUT restarting the Tomcat using Tomcats management API. But that leads to OutOfPermGenSpace issues and so I wouldn't use those solutions for production. In addition it is a hassle to kill an out of control Tomcat.

Is there any technology that would make it easy to deploy Java web apps to production? I use maven to build my artifacts and deploy to nexus repository.

EDIT:

I'm not trying to find ways to prevent Permgen space issues. I'm trying to automatically deploy to production. There should be no manual steps beyond choosing a version and clicking a button(or giving a version number to a commandline script). I want to find out if I have to create this kind of setup manually, or if there is a ready made solution for this. Thus far LiveRebel seems to be the only solution so far that doesn't require me to implement everything myself.

答: I think you could increase the PermGen szie(-XX:PermSize=64M -XX:MaxPermSize=128m),this default value is 64M. If you do not want to increase it ,you may be could use ANT to deploy your web app.</p>


答:
First off, the Navier-Stokes Equations don't assume incompressibility in general.  You can simplify the equations if you assume incompressibility, but it's not necessary.

Second, I have to ask:  Do you have a really good reason not to be using off-the-shelf computational fluid dynamics software?  Finite element analysis in general is not for the faint of heart.

To address your actual question:  Dividing the fluid volume into cubes should be straightforward.  Personally, I would just divide the entire volume into cubes, then find the ones which are in the fluid. You can speed things up with a proper recursive fill (as suggested by Tydus), but you can also just check every single cube, if you don't mind trading a bit of CPU heat for some typing.

Another aside, addressing your proposed solution:  Assuming homogeneity within the cube (element) is an odd choice.  It would be much more typical to use first order interpolation.  If you're hoping to use a left-hand approximation to try to solve the differential equation for each element independently, beware: numerical instability looms, and your results may well be totally wrong.  (In general, you should be thinking 'these results are probably wrong' whenever using numerical methods, but this probably is particularly probable).

Typically, for this sort of problem, you need to assemble the full system of equations and solve simultaneously.  (Like I said, not for the faint of heart).

Title: Filling a scene with cubes

Body:
I am trying to design a solution for simulating gaseous fluids in confined areas, I am using naiver-stokes equations for fluid dynamics but since it only covers incompressible fluids like liquid, i needed to find a way to simulate compression

Recently, I came up with the solution which is, creating a field storing pressure data for each volumetric partition and I thought it would be a good idea to construct this field as a composition of cubes where each cube has homogeneous pressure value within itself.

I tried to inflate a cube from a point and create other cubes from its surfaces recursively minding the collision with surfaces inside that scene, but this algorithm fails because there are lots of detailed cases involving complex holes and notches on the object. Is there a better way to construct this field?


问:
Data indexing frameworks fit for large E-Commerce applications
we wrote and still maintain a large E-Commerce application. Our feature list resembles what you would expect from most shops. We'd like to improve some of our features, and now the search/suggestion list functionality (enter some letters, a JScripted suggestion list appears) has caught our eye.

Currently, we use http://xapian.org/. It has some drawbacks. Firstly, it's not actually the right solution. It has been created to index documents, not ever-changing data in a granularity that an E-Commerce application would need. Secondly, the load on the database is significant when we reindex all data every night.

We'd like a framework that has been designed for indexing database data, which can add to the index easily and without much load, which can supply data changes in the backoffice quickly to the frontend without much load and delay.

I'm aware of the fact that Xapian is Open Source and even Free Software, so we could adapt it to our needs if we decided to invest the time and manpower. But taking a quick look around for a solution more suited seems fair, right?

Oh, and commercial applications are fine, too. FOSS is not required.

答:
We had EXACTLY the same needs that you are describing. We are a python shop... we sell around 300,000 unique items - so we needed fast updates.  After testing Xapian I decided against it.  What we ended up with was PyLucene - we have a server that is constantly rebuilding search indexes and replaces copies of read-only search indexes periodically.  When you can have a local-copy on your servers of your search index it makes things amazingly fast.
Transporting the database is just copying gzipped files on disk.

We actually spoke to several larger companies and got some advice from them - this seemed like the right way to go.  If you are looking for a FTS engine that is real-time updated I would look at TSEARCH2 and Postgres, otherwise Lucene, or PyLucene is a great way to go.
It takes about 20 seconds to build our index - and we can obviously adjust our weights and search formula's as frequently as we like.


问:
What's a good way to prepare for this course titled "Programming Language Security"?
I have a course with the following description:

The purpose of this course is the study of programming language security features  and languages designed to support it explicitly. Static and dynamic constructs for security in languages and systems, as well as software engineering security principles/patterns.

Topics:

Basic Programming Language security framework.

Designing secure programming languages

Access control in programming languages

Information flow languages

Capability Languages

Mobile programming languages

Software Engineering and Security

Basic software vulnerabilities in systems

Secure Software Engineering life-cycle

Patterns, and Practices for software security

I'm confused - How is PL security different from regular security? I'm looking for possible textbooks/books to study, or websites that are good in this topic, or any advice/tips. The professor told me to know C and Java well, that's all I know so far.

I appreciate any tips or advice.

答: In college my roomate prepared for such a course by learning how to manipulate memory for an online game he played.  It kept him motivated to brush up on his C skills (and assembly) and also gave him the motivation to learn the details of the compiler, and memory/pointer manipulation.  Eventually when he had to work on a project he would just play/hack his game... The results of which became his semester project.</p>


问:
Developing a Configurable Pricing Program
The organization I work at has some interesting requirements when it comes to pricing for online commerce.  Currently the developers write different 'pricing rules' and those rules can be applied to our items based on attributes of the items.

For Example:

  INPUTS: [cost, sug_retail, discontinued, warehouse_qty, orderable_qty, brand, type, days_available, shipping_rate, weight, map_protected, map_discount]

  MATCH: brand=x, warehouse_qty > 1, discontinued=True, map_protected=False

  SET: retail_price = (sug_retail * 0.95), offer_price1 = (cost * 1.25 + shipping_rate)

I am looking to allow the merchandising team to have more control over the pricing and formulas - they are afterall technical enough to write excel formulas.

I've been looking at writing a desktop application that uses something like numexpr http://code.google.com/p/numexpr/ or http://sympy.org/en/index.html to allow non-programmers to integrate their own logic into our pricing backend.

We have multiple price-tiers we have to set, for multiple markets, so an elegant solution is needed.  It's getting frustrating for the dev team to continually tweak/manage all of the pricing rules (we sell over 200 brands in 3 markets).

My question is; does this seem like a decent approach?  Can you think of a better way to parse string-mathematical-grammer?  Can you think of a different way for users to provide formula's to integrate into a automated pricing system?
Does anyone know of any examples of existing applications that do this?

Excel, and Access are out of the question - the volume of data we manipulate has already proven the need to automate it - now we just need some visibility into that automation.

答:
I think its bad idea, for the simple reason that I don’t think your merchandisers are smart enough to do this right. They are going to make conflicting rules; they are going to need a utility to mass assign a rule to items based on criteria. And the criteria used to assign the rule should have been part of the rule to begin with. It’s just going to get messy. (Then  one day the site will sell 400 90 inch plasma TVs @ $20 a piece, management will flip out that the merchandises was able to f* up so badly because of a misplaced parentheses)

Because new variables are introduced every other week, you will need to modify your rules engine anyhow, so you are not saving much there anyhow.

I suggest you have one master algorithm (taking in all 800 parameters and cross reference tables) and be done with it. I know you are going to have to modify that algorithm every other week, but that’s just the nature of the industry.


问:
Which languages use "paired" header/implementation files?
C is ubiquitous, and C++ nearly as much, but I'm curious which other languages follow a similar model of header files.  Specifically, in which other languages is it idiomatic to edit pairs or groups of "header" and "implementation" files?  (A group as in multiple headers with one corresponding implementation file or a single header with multiple implementation files, as also seen in C.)  For example, the pair "blah.h" and "blah.c".

C's header files are tied into the C preprocessor, but that's not the detail I'm focusing on here.  For example, PHP has various include mechanisms, but you don't have a pair/group of "blah-header.php" plus "blah-notheader.php".

Some languages generate a file from source in a one-to-one mapping, such as Java, but that's not what I'm talking about either.  I'm interested in cases where the programmer directly edits both/all files in the pair/group.

Perhaps to put it another way: which languages have a declaration file ("header") and definition file ("implementation") such that a person would generally edit both files in tandem?

答:
Ada

Any Ada package on the other hand consists of two parts, the specification (header) and body (code). The specification however is a completely stand alone entity which can be compiled on its own and so must include specifications from other packages to do so. An Ada package body at compile time must refer to its package specification to ensure legal declarations, but in many Ada environments it would look up a compiled version of the specification.

```<code>--file example.ads, the package specification.
package example is
:
:
end example;

--file example.adb, the package body.
package body example is
:
:
end example;
</code>```

Source: http://www.adahome.com/ammo/cpp2ada.html#2

OwnerDisplayName: Roger Pate

LastEditorDisplayName: Roger Pate

ContentLicense: CC BY-SA 2.5

Body:
Ada

Any Ada package on the other hand consists of two parts, the specification (header) and body (code). The specification however is a completely stand alone entity which can be compiled on its own and so must include specifications from other packages to do so. An Ada package body at compile time must refer to its package specification to ensure legal declarations, but in many Ada environments it would look up a compiled version of the specification.

--file example.ads, the package specification.
package example is
:
:
end example;

--file example.adb, the package body.
package body example is
:
:
end example;

Source: http://www.adahome.com/ammo/cpp2ada.html#2


问:
TRS-80 Color BASIC as an inspiration for a new programming language
For a time now I have been wanting to make my own programming language.

I'm 17 and the only language I know is Color BASIC. I know that compared to today's complicated languages, it's pretty weak.

But I was wondering if it would be hard to create a language that is kinda like color BASIC/BASIC and how would I start it?

What to do or what do I need to do to learn how to make my own programming language?

答:
I found this book Game Scripting Mastery a very good book. It's not a very well known book but it goes from implementing a super basic scripting language all the way to a custom designed compiled scripting language. It's also easy to follow and all the examples are related to games. The only problem is that it's in C++ but all the basics are very well explained.

You can find a pretty cheap used copy in Amazon or elsewhere, just make sure you get a copy that includes the CD with it.


答:
Remember Bill Gates got started writing a Tiny BASIC interpreter for the ALTAIR.

There are better languages around, but you can easily write an interpreter for a small language of your own, and it's fun and good experience.

Start with whatever language you've already got.
You probably want to keep it really simple, like for starters only have numeric variables, and keep the variable names to single characters like A, I, or X.
You can do arrays later.

For expressions, like (F-32)*5/9 a recursive-descent parser is easy to write and excellent practice.
You don't need to build a parse tree - you can just calculate the results as you parse along.

Forget functions/subroutines. You can do those later.
For control structure, if you wanted to be really minimalist, you could stick to IF and GOTO.
You can do the more structured stuff when you get more confident.

When you get something working, you can elaborate it in whatever directions you want.

Have fun!

Title: TRS-80 Color BASIC as an inspiration for a new programming language

Body:
For a time now I have been wanting to make my own programming language.

I'm 17 and the only language I know is Color BASIC. I know that compared to today's complicated languages, it's pretty weak.

But I was wondering if it would be hard to create a language that is kinda like color BASIC/BASIC and how would I start it?

What to do or what do I need to do to learn how to make my own programming language?


问:
What performance can we expect from std::string's c_str()? Always constant time?
I've been doing some needed optimizations lately. One thing I've been doing is changing some ostringstreams -> sprintfs. I'm sprintf'ing a bunch of std::strings to a c style array, ala

```<code>char foo[500];
sprintf(foo, "%s+%s", str1.c_str(), str2.c_str());
</code>```

It turns out that Microsoft's std::string::c_str() implementation runs in constant time (it just returns an internal pointer). It appears that libstdc++ does the same. I realize the std makes no guarantees for c_str, but its hard to imagine another way of doing this. If, for example, they copied into memory they'd either have to allocate memory for a buffer (leaving it up to the caller to destroy it -- NOT part of the STL contract) OR they'd have to copy to an internal static buffer (probably not threadsafe, and you have no guarantees on its lifetime). So simply returning a pointer to an internally maintained null terminated string seems to be the only realistic solution.

答:
If I recall, the standard allows string::c_str() to return pretty much anything that satisfies:

Storage which is large enough for the contents of the string and the terminating NULL

Must be valid until a non-const member of the given string object is called

So in practice, this means a pointer to the internal storage; as there is no way to externally track the life of the returned pointer.  I think your optimisation is safe to assume this is (small) constant time.

On a related note, if string formatting is performance limiting; you may find better luck deferring the evaluation until absolutely needed with something like Boost.Phoenix.

Boost.Format I believe defers the formatting internally until the result is required, and you can use the same format object repeatedly without re-parsing the format string, which I've found to make a significant difference for high-frequency logging.


答:
A programming language implementation typically starts by transforming the source code in passes:

Lexical analysis: break up the input text into tokens.  This deals with whitespace and comments.  For example:

```<code>a := 1 + 2 * 3 -- comment
</code>```

might be turned into:

```<code>identifier a
operator :=
number 1
operator +
number 2
operator *
number 3
</code>```

The above is pseudocode representing a list of values, where each value is a token.

Parsing: Build a tree representing the source code:

```<code>assignment:
    lvalue:
        variable a
    rvalue:
        add:
            number 1
            multiply:
                number 2
                number 3
</code>```

Parsing determines things like where statements start and end, and order of operations.

There may be additional passes after this, depending on the complexity of the language and the quality of the implementation.

Finally, the resulting tree is either interpreted or compiled.

Interpreted: The program is run directly.  This is usually easier to implement.

Compiled: The program is converted into one of the following:

Machine code, so the CPU can run it directly.

Bytecode, so it can be executed by a virtual machine.

Another programming language.  For example, some programming language implementations compile to C, then invoke a C compiler to produce machine code.

This is a rough overview.  As you can see, implementing a programming language is rather involved.  To avoid feeling overwhelmed, start by implementing a very small set of features.  Don't start by writing a lexer or parser that supports your entire language; you'll get burnt out before you get to see something working.  The key is to get something working.  It will set up a strong feedback loop: adding new features will be fun because you'll get to see them work right away.

I don't recommend jumping into writing an interpreter for BASIC right away.  Here are some starting points:

Implement a calculator supporting order of operations.  Example:

```<code>> 1 + (2 + 3) * (4 + 5)
46
</code>```

Implement a random sentence generator, using a template that looks something like this:

```<code><weapons>
a snake
many snakes
a gun
a rocket launcher
a thick board and something sharp

<verb>
kill
destroy
dismember
impale

<sentence>
I will <verb> you with <weapons>.
</code>```

This is a nice example of a domain-specific language.

Learn the C programming language.  It'll give you a better understanding of how computers work.  C will seem less convenient at first (e.g. you can't simply take two strings and concatenate them, you have to allocate a buffer large enough for both strings first), but you'll find that it provides better methods of structuring data than you had in BASIC.

Body:
A programming language implementation typically starts by transforming the source code in passes:

Lexical analysis: break up the input text into tokens.  This deals with whitespace and comments.  For example:

a := 1 + 2 * 3 -- comment

might be turned into:

identifier a
operator :=
number 1
operator +
number 2
operator *
number 3

The above is pseudocode representing a list of values, where each value is a token.

Parsing: Build a tree representing the source code:

assignment:
    lvalue:
        variable a
    rvalue:
        add:
            number 1
            multiply:
                number 2
                number 3

Parsing determines things like where statements start and end, and order of operations.

There may be additional passes after this, depending on the complexity of the language and the quality of the implementation.

Finally, the resulting tree is either interpreted or compiled.

Interpreted: The program is run directly.  This is usually easier to implement.

Compiled: The program is converted into one of the following:

Machine code, so the CPU can run it directly.

Bytecode, so it can be executed by a virtual machine.

Another programming language.  For example, some programming language implementations compile to C, then invoke a C compiler to produce machine code.

This is a rough overview.  As you can see, implementing a programming language is rather involved.  To avoid feeling overwhelmed, start by implementing a very small set of features.  Don't start by writing a lexer or parser that supports your entire language; you'll get burnt out before you get to see something working.  The key is to get something working.  It will set up a strong feedback loop: adding new features will be fun because you'll get to see them work right away.

I don't recommend jumping into writing an interpreter for BASIC right away.  Here are some starting points:

Implement a calculator supporting order of operations.  Example:

> 1 + (2 + 3) * (4 + 5)
46

Implement a random sentence generator, using a template that looks something like this:

<weapons>
a snake
many snakes
a gun
a rocket launcher
a thick board and something sharp

<verb>
kill
destroy
dismember
impale

<sentence>
I will <verb> you with <weapons>.

This is a nice example of a domain-specific language.

Learn the C programming language.  It'll give you a better understanding of how computers work.  C will seem less convenient at first (e.g. you can't simply take two strings and concatenate them, you have to allocate a buffer large enough for both strings first), but you'll find that it provides better methods of structuring data than you had in BASIC.


问:
Does any programming language use variables as they're in maths?
In maths, a variable means you can put any number there, and an equation will still be true:

```<code>root(square(x)) = abs(x)
</code>```

In programming languages, this is not so: a var can change. In Python:

```<code>y = (x**2)**.5
x *= 2
assert y == abs(x)
</code>```

will raise an exception, since x in the last line is not the same.

Are there programming languages that use immutable variables?

答:
To answer your title question "Does any programming language use variables as they're in maths?":
C, C#, Java, C++, and any other C style language use variables in the way they are used in math.

You just need to use == instead of =.

If I take your original

```<code>root(square(x)) = abs(x)
</code>```

Then I can translate that into C# directly without any changes other than for the syntax.
Math.Sqrt(Math.Pow(x,2)) == Math.Abs(x)

This will evaluate to true for any value of x as long as x squared is less than the max for the data type you are using.
(Java will be grossly similar, but I believe the Math namespace is a bit different)

This next bit will fail to compile in C# because the compiler is smart enough to know I can't assign the return of one operation to another operation.

Math.Sqrt(Math.Pow(x,2)) = Math.Abs(x)

Immutability has nothing to do with this. You still need to assign the value in an immutable language and it's entirely possible that a given language may chose to do this by using = as the operator.

Further proving the point, this loop will run until you exhaust legal values of x and get an overflow exception:

```<code> while (Math.Sqrt(Math.Pow(x, 2)) == Math.Abs(x))
        {
            ++x;
            System.Console.WriteLine(x);
        }
</code>```

This is why mathematicians hate the use of = for assignment. It confuses them. I think this has led you to confuse yourself. Take your example

```<code>y = (x**2)**.5
x *= 2
assert y == abs(x)
</code>```

When I turn this into algebra, I get this:

abs(2x) = root(x^2)

Which of course is not true for values other than 0. Immutability only saves you from the error of changing the value of x when you add extra steps between evaluating the Left Hand Side and Right Hand Side of the original equation. It's doesn't actually change how you evaluate the expression.

Body:
To answer your title question "Does any programming language use variables as they're in maths?":
C, C#, Java, C++, and any other C style language use variables in the way they are used in math.

You just need to use == instead of =.

If I take your original

root(square(x)) = abs(x)

Then I can translate that into C# directly without any changes other than for the syntax.
Math.Sqrt(Math.Pow(x,2)) == Math.Abs(x)

This will evaluate to true for any value of x as long as x squared is less than the max for the data type you are using.
(Java will be grossly similar, but I believe the Math namespace is a bit different)

This next bit will fail to compile in C# because the compiler is smart enough to know I can't assign the return of one operation to another operation.

Math.Sqrt(Math.Pow(x,2)) = Math.Abs(x)

Immutability has nothing to do with this. You still need to assign the value in an immutable language and it's entirely possible that a given language may chose to do this by using = as the operator.

Further proving the point, this loop will run until you exhaust legal values of x and get an overflow exception:

 while (Math.Sqrt(Math.Pow(x, 2)) == Math.Abs(x))
        {
            ++x;
            System.Console.WriteLine(x);
        }

This is why mathematicians hate the use of = for assignment. It confuses them. I think this has led you to confuse yourself. Take your example

y = (x**2)**.5
x *= 2
assert y == abs(x)

When I turn this into algebra, I get this:

abs(2x) = root(x^2)

Which of course is not true for values other than 0. Immutability only saves you from the error of changing the value of x when you add extra steps between evaluating the Left Hand Side and Right Hand Side of the original equation. It's doesn't actually change how you evaluate the expression.


问:
What is the difference between Software Project Management Process and Software Development Process?
What is the difference between Software Project Management Process, and Software Development Process, or Software Life Cycle?</p>

答:
The Software Life Cycle is any process model that has specification, development, validation and maintenance phases and these can repeat in cycles so it's sort of the structure of the development processes:

Software project management considers the practical limits, risks and deadlines and forms a complete plan for the entire project and the maintenance of its progress.

see Wikipedia for more details about Development and Management

ContentLicense: CC BY-SA 4.0


答:
Slow down. This is a major project, and you're nowhere near ready for this. I'm not trying to put you down, just to save you a lot of wasted time.

Learn several other languages, and make sure that C is one of them. Learn assembly (maybe start with a simple instruction set like ARM). Learn how compilers work. Write a few programs that actually do useful stuff for  people. By that time, you'll have a good foundation to come back to this plan, if you still want to.


问:
Should I choose Doctrine 2 or Propel 1.5/1.6, and why?
I'd like to hear from those who have used Doctrine 2 (or later) and Propel 1.5 (or later). Most comparisons between these two object relational mappers are based on old versions -- Doctrine 1 versus Propel 1.3/1.4, and both ORMs went through significant redesigns in their recent revisions. For example, most of the criticism of Propel seems to center around the "ModelName Peer" classes, which are deprecated in 1.5 in any case.

Here's what I've accumulated so far (And I've tried to make this list as balanced as possible...):

Propel

Pros

Extremely IDE friendly, because actual code is generated, instead of relying on PHP magic methods. This means IDE features like code completion are actually helpful.

Fast (In terms of database usage -- no runtime introspection is done on the database)

Clean migration between schema versions (at least in the 1.6 beta)

Can generate PHP 5.3 models (i.e. namespaces)

Easy to chain a lot of things into a single database query with things like useXxx methods. (See the "code completion" video above)

Cons

Requires an extra build step, namely building the model classes.

Generated code needs rebuilt whenever Propel version is changed, a setting is changed, or the schema changes. <s>This might be unintuitive to some and custom methods applied to the model are lost. (I think?)</s> -- Not true; custom methods aren't lost because the generated class is a base class; Propel provides an entity class specifically for extension.

Some useful features (i.e. version behavior, schema migrations) are in beta status.

Doctrine

Pros

More popular

Doctrine Query Language can express potentially more complicated relationships between data than easily possible with Propel's ActiveRecord strategy.

Easier to add reusable behaviors when compared with Propel.

DocBlock based commenting for building the schema is embedded in the actual PHP instead of a separate XML file.

Uses PHP 5.3 Namespaces everywhere

Cons

Requires learning an entirely new programming language (Doctrine Query Language)

Implemented in terms of "magic methods" in several places, making IDE autocomplete worthless.

Requires database introspection and thus is slightly slower than Propel by default; caching can remove this but the caching adds considerable complexity.

Fewer behaviors are included in the core codebase. Several features Propel provides out of the box (such as Nested Set) are available only through extensions.

Freakin' HUGE :)

This I have gleaned though only through reading the documentation available for both tools -- I've not actually built anything yet.

I'd like to hear from those who have used both tools though, to share their experience on pros/cons of each library, and what their recommendation is at this point :)

答: I chose Propel 1.63 for a large legacy mysql application (200 tables or so) - the factors here included: IDE support that enables new developers to find their way easily with code completion; cross database schema support, performance; better native support for enums and the use of several behaviours.  Actually I started with Doctrine since this was the best supported by Symfony2 but once Propel vastly improved their support with Symfony (the next platform I will eventually migrate to) I switched due to the better handling of above issues.  No regrets at all Propel is a decisive winner.</p>


问:
Is there an expiration date for well regarded, but old books on programming?
After reading a question about books every programmer should read, I wonder if the following should be considered obsolete:

Code complete: 1st edition in 1993; 2nd edition in May, 2004

Introduction to algorithms (Cormen, Leiserson, Rivest, Stein): 1st edition in 1990; 2nd edition in September, 2001; 3rd edition in 2009

The Pragmatic Programmer: October, 1999

Structure and Interpretation of Computer Programs: 1st edition in 1984; 2nd edition in September, 1996

The C Programming Language: 1st edition in 1978; 2nd edition in April, 1988

All these books seem very old. Isn't there a difference between modern computing and what was current when those book were written?

For example, my 61-year-old teacher explains things very nicely but forgets to take into account all that has been done between when he began to teach 25 years ago and now.

Isn't the same true for those books? Aren't there any more modern books that teach principles and technologies that are closer to current practice? Or do you consider them to be useful and relevant even today?

答:
Ok, so I am going to offer an answer that is much more theoretical. I agree with all of you guys that answered the, quite obvious in my opinion, these books are the basis of what we as programmers do and all of these new frameworks are built on these same old pillars line.

Here are my two cents-- not really mine, I learned it from St. Aquinas and from Aristotle before him.

```<code>An abstraction is useless to someone who doesn't understand the particulars.
</code>```

The mechanics of a computer have not changed since von-neumann. Similarly, the particulars you need to learn to be a great programmer will be the same until the von-neumann model is obsolete. Assembly, is the language of computers ... learn it, no excuses.

C is the native language of both Windows and Unix. Learn it or find a new trade. If you are one of those guys that went straight to JAVA or C#, you may be a good programmer, but you would be a much better programmer if you would learn C-- period.

Algorithms and Data Structures are the foundation of computer programs, learn them.

Everything else is an abstraction of these very core disciplines. Abstractions are wonderful when used properly-- seriously, I use C# for 75% of all of my projects. However, they make you stupid if you do not take the time to understand how they work and how to function without them. You will spend endless time making software to fit through the proverbial square hole when there are much better approaches and will have bugs that could have been avoided. Software Development is a craft that must be mastered, and at the end of the day, the tools rarely change. That is why these books are so important.

All of these JAVA and C# only programmers, tsk, I'll bet most of them have never even seen an episode of Star Trek!

Body:
Ok, so I am going to offer an answer that is much more theoretical. I agree with all of you guys that answered the, quite obvious in my opinion, these books are the basis of what we as programmers do and all of these new frameworks are built on these same old pillars line.

Here are my two cents-- not really mine, I learned it from St. Aquinas and from Aristotle before him.

An abstraction is useless to someone who doesn't understand the particulars.

The mechanics of a computer have not changed since von-neumann. Similarly, the particulars you need to learn to be a great programmer will be the same until the von-neumann model is obsolete. Assembly, is the language of computers ... learn it, no excuses.

C is the native language of both Windows and Unix. Learn it or find a new trade. If you are one of those guys that went straight to JAVA or C#, you may be a good programmer, but you would be a much better programmer if you would learn C-- period.

Algorithms and Data Structures are the foundation of computer programs, learn them.

Everything else is an abstraction of these very core disciplines. Abstractions are wonderful when used properly-- seriously, I use C# for 75% of all of my projects. However, they make you stupid if you do not take the time to understand how they work and how to function without them. You will spend endless time making software to fit through the proverbial square hole when there are much better approaches and will have bugs that could have been avoided. Software Development is a craft that must be mastered, and at the end of the day, the tools rarely change. That is why these books are so important.

All of these JAVA and C# only programmers, tsk, I'll bet most of them have never even seen an episode of Star Trek!


答:
PL Security is fundamentally no different to real world physical security, pity most of the industry has yet to realize this.

Some languages make it easier to shot yourself in the foot (C) than others (Java), but you can do it in any language if you try hard enough.

Reading the later works of Bruce Schneier and some back issue of his monthly news letter will give you some real insight into what goes wrong.

Title: What's a good way to prepare for this course titled "Programming Language Security"?

Body:
I have a course with the following description:

The purpose of this course is the study of programming language security features  and languages designed to support it explicitly. Static and dynamic constructs for security in languages and systems, as well as software engineering security principles/patterns.

Topics:

Basic Programming Language security framework.

Designing secure programming languages

Access control in programming languages

Information flow languages

Capability Languages

Mobile programming languages

Software Engineering and Security

Basic software vulnerabilities in systems

Secure Software Engineering life-cycle

Patterns, and Practices for software security

I'm confused - How is PL security different from regular security? I'm looking for possible textbooks/books to study, or websites that are good in this topic, or any advice/tips. The professor told me to know C and Java well, that's all I know so far.

I appreciate any tips or advice.


问:
Do I need to get permission to access a site's data or functionality programmatically?
I'm creating an application which will programmatically sent HTTP GET and POST requests to a site and processing the data received.

If I want to release that application, do I have to get permission from the site's owners?

答:
While I don't think there are any specific laws that would prevent you from doing this, personally I would be very sketched out about using someone else's web services that have not been officially published for the world.

The reason being is not legal reasons but the fact that you are taking your eggs and putting it into a basket that can be easily taken right from under you. What happens if you spend 3-12 man-months developing an app that is based on some specific web service and then the company discovers you and changes/locks down their API? Is all that time wasted? Do you have a backup plan?

Doing this is kind of like what Boxee tried to do with Hulu. Hulu has its own site but it clearly has streaming servers for its media content. Boxee tried to create their software so it could stream directly from Hulu, but Hulu had other plans. This never went to court but since Hulu can keep changing interfaces without any notice, it simply prevented Boxee from receiving its content.

So my advice is 1) use only public APIs that are guaranteed to stay public, 2) if not public, contact the company and see if you can enter into some kind of agreement or 3) look somewhere else for what you need, perhaps another open source project


问:
Why aren't there automated translators from one programming language to another?
Most programming languages are Turing complete, which means that any task that can be solved in one language can be solved in another one, or even on Turing machine. Then why aren't there automatic translators that can convert programs from any given language to any other language? I've seen couple attempts for two languages, but they always work only on a limited subset of a language and can hardly be used for converting real projects.

Is it possible, at least in theory, to write 100% correct translator between all languages? What are the challenges in practice? Are there any existing translators that work?

答:
There are no language translators for programming languages because programming languages are incredibly complex.  While it is hypothetically possible, there are many challenges.

The first challenge is merely in the acceptable practices of the language.  Converting between two object oriented languages like Java and C++ is incredibly complex, and they are both C based.  The translator program would have to have perfect knowledge of the standard libraries for both languages and be able to know the differences in behavior.  You would have to create a massive dictionary and even then, the differences in programming styles from programmer to programmer would mean that it would have to guess on how to perform some changes.

Once you've gotten the syntax translation down, you then have to figure out how to convert a construct in the first language to a construct in the second language.  This is fine if you're going an object in C++ to an object in Java (comparatively easy that is) but what do you do with your C++ structs? Or the functions outside of the C++ classes? Deciding how to handle this can be tricky as it can result in another problem, namely the creation of a blob object. The blob is an antipattern which is common enough.

This isn't a complete list of the problems, but those are just two and they're big ones.  One of my professors mentioned that someone convinced his employer they could make one from machine code to C in the 80s, but it didn't work then. I doubt there will ever be one that works fully.


问:
Best practice for using a user control across many projects
I have a messaging User Control, that is used across 4 projects, and for each change I have to propagate it in 4 places. This is obviously against the DRY principle. However, centralizing user controls is not an easy task too, because you have both markup, and code-behind, and we know that markup won't get compiled till run-time requests. This means that you can't simply put the User Control in one project, and compile it, and use its result DLL file in many places.

So, what do you suggest as a good, neat approach for centralizing use of User Controls?

答: Create a NuGet package for it.  You should be able to deploy the markup and code behind to the appropriate locations as well as handle any web.config changes, and manage updating all of this as a unit, with a NuGet package.</p>


问:
How should semi-agile team operate during management-imposed waterfall-like "testing phase"
I'm not looking for advice how agile process should work. I know that part. I'm curious what the best way to adapt the process to a typical large, well-established corporation who loves its "processes" and gate/passport reviews.

For those lucky enough not to know what they are, gates/passport things are essentially waterfall milestones presented by development teams to executives: Gate 0 - kick off, identifying positive npv projects; Gate 1 - planning work for the release, coding begins, Gate 2 - code complete/testing phase, Gate 3....

While within our team we've tried to embrace agile as much as we could (peer reviews, iterations, constant communication, doing what makes sense, continuous improvement...), these gates come from way up and there's nothing we can do about them.

Of many things that bug me, one of them is that the corporate environment we are in, imposes some constraints which seem to have adverse effects on how we work. One example is that during development we only focus on new features and ignore existing bugs and even introduce new bugs.  This is unfortunate and goes against agile, but we have no choice since code complete could be in 2 months, but "testing/bug fixing" phase can last 6 months after that.  We are under constant pressure to "finish work" but emphasis is on completing features, not getting a stable product.  This part we sorta learned to live with.

My question is what strategy (successful mode of operation) other teams/companies have found for the "testing" phase that follows a "code complete" milestone?

During "new development" we have iterations and each one gets filled in with stories and tasks. However, currently once development is "done", there's no more iterations and no more planning. Instead, we solely use bug tracking database to monitor how many new bugs are being found and how fast the bugs are being resolved.

Personally, I don't see the difference between adding new UI feature and making existing UI feature work. To me work is work. I proposed that we continue having iterations as normal and continue to schedule work as before, but neither management nor other team members seemed to be on board with that.  So 1) am I way off and is bug track database the best we can do? and 2) if there's a better approach, I'd like to explore it and maybe acquire enough ammunition to take back to my boss.  At the same time I somewhat agree that a lot of times when reacting to bugs we don't have the luxury of waiting till next iteration.

--- Slight clarification based on first few responses ---

We just entered the testing phase. At the moment, there's no more stories, no more iterations. Only bug tracking database. That doesn't sit right with me, that's why I'm curious what other teams would do in this situation.  Also some bugs are definitely the size of a medium size story, while other bugs would take 5 min to fix.  Should 5-min bugs also become stories if we were to continue with iterations? The other argument we've been having is that during "new development" we only interact with Agile tracking tool (Rally) but in "testing" if we continue with iterations, we'd have to maintain paper trail in Rally as well as in bug tracking software.

答:
How do you know that your code is complete without any test ? How do you validate that you can cross Gate 2 ?

My way of doing Agile in a Waterfall process as a developer is to do TDD hidden behind a debugging curtain.

Doing so, I know when my code is complete and I am confident about its stability.

Of course coding takes a more than 2 months but coding+testing takes less than 8 months.

About new features/fixing bugs, I am sure that you can arge that the new feature cannot be introduced if that bug is not fixed before.


答:
Hm. Not that I really done this, but it seems to me that one of the most ideal models for this situation would be based on agile technique of "play and then throw away experiment".
Treat all the code you created during two months of not having opportunity to create good code as a long experiment - now you are clear what do you want to achieve and also more or less how. Toss it out and begin to do things right. Every time you successfully finish a feature, report it as "bug fixed". After all, doing everything right from the scratch is the best way to fix bugs of inherently flawed legacy code. Treat the two-month effort as bad legacy code that needs to be completely refactored, just report it as bug fixing.</p>

Title: How should semi-agile team operate during management-imposed waterfall-like "testing phase"

Body:
I'm not looking for advice how agile process should work. I know that part. I'm curious what the best way to adapt the process to a typical large, well-established corporation who loves its "processes" and gate/passport reviews.

For those lucky enough not to know what they are, gates/passport things are essentially waterfall milestones presented by development teams to executives: Gate 0 - kick off, identifying positive npv projects; Gate 1 - planning work for the release, coding begins, Gate 2 - code complete/testing phase, Gate 3....

While within our team we've tried to embrace agile as much as we could (peer reviews, iterations, constant communication, doing what makes sense, continuous improvement...), these gates come from way up and there's nothing we can do about them.

Of many things that bug me, one of them is that the corporate environment we are in, imposes some constraints which seem to have adverse effects on how we work. One example is that during development we only focus on new features and ignore existing bugs and even introduce new bugs.  This is unfortunate and goes against agile, but we have no choice since code complete could be in 2 months, but "testing/bug fixing" phase can last 6 months after that.  We are under constant pressure to "finish work" but emphasis is on completing features, not getting a stable product.  This part we sorta learned to live with.

My question is what strategy (successful mode of operation) other teams/companies have found for the "testing" phase that follows a "code complete" milestone?

During "new development" we have iterations and each one gets filled in with stories and tasks. However, currently once development is "done", there's no more iterations and no more planning. Instead, we solely use bug tracking database to monitor how many new bugs are being found and how fast the bugs are being resolved.

Personally, I don't see the difference between adding new UI feature and making existing UI feature work. To me work is work. I proposed that we continue having iterations as normal and continue to schedule work as before, but neither management nor other team members seemed to be on board with that.  So 1) am I way off and is bug track database the best we can do? and 2) if there's a better approach, I'd like to explore it and maybe acquire enough ammunition to take back to my boss.  At the same time I somewhat agree that a lot of times when reacting to bugs we don't have the luxury of waiting till next iteration.

--- Slight clarification based on first few responses ---

We just entered the testing phase. At the moment, there's no more stories, no more iterations. Only bug tracking database. That doesn't sit right with me, that's why I'm curious what other teams would do in this situation.  Also some bugs are definitely the size of a medium size story, while other bugs would take 5 min to fix.  Should 5-min bugs also become stories if we were to continue with iterations? The other argument we've been having is that during "new development" we only interact with Agile tracking tool (Rally) but in "testing" if we continue with iterations, we'd have to maintain paper trail in Rally as well as in bug tracking software.


答: FWIW, there is a translator from Java to D.  It's called TioPort and was used in a fairly serious attempt to port SWT to D.  The main problem it ran into was that it would have been necessary to port massive portions of the Java standard library.</p>

Title: Why aren't there automated translators from one programming language to another?

Body:
Most programming languages are Turing complete, which means that any task that can be solved in one language can be solved in another one, or even on Turing machine. Then why aren't there automatic translators that can convert programs from any given language to any other language? I've seen couple attempts for two languages, but they always work only on a limited subset of a language and can hardly be used for converting real projects.

Is it possible, at least in theory, to write 100% correct translator between all languages? What are the challenges in practice? Are there any existing translators that work?


答:
There are secure coding guidelines for Java, which is a very detailed list of "tips" specifically related to Java (and they explain what could happen if you. It's been a while since I used C, but as for C# which I know use frequently there are outdated (because it's for .NET 2.0) security guidelines, still a good read overall. Now, this is related to PL security.

As for software engineering security, MSDN Magazine for example has a Security portal that contains (click on "Learn") many interesting articles/stories related to writing secure applications regardless of the programming language used. It is not necessarily related to C#, VB.Net or any other specific Microsoft languages. I'll just add here a very interesting article I just read yesterday: Lessons Learned from Five Years of Building More Secure Software, but there are many more.


问:
Why pointer symbol and multiplication sign are same in C/C++?
I am writing a limited C/C++ code parser. Now, multiplication and pointer signs give me really a tough time, as both are same. For example,

```<code>int main ()
{
  int foo(X * p); // forward declaration
  bar(x * y);  // function call
}
</code>```

I need to apply special rules to sort out if * is indeed a pointer. In above code, I have to find out if foo() is a forward declaration and bar() is a function call. Real world code can be lot more complex. Had there been different symbol like @ for pointers, then it would have been straight forward.

The pointers were introduced in C, then why some different symbol was not chosen for the same ? Was keyboard so limited ?

[It will be an add-on if someone can throw light on how modern day parser deal with this ? Keep in mind that, in one scope X can be typename and another scope it can be a variable name, at the same time.]

答:
Consider using a GLR parsing, it allows you to postpone the choice between the ambiguous syntax interpretations till you've got type information. That is how parsers like Elsa work.

Another alternative is to collect and expand the types while parsing - e.g., it works well with an ad hoc recursive descent parsing implementation. This approach is used in both gcc and Clang.

There are more possibilities available: you can still use a high level generator producing a Packrat parser out of PEG specifications - this way you can stuff more side effect logic into a parsing without having to implement the whole thing manually, as with an ad hoc approach.


答:
Security (as it is related to PLs) is closely related to the notion of correctness. If your language implementation can guarantee  that a certain constraint will alway hold, it allows a better security than a less restricted language. For example, if it is guaranteed that an out of bounds array access is either impossible or will trigger an exception, your code is already safe from a very broad range of possible security exploits.

If a language allows you to reason  about certain aspects of how your code will behave, it is more suitable for secure coding than a language with a high degree of unpredictability. Consider comparing, say, C, with something like Coq or Agda2.


问:
Where can I find a legal "permission to work on open source" document?
One of the things I really like about my current job is that we developers are encouraged to make open source contributions.

However, this encouragement has always been verbal. I've read some horror stories about developers having their open-source work legally claimed by their employer. I'd be more comfortable if we had something in writing from my employer saying that contributions are allowed and not owned by the company.

Understanding that you are not lawyers, does anyone know where to find a boilerplate document to this effect?

答:
You already have permission to work on open source. An employer can't "give" this right to you because they don't control it.

However.

The document you need to find is an Intellectual Property agreement that says "Your employer owns all your intellectual property created at work".  If you have signed that, you're in trouble.  You agreed that your employer owns your good ideas.

If you have not agreed that intellectual property created at work is the property of your employer, then you're fine.  They can't suddenly claim that intellectual property belongs to them.

You have to agree.  In writing.  In advance.


答:
I don't think you'll really get anywhere without reworking the way things are done right now.

One example is that during development we only focus on new features
  and ignore existing bugs and even introduce new bugs.

I am fairly certain that this is a grave mistake. Try to explain that bug fixing becomes more difficult and more expensive the longer it is postponed. I don't think there is any excuse for postponing bug fixes for so long.

All agile methods I know emphasize that the software should be technically ready to ship at the end of each cycle/iteration (or even continuously). That means any bug that you wouldn't want to ship must be fixed before any new features is started.

Try to work with people, and explain your concerns.

Finally, if you cannot get any kind of agreement on such basics, it may be best to move on.

Edit

Based on your amended question: I agree that bug fixing should be handled just like new features. I'd normally have single tasks for "small" bugs (up to a few hours) and stories with subtasks for "big" bugs (multiple days, possible to split into tasks). If your colleagues do not agree, point out that the advantages of agile methods apply to bug fixing just like to new features.

As to wheter to use an agile tracking tool or a bug database: Ideally, the two are integrated. If they are not, then yes, you'll have to track work in both. It's annoying, but I've done it myself, and didn't find it a big problem. You track bugs as usual, and just copy&paste the bug id into the title of a task/story when you schedule a bug to be worked on. The task is just a link to the bugtracker (eays if both are web-based), and all discussion is in the bug db. If you link consistenly, you could probably even run reports across both systems.

Finally, it you believe you cannot change the way development is organized, you'll have to work within these constraints. Things like introducing some agile methods into the bug fixing phase will probably help.

Still, I am convinced that splitting development into a "feature phase" and a "bugfixing phase" is a grave, possibly fatal mistake. It may not be so serious for your company (every situation is different), but if it is, and if your organization is unable to change this, then your organization may be so dysfunctional that you'd be better off elsewhere. But that is your call to make... good luck!

Edit 2

Finally, if company policies dictate "features first, bug fixing later", maybe you can sidestep them, e.g. by redefining bug fixes as new features (the difference is often a matter of opinion anyway). To some extent, you can try to introduce new ideas "from below" that way. You know, "if you can't beat them, join them".


答: You can do this in D with .di files.  It's useful for distributing closed source libraries and such.  The .di files can also be generated automatically from the .d files.  However, unless you need to distribute a closed-source library or compile times become a major issue and you need to cut down on what the compiler has to parse, it's not idiomatic.</p>

Title: Which languages use "paired" header/implementation files?

Body:
C is ubiquitous, and C++ nearly as much, but I'm curious which other languages follow a similar model of header files.  Specifically, in which other languages is it idiomatic to edit pairs or groups of "header" and "implementation" files?  (A group as in multiple headers with one corresponding implementation file or a single header with multiple implementation files, as also seen in C.)  For example, the pair "blah.h" and "blah.c".

C's header files are tied into the C preprocessor, but that's not the detail I'm focusing on here.  For example, PHP has various include mechanisms, but you don't have a pair/group of "blah-header.php" plus "blah-notheader.php".

Some languages generate a file from source in a one-to-one mapping, such as Java, but that's not what I'm talking about either.  I'm interested in cases where the programmer directly edits both/all files in the pair/group.

Perhaps to put it another way: which languages have a declaration file ("header") and definition file ("implementation") such that a person would generally edit both files in tandem?


答:
One example is that during development we only focus on new features and ignore existing bugs and even introduce new bugs.

This is a bad thing.  A very bad thing.

You're not "Semi-Agile" if you're introducing bugs during an iteration.  You should have gotten stuff to work and moved things back to the backlog because they weren't getting done.

If you take 6 more months to build stuff well, then you don't spend 6 months testing and fixing bugs.

It's supposed to be simple.  Stop rushing and called bad code "done".

If management insists on rushing bad code into a "done" state, they're blind to the waste of time that 6 months of bug fix called "testing" is.  Inform them.

Also some bugs are definitely the size of a medium size story, while other bugs would take 5 min to fix. Should 5-min bugs also become stories if we were to continue with iterations?

You really have no choice but to put the bugs into the backlog and try to iterate correctly.  Stuff isn't "done" until it's bug-free.

If you can't get it bug free, it goes back into the backlog for the next iteration.  Then, you'll be able to make it bug free.


问:
How are software tests done at tech startups?
I've seen a lot research articles and tech blogs that boast the benefits of software testing. I've convinced on that. But since all the software testing research are conducted by large software companies, I do not believe they really apply to startups. Since startups have different needs and constraints compared to large software companies.

So this raised the questions. Should tech startups write automated tests? If so, are they done in the same manner as the large software companies? (smoke test, regression test, etc.) It's best if you can refer some research articles on this subject..since I was unable to find any on my own.

(I must admit that even though I'm still early in my career, but I have yet to see a startup that's seriously committed to writing automated tests)

答:
For many years, while working in small companies and start-ups, I was under the misapprehension that I "didn't have enough time to write unit tests for my code".

When I did write tests, they were bloated, heavy things which only encouraged me to think that I should only ever write unit tests when I knew they were needed.

Recently I've been encouraged to use Test Driven Development and I found it to be a complete revelation.

I'm now firmly convinced that I "don't have the time to not write unit-tests".

In my experience, by developing with testing in mind you end up with cleaner interfaces, more focussed classes & modules and generally more SOLID, testable code.

Every time I work with legacy code which doesn't have unit tests, and have to manually test something, I keep thinking "this would be so much quicker if this code already had unit tests". Every time I have to try and add unit test functionality to code with high coupling, I keep thinking "this would be so much easier if it had been written in a de-coupled way".

If there's one thing I've discovered over the years, if you're working at a start-up you need to be agile, and not just in the software development methodology sense. For me TDD is an important tool which enables starting and staying agile.


答:
In the c++11 standard (I am reading N 3290 version), chapter 21.4.7.1 speaks about the c_str() method :

const charT* c_str() const noexcept; const charT* data() const noexcept;

Returns: A pointer p such that p + i == &operator for
  each i in [0,size()].

  Complexity: constant time.

  Requires: The program shall not alter any of the values stored in the character array.

So, yes: the constant time complexity is guaranteed by the standard.

I just checked c++03 standard, and it has no such requirements, nor it tells the complexity.

Title: What performance can we expect from std::string's c_str()? Always constant time?

Body:
I've been doing some needed optimizations lately. One thing I've been doing is changing some ostringstreams -> sprintfs. I'm sprintf'ing a bunch of std::strings to a c style array, ala

```<code>char foo[500];
sprintf(foo, "%s+%s", str1.c_str(), str2.c_str());
</code>```

It turns out that Microsoft's std::string::c_str() implementation runs in constant time (it just returns an internal pointer). It appears that libstdc++ does the same. I realize the std makes no guarantees for c_str, but its hard to imagine another way of doing this. If, for example, they copied into memory they'd either have to allocate memory for a buffer (leaving it up to the caller to destroy it -- NOT part of the STL contract) OR they'd have to copy to an internal static buffer (probably not threadsafe, and you have no guarantees on its lifetime). So simply returning a pointer to an internally maintained null terminated string seems to be the only realistic solution.


问:
Why is Python recommended as an entry level programming language?
I've read here on P.SE more questions in which beginner programmers are advised to pick Python as their first programming language.

Don't get me wrong, I like Python. I like it a lot! But its philosophy revolves around "We are all consenting adults here".

From an experience/knowledge point of view, a beginner programmer is not an adult. Which then kinda means it is easier to shoot yourself in the foot and pick up some bad habits even if you survive the wound.

I'm thinking that in a "more static" language it would be harder to shoot yourself in the foot as it will be more restrictive.

Back to my question. Why is Python recommended as an entry level programming language?

What are the points that make it good for teaching a programming language. Or... is it personal preference of the adviser?

答:
That's an unusual viewpoint.

The consenting adults thing is a very small part of Python's philosophy. It certainly doesn't "revolve" around that. It's not even part of the "Zen of Python" that you get if you do import this in the interpreter.

Other things, like "explicit is better than implicit", "Simple is better than complex", and "Readability counts" are much much more central to Python, and show why Python is a good first language.

Anyway, the "consenting adults" is really only about the lack of private objects in Python. Which itself is, in my opinion, another indication of why it's good for beginners: you don't need to worry about things like interfaces when you're just starting out.


答:
There are problems mapping purely agile processes (like SCRUM) onto a project setting. Biggest issue is that in the agile approach, there is a constant negotiation and re-evaluation of the scope for each iteration. In a project, however, you will have a fixed deadline, a fixed budget and an expectation of what should be delivered ON THAT DATE. For me, SCRUM is about software maintenance more than a project methodology.

My suggestion (that I've employed myself) is to shrink your gates. If you're trying to maintain, for instance, 4 week iterations then your gates should be 4 weeks. Establish deliverables and "definitions of done" for each gate. If you, at the end of an iteration/gate still have bugs in your code then the gate is not complete and should be flagged as overdue. This is the mindset that both you and your business stakeholders should try to get into. At the end of each iteration there should be a completed set of goals and no half-finished or non-working features.


答:
There are two different few points. When raising a child, should you put them in a bubble that only has safe things in it or let them play in the yard where they might trip and fall?

Being inside the bubble is very restrictive. You have to write your code in a very specific way in order for it to run. When people are first starting out, anything that isn't there to do what the person wants is seen as wasteful. This can also lead to "I don't know why that is there, but someone told me it's necessary."

In Python, that doesn't exist. If you want to say "Hello World", you just print "Hello World". Using Python as an entry point allows someone to hit the ground running and just write the code they need to make what they want happen. A first time programmer can not understand the value of encapsulation before they understand the basics of programming.

Also, in small programs, type safety is not a large problem. Any code a beginning developer writes is going to be small and contained. It is not until you have a larger code-base, with lots of sections that you use as abstraction layers and don't actively think about, when type safety shows it's benefits of ensuring you do what you need to. When all the code is in the same file, it is easier to just go look at the function and see what you did wrong.

Other benefits:

Lots of libraries that do lots of things

Flexibility to teach both Object Oriented and Functional programing techniques without making it seem like one was forced to fit into a language designed to do the other.

Body:
I've read here on P.SE more questions in which beginner programmers are advised to pick Python as their first programming language.

Don't get me wrong, I like Python. I like it a lot! But its philosophy revolves around "We are all consenting adults here".

From an experience/knowledge point of view, a beginner programmer is not an adult. Which then kinda means it is easier to shoot yourself in the foot and pick up some bad habits even if you survive the wound.

I'm thinking that in a "more static" language it would be harder to shoot yourself in the foot as it will be more restrictive.

Back to my question. Why is Python recommended as an entry level programming language?

What are the points that make it good for teaching a programming language. Or... is it personal preference of the adviser?


答:
Did you used to work for my old company?  The similarities are frightening...

Some words of advice... nothing you say or do will change the process in any meaningful way whatsoever.  You are not a PM, you prolly do not have PM cerficiations or any political importance to effect change on such a large operation.  Exposing how they are doing things wrong will inevitably equate to you pointing the finger at somebody of greater political importance than yourself and will get you fired.  I have seen this happen too.

Your options are clear, live with it and accept it, because the project likely has an enormous budget and clients suffering from vendor lock-in or government contracts so there are quite literally dis-incentives for completing work in less time.  Further why focus on quality if it doesn't affect your bottom line?

If the above situation doesn't describe your companies market position then it is just a matter of time before a lean agile startup will eat their lunch and put them out of business.  If it does then you can decide to live with it and continue or leave for a company that is actually focused on producing software, and not a company that finds ways to justify a massive budget by consuming it.


答: I see Python as a good choice. Typically for "entry" level programming you want something simple yet productive. Receiving quick feedbacks supports both motivation and speed of learning. I dare to say it's not about learning the "right way" but rather "getting hooked and falling in love with programming for life". The rest will come along nicely later through experience, secondary education, whatever. </p>

Title: Why is Python recommended as an entry level programming language?


答:
If you have an intermediate format, then you could implement something that translates a program in Language X to that format, and also from that format to Language Y. Implement those conversions for all languages you're interested and you're done, right?

Well you know what? Such a format already exists: assembly. The compiler already does the "Language X to assembly" conversion, and disassemblers to the "assembly to Language Y" conversion.

Now, assembly is not that great a language for doing the reverse conversion, but MSIL is actually not that bad. Download Reflector and you'll see it's got options to disassemble a .NET assembly into a bunch of different languages (and plugins provide even more). So it's quite possible to take a program in C#, compile it to a DLL (that is, MSIL), then use reflector to disassemble it into VB, C++/CLI, F#, and a whole bunch others. Of course, all the other conversion work, too. Take an F# file, compile to a DLL, use Reflector to convert it to C#.

Of course, the two big problems that you'll find are:

The code is basically unreadable. MSIL (even with debugging information) removes a lot of information from the original source, so the translated version doesn't have 100% fidelity (theoretically doing a C#->MSIL->C# conversion should give you back the original code, but it won't).

Many .NET languages have their own custom libraries (e.g. the VB runtime library, F# library and so on). These would need to be included (or converted) when you do your conversion as well.

There's really nothing to get around #2, but you could probably get around #1 with some additional annotations in the MSIL (via attributes, maybe). That would be additional work, of course.


问:
Worst practices in developing database applications
In constrast to

Database design good practices

I wanted to ask:

What are the top worst practises you encountered when having to work with other people's database application code & databases ?

Mine so far are:

Not putting any foreign key constrains in the database (for ease of
web forms development...)

SQL queries by string concatenation (no
escaping of ', no parameters)

Usage of thread-unsafe code (with static variables) to decrypt the database password...

答:
In no particular order

DB

Business logic split between the application layer and database (Stored Procs / Packages)

Setting user accounts to db_owner (SQL Server)

No auditing of sensitive information (E.G., record last updated by, last updated date)

Clear text passwords and sensitive information (E.G., credit card numbers) stored in database tables.

Nested stored procedures, we have one application at work that has a chain of 18 stored procedures

Mixing of naming conventions (tbl_SomeTable, TBL_SOMETABLE, SomeTable, SOMETABLE), just pick one and stick with it.

Allowing table sizes to exceed 8192 bytes (SQL Server)

No indexes

OwnerDisplayName: Quandary


答:
N+1 selects problem.

That is, having a secondary query execute multiple times in a tight loop over the results of a previous query (or a tertiary... etc...).

Title: Worst practices in developing database applications

Body:
In constrast to

Database design good practices

I wanted to ask:

What are the top worst practises you encountered when having to work with other people's database application code & databases ?

Mine so far are:

Not putting any foreign key constrains in the database (for ease of
web forms development...)

SQL queries by string concatenation (no
escaping of ', no parameters)

Usage of thread-unsafe code (with static variables) to decrypt the database password...


问:
How can I retain knowledge about new technologies I don't use every day?
At work we mostly do WinForms development and it’s not a secret that it is already very outdated. I have a passion to learn new stuff like WPF, MVVM and want to use full advantages of C# 4.0. There is no way I can push my bosses to change “well-recommended” and “proven” technologies like WinForms to something else.

I have up to two hours a day which I can dedicate to self-learning but I simply don’t know the most efficient way to study. I tried to read couple of books and even wrote a simple WPF application but think that it’s not enough.

How can I manage my time learning new things in a way that sticks, even if I don't use it on a daily basis?

答:
Find a business problem that needs solving - something that needs automating or a small application that will help some of the users.

Write the application using the technologies you want to learn.

You now have both learned something and have provided value to the company.


答:
We should all be so lucky to work somewhere that gives us 2 hours per day dedicated to self-learning! :)  Don't waste that time certainly!

I wouldn't use that time for books and reading.  I find myself reading books and online tutorials in my spare time at home anyway since I wouldn't need access to company resources to do that.  The best thing to do is try to prototype a component or software in WPF that your company has already written in WinForms.

I learn best by taking a real world scenario and tackling it with a new technology or language.  If it doesn't turn out well then you still have good experience with the new technology that you can put on your resume, however if it works out well, then you can also use the prototype as an example of how much better the new technology is, and you may be able to convince your boss with a working prototype.

It is a win-win situation.

Title: How can I retain knowledge about new technologies I don't use every day?

Body:
At work we mostly do WinForms development and it’s not a secret that it is already very outdated. I have a passion to learn new stuff like WPF, MVVM and want to use full advantages of C# 4.0. There is no way I can push my bosses to change “well-recommended” and “proven” technologies like WinForms to something else.

I have up to two hours a day which I can dedicate to self-learning but I simply don’t know the most efficient way to study. I tried to read couple of books and even wrote a simple WPF application but think that it’s not enough.

How can I manage my time learning new things in a way that sticks, even if I don't use it on a daily basis?


答:
Things that I've seen that have become my pet hates:

Using strings for all data (instead of dates, integers etc)

Lack of normalization

Gratuitous use of cursors

UI logic in stored procedures


答: You might consider focusing on theory instead of APIs. Then when confronted with problems, you'll know how to solve them and you can just skim the reference manual for whatever technology you have to use and implement a solution. It'll also help when you do want a new job :) If the self-study time is completely self-directed I would suggest choosing something completely unrelated to what you do; even if it seems unrelated at the time, the more you learn the more you might learn something useful.</p>


答: My approach is similar to Oded's one. More abstract I try to identify a concrete feature set, be it for a customer or for myself. I then try to be pretty TDD heavy, because that way I can approach the idiomatic ways of, say, a new language and see whether the features still work.</p>


答: Over-use of triggers. I once worked with a system where much of the actual work happened in triggers in the db. This created bottlenecks that had our DBA wanting to hunt down the original authors and beat them soundly. </p>


答: Lacking any sort of database scheme versioning, such as an incremental series of DDL scripts, is far far too common. If your "how to setup new development environment" requires a copy of the production db this probably applies to you.</p>


答: Have you checked the sites terms of service? Many prohibit just that sort of screen scraping.</p>

Title: Do I need to get permission to access a site's data or functionality programmatically?

Body:
I'm creating an application which will programmatically sent HTTP GET and POST requests to a site and processing the data received.

If I want to release that application, do I have to get permission from the site's owners?


答:
In general, it's okay.  Obviously, you should get your own legal advice, yada yada.

Web pages are crawled by all sorts of bots all the time, as any developer should know - most sites rely on it for search ranking, indexing, etc.  Anything that is available without a user login or captcha is pretty much fair game.  A robot can be expected to find anything that can be linked to from another site (i.e. does not require a logged-in session), and can't be expected to understand a Terms-of-Service document.  That's why there's robots.txt.

To have the best chance of being on the right footing:

Use a distinct and obvious User-agent: header.  Throwing in a contact address is excellent practice.   FooCrawler 1.0 (webservices at example dot com)

Respect robots.txt

Minimise the load you put on their hosting providers.  No polling every minute, put a few seconds delay between requests, etc.

Respect Cache-control and Expiry headers (if the HTTP response says it's valid for an hour, don't poll before then).  If you're going to distribute your app widely and your users will 'target' the same sites, consider designing-in the facility to use a proxy to shift the load on to your own hosting.

Put in a reasonable effort to grok any copyright notices on the page

Understand (and document well in your code, if you do end up distributing it) that the services you use may break your app when they change, or deliberately block it.

If they block it, do not try to circumvent that


答: User Controls are not supposed to be used to centralize functionality that different projects have in common. Proper way to create general components would be to create custom server controls. Server controls can be compiled to dll and referenced in projects that use them.</p>

Title: Best practice for using a user control across many projects

Body:
I have a messaging User Control, that is used across 4 projects, and for each change I have to propagate it in 4 places. This is obviously against the DRY principle. However, centralizing user controls is not an easy task too, because you have both markup, and code-behind, and we know that markup won't get compiled till run-time requests. This means that you can't simply put the User Control in one project, and compile it, and use its result DLL file in many places.

So, what do you suggest as a good, neat approach for centralizing use of User Controls?


答:
If you have built a WebUserControl into a .dll, and you build that .dll to a commonly located deployment package folder, then it should be referenced (from all projects) from that folder. This way when each subsequent project that references this file (regardless of the location of the project on the local file system) will automatically get the latest copy of the .dll from that location. Our team has a common folder kept relative to our global solutions folder that references all 3rd party libraries and common company libraries that we treat as if they were 3rd party libraries.

The references are made to this folder and web application projects will use this file for each build. If you have a website project, the .dll will attach a .refresh file to it. As long as that refresh file points to the relative path indicated in the global folder, you should only have to build this file once. Each subsequent external project build will include the new dll automagically.

As an example:

```<code>C:\Projects

C:\Projects\Common    <-- Store your dll here

C:\Projects\MyWebsiteProject

C:\Projects\MyWebApplicationProject
</code>```

As long as the other projects reference C:\Projects\Common\MySharedControls.dll the same way it should be seamless.

Body:
If you have built a WebUserControl into a .dll, and you build that .dll to a commonly located deployment package folder, then it should be referenced (from all projects) from that folder. This way when each subsequent project that references this file (regardless of the location of the project on the local file system) will automatically get the latest copy of the .dll from that location. Our team has a common folder kept relative to our global solutions folder that references all 3rd party libraries and common company libraries that we treat as if they were 3rd party libraries.

The references are made to this folder and web application projects will use this file for each build. If you have a website project, the .dll will attach a .refresh file to it. As long as that refresh file points to the relative path indicated in the global folder, you should only have to build this file once. Each subsequent external project build will include the new dll automagically.

As an example:

C:\Projects

C:\Projects\Common    <-- Store your dll here

C:\Projects\MyWebsiteProject

C:\Projects\MyWebApplicationProject

As long as the other projects reference C:\Projects\Common\MySharedControls.dll the same way it should be seamless.


答:
IMO, the most prominent points that speak for Python as an entry-level language are these:

it has a shallow learning curve - going from nothing to "Hello world" is much faster than in most other languages

it is intuitive - the syntax was designed to follow the principle of least surprise, and it is very consistent overall (unfortunately, the standard libraries don't always follow this consistency)

it requires very little boilerplate: a typical "Hello world" is one line of code, and simple programs can be written without any additional background noise that needs to be explained (such as function declaration keywords, import statements, class constructs, preprocessor directives, etc.)

there are excellent, straightforward tools to work with python code, especially the interactive interpreter; you don't need to learn a build system, IDE, special text editor, or anything else to start using python - a command prompt, the interactive editor, and a simple text editor, are all you need

it uses dynamic typing, but unlike many other dynamically-typed languages, types are transparent, and type-related pitfalls are rare


问:
Can you successfully keep managing when you are forced back into development?
For about eight months I managed a development team doing a re-write of a web based application. During this time, I was focused on many aspects of the project that did not involve directly writing code, even though by trade that's what I started out as.

Recently the number of developers assigned to the project has dropped and I am now forced to drop back into a developer/management role. Since that time I have found that it's very difficult to focus on a feature and get it completed while at the same time trying to stay ahead of the other developers and make sure that we're keeping on track.

My questions is this: can you successfully keep managing a project when you are forced back into development?

答:
This can possibly work out well if the "team" shrinks to a small size, e.g. just you and another (experienced) developer, so there is not to manage anymore beyond that of a self-managed developer. Of course you still have to plan features, iterations, deadlines etc. but this doesn't conflict too much - if at all - with your role as a developer.

But if the number of developers is still to large to run without proper management, the little output you can produce on the side will hardly compensate the decline in their productivity.


问:
Using frameworks or writing code without any framework ? Which is better for 3 months aged PHP programmer?

Possible Duplicate:

  When do I need to use a framework?

  When should I start learning a PHP Framework

I started to learn PHP about four months ago, and I have been writing some applications for three months. Recently, I've been using CodeIgniter for various projects. Using CodeIgniter is awesome as it is easy to code with, and I don't care about security while using it. I do think though that using a framework may be bad for my background PHP knowledge, because with CodeIgniter I use absolutely different programming methods than when I code normally. I want to ask you which is better; using a framework, or not using a framework?

答:
One of the fundamentals of programming is "don't reinvent the wheel." If a framework has code that you would otherwise implement yourself, by all means use it so that you can focus on your application as a whole. However if you don't like the implementation, then you put your php knowledge to work and flesh out your own alternative.

That said, if you're just studying php to learn the ins and outs, you shouldn't use a framework, but you may benefit from reading its code.


答:
I'd recommend developing something useful during your free time that can serve as a proof of concept for what you want to do. Plus, it allows you to apply a new technology to a problem domain that you and your management are familiar with. </p>

<p>For example, if there's some relatively simple utility program that users are clamoring for but nobody has time to write it, write it using WPF. Then present it to your boss. If they like what you've accomplished, they may be more open to moving in that direction in the future. If they reject it, then it is certainly time to polish up the resume. </p>

Body:
I'd recommend developing something useful during your free time that can serve as a proof of concept for what you want to do. Plus, it allows you to apply a new technology to a problem domain that you and your management are familiar with.

For example, if there's some relatively simple utility program that users are clamoring for but nobody has time to write it, write it using WPF. Then present it to your boss. If they like what you've accomplished, they may be more open to moving in that direction in the future. If they reject it, then it is certainly time to polish up the resume.


答:
The hello world in python:

```<code> print "Hi there"
</code>```

hello world in Java:

```<code> class HelloWorldApp {
  public static void main(String[] args) {
    System.out.println("Hello World!"); // Display the string.
    }
  }
</code>```

hello world in C:

```<code>  #include<stdio.h>
  int main(int argc, char** argv)
  {
    printf("Hello World");
   }
</code>```

Throw in having to talk about compilation for the other two, and python is much simpler. I only have to talk about the single idea I am interested in looking at, all of the machinery that complicates the matter just disappears in python.  I can wait until they are ready to talk about modules, no need to rush it to get stdio.h for simple programs.  I can wait until they are ready for topics like classes no need to rush them for their first programs.  It has a REPL for fooling around at the command line.  Python is very good at being conceptually minimal.  This is a good thing because it helps beginners focus on the task at hand.

Body:
The hello world in python:

 print "Hi there"

hello world in Java:

 class HelloWorldApp {
  public static void main(String[] args) {
    System.out.println("Hello World!"); // Display the string.
    }
  }

hello world in C:

  #include<stdio.h>
  int main(int argc, char** argv)
  {
    printf("Hello World");
   }

Throw in having to talk about compilation for the other two, and python is much simpler. I only have to talk about the single idea I am interested in looking at, all of the machinery that complicates the matter just disappears in python.  I can wait until they are ready to talk about modules, no need to rush it to get stdio.h for simple programs.  I can wait until they are ready for topics like classes no need to rush them for their first programs.  It has a REPL for fooling around at the command line.  Python is very good at being conceptually minimal.  This is a good thing because it helps beginners focus on the task at hand.