问:
Simple dependency tree diagram generator
I have a need to produce a simple dependency tree diagram. The input data would be in the following simple format:

```<code>ITEM_NAME   DEPENDENCY
----------------------------
ITEM_101    ITEM_75
ITEM_102    ITEM_77
ITEM_102    ITEM_61
ITEM_102    ITEM_11
</code>```

This means that ITEM_101 depends on ITEM_75 and ITEM_102 depends on items ITEM_77, ITEM_61 and ITEM_11.  So the diagram would have items ITEM_77, ITEM_61 and ITEM_11 in one vertical level and ITEM_102 would be below it with a line connecting each of the three dependencies to ITEM_102.  The same would be for ITEM_101, ITEM_75 would be somewhere above it and there would be a line connecting it.

In the real world this tree represents a hierarchy of scheduling jobs.  We have a very extensive workload automation hierarchy in Autosys and I have heard that its front end utility has something like this tree visual representation, however, for some reason, that utility has been disabled by admins.  My business users want to see this hierarchy in an easy-to-consume format.

I was hoping that I won't have to program something like this from scratch because it seems like quite a common reporting requirement and the input data is simply formatted.  My question is:  is there a FOSS tool that takes standardized data input and produces such a hierarchical tree?

Thanks

答:
What you need is graphviz</p>

```<code>digraph {
    ITEM_101 -> ITEM_75
    ITEM_202 -> ITEM_77
}

dot input.dot -Tpng > image.png
</code>```

Body:
What you need is graphviz

digraph {
    ITEM_101 -> ITEM_75
    ITEM_202 -> ITEM_77
}

dot input.dot -Tpng > image.png


问:
Arithmetic Coding Questions
I have been reading up on arithmetic coding and, while I understand how it works, all the guides and instructions I've read start with something like:

Set up your intervals based upon the frequency of symbols in your data; i.e., more likely symbols get proportionally larger intervals.

My main query is, once I have encoded my data, presumably I also need to include this statistical model with the encoding, otherwise the compressed data can't be decoded. Is that correct? I don't see this mentioned anywhere -- the most I've seen is that you need to include the number of iterations (i.e., encoded symbols) -- but unless I'm missing something, this also seems necessary to me.

If this is true, that will obviously add an overhead to the final output. At what point does this outweigh the benefits of compression (e.g., say if I'm trying to compress just a few thousand bits)? Will the choice of symbol size also make a significant difference (e.g., if I'm looking at 2-bit words, rather than full octets/whatever)?

答:
Typically the overhead of including the statistical model is avoided by using an adaptive approach.  The encoder and decoder begin in the same predefined state and adapt to the data.  This allows the decoder to track the encode. An example would be starting with 128 uniform intervals for each ascii char in [0..127].  Then the encoder logic is:

```<code> while (there is data)

      encode the char to a symbol

      increment that chars count

      update the model

 end while
</code>```

The decoder follows the similar logic:

```<code> while (there is data)

      decode the symbol to a char

      increment that chars count

      update the model

 end while
</code>```

In practice arithmetic coding is highly time consuming for marginal gains in compression performance.  An H.264 video decoder I worked on slowed down by about a third due to arithmetic coding.

ContentLicense: CC BY-SA 3.0

Title: Arithmetic Coding Questions

Body:
Typically the overhead of including the statistical model is avoided by using an adaptive approach.  The encoder and decoder begin in the same predefined state and adapt to the data.  This allows the decoder to track the encode. An example would be starting with 128 uniform intervals for each ascii char in [0..127].  Then the encoder logic is:

 while (there is data)

      encode the char to a symbol

      increment that chars count

      update the model

 end while

The decoder follows the similar logic:

 while (there is data)

      decode the symbol to a char

      increment that chars count

      update the model

 end while

In practice arithmetic coding is highly time consuming for marginal gains in compression performance.  An H.264 video decoder I worked on slowed down by about a third due to arithmetic coding.


问:
Is true multithreading really necessary?
So yeah, I'm creating a programming language. And the language allows multiple threads. But, all threads are synchronized with a global interpreter lock, which means only one thread is allowed to execute at a time. The only way to get the threads to switch off is to explicitly tell the current thread to wait, which allows another thread to execute.

Parallel processing is of course possible by spawning multiple processes, but the variables and objects in one process cannot be accessed from another. However the language does have a fairly efficient IPC interface for communicating between processes.

My question is: Would there ever be a reason to have multiple, unsynchronized threads within a single process (thus circumventing the GIL)? Why not just put thread.wait() statements in key positions in the program logic (presuming thread.wait() isn't a CPU hog, of course)?

I understand that certain other languages that use a GIL have processor scheduling issues (cough Python), but they have all been resolved.

答:
Here's a quick answer - one thread for the UI and one for asynchronous data processing work.  So yes, there's a need for true multi-threading.  Massive parallel computations are another obvious answer that you alluded to.

From a broader point of view, why wouldn't you offer the capability?  Many, many devices have multiple cores available to handle processes.  Why would you arbitrarily limit the ability of any program written in the language you're creating?


答:
In a world where CPU's can have multiple "cores" and each "core" can work on a separate thread then having multiple independent threads can be a useful feature.

In a world where "events" such as data arriving from the network need to be processed "now" and not when another thread says "I'm done for now" then it may be useful to have multiple independent threads.

Is it really "parallel" processing if only one task is being worked on at a time?

The better question is this: why, why are you doing this?

If it's a domain specific language then you shouldn't care what we think, you know the domain better.

If it's a general purpose language, what makes it distinct enough to be recognized among the many already existing (besides adding this limitation)?

Title: Is true multithreading really necessary?

Body:
So yeah, I'm creating a programming language. And the language allows multiple threads. But, all threads are synchronized with a global interpreter lock, which means only one thread is allowed to execute at a time. The only way to get the threads to switch off is to explicitly tell the current thread to wait, which allows another thread to execute.

Parallel processing is of course possible by spawning multiple processes, but the variables and objects in one process cannot be accessed from another. However the language does have a fairly efficient IPC interface for communicating between processes.

My question is: Would there ever be a reason to have multiple, unsynchronized threads within a single process (thus circumventing the GIL)? Why not just put thread.wait() statements in key positions in the program logic (presuming thread.wait() isn't a CPU hog, of course)?

I understand that certain other languages that use a GIL have processor scheduling issues (cough Python), but they have all been resolved.


答:
You say parallelism is handled by multiple processes, but I would beg to differ. In-process parallelism is, depending on the program, much simpler and faster, due to (universal and by-default) shared memory.

When you don't have shared memory, you need a lot of extra engineering (like a common server process, with message passing to and fro) to have any shared state outside of what the OS provides for all processes (e.g. the file system). This also implies a lot of overhead for programs with a fair bit of shared state. Yes, you need locking most of the time, provided you don't have another mechanism (like STM). But in-process locking can be much simpler/faster than IPC, and actually accessing the data is much simpler: You just fricking do it, rather than doing IPC.

You also imply (I'm inferring this from your description of thread.wait) that thread are non-preemptive, i.e. it's up to each thread when its time slice ends. Two notes on this:

It's incompatible to some common uses of threads (e.g. running a computation with a timeout, or asynchronously even if it wasn't built to be async).

It's unlike the threads in many common languages, so expect newcomers to be confused and expect lots of code that simply doesn't ever wait.

On the other hand, I rather like the increase in determinism (if the scheduler is deterministic too, certain concurrency bugs ought to be much simpler to reproduce). It's a trade-off.


答:
these day if you want more speed for calculations you need to go concurrent, especially when you have more cores to use

to give an example: most GUI frameworks have a single thread that manipulates the screen and handles the user events, but the handling of these events must finish quickly or the entire GUI will hang

if you want to do any IO you could use async io and call backs

you language seems to rely on cooperative multithreading which requires all the code in the application to cooperate (or at least don't block indefinitely), preemptive multithreading is comparatively easier to code for (with greater pitfalls though)


问:
How many types of programming languages are there?
Basically, I want to learn lots of programming languages to become a great programmer.  I know only a handful to depth and I was hoping someone could elaborate on how many classes or types of programming languages there are.  Like how you would lump them together if you had to learn them in groups.

Coming from a Java background, I'm familiar with static typing, but I know that in addition to dynamic typing there has to be such variety in available languages that I would love to see a categorical breakdown if possible.

答:
For types of programming languages (Paradigms), look here:
 http://en.wikipedia.org/wiki/Programming_paradigm

For other characteristics of programming languages (e.g. Type Systems), look here:
http://en.wikipedia.org/wiki/Programming_language

ContentLicense: CC BY-SA 2.5


答:
Firstly, your question seems confused about the relationship between a GIL and cooperative multithreading. Co-operative multithreading is when the the current thread continues to execute until it gives up execution. The greenlet library for python is based on this model. It simplifies coding in many cases because you don't have to worry about context switches except at specific points.

A global interpreter lock is a lock which prevents more than one thread from executing code inside the virtual machine at once. Execution will still jump from thread to thread without the thread requesting it. The times that switches will happen is limited (exactly how depends on the language implementation). But you don't really the simplification that the co-operative multitasking gives you.

Your question actually appears to be asking about whether you can get away with co-operative multitasking with multi-process options. Of course strictly speaking you can still do whatever you want without pre-emptive multithreading, the question is whether it'll be easier/more efficient with it.

I use co-operative multithreading and process parallelization whenever I can. Most of the time I find that works beautifully and is a simpler approach then would be required if I were to try and use threads. But I think there are some cases where this falls down.

Let's consider some examples:

1) Worker Thread and UI Thread

Its not uncommon to have a long running task executed in an application while a progress bar is displayed. In order to keep things working we need to execute UI events as well as continue running the task. Normally, we'd have the task executing in a separate thread. But if the threads are co-operative, this won't work because the task won't normally have any reason to delay itself.

So what can we do?

In some cases, there were be natural pause points in the long running task. There could be File I/O, database calls, sockets reads. All of these naturally block, and if your language automatically thread waits at these points, many long running tasks may yield naturally.

The task could be moved into another process. But for some tasks, this will take a lot of effort. I may have to ship a lot of data to the subprocess and then let it process and ship the data back.

You could introduce explicit thread yield calls. The disadvantage here is that you are doing something manually that other languages do automatically.

2) Serving many requests

A system such as a database or a web server may need to serve requests coming from many different external systems. In doing so it will have to navigate in-memory data structures and multiple requests may require the same data structures. Typically, we might implement this using multiple threads and using locks on the data structure to make sure nobody changes it while it is being read.

As long as we only have on core operating, co-operative multithreading actually works great. But when you've got multiple cores, you can't take advantage of it that way. You could introduce multiple processes. But the trouble there is that you can't really share in-memory data structures all that well. I'm sure you can work around it with IPC techniques, but I think it'll always be awkward compared to the locks model.


问:
Should developers be responsible for tests other than unit tests, if so which ones are the most common?
I am currently working on a rather large project, and I have used JUnit and EasyMock to fairly extensively unit test functionality. I am now interested in what other types of testing I should worry about. As a developer is it my responsibility to worry about things like functional, or regression testing? Is there a good way to integrate these in a useable way in tools such as Maven/Ant/Gradle?  Are these better suited for a Tester or BA? Are there other useful types of testing that I am missing?</p>

答:
Obviously integration tests; they are more important and more difficult to write than unit tests. It's like building a house; with unit testing you only assure the fact that the bricks are solid and resist the pressure, temperature, humidity and other conditions. But you have no clue how the house looks and behaves with the bricks put together.

The problem with large projects, especially Java ones residing in a container is that integration testing is difficult. So to facilitate system integration tests in large projects, a testing framework is needed, made specially for the project, which is the developer's job to code it. Recently great improvements have been made in this area and platforms like Arquillian greatly simplify the writing of a testing framework (or even substitutes it).


答:
In the real world you are only as responsible as your team / boss holds you accountable to be. If you are paid or indentured to toil endlessly to find every nook and cranny edge case and jump to the whim of your boss's (or worse marketing's) interpretation of business logic bugs, then by all means, you are responsible for all.

So in other words, do what is required by the scope given to you. Its a nice extra to throw in some common sense or see others use the product you are building to get a sense of use cases and possible issues to fix but bring this up to your team or boss prior to "fixing". This includes the tools of your choosing. All your efforts should be something everyone is on board with.

If your question is of useful bug tracking, I like bugzilla, google docs, zendesk or basecamp in terms of communication systems.

Title: Should developers be responsible for tests other than unit tests, if so which ones are the most common?

Body: I am currently working on a rather large project, and I have used JUnit and EasyMock to fairly extensively unit test functionality. I am now interested in what other types of testing I should worry about. As a developer is it my responsibility to worry about things like functional, or regression testing? Is there a good way to integrate these in a useable way in tools such as Maven/Ant/Gradle?  Are these better suited for a Tester or BA? Are there other useful types of testing that I am missing?</p>


答:
I think the approach described by @CWallach is the most common way to handle this, but it has two potential downsides, since you're continually updating the model in during encoding and decoding:

It's somewhat slower.

It's (even more) difficult to do random access.

Some schemes do put the codebook at the front of the data file. This would add some overhead to very small files, though you could potentially do something clever like transmit the smaller of the compressed file + codebook or the original file.

Finally, a fixed codebook could work pretty well for some applications. English text, for example, has a pretty typical character structure, and a model trained on one large corpus would probably perform pretty well when applied to another large document. That said, small or atypical documents might not compress well.

I vaguely remember an old (BBS-era) compression program which had options to do all three of these options. I think it even had several built-in codebooks for different file types. Unfortunately, I can't remember what it was called, but I'll update if I do!

Title: Arithmetic Coding Questions

Body:
I have been reading up on arithmetic coding and, while I understand how it works, all the guides and instructions I've read start with something like:

Set up your intervals based upon the frequency of symbols in your data; i.e., more likely symbols get proportionally larger intervals.

My main query is, once I have encoded my data, presumably I also need to include this statistical model with the encoding, otherwise the compressed data can't be decoded. Is that correct? I don't see this mentioned anywhere -- the most I've seen is that you need to include the number of iterations (i.e., encoded symbols) -- but unless I'm missing something, this also seems necessary to me.

If this is true, that will obviously add an overhead to the final output. At what point does this outweigh the benefits of compression (e.g., say if I'm trying to compress just a few thousand bits)? Will the choice of symbol size also make a significant difference (e.g., if I'm looking at 2-bit words, rather than full octets/whatever)?


问:
How to implement Scrum in a company with three similar web-based products
I am somewhat familiar with the concepts and benefits of Scrum. With that in mind, I am trying to improve the failing Scrum product management structure of a company I'm now working for that has three separate B2C products, catering to the same demographic and accessible on the same website. Each product has a product owner and a unique development team (5 - 9 people in each) behind it.

Given that the target audiences are similar (not sure if it should matter) and the 3 web products are similar in nature, what are the potential benefits/risks associated with merging the teams and having just one product owner/scrum master/dev team? Some questions that come to mind are: does it make sense to have 3 product owners and three distinct backlogs if your website has three distinct products? Also, if you only have one product owner, what is the best metric off which to choose who that will be?

答:
It sounds like merging the products would make good business sense for both your users and for management.  While merging the teams into one large team may not make sense, consolidating your product base to leverage core functionality might be a good benefit.

The teams could work separately but together then. They would need to work together and collaborate on components that are shared, but could focus internally on the areas that are unique to their part of the product.

I would think that having a scrum master and product owner that is well versed in all areas would be beneficial, provided that the product suite is not too broad for that.

It also means that may not need 3 product managers either, so you might get some serious resistance from the downsizing of this role.

Good Luck.


问:
Good practice about Javascript referencing
I am fighting about a web application script optimization. I have an ASP.NET web app that reference jQuery in the master page, and in every child page can reference other library or JavaScript extension.

I would like to optimize the application with YUI for .NET.

The question is, I should put all the libraries reference in the master page or to compress all the JavaScript code in a single file, or I should create a file for every page that contains only the code useful to the page?

Is there any guidance to follow?

答:
For common libraries, link to a CDN

The point of combining JS imports is to cut down on the number of HTTP requests required to load the page.

With that in mind, common libraries like jQuery may already be on in the user's browser cache. By using a common CDN link, your users get the speed advantage of a pre-warmed cache and you get the added benefit of not having to maintain a local copy on your server.

Any common JS library of appreciable size will usually have the ability to fetch the code from an internal or third-party (ex google) CDN. They will usually provide links to multiple versions so users can lock into a specific while the dev team maintains the freedom to continue development.

To give you an idea, here's the test runner for one of my projects. If you 'View Source' you'll see that jQuery is being served by the Google APIs CDN and qUnit is being served by the jQuery CDN.

For local stuff, it might be a good idea to compile everything into one file

It depends on the size of your codebase but there is a measurable benefit to be gained by reducing the number of web requests required to load the page. The same rule holds true for using image sprites for the UI/CSS.


问:
Confusion of the "stack" in Assembly-level programming
What is the "stack" exactly?

I've read articles, tried comprehending it through my understanding, experience, and educated guessing of programming and computers, but I'm a bit perplexed here.

The "stack" is a region in RAM? Or is it some other space I'm uncertain of here?

The processor pushes bits through registers on to the stack in RAM, or do I have it wrong here?

Also, the processor moves the bits from the RAM to the register to "process" it, such as maybe a compare, arithmetic, etc.

But what actually can help understand, in some visual or verbal description or both, of how to implement the idea of a "stack" here?

Is the stack actually the same in terminology with a "machine stack" meaning it's in RAM?

I know what a software stack is. I know about LIFO, FIFO, etc. I just want to gain a better understanding of the assembly level stack, what it is, where it is, how exactly it works, etc...

答:
Typically, the stack is a memory region.

It is possible to add data to the stack ("push"), or to retrieve it and take it out of the stack ("pop").
The last data added to the stack is the first to be retrieved.

```<code>PUSH 1
PUSH 2
PUSH 3
POP -> Result 3
PUSH 4
POP -> Result 4
POP -> Result 2
POP -> Result 1
</code>```

The processor pushes bits through registers on to the stack in RAM, or
  do I have it wrong here?

Processors often have instructions to copy data from the registers to the stack and vice-versa.

In x86 assembly (32 bits):

```<code>MOV EAX, 20
PUSH EAX ; Adds 20 to the stack (32 bits, many of which are zero)
POP EBX ; EBX will have the value 20, and the stack will be restored to its former state
</code>```

However, in most (all?) architectures, it is possible to obtain data from the stack without actually popping it.

In x86 (32 bits)

```<code>MOV EAX, [ESP+20] ; Will copy to EAX the contents of the stack 20 bytes before its current state
</code>```

The "stack" is a region in RAM? Or is it some other space I'm
  uncertain of here?

You can think of it like that.

In modern architectures, there is something called the virtual memory which will be frequently, but not always, mapped to the physical memory (RAM). Ocasionally, when the physical memory runs out, this memory will be stored to disk.

The virtual memory is where the stack is usually placed.

However, the stack will also be accessed frequently, so it will often be in the processor cache too.

Fortunately, that is all abstracted away. As far as a program running in the machine knows, the stack is in the RAM. The OS typically takes care of the ugly details.

Body:
Typically, the stack is a memory region.

It is possible to add data to the stack ("push"), or to retrieve it and take it out of the stack ("pop").
The last data added to the stack is the first to be retrieved.

PUSH 1
PUSH 2
PUSH 3
POP -> Result 3
PUSH 4
POP -> Result 4
POP -> Result 2
POP -> Result 1

The processor pushes bits through registers on to the stack in RAM, or
  do I have it wrong here?

Processors often have instructions to copy data from the registers to the stack and vice-versa.

In x86 assembly (32 bits):

MOV EAX, 20
PUSH EAX ; Adds 20 to the stack (32 bits, many of which are zero)
POP EBX ; EBX will have the value 20, and the stack will be restored to its former state

However, in most (all?) architectures, it is possible to obtain data from the stack without actually popping it.

In x86 (32 bits)

MOV EAX, [ESP+20] ; Will copy to EAX the contents of the stack 20 bytes before its current state

The "stack" is a region in RAM? Or is it some other space I'm
  uncertain of here?

You can think of it like that.

In modern architectures, there is something called the virtual memory which will be frequently, but not always, mapped to the physical memory (RAM). Ocasionally, when the physical memory runs out, this memory will be stored to disk.

The virtual memory is where the stack is usually placed.

However, the stack will also be accessed frequently, so it will often be in the processor cache too.

Fortunately, that is all abstracted away. As far as a program running in the machine knows, the stack is in the RAM. The OS typically takes care of the ugly details.


问:
Language parsing to find important words
I'm looking for some input and theory on how to approach a lexical topic.

Let's say I have a collection of strings, which may just be one sentence or potentially multiple sentences.  I'd like to parse these strings to and rip out the most important words, perhaps with a score that denotes how likely the word is to be important.

Let's look at a few examples of what I mean.

Example #1:

"I really want a Keurig, but I can't afford one!"

This is a very basic example, just one sentence.  As a human, I can easily see that "Keurig" is the most important word here.  Also, "afford" is relatively important, though it's clearly not the primary point of the sentence.  The word "I" appears twice, but it is not important at all since it doesn't really tell us any information.  I might expect to see a hash of word/scores something like this:

```<code>"Keurig" => 0.9
"afford" => 0.4
"want"   => 0.2
"really" => 0.1
etc...
</code>```

Example #2:

"Just had one of the best swimming practices of my life.  Hopefully I can maintain my times come the competition.  If only I had remembered to take of my non-waterproof watch."

This example has multiple sentences, so there will be more important words throughout.  Without repeating the point exercise from example #1, I would probably expect to see two or three really important words come out of this: "swimming" (or "swimming practice"), "competition", & "watch" (or "waterproof watch" or "non-waterproof watch" depending on how the hyphen is handled).

Given a couple examples like this, how would you go about doing something similar?  Are there any existing (open source) libraries or algorithms in programming that already do this?

答:
Natural language processing is its own discipline with quite a lot of formal research done on it. I would start by looking there.

I would also reconsider my needs. Even after 50+ years of research, the best computer scientists have been able to come up with is Siri. I would not expect a computer to successfully do what you're talking about with regularity.

If there are certain limitations to the speech (like Siri assuming you have a simple command or question) it can be better. Reconsidering my needs (assuming I do need NLP) would include defining my limitations. After that I would likely hunt for a ton of examples. Partly to test anything I come up with, but many modern solutions involve machine learning. I'd need those examples as input to the learning curve.

So in summary, I seriously doubt anything will be able to give you good scores in this sort of context free scenario.


问:
How to create a random generator
How could a random generator be implemented?

I'm not speaking about the invocation of a language mathRandom() method, but the implementation of the routines that lead to generate numbers totally random.

答: First, you can't generate truly random numbers in software.  There are a ton of different algorithms that let you generate pseudo-random numbers.  Depending on why you need pseudo-random numbers (i.e. if you are using them in cryptography the requirements are much different), you would generally use something like the random number generator in the GNU scientific library (which, of course, you can implement in whatever language you prefer).</p>

Title: How to create a random generator


问:
Career guidance books for programmers
I am currently reading the recently published Being Geek by Michael "Rands" Lopp and I can't get enough of it.

Is there any other career guidance books aimed directly or indirectly at programmers that are worth reading?

答: Most of the books by the Pragmatic Programmers are well worth reading. They have an entire section in their catalog on career guidance. I can recommend The Pragmatic Programmer (old, but good), Pragmatic Thinking and Learning, and The Passionate Programmer.</p>

Title: Career guidance books for programmers


问:
How to create a manager class without global variables nor singletons?
I would like to implement some kind of manager class in my application. It will be in charge of loading textures, processing them, distributing them etc...

At first, I wanted to make a global variable that simply contains an instance of my manager class. I found this question: https://stackoverflow.com/questions/4646577/global-variables-in-java. However, the users there seem to recommend to never use global variables.

Fine then, I once heard about Singletons, so I though I could use that instead. I mean, creating just one instance of my manager class sounds good. However, I found this other question: When is Singleton appropriate?, which basically tells me that Singletons are, in most scenarios, some kind of anti-pattern.

Now I am a bit lost - what other approach can I take to create my manager class, whose only requirement is to be accessible from anywhere?

答:
it will be in charge of loading textures, processing them, distributing them

Well, I don't know your application, but this hardly sounds like a thing you need everywhere in your application, especially when your application is layered. You will need it somewhere in your application, and that is where you should pass it, no less, no more.

Moreover, these three responsibilities may be better split up into three classes - one for loading the textures, one for processing them and one for distributing them. The last one is probably the only one some other parts of your application may need to access from outside.

I would also consider to create an interface for your "texture manager", let's call it ITextureManager. The classes/objects needing access to the manager should get passed an ITextureManager instance through their constructor. Later on, you may consider the use of a DI framework, like @smp7d suggested, but actually that does not make a real difference concerning your question - if you are not able to decouple your code from a manager class "manually", you won't be more successfull when trying to use DI framework.


答:
It's a reserved area of RAM that is accessed by an offset from a stack pointer.  For example, consider a stack consisting of 5 words:

```<code>5 garbage
4 garbage
3 garbage
2 garbage
1 garbage
</code>```

Before a function is called it has a stack pointer (SP) equal to 6.  The function call instruction puts the return address on the stack and decrements the stack pointer, so now it looks like:

```<code>5 return address <-------- SP
4 garbage
3 garbage
2 garbage
1 garbage
</code>```

If you want to allocate an integer on the stack, just decrement the stack pointer:

```<code>5 return address
4 local integer  <-------- SP
3 garbage
2 garbage
1 garbage
</code>```

Now when my function needs to access my local integer, it uses the memory address of SP+0.  If I call another function, it decrements the SP again, and I can allocate some storage again, like:

```<code>5 return address
4 local integer
3 return address for second function
2 local integer for second function
1 another local integer for second function   <-------- SP
</code>```

Now, if I use the memory address SP+0, it is referring to the second function's local integer.  Note that I'm now out of stack space, so any more operations will result in a stack overflow.

When I return, I just do it in reverse, add to the SP to deallocate the memory, then the return instruction reads the return address from the stack.

Note that the stacks of different architectures work slightly differently.  On some the SP is decremented before pushing the return address and some after.  Some automatically save registers on the stack in addition to just the return address, especially during an interrupt.  On a PIC, for another example, the stack is completely isolated memory that only holds the return addresses and can't be used for variables.  What's common is the LIFO allocation of memory.

Title: Confusion of the "stack" in Assembly-level programming

Body:
What is the "stack" exactly?

I've read articles, tried comprehending it through my understanding, experience, and educated guessing of programming and computers, but I'm a bit perplexed here.

The "stack" is a region in RAM? Or is it some other space I'm uncertain of here?

The processor pushes bits through registers on to the stack in RAM, or do I have it wrong here?

Also, the processor moves the bits from the RAM to the register to "process" it, such as maybe a compare, arithmetic, etc.

But what actually can help understand, in some visual or verbal description or both, of how to implement the idea of a "stack" here?

Is the stack actually the same in terminology with a "machine stack" meaning it's in RAM?

I know what a software stack is. I know about LIFO, FIFO, etc. I just want to gain a better understanding of the assembly level stack, what it is, where it is, how exactly it works, etc...

Body:
It's a reserved area of RAM that is accessed by an offset from a stack pointer.  For example, consider a stack consisting of 5 words:

5 garbage
4 garbage
3 garbage
2 garbage
1 garbage

Before a function is called it has a stack pointer (SP) equal to 6.  The function call instruction puts the return address on the stack and decrements the stack pointer, so now it looks like:

5 return address <-------- SP
4 garbage
3 garbage
2 garbage
1 garbage

If you want to allocate an integer on the stack, just decrement the stack pointer:

5 return address
4 local integer  <-------- SP
3 garbage
2 garbage
1 garbage

Now when my function needs to access my local integer, it uses the memory address of SP+0.  If I call another function, it decrements the SP again, and I can allocate some storage again, like:

5 return address
4 local integer
3 return address for second function
2 local integer for second function
1 another local integer for second function   <-------- SP

Now, if I use the memory address SP+0, it is referring to the second function's local integer.  Note that I'm now out of stack space, so any more operations will result in a stack overflow.

When I return, I just do it in reverse, add to the SP to deallocate the memory, then the return instruction reads the return address from the stack.

Note that the stacks of different architectures work slightly differently.  On some the SP is decremented before pushing the return address and some after.  Some automatically save registers on the stack in addition to just the return address, especially during an interrupt.  On a PIC, for another example, the stack is completely isolated memory that only holds the return addresses and can't be used for variables.  What's common is the LIFO allocation of memory.


答:
You do not state what processor your assembly is for, however the basic understanding will not change as they all do the same thing.

Virtually all computers have a small set of machine codes that provide support for basic stack operations. These are PUSH and POP and a stack pointer register (I'll call it SP)- that points to a location in memory. If supported, procedure calls (CALL) and returns (RET) use a stack by pushing and poping the return address. Hardware interrupts use a stack for saving return address and registers. Depending on the machine, there may be more than one stack pointer (e.g. One for Hardware interrupts, one for program flow and one for data).

The concept of a "Stack" is supported by the processor instructions, but is really something the processor knows little about. SP points to an address, PUSH stores and updates SP, POP updates SP and retrieves from the address. As programmers, we make those simple instructions into a "stack". Clever Assembly can make use of those instructions for other tasks (At the developers peril).

Most processors have other instructions for managing the stack and manipulating the stack pointer.

The stack operates by first setting SP to point to a RAM memory location.
PUSH Decreases SP (by the size of the item) and then copies the item to the SP location.
POP  Copies the item from the location SP points to, then increases SP by the size of the item. Note: Typically Stacks grow from higher memory addresses down to lower memory addresses. There is not particular reason for this beyond historical choices - The stack sat at the upper memory locations, and the program at the lower locations. In the early days, you were out of memory when the stack and program memory collided, however, it made it easier to manage memory . This still happens on small micro computers.  On more complex architecture, there is a memory management system that prevents this happening

Depending on the machine in use, the PUSH and POP instructions can move registers, memory locations etc of various sizes between the stack. Many processors have other registers that allow detection of stack overflow/underflow, use of multiple stacks etc.


答:
Hardware. You need to connect to hardware that can gather entropy from... wherever. Read the static from a radio, put a webcamera on a lavalamp, or have the user type gibberish or play with the mouse. Without some contact with the real world, generating true randomness is impossible. It's an important area of study, and a lot of work has been put into it. I doubt you're going to be blazing any new trails, so you really ought to stand on the shoulders of giants and start reading wikipedia entries.

"The generation of random numbers is too important to be left to chance."

-Robert R. Coveyou

EDIT

So I've learned that the hardware you want is in fact just a CMOS chip. The sort in cheap cameras. Just keep it in darkness, set the sensitivity way up, and apparently the minute variances it observes has roots in quantum mechanics, which is where we derive our entropy in real life.

Title: How to create a random generator

Body:
How could a random generator be implemented?

I'm not speaking about the invocation of a language mathRandom() method, but the implementation of the routines that lead to generate numbers totally random.


答:
The key for a truly random number is random data source.  Sometimes this is information such as delays in keyboard events or network events.  Where high quality random data is desired, it may be radioactive decay.  SGI implemented lavarand which drew its seed for a random number generator from a digitized image of a lava lamp.  This was sufficient for being considered a random number generator.

Outside of truely random data, one can work with a deterministic but chaotic system.  For example, the mersenne twister.  In these situations, one seeds the generator with a number and then runs it forward to get pseudo-random numbers.  These are sufficient for games and the like where it isn't critical if someone can determine the seed (and the next number in the sequence).

Consider reading patent 5,732,138 and http://www.lavarnd.org/ for the implementation details on how to make a number.

Title: How to create a random generator


答:
What kind of random are you talking about?

There are two main properties that define random in mathematical sense: the first is unpredictability and the second is uniform distribution.

If you're talking about the first, it's generally almost impossible to generate it entirely within software (and to do it properly). There are some ways, such as gathering entropy from human interface devices, e.g. /dev/random in Linux, but we generate a fairly low level of entropy to be useful. Others have already pointed some hardware implementations. They all have roots deep within physics theory (like our belief that the precise moment a photon will hit a detector is truly random). There are some software algorithms for this, like Blum-Blum-Shub. In general, don't write a PRNG if you need unpredictability, but rather use an established one. This goes especially with crypto.

The other important property of random functions is actually fairly easy to satisfy. There are many examples of this, like the RNG behind RC4, Linear Feedback Shift Registers (this was actually used for crypto, too, once upon a time, but was found insufficiently secure), etc. Even the standard C library rand() will probably work fine for this purpose.

Most important: Make sure you know which of the two properties is fundamental to your need. Unpredictable PRNGs are uniformly distributed, too, but the other way around is not true. Also, if you are exposing the randomness inside an 'engine' of some sort (like a game engine), make sure people cannot game the system, because you might be surprised how easy that actually is. For example, CSS (the DVD encryption algorithm) used 2 LSFRs for cryptography purposes and was broken fairly easy.

Title: How to create a random generator


问:
C++ Pointers: Number of levels of Indirection
In a C++ program that doesn't contain legacy C code, is there a guideline regarding the maximum number of levels of indirection that should be used in the source code?  I know that in C (as opposed to C++), some programmers have used pointers to pointers for a multiple dimension array, but for the case of arrays, there are data structures in C++ that can be used to avoid the pointers to pointers.

Are users who still create pointers to pointers (or more than this) trying to use pointers to pointers only for performance ETC. reasons?

I have tried NOT to use any more than a pointer to a pointer, only in the case that a pointer needed modification; does anyone have any other official or unofficial guidelines or rules regarding the number of levels of indirection?

答:
There are no guidelines or any practical limits on indirection. There's no good reason to place a constraint like this unless you're regularly dealing with several levels of indirection in a case indicative of a sloppy design.

That is to say that there are valid cases where 4, 5, 6, or more levels of indirection is to be expected, but these are rare and should not typically appear in your code unless someone has done something terrible, not directly related to the level of indirection being employed.

If you are finding yourself using, say, 3 or more levels of indirection, then you should probably consider whether your architecture needs to be changed.

But does that mean you should never allow more than 3 levels of indirection? Absolutely not. It simply means that it might potentially be an indication that there could possibly be an inherent inefficiency in the architecture of your code. Nothing more. (Do note the deliberate vagueness of that statement: it is a mere possibility of something that could lead to a problem, not necessarily an actual problem.)


问:
Can a designer start an open source project?
I appreciate you can't start an open source project with just an idea but would just a design be enough? Has anyone ever seen that done where a designer posts a design and developers join to start the coding?</p>

答:
If you don't find a programmer directly, like knowing somebody and "talking them into it", then I don't think that project will work.

I have seen many projects with complete designs and a framework, that never even generate a prototype.

It is difficult to attract developers to "dead" projects. So I wouldn't suggest starting a (complete) design if you don't have anybody to code, yet.
Of course, having a general architecture might help starting a team.


答:
I would say you've got a good start. If you have an idea of what the final product should look like and how each button / user interaction should be handled you're probably closer than you think.. NOW, getting someone to jump on board and code it out might take some time and maybe never happen.. depending on your product, you might be able to "shop it around" and get some traction.

In my experience, the "final design" is often missing from the stakeholders project plan. In my opinion having the functionality "flushed out" so that the user interactions and program / process flow is laid out it's a huge step in the right direction. If you are intent on going open source then create the documentation on how the final product should behave and you'll be creating (i say this loosely) a user acceptance test which is much easier to develop.

I think the biggest challenge is getting a programmer (or community) on board because we are all probably working on our own projects which we think is the "next big thing".

Or it would be a great project / opportunity for you to learn to code.

Title: Can a designer start an open source project?

Body: I appreciate you can't start an open source project with just an idea but would just a design be enough? Has anyone ever seen that done where a designer posts a design and developers join to start the coding?</p>


问:
Design patterns to avoiding breaking the SRP while performing heavy data logging
A class that performs both computations and data logging* seems to have at least two responsibilities. Given a system for which the specifications require heavy data logging, what kind of design patterns or architectural patterns can be used to avoid bloating all the classes with logging calls every time they compute something?

The decorator pattern be used (e.g. Interpolator decorated to LoggingInterpolator), but it seems that would result in a situation hardly more desirable in which almost every major class would need to be decorated with logging.

*Note: When I wrote this, I was working in a context in which it was called logging, but it was actually writing to a database. I'm not particularly referring issuing debug or error messages in a log4net log or the like.

答:
My first thought is to treat the computational parts as a model, and the logging parts as a view. You could then manage the work flow activities of each using a controller or presenter pattern. Substitute other fancy names for each part if you wish, but I see three parts.

So, the controller would initiate the computation, retrieve the result, and relay that to the logger. The computation and logging parts stay ignorant of each other, and the high level logic of your main job is expressed in one place.


答:
Note that a linked list of 42 elements contains 42 levels of indirection for accessing the last element. To get to the element of a one-element list, you use a single indirection: given a pointer to the list, you do something like p->data.  To get to the second element, two indirections are required: p->next->data. Each arrow is an indirection.  Only, the notation isn't just a row of ****'s.  Of course, p->next is really (*p).next. So you could write that as (*(*(*p).next).next).data.   If you want to see forty-two asterisks, that can be accomodated.

If the next field of the linked list is at the beginning of the structure, then at the machine level it really is just the equivalent of (***...***p).data, where only the final access to data uses an offset.

And of course, tree structures contain many levels of indirection, particularly if their fan-out is low, such as binary search trees, and particularly if they are allowed to become unbalanced.

Title: C++ Pointers: Number of levels of Indirection

Body:
In a C++ program that doesn't contain legacy C code, is there a guideline regarding the maximum number of levels of indirection that should be used in the source code?  I know that in C (as opposed to C++), some programmers have used pointers to pointers for a multiple dimension array, but for the case of arrays, there are data structures in C++ that can be used to avoid the pointers to pointers.

Are users who still create pointers to pointers (or more than this) trying to use pointers to pointers only for performance ETC. reasons?

I have tried NOT to use any more than a pointer to a pointer, only in the case that a pointer needed modification; does anyone have any other official or unofficial guidelines or rules regarding the number of levels of indirection?


问:
Decrementing/Incrementing loop variable inside for loop. Is this code smell?
I have to read lines from a text file in sequential order. The file is a custom text format that contains sections. If some sections are out of order, I would like to look for the starting of the next valid section and continue processing.

Currently, I have some code that looks like this:

```<code>for (int currentLineIndex=0; currentLineIndex < lines.Count; currentLineIndex++ )
{
    //Process section here
    if( out_of_order_condition )
    {
        currentLineIndex--;//Stay on the same line in the next iteration because this line may be the start of a valid section.
       continue;
    }
}
</code>```

Is this code smell?

UPDATE: I didn't mention this earlier, but the root cause of this kind of code was a complicated switch-case (typical when you're parsing).

I got rid of the incrementing/decrementing variable by using the "goto case" statement.

The structure now looks like this:

```<code>switch(state)
{
   case State.BOF:
       {
           //Process BOF case
       }
   case State.SeenHeader:
       {
           if( out_of_order_condition )
           {
               state = State.BOF;    //Reset the state to some respectable one

               //currentLineIndex--; Removed
               //continue;           Removed

               goto case State.BOF;//Handle this in this iteration itself.
           }
       }
}
</code>```

答:
No.  Or at least I don't think so.  It is an indication that the iteration is complicated, but that's not necessarily a sign of a fundamental design problem ... or bad coding practice.

However, you might want to look at the code and think about whether there is a more readable way of doing this.  And if you keep the code as it is, you might want to either:

add a comment at the start of the loop to say that the loop variable is changed, or

change this to a while loop.

On the other hand "code smell" is very subjective ...


问:
How are "Json.org"-like specs graphs called and how can I generate them?
In http://www.json.org Douglas Crockford shows the specs of the JSON format in two interesting ways:

In the right side column he lists a text spec that looks like a YACC or LEX listing.

In the main body of the homepage, he put several images that gives us a simple way to visually understand the valid sequences that composes a JSON string.

Those images look like a description of the path that a finite state automaton would follow when parsing the JSON string.

Wich are the names (if any) of that listing format and that kind of graphics?

Is there any software that renders a source file containing the specification into that kind of images?

答:
The name you are looking for is "Syntax Diagram" or "Railroad Diagram". This question on Stack Overflow gives a good overview of some of the available tools for generating these types of diagrams.

According to this answer by aleemb, which contains an email response from Douglas Crockford, the diagrams on json.org were made using Microsoft Visio, but Creative Docs.NET is also a viable tool. This answer by Peter Ajtai suggests the Railroad Diagram Generator which takes a formatted context-free grammar and converts it into an SVG image that can be downloaded.

A similar question on Stack Overflow also provides other tools, such as the EBNF-Visualizer and Graphviz.


答:
Well, since a code smell is something that makes you take a second look at it, which you yourself are doing, I'd say it definitely qualifies.  However, code smells don't automatically need removing, just a hard look to make sure it's really the best way to solve the problem.

In this particular case, the reason you don't often see code like that is it can cause the loop to never terminate under certain input conditions.  You're also commingling two different responsibilities into the loop:  detecting section starts and processing a section.  I would try to have one loop that only detects section boundaries, and once the entire section is known, pass the section contents to another function for processing.

It's also possibly a sign your format is complex enough that a homegrown parser is going to have difficulty catching all the boundary conditions.  You might want to look into a full parser like bison or antlr.

Title: Decrementing/Incrementing loop variable inside for loop. Is this code smell?

Body:
I have to read lines from a text file in sequential order. The file is a custom text format that contains sections. If some sections are out of order, I would like to look for the starting of the next valid section and continue processing.

Currently, I have some code that looks like this:

```<code>for (int currentLineIndex=0; currentLineIndex < lines.Count; currentLineIndex++ )
{
    //Process section here
    if( out_of_order_condition )
    {
        currentLineIndex--;//Stay on the same line in the next iteration because this line may be the start of a valid section.
       continue;
    }
}
</code>```

Is this code smell?

UPDATE: I didn't mention this earlier, but the root cause of this kind of code was a complicated switch-case (typical when you're parsing).

I got rid of the incrementing/decrementing variable by using the "goto case" statement.

The structure now looks like this:

```<code>switch(state)
{
   case State.BOF:
       {
           //Process BOF case
       }
   case State.SeenHeader:
       {
           if( out_of_order_condition )
           {
               state = State.BOF;    //Reset the state to some respectable one

               //currentLineIndex--; Removed
               //continue;           Removed

               goto case State.BOF;//Handle this in this iteration itself.
           }
       }
}
</code>```


答:
I think it is a code smell.  The idiom in a for loop is to have it increment/decrement consistently.  People reading your code are going to expect the increment expression (currentLineIndex++) to be the controlling logic.

I think it would be better to do one of the following:

turn this code into a while loop.  The idiom for while loops vary more making developers more likely to read your code.

add a nested while loop to handle the case where you stay on one line.  That way the outer loop preserves the idiom and you make it more obvious that the inner loop keeps going until out_of_order_condition is no longer met.


答:
It is EXTREMELY rare that it is actually a good idea to write code with more than one level of indirection at any given instant.

Part of this is because prudence dictates that you check every pointer for NULL before you dereference it, and that's hard to do if you write more than one level of indirection.

Part of this is because modern processors have complicated data cache, and even more complicated memory allocation schemes, and walking multiple levels of indirection (through long pointer chains) can thrash the holy crap out of the cache.

I have seen processors that can deliver up erroneous results if you thrash the cache in certain ways.  (Yes, these are hardware problems.  No, the vendor is NOT going to fix them any time soon, and in any case those chips are already out in the field.)  I personally fixed a problem, that smelled like one of those, on a processor for which the manufacturer had already warned about issues like this, by rewriting the code to be very careful about locality of references.  (I did not do the rewrite because I suspected a thrashed cache.  I found out about that issue later.  I did the rewrite because the original code was an unreadable pile of spaghetti and pointers to pointers to pointers.  I was mildly perturbed when the problem I was chasing just vanished swiftly and silently away.)

AND part of it is because code that is only doing one level of indirection is usually a LOT easier for the poor maintenance schlub to understand.


答:
Last time I looked, which was a LOOOOONG time ago, the canonical reference on implementation of pseudorandom number generators (PRNG) is Knuth, Vol. 2, "Seminumerical Algorithms".

Don't even THINK about trying to implement your own PRNG until you've at least looked through Knuth.

Title: How to create a random generator


问:
Support for non-english characters?
Is support for non-english characters common in programming languages? I mean, technically, I would think it is feasable, but I don't have any experience in anything other than english, so I don't know how common it is.

I know that there are non-english based programming languages, but can something like C#, C++, C, Java, or Python support non-english classes/methods/variables?

Example in go (url, http://play.golang.org/p/wRYCNVdbjC)

```<code>package main

import "fmt"

type 世界 struct {
    世界 string
}

func main() {
    fmt.Println("Hello, 世界")
    世界 := new(世界)
    世界.世界 = "hello world"
    fmt.Println(世界.世界)
}
</code>```

答:
Support for non-ASCII literals is present in virtually every modern language. That is, you can write something like japanese = "今日は世界" in Java, Python, Go, C#, Ruby, etc.

Support for non-ASCII identifiers, that is, things like 英語で = "Hello world" is also widespread. Languages that allow this, among others, are: Java, Python 3, but not 2 and 1, C#, etc.

Take a look at this lengthy list.

Title: Support for non-english characters?


问:
Is C++11 Uniform Initialization a replacement for the old style syntax?
I understand that C++11's uniform initialization solves some syntactical ambiguity in the language, but in a lot of Bjarne Stroustrup's presentations (particularly those during the GoingNative 2012 talks), his examples primarily use this syntax now whenever he is constructing objects.

Is it recommended now to use uniform initialization in all cases? What should the general approach be for this new feature as far as coding style goes and general usage? What are some reasons to not use it?

Note that in my mind I'm thinking primarily of object construction as my use case, but if there are other scenarios to consider please let me know.

答:
I'm going to disagree with Nicol Bolas' answer's section Minimizes Redundant Typenames. Because code is written once and read multiple times, we should be trying to minimize the amount of time it takes to read and understand code, not the amount of time it takes to write code. Trying to merely minimize typing is trying to optimize the wrong thing.

See the following code:

```<code>vec3 GetValue()
{
  <lots and lots of code here>
  ...
  return {x, y, z};
}
</code>```

Someone reading the code above for the first time won't probably understand the return statement immediately, because by the time he reaches that line, he will have forgotten about the return type. Now, he'll have to scroll back to the function signature or use some IDE feature in order to see the return type and fully understand the return statement.

And here again it's not easy for someone reading the code for the first time to understand what is actually being constructed:

```<code>void DoSomething(const std::string &str);
...
const char* strValue = ...;
size_t strLen = ...;

DoSomething({strValue, strLen});
</code>```

The code above is going to break when someone decides that DoSomething should also support some other string type, and adds this overload:

```<code>void DoSomething(const CoolStringType& str);
</code>```

If CoolStringType happens to have a constructor which takes a const char* and a size_t (just like std::string does) then the call to DoSomething({strValue, strLen}) will result in an ambiguity error.

My answer to the actual question:

No, Uniform Initialization should not be thought of as a replacement for the old style constructor syntax.

And my reasoning is this:

If two statements don't have the same kind of intention, they shouldn't look the same. There are two kinds of notions of object initialization:

1) Take all these items and pour them into this object I'm initializing.

2) Construct this object using these arguments I provided as a guide.

Examples of the use of notion #1:

```<code>struct Collection
{
    int first;
    char second;
    double third;
};

Collection c {1, '2', 3.0};
std::array<int, 3> a {{ 1, 2, 3 }};
std::map<int, char> m { {1, '1'}, {2, '2'}, {3, '3'} };
</code>```

Example of the use of notion #2:

```<code>class Stairs
{
    std::vector<float> stepHeights;

public:
    Stairs(float initHeight, int numSteps, float stepHeight)
    {
        float height = initHeight;

        for (int i = 0; i < numSteps; ++i)
        {
            stepHeights.push_back(height);
            height += stepHeight;
        }
    }
};

Stairs s (2.5, 10, 0.5);
</code>```

I think it's a bad thing that the new standard allows people to initialize Stairs like this:

```<code>Stairs s {2, 4, 6};
</code>```

...because that obfuscates the meaning of the constructor. Initialization like that looks just like notion #1, but it's not. It's not pouring three different values of step heights into the object s, even though it looks like it is. And also, more importantly, if a library implementation of Stairs like above has been published and programmers have been using it, and then if the library implementor later adds an initializer_list constructor to Stairs, then all the code that has been using Stairs with Uniform Initialization Syntax is going to break.

I think that the C++ community should agree to a common convention on how Uniform Initialization is used, i.e. uniformly on all initializations, or, like I strongly suggest, separating these two notions of initialization and thus clarifying the intention of the programmer to the reader of the code.

AFTERTHOUGHT:

Here's yet another reason why you shouldn't think of Uniform Initialization as a replacement for the old syntax, and why you can't use brace notation for all initializations:

Say, your preferred syntax for making a copy is:

```<code>T var1;
T var2 (var1);
</code>```

Now you think you should replace all initializations with the new brace syntax so that you can be (and the code will look) more consistent. But the syntax using braces doesn't work if type T is an aggregate:

```<code>T var2 {var1}; // fails if T is std::array for example
</code>```

OwnerDisplayName: Robert Dailey

Body:
I'm going to disagree with Nicol Bolas' answer's section Minimizes Redundant Typenames. Because code is written once and read multiple times, we should be trying to minimize the amount of time it takes to read and understand code, not the amount of time it takes to write code. Trying to merely minimize typing is trying to optimize the wrong thing.

See the following code:

vec3 GetValue()
{
  <lots and lots of code here>
  ...
  return {x, y, z};
}

Someone reading the code above for the first time won't probably understand the return statement immediately, because by the time he reaches that line, he will have forgotten about the return type. Now, he'll have to scroll back to the function signature or use some IDE feature in order to see the return type and fully understand the return statement.

And here again it's not easy for someone reading the code for the first time to understand what is actually being constructed:

void DoSomething(const std::string &str);
...
const char* strValue = ...;
size_t strLen = ...;

DoSomething({strValue, strLen});

The code above is going to break when someone decides that DoSomething should also support some other string type, and adds this overload:

void DoSomething(const CoolStringType& str);

If CoolStringType happens to have a constructor which takes a const char* and a size_t (just like std::string does) then the call to DoSomething({strValue, strLen}) will result in an ambiguity error.

My answer to the actual question:

No, Uniform Initialization should not be thought of as a replacement for the old style constructor syntax.

And my reasoning is this:

If two statements don't have the same kind of intention, they shouldn't look the same. There are two kinds of notions of object initialization:

1) Take all these items and pour them into this object I'm initializing.

2) Construct this object using these arguments I provided as a guide.

Examples of the use of notion #1:

struct Collection
{
    int first;
    char second;
    double third;
};

Collection c {1, '2', 3.0};
std::array<int, 3> a {{ 1, 2, 3 }};
std::map<int, char> m { {1, '1'}, {2, '2'}, {3, '3'} };

Example of the use of notion #2:

class Stairs
{
    std::vector<float> stepHeights;

public:
    Stairs(float initHeight, int numSteps, float stepHeight)
    {
        float height = initHeight;

        for (int i = 0; i < numSteps; ++i)
        {
            stepHeights.push_back(height);
            height += stepHeight;
        }
    }
};

Stairs s (2.5, 10, 0.5);

I think it's a bad thing that the new standard allows people to initialize Stairs like this:

Stairs s {2, 4, 6};

...because that obfuscates the meaning of the constructor. Initialization like that looks just like notion #1, but it's not. It's not pouring three different values of step heights into the object s, even though it looks like it is. And also, more importantly, if a library implementation of Stairs like above has been published and programmers have been using it, and then if the library implementor later adds an initializer_list constructor to Stairs, then all the code that has been using Stairs with Uniform Initialization Syntax is going to break.

I think that the C++ community should agree to a common convention on how Uniform Initialization is used, i.e. uniformly on all initializations, or, like I strongly suggest, separating these two notions of initialization and thus clarifying the intention of the programmer to the reader of the code.

AFTERTHOUGHT:

Here's yet another reason why you shouldn't think of Uniform Initialization as a replacement for the old syntax, and why you can't use brace notation for all initializations:

Say, your preferred syntax for making a copy is:

T var1;
T var2 (var1);

Now you think you should replace all initializations with the new brace syntax so that you can be (and the code will look) more consistent. But the syntax using braces doesn't work if type T is an aggregate:

T var2 {var1}; // fails if T is std::array for example


答:
Erm... In the past I'd been programming in English but to support Asian language (mostly Chinese) in the UI.

For most of the coding, we use English.
Only for the UI matter, i.e. label in Windows Forms, Row Header in GridView, text within html/aspx, we will use Chinese.

Thus, we won't code something like this...

```<code>type 世界 struct {
     世界 string
}
</code>```

But will have things like

```<code><b>你好, 欢迎你到来。</b>
</code>```

Title: Support for non-english characters?

Body:
Is support for non-english characters common in programming languages? I mean, technically, I would think it is feasable, but I don't have any experience in anything other than english, so I don't know how common it is.

I know that there are non-english based programming languages, but can something like C#, C++, C, Java, or Python support non-english classes/methods/variables?

Example in go (url, http://play.golang.org/p/wRYCNVdbjC)

```<code>package main

import "fmt"

type 世界 struct {
    世界 string
}

func main() {
    fmt.Println("Hello, 世界")
    世界 := new(世界)
    世界.世界 = "hello world"
    fmt.Println(世界.世界)
}
</code>```

Body:
Erm... In the past I'd been programming in English but to support Asian language (mostly Chinese) in the UI.

For most of the coding, we use English.
Only for the UI matter, i.e. label in Windows Forms, Row Header in GridView, text within html/aspx, we will use Chinese.

Thus, we won't code something like this...

type 世界 struct {
     世界 string
}

But will have things like

<b>你好, 欢迎你到来。</b>


问:
Is true multithreading really necessary?
So yeah, I'm creating a programming language. And the language allows multiple threads. But, all threads are synchronized with a global interpreter lock, which means only one thread is allowed to execute at a time. The only way to get the threads to switch off is to explicitly tell the current thread to wait, which allows another thread to execute.

Parallel processing is of course possible by spawning multiple processes, but the variables and objects in one process cannot be accessed from another. However the language does have a fairly efficient IPC interface for communicating between processes.

My question is: Would there ever be a reason to have multiple, unsynchronized threads within a single process (thus circumventing the GIL)? Why not just put thread.wait() statements in key positions in the program logic (presuming thread.wait() isn't a CPU hog, of course)?

I understand that certain other languages that use a GIL have processor scheduling issues (cough Python), but they have all been resolved.

答:
After analyzing other people's answers, I believe I now understand why simultaneous multithreading is important.

There are two main reasons why a general-purpose language should have real, preemptive multithreading support:

Sometimes developers want to use real threads in their programs. 'Nuff said.

Real threads are necessary to allow memory to be shared across threads running on multiple processor cores. This feature is essential for performance optimization in some cases, and in other cases it just makes the code easier to write.

However, in cases where memory-sharing is less important, cooperative multithreading programs are just as easy to write and far easier to debug, as long as the developer understands how to use the system.

So the answer is: Yes, true multithreading really is necessary in some cases, but only for certain performance optimizations and accessibility to developers who prefer it. Otherwise, cooperative ("fake") multithreading is the best solution.

Thanks for all the input guys, I might not have figured this out without you. I'm going to include both threading schemes in my language. We'll see how well that goes.


问:
How common is it to submit papers to journals or conferences outside of academia?
I worked in academia a few years, but more on the D-side of R&D. The race for papers never appealed to me and I'm a practical not theoretical type, but I do like reading papers on certain topics (e.g. Google Papers, NLP, FB papers, ...) a lot.

How common is it that normally working developers submit papers to conferences or even journals? It seems to be somewhat common in certain companies (it's not common or encouraged in mine). Do journals or conferences even take papers by an academic nobody (BSc) under consideration? I ask, because I have a few rough ideas and I would just like to bring them into form, one way or the other.

Bonus question: Is there a list of CS (in the widest sense) conferences/journals with short descriptions?

PS (Four out of five researchers I met published quite some fluffy stuff for my taste. I am no expert, but those people told me sometimes themselves, that the implementation does not matter, just the idea and the presentation.

I always wondered about that. I probably could write about ideas all day long (not instantly but with a bit of preparation), but the implementation and the practical part is the really hard part, that academia just does not like to be concerned with. Also many papers actually scream: I was written so the publication list of my author gets longer - which is a waste of time for everyone, and often a waste of tax money, too.

When I think of CS-ish papers, I think of running implementations or actual data, like e.g. Google's Map Reduce, Serving Large-scale Batch Computed Data with Project Voldemort or the like.)

答:
Indeed the quality of papers differs tremenduously and you have recognized well enough that often the system requires of researchers to publish or perish, hence, the fluffy stuff.

There are, however, also papers with solid implementations behind them, but they are rare, as they do not fit the publish or perish style. After all, implementations take a lot more time to implement, than to describe.

If you want to publish papers on your own, I suggest you try to find the reason why you want to do that:

get a grip on the idea and bring it into form: you can do that without the need to publish as a paper - what about a blog?

get a publication (for your CV or whatever reasons) - you may want to consider a journal instead of a conference. For one, they want more solid material and do not accept the fluffy stuff (usually), also they have a higher reputation.

meet other researchers: go for the conference paper then. In fact, even the fluffy stuff papers do have the advantage that you get to join the other researchers on the conference, which in itself is way more valuable than extending your publication list by one entry. On the other hand, you have to pay for your attendance yourself (i.e. travel fees and signup fees).

Finally, there are dedicated conferences (f.ex. JavaOne) which focus on practitioners from industry. The material in these conferences tends to be more fluffy even, because often the papers are written by people with fulltime jobs, but in their spare time. Companies in my experience either actively promote your participation in such conferences (f.ex. you can label it as training due to the very interesting talks you will have with other participants), or at least tolerate it (i.e. you roll on your own, but at least they don't oppose the required vacation days). Of course, this varies from company to company.


答:
Almost all languages support non-ASCII characters directly or indirectly.

E.g. in Java you can directly give the non-ASCII characters; But in C# you have to use an escape character sequence i.e.\u00e1 for á.

Support for non-ASCII is also dependent on the text editor you are using.

Title: Support for non-english characters?


问:
unseen/unknown function definition in linux source
Can any one please explain this piece of code I found in the linux kernel source. I see a lots of code like this in linux and minix kernel but dont seem to find what it does (even if C compilers support that kind of function definition)

```<code>/* IRQs are disabled and uidhash_lock is held upon function entry.
 * IRQ state (as stored in flags) is restored and uidhash_lock released
 * upon function exit.
 */
static void free_user(struct user_struct *up, unsigned long flags)
__releases(&uidhash_lock)
{
uid_hash_remove(up);
spin_unlock_irqrestore(&uidhash_lock, flags);
key_put(up->uid_keyring);
key_put(up->session_keyring);
kmem_cache_free(uid_cachep, up);
}
</code>```

I cannot find out if this reference __releases(&uidhash_lock) before the parenthesis starts is allowed OR supported. (It sure is supported as it is in the linux kernel)

答:
These are annotations used by Sparse, the Static Analysis Tool for the Linux Kernel, originally written by Linus Torvalds. When compiled normally, without Sparse, they are simply #defined away to nothing.

The definitions are in include/linux/compiler.h:

```<code># define __releases(x)  __attribute__((context(x,1,0)))
</code>```

This one uses the __attribute__ non-standard GCC extension.

This specific annotation is paired with another one called __acquires(x), which allows Sparse to determine whether the code paths which acquire and release a specific lock are correctly balanced.

Body:
These are annotations used by Sparse, the Static Analysis Tool for the Linux Kernel, originally written by Linus Torvalds. When compiled normally, without Sparse, they are simply #defined away to nothing.

The definitions are in include/linux/compiler.h:

# define __releases(x)  __attribute__((context(x,1,0)))

This one uses the __attribute__ non-standard GCC extension.

This specific annotation is paired with another one called __acquires(x), which allows Sparse to determine whether the code paths which acquire and release a specific lock are correctly balanced.


问:
iOS - Unit tests for KVO/delegate codes
I am going to design a MVC pattern. It could be either designed as a delegate pattern, or a Key-Value-Observing(KVO), to notify the controller about changing models. The project requires certain quality control procedures to conform to those verification documents.

My questions:

Does delegate pattern fit better for unit testing than KVO?

If KVO fits better, would you please suggest some sample codes?

答: The delegate approach is easier to unit test because the delegate can be mocked and that mock used without needing to change (or performance heroics) in the original code.</p>

Title: iOS - Unit tests for KVO/delegate codes


问:
Matrix Pattern Recognition Algorithm
I am designing a logic analyzer and I would like to implement some Matrix Algorithm.
I have several channels each one represented by a row in the matrix and every element in the column would be the state, for example:

```<code>Channel 1   1 0 0 1 0 1 1 0 1
Channel 2   1 1 0 1 1 0 0 1 1
Channel 3   0 1 0 1 1 0 1 0 0
</code>```

I would like to detect a pattern inside my matrix for example, detect ALL the matches of the bitmap inside the matrix:

```<code>1 0
1 1
</code>```

I think it can be accomplished testing element by element but I think there should be a better way of doing it. Is there any Java API or any way to do it ? If there is a API ARM optimized for NEON instructions would be great also but not mandatory.

They will be about 8 matrix of 3 or 2 rows by 20000 columns approximately, the matrix is not fixed, it change every time I scan it because I am constantly receiving data. I need to process them in 500mS or less. I am working on an ARM platform, dual core, 1.2GHz, 1Gb RAM, Android 4.1.2

Thank you very much in advance.

答: I don't know whether there's a Java API to do it, but a search for "two-dimensional string matching" or "two-dimensional pattern matching" turns up plenty of papers. For example, the master's thesis of Martijn van de Rijdt (PDF) reviews several algorithms and (being a thesis rather than a journal paper) is probably more readable than the original papers.</p>

Title: Matrix Pattern Recognition Algorithm


问:
Constant Interface antipattern - PHP
I came across this Wikiepedia article which says that using interfaces for defining constants is not a good thing.

Solution suggested there is to define constants in a final class and use static import. That works for Java. I come from the PHP world which does not have the "import" thing. So, what is the acceptable solution for PHP?

答:
You are referring to an article that say's

In the Java programming language, the constant interface pattern
  describes the use of an interface solely to define constants, and
  having classes implement that interface in order to achieve convenient
  syntactic access to those constants. However, since constants are very
  often merely an implementation detail, and the interfaces implemented
  by a class are part of its exported API, this practice amounts to
  putting implementations details into the API, which is considered
  inappropriate. In general, collecting system constants into
  classes independent of behaviour, might create a poor object-oriented
  design, because it is often a sign of low cohesion. It is for these
  reasons that implementing constants interfaces is considered to be an
  anti-pattern.

I come from Java, and I am doing PHP right now ...
From my point of view, as long as you use interface constants which are of internal system nature, you are fine... once you start exposing your interface constants as part of your external API, you shoud do that using classes not interfaces.

Another thing to consider is serialization, and deployment packages. If you need constants as part of the deployment package to enable an error free de-serialization remember: You can add implementation details into classes, but not into interfaces.

Sadly PHP only knows public,protected and private to control the namespace, and to control the scope of constants. In Java you have package-private on top, which basically says "in the same directory"/"java package de.*".

Remember this when comparing Java to other languages and make conclusions regarding ant-patterns which refer to OODesign in general and across languages. It may lead to wrong conclusions ;-) ...

I don't say the wikipedia article is wrong... but it is not 100% correct either.

Just my 2 €cent

Title: Constant Interface antipattern - PHP


问:
Best way to store revision information for quick access to view or revert changes
What I am looking for is the most optimal solution for storing content revisions in an MSSQL database. We have an application that allows users to make changes to small HTML content blocks similar to a wiki, but we need to have tight audit control over the changes. At any point in time, the manager might want to look at previously submitted contents or revert the entire HTML block back to the previous state.

I had it setup in the past where we had a primary table that stored the HTML information (along with various other meta tags) and then an audit table that kept a copy of the entire data row everytime a change was made. What I am wondering is if this is the best way to go, or should I just keep 1 table with all the current records and the changes in it and just have a flag that lets me know which one is the current one?

答:
I have had decent success with doing a bit of both.

One table that has the current version of the record and one table with every version (and a timestamp and an edited by) in another table.

This gives you the advantage of having a complete copy of each version without the overhead of having to sort out the current version from all the others at runtime.  it also allows you to set much stricter permissions on the audit table and optionally implement the audit copy with triggers and completely hide the audit information from the rest of the app if you like that sort of thing.


问:
Alternative Web model
One of the problems web apps have against native apps, especially on the mobile front, is the constant need to re-download each web page on request. Ultimately, this leads to slower performance. Why if web apps only download new pages if they're actually needed, not because they're simply requested.

For example: perhaps the server can store a web page version in a cookie. Every slight change to the page on the server-side changes the version number. Now instead of the browser requesting a new page each time, why not just check the version number and have the server send the page if they're different? If the page similar, the user can just use a cached page.

I'm sure browsers doesn't necessarily have to change to accommodate changes to this, correct?

答:
Have a read of RFC 1945 - Hypertext Transfer Protocol -- HTTP/1.0.

The idea that "instead of the browser requesting a new page each time, why not just check the version number and have the server send the page if they're different" has been part of the spec since May 1996, and I assume that was just formalizing what was already implemented.

Title: Alternative Web model


问:
Using a GPL game engine
I am confused. I thought I would try and use a new game engine in order to expand my abilities, and found a nice engine called springrts. I was looking through the licensing info and it is licensed under the GPL 2 licence. If I remember correctly, does that mean that anything I make with it, I have to distribute the source code to?</p>

答:
No, in this case it does not.

In their list of games they are pretty clear that they consider the game data as using the engine rather than being derived work of it. So GPL does not apply to the game data.

Therefore you can put the game data under any license you want including fully commercial. You still have to provide download of the engine sources somewhere, including possible modifications you make to the engine code itself, but you don't have to do it for the game data source.

Title: Using a GPL game engine


问:
Can I display part of the source code of an open source plugin's with GPLv2 liscence?
I would like to publish part or full source code of one or more plugins (licensed under GPL, GPLv2, MIT or no license) in my website/blog. Website I am talking about is for everyone, free to use and free to copy code. Plus, is it okay if I do not provide any link to the source code/plugin? I will definitely give full credits to the developer.</p>

答:
GPL: You must provide full source code if you are providing compiled form. If you are not providing compiled form, you still can provide the source in full or any part of it. You must attach the license notice to it. I.e. even if you take few functions out of a source file, you have to put the copyright notice from the beginning of the original source before them and you have to have link on web/pack it with any archives for download.

MIT: You can do whatever you want with it except claim you wrote it yourself. You can even provide it under stricter license (this often happens if you combine it with GPL code).

"no license": There is no such thing as "no license". Any work subject to copyright may only be used with author's permission. If there is no license notice attached, you have to contact the author and ask them.

There is "public domain", but non-US jurisdictions generally either don't have that term or it only means works for which the copyright protection already expired. That's why there are licenses like WTFPL, which is equivalent to "public domain", but does not use that term.

Note that it's actually questionable whether it's allowed to put plugin for proprietary program under GPL since a plugin can be considered derived work of the program and GPL only excludes "system libraries". I suppose the plugin itself can always have exception for the program it is plugin for, but it may not use pre-existing GPL code written without such exception (LGPL code is OK, because LGPL stops at dynamic link boundary and anything that qualifies as plugin is dynamically loaded).


答:
You are talking about client side caching and it's been available and extensively in use for many years.

There are several ways to implement and control client side caching, mostly involving changing the HTTP headers that the server sends along with the initial page response. Similar to the cookie method you propose.

Here's a good summary: http://www.librosweb.es/symfony_1_2_en/capitulo12/http_11_and_clientside_caching.html

Title: Alternative Web model

Body:
One of the problems web apps have against native apps, especially on the mobile front, is the constant need to re-download each web page on request. Ultimately, this leads to slower performance. Why if web apps only download new pages if they're actually needed, not because they're simply requested.

For example: perhaps the server can store a web page version in a cookie. Every slight change to the page on the server-side changes the version number. Now instead of the browser requesting a new page each time, why not just check the version number and have the server send the page if they're different? If the page similar, the user can just use a cached page.

I'm sure browsers doesn't necessarily have to change to accommodate changes to this, correct?


答:
When talking about web apps (instead of static content), the accepted approach to this is AJAX - just reload the parts of a page that have to change (instead of the whole page).

Caching doesn't really help much, because in many cases the page is hardly ever identical.

Title: Alternative Web model


问:
Why the name 'continue'
The 'continue' keyword in Java (and probably in many other programming languages) is used to skip further execution of the current iteration.

Why was the name 'continue' chosen? Why not something more straightforward like 'skip' ?

答:
While most likely not a very big difference and programmers would have been able to handle it just the same:

"continue" makes it clear that the loop will go on processing data (stop the details, continue the loop), while "skip" could be thought of as terminating the loop totally (like break in C++). It's one of those cases where it can be difficult to find the "perfect" name for some functionality. Ruby and Perl use "next" in similar situations which to me seems a slightly better choice.

Title: Why the name 'continue'


问:
Should I use both WCF and ASP.NET Web API
We already have a WCF API with basichttpbinding.
Some of the calls have complex objects in both the response and request.

We need to add RESTful abilities to the API.
at first I tried adding a webHttp endpoint, but I got

```<code>At most one body parameter can be serialized without wrapper elements
</code>```

If I made it Wrapped it wasn't pure as I need it to be.

I got to read this, and this (which states "ASP.NET Web API is the new way to build RESTful service on .NET").

So my question is, should I make 2 APIs(2 different projects)? one for SOAP with WCF and one RESTful with ASP.NET Web API? is there anything wrong architecturally speaking with this approach?

答:
I was asking myself the same question until I found this WCF and ASP.NET Web API comparison page on MSDN (with my own emphasis below):

Use WCF to create reliable, secure web services that accessible over a
  variety of transports. Use ASP.NET Web API to create HTTP-based
  services that are accessible from a wide variety of clients. Use
  ASP.NET Web API if you are creating and designing new REST-style
  services. Although WCF provides some support for writing REST-style
  services, the support for REST in ASP.NET Web API is more complete and
  all future REST feature improvements will be made in ASP.NET Web API.
  If you have an existing WCF service and you want to expose additional
  REST endpoints, use WCF and the WebHttpBinding.

IMO, having two APIs (two projects) is not a good approach: you are going to have maintenance problems, and you may confuse or trouble your service consumers / clients.

I would say it depends on your project requirements and client needs. If SOAP is a must, go with @Smokefoot's answer, use WCF and expose SOAP and REST endpoints. If no client wants to use SOAP any more and they want REST, stop the development on the WCF version (web service v1) and  go for ASP.NET Web API (web service v2)


问:
Performance: recursion vs. iteration in Javascript
I have read recently some articles (e.g. http://dailyjs.com/2012/09/14/functional-programming/) about the functional aspects of Javascript and the relationship between Scheme and Javascript (the latter was influenced by the first, which is a functional language, while the O-O aspects are inherited from Self which is a prototyping-based language).

However my question is more specific: I was wondering if there are metrics about the performance of recursion vs. iteration in Javascript.

I know that in some languages (where by design iteration performs better) the difference is minimal because the interpreter / compiler converts recursion into iteration, however I guess that probably this is not the case of Javascript since it is, at least partially, a functional language.

答:
JavaScript does not perform tail recursion optimization, so if your recursion is too deep, you may get a call stack overflow. Iteration doesn't have such issues. If you think you are going to recurse too much, and you really need recursion (for example, to do flood-fill), replace the recursion with your own stack.

Recursion performance is probably worse than iteration performance, because function calls and returns require state preservation and restoration, while iteration simply jumps to another point in a function.


答:
Update: since ES2015, JavaScript has TCO, so part of the argument below doesn't stand anymore.

Although Javascript doesn't have tail call optimization, recursion is often the best way to go. And sincerely, except in edge cases, you're not going to get call stack overflows.

Performance is something to keep in mind, but premature optimization too. If you think that recursion is more elegant than iteration, then go for it. If it turns out this is your bottleneck (which may never be), then you can replace with some ugly iteration. But most of the times, the bottleneck lies in the DOM manipulations or more generally the I/O, not the code itself.

Recursion is always more elegant1.

1: Personal opinion.

Title: Performance: recursion vs. iteration in Javascript

Body:
I have read recently some articles (e.g. http://dailyjs.com/2012/09/14/functional-programming/) about the functional aspects of Javascript and the relationship between Scheme and Javascript (the latter was influenced by the first, which is a functional language, while the O-O aspects are inherited from Self which is a prototyping-based language).

However my question is more specific: I was wondering if there are metrics about the performance of recursion vs. iteration in Javascript.

I know that in some languages (where by design iteration performs better) the difference is minimal because the interpreter / compiler converts recursion into iteration, however I guess that probably this is not the case of Javascript since it is, at least partially, a functional language.


答:
Jan's answer gives what you can do according to the various licenses. But I think you may have another option depending on exactly how you tend to use the code in your blog and how much of it.

US (and many other contries) copyright law contains a fair use clause. If you are providing commentary or critique of the code the fair use would give you the right to incorporate and cite copyrighted material without needing a license or the copyright holders permission. The main advantage here would be being able to omit the license details from the blog text.

As ever with these things there is a health dose of 'it depends' here and if you want to be sure that your use constitutes fair use then you need to consult a lawyer.

Title: Can I display part of the source code of an open source plugin's with GPLv2 liscence?

Body: I would like to publish part or full source code of one or more plugins (licensed under GPL, GPLv2, MIT or no license) in my website/blog. Website I am talking about is for everyone, free to use and free to copy code. Plus, is it okay if I do not provide any link to the source code/plugin? I will definitely give full credits to the developer.</p>


问:
To map - word usage in software context
I always get confused about how to use the verb "to map" in the context of associating objects with each other, particularly if the mapping is directional.

Is there a distinction between

mapping users to IDs

and

mapping IDs to users

In the given example, which would be the better way to put it?

答:
A map from X to Y would be something (function, table, data-structure) which, given an X (from an X), would allow you to retrieve the (often, but not necessarily, unique) corresponding Y (to a Y).

Something that maps IDs to users would allow you to retrieve a user given his/here ID. A map from users to IDs would be the opposite. A bi-directional mapping would allow you to do the search both ways.

Title: To map - word usage in software context


问:
What is a *slightly* less extreme equivalent to being "fluent" in a language?
tl;dr: What is a less extreme (but still noticeable) alternative to the word "fluent", when saying e.g. "I am fluent in C++/Python/whatever?"

I think I can call myself "fluent" in C#, because I know the language and runtime very well, and I'm very familiar with the .NET framework's APIs and classes, etc.

I would like to claim the same thing for Python and C++.
But while I can program in Python (I did so for an entire summer, making a website with Django), for example, I would not call myself fluent because my code isn't always "Pythonic" (e.g. using map/filter vs. list comprehensions), and I'm not too intimate with some aspects of the language and standard library yet (e.g. the introspection API, etc.).

Is there a word or phrase I can use on e.g. a resume to describe what I know?

I can think of "very familiar with", but is there a better word/phrase I can use?

答:
These are the terms I usually see in real application forms that allow you to pick it from a list:

Competent

Skilled

Experienced

Good

Full working capacity/capability