答:
I programmed java web apps for 10 years before I switched to python, 4+ years ago. I feel that I'm much more productive using python and can get much more done in a shorter period of time, and to be honest, I'm much happier when I develop in python. Here are some of the reasons why I think python is better then Java based on my personal experience, your milage may very.

Web Frameworks:

When I first start programming web apps in Java, Struts just came out, and it wasn't great, but it was the best thing available. I created a bunch of struts apps, and a few in other frameworks along the way. Whenever a new framework came out (Tapestry, Wicket, GWT, stripe, grails, AppFuse, Play, RichFaces, Spring, etc), I would try it out and see if it was any better, and most times it was only a little better, and sometimes not better at all. I do have to say the play framework is a step in the right direction.

Batteries not included:

One of the most annoying parts of Java was the fact that most of the libraries that you use were not included in java itself, you had to include a ton of 3rd party libs from places like apache commons. If you use something like hibernate with any other large library, you end up in Jar dependency hell, where hibernate needs one version of a jar, and something else needs another version. If you load the jar files in the wrong order, you are out of luck. You need to depend on tools like maven, and ivy to manage your dependencies, and this just brings in more dependencies into your project which results in projects being huge. I had some war files 100MB+ war files for the simplest web apps.

Too many options:

For some reason there seems to be way too many different ways to do the same thing in Java. There are over 38 different web frameworks for java according to wikipedia ( http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java ) and 23 different ORM's ( http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software#Java ) just to name a couple of examples. If you look at other languages they have a more reasonable number. Some people think that having lots of options is a good thing, but it isn't it leads to a lot of wasted effort in the developer community, everyone is reinventing the same wheel, and if you are a new person to the language you have too many option to pick from.

App servers:

Java web applications are really heavy, and require a lot of resources to run. They are especially memory hungry. Like any piece of software they can be tuned to reduce their resource footprint, but compared to other languages their out of the box setup is horrible. In my past I have used weblogic, websphere, Jboss, tomcat, and jetty. I only used the first three when I was forced to use EJB's, but even if you aren't using EJB's they were large app servers and sometimes hard to configure and get running correctly. Tomcat and Jetty are much better and easier to setup, but are still resource hogs.

App Hosting:

If you aren't running your own server it is real hard to find shared hosting for your java apps at a reasonable price. The main reason is because java apps require much more memory compared to other languages, so it doesn't make sense for a shared hosting provider to spend their valuable RAM running a java site, when they could run 5 php sites in the same place. That means there are less providers offering java hosting, which in turn means higher costs to run your website.

Development Time:

When I developing in java, I found myself much slower then what I can do in python. I would need to make a change, compile, redeploy and then test, and this slows down the iterative process. I know there are ways to make this faster, but even at it's best, I felt much slower then what I can do in python.

There is also a lot less boilerplate code to do the same thing in python, so I spend less time developing the code as well.

Java just feels over engineered in a lot of parts, A lot of the API's and interfaces are just way to complicated for what you want to do. And everyone and their brother thinks they are a java architect and this results in big complicated systems that are hard to use and develop with.

IDE:

When I was developing in Java, I felt stuck to the IDE, I was lost without it. IntelliJ is the best IDE's on the market, and it was hard switching to python because there wasn't anything like it for python. So instead of an IDE, I just used textmate, which is just a normal text editor. It was hard at first, but because it was just a text editor, it was a really fast and responsive application. I could open my whole project in a few seconds, whereas when I want to open a project in an IDE it could take a minute or more, with a machine with a ton of RAM. The makers of IntelliJ came out with a python editor called pycharm, I bought it when it first came out, and it is great. But what I realized is that I don't need an IDE for python, I'm fine with a text editor. When I go back to working on Java web apps which I have to do from time to time, I try to use the text editor, but I haven't quite mastered that yet. I personally need the IDE for Java more because If I mess up something it takes longer to recompile and redeploy, which slows me down.

ORM:

When I first started using Hibernate as an ORM, I thought it was great, it had it's problems, and it wasn't perfect, but it was better then what I was doing before. I was happy with it, until I did an application with Django's ORM on a python project, and that opened up my eyes, that is how an ORM is supposed to work. After that project I went back to hibernate, and I just felt disappointed, and longed for going back to Django's ORM. Another great python ORM is sqlalchemy, which is similar to Django's ORM, but a little different. I have limited experience with ROR's ORM, but from what I remember, it was pretty good as well.

Templates:

The web templating systems in Java aren't that good, and I think I have tried them all (tiles, freemarker, velocity, etc). Most of them offer only basic functionality and are a pain to work with. On the Python side, my two favorites are Django templates and Jinja2, they have everything that I could need in a templating engine, and are really easy to use.


问:
Why don't browsers support haml and sass?
The time needed to download a website would be significantly reduced, and parsing would be also easier I think.

Why are not these languages imposed as a standard? Obviously they are better than raw html and CSS...

Browsers are the only thing that keeps us away from eliminating the intermediate HTML/CSS code.

答:
"Technically better" and "easier to use" are just two out of many criteria for making something a standard. There are lots of others, such as:

Compatibility with existing standards

Existing implementations (informal de-facto standards)

Effort required to implement

Existing user base (and hence, community support, available skilled manpower)

Existing toolchains

Platform support

Integration with related standards

You will have to agree that HTML and CSS have an overwhelming advantage against any newcomer on these criteria.

ContentLicense: CC BY-SA 3.0


问:
I need help deciding between silverlight/silverlight out-of-browser/wpf
I'm in the initial planning phase of a re-write project and I'm deciding between silverlight/silverlight oob/wpf. TL;DR at the end.

It's a LOB app that handles leads/customers/appointment calendars. Not too complicated. I'm independently researching these options elsewhere, but I thought I'd ask around. Some rough initial requirements/foreseeable problems are:

I have to be able to call an exe on the system with commandline args (sip phone).

Makes SL a problem

The userbase is distributed and I want to limit the traffic that goes over the wire as much as possible and avoid some nasty concurrency issues

I can see this being a problem using WPF

Software deployment/updating has to be dead simple. Some users are highly non-technical (see: 70 years old, on a computer for the first time)

This isn't a huge problem now with the ClickOnce app we are replacing, and I have control over the machines that it gets used on. However, it's simpler for users if they don't even have to click the clickonce "Install" button. I don't know how this is handled with Silverlight OOB.

The company is planning a hard expansion in 12 months so hardware deployment should be fast/easy. The idea is to get an internet connection at a new location, plug in some computers and be able to work without the need for dedicated IT people or server setup.

Makes SL appealing

Integration with other services (financial software, asterix server) isn't an immediate goal, but it is an eventual goal to be part of the system. This is made much simpler/more efficient if a single service is setup to integrate with those secondary services and doesn't have to transfer all of that data over the wire

Makes SL appealing

Making multiple 'versions' is out the window. I don't know what it's like maintaining a silverlight + silverlight oob version (if there's even any problems)

Might make WPF a better option.

TL;DR: From my vantage point, a silverlight app makes the best sense for 90% of the users - the other 10% can't use it because they need to run an exe. Silverlight OOB might be a happy middleground but I don't know at the moment what the execution model for it is like (is there still a concept of server-side code? If so, that would possibly be ideal) and I don't know how deployment/updating works for it.

答:
Well - interesting problem. You forgot to mention that you can have a Silverlight full trust application as of SL4, so if you're thinking of WPF you might want to consider that instead. It would need installing (ClickOnce), but you seem to be moving away from that.

I've not done anything with OOB yet, but I'm pretty sure that the same binary can be used both in broswer and out of browser as it's a project setting rather than a separate build target.

"Enable running application out of the browser"

on the Silverlight project's Silverlight tab.

So there'd be no separate maintenance issue there.

You can build a fair amount of code into the web application that hosts the Silverlight app and communicate using WCF RIA Services - again you'd have to go with .NET 4 and SL 4 to get version 1.0 of this. .NET 3.5 and SL 4 only supports the WCF RIA services beta. This would reduce a) the size of the download and b) the amount of code that would need to execute on the client but would increase the network traffic.

On that score you can split your Silverlight code into several assemblies and using something like Prism set them to load on demand. This means that the user only downloads those parts of the application they are actually using. You can further reduce the amount downloaded by checking the

"Reduce XAP size by using application library caching"

option.

If you have an "extmap" file to go with any external dlls (third party or .NET) then this means that they get bundled into a zip file and downloaded separately to be shared across all xap files in your project. This keeps the individual xap files to their minimum size and ensures that you only have one copy of these other dlls on the client machine.

ContentLicense: CC BY-SA 2.5


问:
Why isn't Java used for modern web application development?
As a professional Java programmer, I've been trying to understand - why the hate toward Java for modern web applications?

I've noticed a trend that out of modern day web startups, a relatively small percentage of them appears to be using Java (compared to Java's overall popularity).  When I've asked a few about this, I've typically received a response like, "I hate Java with a passion."  But no one really seems to be able to give a definitive answer.

I've also heard this same web startup community refer negatively to Java developers - more or less implying that they are slow, not creative, old.

As a result, I've spent time working to pick up Ruby/Rails, basically to find out what I'm missing.  But I can't help thinking to myself, "I could do this much faster if I were using Java," primarily due to my relative experience levels.

But also because I haven't seen anything critical "missing" from Java, preventing me from building the same application.

Which brings me to my question(s):

Why is Java not being used in modern web applications?

Is it a weakness of the language?

Is it an unfair stereotype of Java because it's been around so long (it's been unfairly associated with its older technologies, and doesn't receive recognition for its "modern" capabilities)?

Is the negative stereotype of Java developers too strong? (Java is just no longer "cool")

Are applications written in other languages really faster to build, easier to maintain, and do they perform better?

Is Java only used by big companies who are too slow to adapt to a new language?

答:
About 5 yrs back, me and a colleague were given a programming task for some internal project. A simple enough task which required command parsing.

I came up with the entire thing in about 80 lines of java code and my colleague took a week, about 20 java classes and much more lines of java code to do the same. Needless to say, his code was picked.

This made me wonder. Everywhere, complexity was appreciated. ( I was working in one of the biggest software products company. ) Java was the tool of choice and  design patterns were THE way to code.

Now, is it the mindset or just arrogance that rejects simplicity. Well, I always thought common sense should prevail. Whether it is an enterprise or a simple web application, the basic use cases are the same. It should be correct and verifiable.

I don't use java anymore for several reasons. But one of the factors -  complexity, is the prevailing mindset in a ton of java devs when it comes to developing software.

As for scaling dynamic languages, JVM is the result of decades of research. There is a lot of the same happening for Ruby etc.

Scala is one language which I find is extremely clever and practical. Play! with Scala is just as excellent for web/enterprise application development as any out there.

As for Ruby and Rails being the shiny new thing for start-ups, it is extremely difficult to hire a solid Rails developer. It is actually an impediment to any start-up whereas the plethora of java devs should make more business sense.


问:
What does a programmer really need to become a professional?
There are huge numbers of programmers, especially juniors, who need good assistance in becoming professional.

I've heard a lot of about "books every programmer should read", etc. I have two years of programming experience, feel good in C++, but currently have a strange feeling, that I do not know anything about programming.

I should read Algorithms by Cormen, Code Complete by McConnell etc., but I don't know the exact steps required to become a professional.

What should we do? What should we learn? Operating systems? Computer organization? Algorithms? C++ in depth? How much time do we have to spend to become what we want?

答:
You don't become professional just by reading books, but by practicing.

Write code every day.

Like you can't learn how to play a violin without playing, you have to code in order to become a developer. Like any other domain, development requires years and years of practice.

Read code of other people. Why are they writing something this way? Is it better than yours? If yours is better, how could you explain it?

Anyone can come with a programming solution to most problems most developers have daily. The difference between a good and a less good developer is that a good one will solve the problem beautifully: just by looking at her code, you'll understand both the problem and how it is nicely solved. A less good developer will write lots of code which will be unclear, difficult to read, and while solving the problem, will do it in a confusing way.

Ask others to review your code: if there is no full code review in your company, ask your most experienced colleagues to review your code. Don't feel insulted when they make negative remarks about your code, but consider it as an opportunity to learn and to improve your work.

Actively participate to the meetings of your team.

Code is not the only part of the job of a developer. You're not code monkey. You have to understand how the team is organized and lead, how the overall architecture of the project is done, etc.

Be curious about the other team members and the people you work with: what is the job of your database administrator? Why is there a dedicated system administrator? Why every project need a visual designer? What is the difference between your job and the job of the lead developer in your team?

Not only you will be able to learn lots of things, but it will also help you to work with other people later. If you don't know anything about a job of a person who writes HTML/CSS and you work daily with this person, providing her with code behind part of the project, problems will arise soon or later.

Be curious about the projects themselves, aside the development. What happens inside the QA department of your company? How the project is pushed to production? Who writes bug reports?

Understanding the context of the project helps you, as a developer, to have a broader look at the project and provide better code.

Remember that:

Programming in general doesn't become easier to read, write and understand as you gain experience,

When, two years later, you'll read the source code you've written today, you'll find it awful. The rule remains valid through your whole career. That's a sign that your code improve over time.


答:
The strongest point going for the preprocessor languages such as Sass or CoffeeScript is the fact they compile to their "standard" counterparts. That's what is compelling about them - you get all the benefits of their "obviously better" design without adding to the myriad of compatibility issues web developers already have to deal with when working with standard CSS or JS. Backwards compatibility is a big thing when it comes to web development, anyone who still has to mind IE6 at his job will aggree.

Html/CSS/JavaScript package has rough edges and things that may feel inadequate today, but it does provide a bare minimum - but a bare minimum that's widely accepted, understood and implemented - that we can build upon. Haml/Sass/CoffeeScript do precisely that and that's what makes them useful. I'd rather keep my Sass server-side than deal with browser developers engaging in a Sass-Less-Stylus standards war that would serve no one ;)

Title: Why don't browsers support haml and sass?

Body:
The time needed to download a website would be significantly reduced, and parsing would be also easier I think.

Why are not these languages imposed as a standard? Obviously they are better than raw html and CSS...

Browsers are the only thing that keeps us away from eliminating the intermediate HTML/CSS code.


问:
Is OOP becoming easier or harder?
When the concepts of Object Oriented Programming were introduced to programmers years back it looks interesting and programming was cleaner. OOP was like this

```<code>Stock stock = new Stock();
stock.addItem(item);
stock.removeItem(item);
</code>```

That was easier to understand with self-descriptive name.

But now OOP, with pattern like Data Transfer Objects, Value Objects, Repository, Dependency Injection etc, has become more complex. To achieve the above you may have to create several classes (e.g. abstract, factory, DAO etc) and Implement several interfaces

Note: I am not against best practices that makes Collaboration, Testing and Integration easier

答: The "intro to OO" examples are a lot simpler than a real world application.  You only need one class to achieve the above.  The problem is it doesn't do much.  Some design patterns try to come close (like ActiveRecord.)  But ultimately, any example that isn't trivial will have more than one class; that is ok.</p>

Title: Is OOP becoming easier or harder?


答:
No, it's becoming more over-engineered. And you're right- in the SO C++ chat we frequently joke about the AbstractSingletonFactoryProxyBeanBridgeAdapterManagers we see in Java code.

But good code does not exhibit this property. In good code, you can still say

```<code>std::stack<int> s;
s.push(5);
s.pop();
</code>```

Title: Is OOP becoming easier or harder?

Body:
When the concepts of Object Oriented Programming were introduced to programmers years back it looks interesting and programming was cleaner. OOP was like this

```<code>Stock stock = new Stock();
stock.addItem(item);
stock.removeItem(item);
</code>```

That was easier to understand with self-descriptive name.

But now OOP, with pattern like Data Transfer Objects, Value Objects, Repository, Dependency Injection etc, has become more complex. To achieve the above you may have to create several classes (e.g. abstract, factory, DAO etc) and Implement several interfaces

Note: I am not against best practices that makes Collaboration, Testing and Integration easier

Body:
No, it's becoming more over-engineered. And you're right- in the SO C++ chat we frequently joke about the AbstractSingletonFactoryProxyBeanBridgeAdapterManagers we see in Java code.

But good code does not exhibit this property. In good code, you can still say

std::stack<int> s;
s.push(5);
s.pop();


答:
The programming languages using OO today are trying to cater for complex requirements and environments that keep on changing. OO allows its adopters to hide variety of levels of complexity (amongst other features) so that coding becomes more clear and more easy to build and understand. However, this feature is not always out of the box. In your example, OO has allowed you to hide some details from me by providing a method to manage items in a collection and may be even to persist it using the "AddItem" method. Spending effort in hiding complexity may result in an easy to use and a re-usable framework that makes life simpler. For example, Many ORM implementations allow you to communicate with databases without having the programmer write the SQL details. This is indeed powerful and does make it simpler on the developer.

The patterns you refer to are just that. They are supposed to make your life easier. But it is up to you to adopt them and adjust them. The fact that more work is required is just because you gain more benefits. It is like paying more for a Ferrari. If you want the extras you pay for them. So, if you decide to build a scalable N-Tier solution that can be run on several servers and different back end databases, there is a cost for that. If your application does not require this complexity, ignore the extra pieces and fall back to the simplest solution that covers your need (KISS & YAGNI).

So, to wrap up, I don't think that OOP as a concept itself is getting more complex, we, the users of OOP have the choice to use it in different ways, and that is a good thing.

Title: Is OOP becoming easier or harder?


问:
Is comparing cloud computing to main frames a bad analogy?
They both can be seen as centralized processing, but from a developer's perspective is it returning us to the days when access to computers you could program yourself were limited and expensive? To me that was the problem the PC solved.

Heard this on http://thisdeveloperslife.com/ 1.0.6 Abstraction.

答:
Disclaimer:  I do not work for IBM.  I also can't stand Mainframe salesfolks who have repeatedly blown me off when I try to bring them in on some accounts.  I am no IBM fan for many reasons, BUT:

The beauty of Mainframe is that it can act as a big cloud with centralized management or it can act in a highly-scale-up system as well.

The ability to run literally thousands of Linux instances with a physical (energy, rack space) and support footprint in the fractions of what it would cost to manage several hundred VMWare boxen.

Workload management and on-demand ergonomics of CP(U) and memory resources is simply decades ahead of anything else.  This is very important when you are overcommitting computing resources, and running any cloud services company, this would be crucial to your margin.

Stepping down from Mainframe, even AIX can run circles in vertical and management scalability around other computing

Remember the cloud is no different from colocating some slabs, just at an extreme price point for the consumer to adopt as well as the ability to remove the liability of most systems management.  Ask yourself this, if you were to create a new Amazon AWS-style service, what architecture would you choose from the context of your P&L?


答:
I would say that the problems with "complexity" you mention has nothing to do with OOP. It has more to do with separating concerns.

Many years ago I worked on a system, where the domain class had the responsibility of loading itself from the database, e.g.

```<code>var userId = Request.QueryString["UserID"].ToInt();
var user = new User(userId);
user.Name = ...;
...
user.Save();
</code>```

This is very clear code. No problem in understanding this. The problem however would be in unit testing the code. Namely, how would I unit test the User class without having to load one from the database? And how would I test this web request handling code without having access to the database? It is simply not possible.

That is why we have a pattern like a repository, to separate the responsibility of handling the domain logic from a user from the functionality of actually loading and saving one in a data store. IOC helps in reducing coupling, also making code more testable, etc.

So if we go back to the example you write, what would you do with the stock after you create it? Save it in the database

```<code>Stock stock = new Stock();
stock.addItem(item);
stock.removeItem(item);
this.StockRepository.Add(stock);
</code>```

There, done! There is no movement in the progression of OOP that suggests that it should be any harder. Unfortunately, if you choose to use an OR mapper for your data access code, you could run into the problem that the OR mapper is placing restrictions on how you can write your system. But that is another matter.

If you are new to these patterns, you may require to learn a new style of programming. But that style of programming is in no way more hard than old school OOP programming.

Title: Is OOP becoming easier or harder?

Body:
I would say that the problems with "complexity" you mention has nothing to do with OOP. It has more to do with separating concerns.

Many years ago I worked on a system, where the domain class had the responsibility of loading itself from the database, e.g.

var userId = Request.QueryString["UserID"].ToInt();
var user = new User(userId);
user.Name = ...;
...
user.Save();

This is very clear code. No problem in understanding this. The problem however would be in unit testing the code. Namely, how would I unit test the User class without having to load one from the database? And how would I test this web request handling code without having access to the database? It is simply not possible.

That is why we have a pattern like a repository, to separate the responsibility of handling the domain logic from a user from the functionality of actually loading and saving one in a data store. IOC helps in reducing coupling, also making code more testable, etc.

So if we go back to the example you write, what would you do with the stock after you create it? Save it in the database

Stock stock = new Stock();
stock.addItem(item);
stock.removeItem(item);
this.StockRepository.Add(stock);

There, done! There is no movement in the progression of OOP that suggests that it should be any harder. Unfortunately, if you choose to use an OR mapper for your data access code, you could run into the problem that the OR mapper is placing restrictions on how you can write your system. But that is another matter.

If you are new to these patterns, you may require to learn a new style of programming. But that style of programming is in no way more hard than old school OOP programming.


答:
The term "professional" actually means that you earn your living through programming. That's all you need to be a professional.

Quality of your work is a separate issue, and judging by the rest of your question, this is the thing you worry about. It's not clear whether you already have work experience or not - if you do, MainMa's answer provides good pointers.

However, if you don't - know that you'll learn a lot through day-to-day work. I believe it won't be an understatement - I have learned more during the first year of my work than I did over five years university, and I was a good student, if I can say so myself. Having to deal with actual problems instead of artificial textbook ones, having to do so with deadlines looming over and having to do so provided only with incomplete, lacking or outright contradictory specification is what I believe makes you a professional. Code Complete and other "pragmatic" books are certainly a good lecture by themselves, but their value really shows in context of real-world experiences.

Title: What does a programmer really need to become a professional?

Body:
There are huge numbers of programmers, especially juniors, who need good assistance in becoming professional.

I've heard a lot of about "books every programmer should read", etc. I have two years of programming experience, feel good in C++, but currently have a strange feeling, that I do not know anything about programming.

I should read Algorithms by Cormen, Code Complete by McConnell etc., but I don't know the exact steps required to become a professional.

What should we do? What should we learn? Operating systems? Computer organization? Algorithms? C++ in depth? How much time do we have to spend to become what we want?


答:
OOP itself hasn't changed much since its inception. A few new angles to it have been explored, but the core principles are still the same. If anything, the collective knowledge gathered over the years makes the programmer's life easier rather than harder. Design patterns are not a hindrance; they provide a toolbox of solutions to standard problems, distilled from years and years of experience.

So why is it you perceive OOP today as more complex than when you started using it?

One reason may be that the code you are being exposed to becomes more complex - not because OOP has become more complex, but because you have advanced on the learning ladder, and get to read larger and more complex code bases.

Another reason may be that while the complexity paradigm hasn't changed, the size and complexity of an average software project may very well have. With processing power available on customer-grade cellphones that would have been a developer's wet dream on a server less than two decades ago, the general public basically expecting slick animated GUI's for even the cheapest throwaway app, and entry-level desktop PC's being more powerful than a 1980's "supercomputer", it is only natural that the bar has been raised since the early days of Smalltalk and C++.

And then there's the fact that in modern applications, concurrency and parallelism is the norm rather than the exception, and applications frequently need to communicate between different machines, outputting and parsing a whole zoo of protocols. While OOP is great as an organizational paradigm, it does have its limitations, just like any other paradigm: for example, it does not provide a lot of abstraction for concurrency (most implementations being more or less an afterthought, or outsourced to libraries entirely), and it's not the best possible approach for building parsers and transforming data. Modern programming frequently runs into the limitations of the OOP paradigm, and design patterns can only take you so far. (Personally, I consider the fact that we need design patterns a sign of this - if the paradigm provided these solution out-of-the-box, it would be more expressive for these problems, and the standard solutions would be obvious. There is no design pattern to describe method inheritance, because it is a core feature of OOP; but there is a Factory Pattern, because OOP does not provide an obvious natural way of constructing objects polymorphically and transparently.)

Because of this, most modern OOP languages incorporate features from other paradigms, which makes them more expressive and more powerful, but also more complex. C# is the prime example for this: it has obvious OOP roots, but features like delegates, events, type inference, variant data types, attributes, anonymous functions, lambda expressions, generics, etc., originate from other paradigms, most notably Functional Programming.

Title: Is OOP becoming easier or harder?


答:
No production project can use Haml until it is supported by Firefox, Chrome, Safari and Internet Explorer.  It used to be that "enterprise" applications could be IE only, but I think the days of that are over.  Standards aren't imposed from on-high, they are agreed to by browser vendors.

So really to have Haml made a standard, you'd need to get Apple, Google, the Mozilla Foundation and Microsoft to agree.  This isn't trivial.   These companies are going to generally concentrate on expanding capabilities rather than cleaning up existing features.

Haml looks nice to work with, but it won't actually improve download sides as all modern browsers and servers support compression.  Compressed Haml and Html are likely to be about the same size.  (Plus, most of the download time for the average website is in downloading images and script code.)

Now keep in mind that few people write in Html anymore.  People use frameworks that spit out Html as an end product.  Not only would this hurt the adoption of Haml directly, as none of these frameworks will support it, but it obviates the need for it, because the underlying markup language is only seen by the computer.

From the browser vendor point of view, they can improve an existing feature slightly (by supporting something like Haml, which gives cleaner pages) or they can add something entirely new, like WebGL.  The latter just has more bang for the buck.


答:
Does Google, Amazon, or LinkedIn count as modern?

Java is used for modern web applications.  If you look across the enterprise it is the most heavily used language for web applications (internal).

That said, Java went through a period were it's web development standards tried to be everything to everyone (arguably still do).  "Don't repeat yourself" was a response to the xml hell and long build cycles of Java web development.  As a result, Java (EJB, Struts, JSF, etc) became seen as the thing all of the new paradigms were trying to overcome.

Java, the language is verbose.  That is a pro and a con (great for maintenance, sucks for dev). There are a number of modern language features that have not yet made it into Java that can cut coding time down substantially (properties, events, closures, generators, list comprehension, etc).  So, it can be frustrating when coming from a more modern language. That said, they are difficult to add in to a mature language without becoming the rats nest that C# is becoming.

Many languages used in modern web development are dynamically typed. This enables tooling that can dynamically reload code as it is written (this is harder to accomplish in a static language - jrebel). Since web development lends itself to fast iterations, dynamic reloading is a huge win. It significantly reduces the development cycle on greenfield projects and makes it easier to get the UI and the UX right (trial and error by nature).

Static languages have their place, too. For backend logic that is complex, must run for years, must scale without issue, must be very fast, and must be completely error free, statically typed languages (like Java or even C) are preferred.

Additionally, as developer count/turnover grows and products mature the likelihood of well intentioned folks introducing bugs skyrockets. The rigor and discipline that a well designed Java project (interfaces, patterns, and holy water for those php vampires :)) enforces helps to reduce long term risk. While, this can also be achieved via unit testing, the safety net derived from static checking (and static analyzers like findbugs and clang) delivers a built in level of code coverage that is hard to replicate with handwritten tests. Don't get me wrong, there should be unit tests and functional tests, but real organizations never achieve 100% coverage.  For what they check, static analyzers do.

So, in large projects (as defined more by team size than code size), where there is complex interoperation between independently developed chunks of code, languages like Java are still preferred. Examples include large/complex web applications like those at financial brokers (ameritrade), financial exchanges (nasdaq, nyse, maybe london after the .net failure), online banking (almost all of them), email (google), auction (ebay), etc.

From a performance and scale perspective, nothing tops the Java platform for it's combination of scalability and performance for web applications (depending on how you count facebook's application partitioning). Twitter, for example, had to rewrite large portions of it's Ruby infrastructure in Scala on the Java VM in order to put the fail whale back out to sea. I've heard of other large examples, but they elude me right now.

It’s also worth considering security.  While Java browser plugins have suffered their fair share of security vulnerabilities, the java platform itself is one of the more secure platforms created.  Java web applications have a reputation of being very secure. It’s coding practices, libraries, and architecture have long discouraged mistakes that make attacks like sql injection or buffer overflows possible.  While other web platforms(rails) have a good security reputation, none surpass Java.

Bottom line, most web applications are simple technically.  For simple, Java is often overkill (just like in the old days when we wrote them in C :)).  If, though, the webapp is complex (backend or otherwise) or is expected to have 100+ developers, Java is hard to beat.

--

On a personal note, I use Grails a lot because it gives me the best of both worlds (the same can be said of JRuby which I hear is becoming more and more popular in the Ruby world).

BTW - I find the rise of PHP to be truly baffling. PHP as a language is the rough equivalent to perl in readability and VB in the quality of the results.  It encourages horrible practices, is next to impossible to maintain, 3rd party libraries rarely work as expected, and it has a syntax that would drive Larry Wall up...well...a wall.  The only explanation I can conjure is that it lends itself to incremental learning (like VB). In other words, you can accomplish something useful knowing very little about programming/administration and you can extend your knowledge a small chunk at a time.  There is a lot to be said for that from an adoption perspective.  However, for anyone that has every had to support or replace one of the billions of VB apps that were written by "programmers" in the corporate/mfg world, you are probably shaking your head and planning your retirement. :)

Title: Why isn't Java used for modern web application development?

Body:
As a professional Java programmer, I've been trying to understand - why the hate toward Java for modern web applications?

I've noticed a trend that out of modern day web startups, a relatively small percentage of them appears to be using Java (compared to Java's overall popularity).  When I've asked a few about this, I've typically received a response like, "I hate Java with a passion."  But no one really seems to be able to give a definitive answer.

I've also heard this same web startup community refer negatively to Java developers - more or less implying that they are slow, not creative, old.

As a result, I've spent time working to pick up Ruby/Rails, basically to find out what I'm missing.  But I can't help thinking to myself, "I could do this much faster if I were using Java," primarily due to my relative experience levels.

But also because I haven't seen anything critical "missing" from Java, preventing me from building the same application.

Which brings me to my question(s):

Why is Java not being used in modern web applications?

Is it a weakness of the language?

Is it an unfair stereotype of Java because it's been around so long (it's been unfairly associated with its older technologies, and doesn't receive recognition for its "modern" capabilities)?

Is the negative stereotype of Java developers too strong? (Java is just no longer "cool")

Are applications written in other languages really faster to build, easier to maintain, and do they perform better?

Is Java only used by big companies who are too slow to adapt to a new language?


问:
Are symbolic programming and metaprogramming the same thing?
Are symbolic programming and metaprogramming the same thing?

I've always read about symbolic programming while using Mathematica, but I've never searched about it's meaning, I've searched about it today and I found that both concepts are similar, are there any differences?

答:
Symbolic programming is about manipulating symbolic structures, usually representing formulas, and computing consequences.  Mathematica manipulates math formulas by using rewriting techniques to help people gain insight into their meaning.  Prolog uses backward chaining to find consequences.   Constraint systems solves sets of constraints for answers.
These systems tend to mix rewriting, theorem proving, constraint propagation, pattern matching and forward/backward inference to achieve the desired effect.

I think of metaprogramming as a special kind of symbolic programming, in which the symbolic structures represents facts about or pieces of (including entire) programs.   One of most general metaprogramming techniques is program transformation, providing the ability to manipulate program source in roughly the same way as mathematics enables one to manipulate math formulas.

As a practical matter, metaprogramming can use all the techniques of symbolic programming.  It also uses lots of specific algorithms which most people consider to be compiling (e.g., data flow analysis) but is really computing with facts encoded efficiently, so for me most compiling is symbolic computing.

OwnerDisplayName: Gustavo Bandeira

OwnerDisplayName: Ira Baxter


问:
What does path finding in internet routing do and how is it different from A*?
Note: If you don't understand this question then feel free to ask clarification in the comments instead of voting down, it might be that this question needs some more work at the moment. I've been directed here from the Stack Excange chat room Root Access because my question didn't fit on Super User.

In many aspects path finding algorithms like A star are very similar to internet routing. For example:

A node in an A* path finding system can search for a path though edges between other nodes.

A router that's part of the internet can search for a route though cables between other routers.

In the case of A*, open and closed lists are kept by the system as a whole, sepratly from any individual node as well as each node being able to temporarily store a state involving several numbers.

Routers on the internet seem to have remarkable properties, as I understand it:

They are very performant.

New nodes can be added at any time that use a free address from a finite (not tree like) address space.

It's real routing, like A*, there's never any doubling back for example.

Similar IP addresses don't have to be geographically nearby.

The network reacts quickly to changes to the networks shape, for example if a line is down.

Routers share information and it takes time for new IP's to be registered everywhere, but presumably every router doesn't have to store a list of all the addresses each of it's directions leads most directly to.

I'm looking for a basic, general, high level description of the algorithms workings from the point of view of an individual router. Does anyone have one?

I presume public internet routers don't use A* as the overheads would be to large, and scale to poorly. I also presume there is a single method worldwide because it seems as if must involve a lot of transferring data to update and communicate a reasonable amount of state between neighboring routers.

For example, perhaps the amount of data that needs to be stored in each router scales logarithmically with the number of routers that exist worldwide, the detail and reliability of the routing is reduced over increasing distances, there is increasing backtracking involved in parts of the network that are less geographically uniform or maybe each router really does perform an A* style search, temporarily maintaining open and closed lists when a packet arrives.

答:
The main difference between the algorithms actually used for Internet routing, and the A* algorithm, is that

The A* algorithm requires all the information about a network -- knowledge of every node and exactly how the nodes are connected -- on a single machine, and that machine finds the actual best complete path.

packet routing algorithms running on a router are "distributed algorithms" that use various heuristics to get "good" (but rarely the "best") results with very limited amounts of information at each router and very limited amounts of time at each router. Each router does a little bit of the work -- it chooses the next step in the path. None of the routers ever calculate a "complete path", and the actual path traveled by a packet is rarely the best.

Since A* finds the best path, why do we use other algorithms that give us suboptimal paths?
The A* algorithm is impossible on the Internet for several reasons.
There are now so many nodes on the Internet that it is impractical for a router to have enough RAM to store the IP address of every node and which nodes are connected to it.
Even if every router did have plenty of RAM, when a new router is turned on or a new link is installed, we expect that new path to start handling packets more-or-less immediately, rather than waiting for that router to download the connection diagram of the entire internet and waiting for every other router on the planet to update its connection diagram.
Many routers have packets coming in so quickly that there's simply not enough time to run a full A* algorithm on each packet.
In some cases, changes in the network that affect the path of a packet can happen while the packet is in-flight, after the packet has been sent.

I hear that the simplest possible routing protocol -- "hot potato routing" -- works surprisingly well in small internetworks:
Each router keeps track of the IP address of each end-node directly connected to it.
If the router receives a packet with one of those as the destination address, then the router sends it to that end-node, and that packet's journey is complete.
Otherwise, a router using "hot potato routing" randomly sends the incoming packet to any router directly connected to it.

I hear that the Border Gateway Protocol is currently the most popular routing protocol on the internet.
The RFC4271 (and its errata) give detailed information that, in principle, is enough to build a interoperable router.

Such protocols typically use some combination of two techniques to allow each router to build its own routing table:

Passive: When a packet from some IP address A comes in on port X, and later some packet with a destination of the same IP address A comes in on some other port, the router knows it should send that second packet out port X. The number of unique addresses associated with a port will eventually become too many to store all of them, so the router uses route summarization. Route summarization relies on the fact that geographically nearby machines do, in fact, typically have similar IP addresses, and IP addresses are handed out in ways that typically form a hierarchial tree of geographical subnets.

Active: The router sends out its own IP address, and (a summary of) the IP addresses of the machines directly connected to it, to neighboring routers, typically using the routing information protocol.


问:
 Why do so many developers do this in their HTML?
```<code> <body>
  <!-- wrapper -->
  <div id="wrapper">
   <!-- title -->
   <div id="title"><img src="title.png" alt="" /></div>

   <!-- form wrapper -->
   <div id="form_wrapper">

    <!-- form -->
    <form action="thankyou.php" method="POST">
     <!-- ... ... -->
    </form>
    <!-- /form -->
   </div>
   <!-- /form wrapper -->
  </div>
  <!-- /wrapper -->
 </body>
</code>```

I can almost understand the  at the end, because it's so far from the start of the tag/pair...  but seriously, what's the point of the opening comment lines?  I wouldn't ask the question if I didn't see this all the time.

I feel as if I'm missing something.  Maybe there's some unwritten best-practice involved, though I fail to comprehend what it could possibly be.  More than likely it's just obsessive-compulsive behavior.

How do you guys normally comment your markup, if at all?

答:
HTML is like compiled code to me. It's optimized, has no spaces, no comments, and is as small as possible while getting the job done. I do, however, have some comments in my templates which generate the HTML files. You'll never see them though, unless you join the dev team!

Same thing goes for JavaScript. Any JS you see on my site is compressed, minified, and has the comments removed. Comments are for developing, not for wasting bandwidth!

Title: <!-- open --> Why do so many developers do this in their HTML? <!-- /close -->


答:
Short Answer: Yes, because you deal with harder problems.

Long Answer (strongly biased): For me the design patterns usually indicates that some paradigm have problems in given area. The OOP patterns deal with problems of OOP (on lower level the Java patterns deal with problems of Java), FP patterns deal with problems of FP etc.

During programming you may have different priorities. You may want to have correct program, you may want to have shortes time-to-market, fastest program possible, long-term maintainability or instant maintainability by a new hire. Depending on bushiness you are in you will have vastly different - if you are programming controller of power plant you want to do it right first time and not bugfix every time now and then ("Does meltdown occurs every time you press Ctrl+Alt+Del?"). If you are in HPC the logic can be relativly simple but you want to execute it as fast as possible etc. etc. Additionally some paradigms fits certain problems better (say AI and logic programming, data and relational databases).

OOP is to some extend 'too good' in simple cases and it's "modelling real live" story. For example in first book about OOP I read there were classes Person, Employee and Manager with is-a relationship. So far so good but what if employee is promoted to manager?

On the other hand other paradigms have harder first-time lessons - for example FP with immutable variables (funny thing is that people who had experience with programming often find it harder to learn than those for whom this is first language) - however ultimately they are not harder than OOP. Testing pure functions is trivial and in Haskell/Scala/... you have tools that generate tests for you.

PS. Yes - answer is biased against OOP and I admit that to some extend it is 'in reaction' to OOP. OOP have its uses but it is not the only, ultimate solution in my opinion.

PPS. Yes - use design patterns - they make OOP programming ultimately simpler.

PPPS. I used OOP as synonym of OOP imperative programming.

Title: Is OOP becoming easier or harder?


问:
How do you keep released binaries under version control?
How do you keep released binaries under version control?
This allows to track which stuffs are changed between each release.
I mean to separate the released binaries from source repository.
The released binaries are either built from Continuous Integration software or manually compiled.</p>

答:
The best solution is to make exclusive use of your CI system for all organizationally significant builds (releases, release candidates etc...).

This systematically ties the released binaries to the repository content without having to actually store the binaries in the repository.

For example, if you are using SVN, use the branch-major organizational scheme;
do all day-to-day development in /trunk, and create a /tag for each release once it is ready.

Configure your CI system to build from tags as well as from trunk, and get it to write output to a network directory whose structure mirrors the top level structure of the repo:

/builds/trunk/[rev][date][build_id]/

/builds/tags/release_0_1_3beta4/[rev][date][build_id]/

The build system will need to treat the /builds/trunk/ directory like a circular buffer, storing the last n builds, deleting old builds as it goes.

The /builds/tags/ directory, on the other hand, is a permanent store. The build artifacts themselves are stored in directories with names generated according to the following scheme:

[rev][date][build_id]

where [rev] is the SVN revision ID, [date] is the date in YYYYMMDD format, and [build_id] is a 3-digit unique counter, incrementing from the first build onwards, making each build directory unique.

The process detailed above gives you the following benefits:

Build artifacts are tied systematically to the source that generated them, so you can find the source for a particular build artifact very easily, (and vice versa).

This forms the basis for further release automation. For example, automatic generation of release documents etc...


问:
Using Mercurial repository inside a Git one: Feasible? Sane?
I am thinking on creating a Mercurial repository under a Git repository.
e.g.

```<code>..../git-repository/directory/hg-repo/
</code>```

The 2 repositories

Is it possible to manage (keeping your sanity)? How similiar is it to this?

I am a computer science student at University. I manage my work in Git, mainly as a distribution mechanism (after realizing that rsync fails when you have changes in more than one place) between my desktop and usb drive. I try use of Git as a VCS as I do work.

I have finished a semester where I did a small group project to prepare for a larger group project next year. We had to use Subversion, and experienced the joys of a centralised VCS (including downtime).

I tried to keep the subversion repository separate to my Git repository for the subject**, however it was annoying that it was seperate (not in the place where I store assignments). I therefore moved to using an Subversion repository inside my Git repository.

As I think ahead (maybe I am thinking too far ahead) I realise that I will have to try and convince people to use a DVCS and Mercurial will probably be the one that is preferred (Windows and Mac GUI support, closer to Subversion).

Having done some research into the whole Git vs Mercurial debate (however not used Mercurial at all) I still prefer Git.

Can I have a Mercurial repository inside a Git one without going mad (or it ruining something)? Or is it something that I should not consider at all?

(Or is it a bad question that should be deleted?)

** I think outside of Australia it is called a course

答:
For file transfer/synchronization/distribution, you might want to try Unison instead of git.

Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.

Unison shares a number of features with tools such as configuration management packages (CVS, PRCS, Subversion, BitKeeper, etc.), distributed filesystems (Coda, etc.), uni-directional mirroring utilities (rsync, etc.), and other synchronizers (Intellisync, Reconcile, etc). However, there are several points where it differs:

Unison runs on both Windows and many flavors of Unix (Solaris, Linux, OS X, etc.) systems. Moreover, Unison works across platforms, allowing you to synchronize a Windows laptop with a Unix server, for example.

Unlike simple mirroring or backup utilities, Unison can deal with updates to both replicas of a distributed directory structure. Updates that do not conflict are propagated automatically. Conflicting updates are detected and displayed.

Unlike a distributed filesystem, Unison is a user-level program: there is no need to modify the kernel or to have superuser privileges on either host.

Unison works between any pair of machines connected to the internet, communicating over either a direct socket link or tunneling over an encrypted ssh connection. It is careful with network bandwidth, and runs well over slow links such as PPP connections. Transfers of small updates to large files are optimized using a compression protocol similar to rsync.

Unison is resilient to failure. It is careful to leave the replicas and its own private structures in a sensible state at all times, even in case of abnormal termination or communication failures.

Unison has a clear and precise specification.

Unison is free; full source code is available under the GNU Public License...


问:
Is it common for a programmer not to know the difference between C and C++?
During an interview, I was asked whether I knew the difference between C and C++.

I was wondering why such question being asked?

答: Some people have observed that there's a huge amount of programming job applicants who can't write code at all. So, yes, asking "obvious" questions makes perfect sense.</p>


答:
If the questions was phrased like "Do you know the difference between C and C++?" and you were allowed to just respond with "Yes" then I could see your confusion, but if they were actually asking "What -are- the differences between C and C++?" and a more open-ended answer was expected, I can see it as a legitimate "avenue of inquiry" as they say.

For example, only having ever coded in C and never in C++, I would barely be able to answer beyond a vague "C++ supports object oriented coding?".

Title: Is it common for a programmer not to know the difference between C and C++?

Body:
During an interview, I was asked whether I knew the difference between C and C++.

I was wondering why such question being asked?


问:
How do I completely-self-study Computer Science?
Being a completely self taught programmer, I would like it if I could better myself by self-learning the computer science course taught to a typical CS grad.

Finding different resources on internet has been easy, there is of course MIT open course ware, and there are Coursera courses from Stanford and other universities. There are numerous other open resources scattered around the Internet and some good books that are repeatedly recommended.

I have been learning a lot, but my study is heavily fragmented, which really bugs me. I would love If somewhere, I could find a path I should follow and a stack I should limit myself to, so that I can be sure about what essential parts of computer science I have studied, and then systematically approach those I haven't.

The problem with Wikipedia is it doesn't tell you what's essential but insists on being a complete reference.

MIT open course ware for Computer science and Electrical Engg. has a huge list of courses also not telling you what courses are essential and what optional as per person's interest/requirement. I found no mention of an order in which one should study different subjects.

What I would love is to create a list that I can follow, like this dummy one

```<code>SUBJECTS                                                        DONE

Introduction to Computer Science                                  *
Introduction to Algorithms                                        *
Discrete Mathematics
Adv. Discrete Mathematics
Data structures                                                   *
Adv. Algorithms
...
</code>```

As you can clearly see, I have little idea of what specific subjects computer science consists of.

It would be hugely helpful, even if someone pointed out essential courses from MIT Course ware ( + essential subjects not present at MIT OCW) in a recommended order of study.

I'll list the Posts I already went through (and I didn't get what I was looking for there)

https://softwareengineering.stackexchange.com/questions/49557/computer-science-curriculum-for-non-cs-major - top answer says it isn't worth studying cse

https://softwareengineering.stackexchange.com/questions/110345/how-can-a-self-taught-programmer-learn-more-about-computer-science - points to MIT OCW

https://softwareengineering.stackexchange.com/questions/49167/studying-computer-science-what-am-i-getting-myself-into

https://softwareengineering.stackexchange.com/questions/19912/overview-of-computer-science-programming

答:
If I may, I'd like to suggest joining github.com as part of your learning process.

Then you can search around for code that has some real world application that you're interested in, clone it for yourself, work with it, code on it, and get to know it, and eventually start to submit patches back to the source project, and down the line be working on an open source project that you have a vested interest in.

And, of course, you'll get familiar with git, which is just all the better.


答:
Just a couple of quick things:

Deployment and "server-side code": A Silverlight app is a client-side app, plain and simple. Don't let the mere fact that it is delivered through the browser confuse you - when you run an in-browser SL app, you are downloading the assemblies for that app in a zipped package, extracting them, and running them using the plugin. Silverlight by itself has no notion of "server-side code" - if you want code to run on a remote server, write a WCF service.

Updating the app: This is a common scenario for OOB apps and SL has built-in support. Google around for CheckAndDownloadUpdateAsync.

Edit: Forgot to mention - installing the application is done from within the application. By default, an installable SL app will have a context menu action to install it. However, installing can also be done programmatically in response to the user clicking a button. The install state can also be detected programmatically, so what I've seen some SL apps that are only intended to run OOB do is first detect if they are installed. If so, run the app. If not, just show a splash screen with a button that installs the app.

Title: I need help deciding between silverlight/silverlight out-of-browser/wpf

Body:
I'm in the initial planning phase of a re-write project and I'm deciding between silverlight/silverlight oob/wpf. TL;DR at the end.

It's a LOB app that handles leads/customers/appointment calendars. Not too complicated. I'm independently researching these options elsewhere, but I thought I'd ask around. Some rough initial requirements/foreseeable problems are:

I have to be able to call an exe on the system with commandline args (sip phone).

Makes SL a problem

The userbase is distributed and I want to limit the traffic that goes over the wire as much as possible and avoid some nasty concurrency issues

I can see this being a problem using WPF

Software deployment/updating has to be dead simple. Some users are highly non-technical (see: 70 years old, on a computer for the first time)

This isn't a huge problem now with the ClickOnce app we are replacing, and I have control over the machines that it gets used on. However, it's simpler for users if they don't even have to click the clickonce "Install" button. I don't know how this is handled with Silverlight OOB.

The company is planning a hard expansion in 12 months so hardware deployment should be fast/easy. The idea is to get an internet connection at a new location, plug in some computers and be able to work without the need for dedicated IT people or server setup.

Makes SL appealing

Integration with other services (financial software, asterix server) isn't an immediate goal, but it is an eventual goal to be part of the system. This is made much simpler/more efficient if a single service is setup to integrate with those secondary services and doesn't have to transfer all of that data over the wire

Makes SL appealing

Making multiple 'versions' is out the window. I don't know what it's like maintaining a silverlight + silverlight oob version (if there's even any problems)

Might make WPF a better option.

TL;DR: From my vantage point, a silverlight app makes the best sense for 90% of the users - the other 10% can't use it because they need to run an exe. Silverlight OOB might be a happy middleground but I don't know at the moment what the execution model for it is like (is there still a concept of server-side code? If so, that would possibly be ideal) and I don't know how deployment/updating works for it.


问:
How to commit a file conversion?
Say you've committed a file of type foo in your favorite vcs:

```<code>$ vcs add data.foo
$ vcs commit -m "My data"
</code>```

After publishing you realize there's a better data format bar. To convert you can use one of these solutions:

```<code>$ vcs mv data.foo data.bar
$ vcs commit -m "Preparing to use format bar"
$ foo2bar --output data.bar data.bar
$ vcs commit -m "Actual foo to bar conversion"
</code>```

or

```<code>$ foo2bar --output data.foo data.foo
$ vcs commit -m "Converted data to format bar"
$ vcs mv data.foo data.bar
$ vcs commit -m "Renamed to fit data type"
</code>```

or

```<code>$ foo2bar --output data.bar data.foo
$ vcs rm data.foo
$ vcs add data.bar
$ vcs commit -m "Converted data to format bar"
</code>```

In the first two cases the conversion is not an atomic operation and the file extension is "lying" in the first commit. In the last case the conversion will not be detected as a move operation, so as far as I can tell it'll be difficult to trace the file history across the commit. Although I'd instinctively prefer the last solution, I can't help thinking that tracing history should be given very high priority in version control. What is the best thing to do here?

答:
Well, in git (and others like it as well), it doesn't matter whether you specifically move the file or not. The information about the move operation isn't stored in the repository. Git calculates it based on file similarity when you're working with the history. If the converted file is very different from the original (which I'd guess is likely), it won't know the two files are related, regardless of what order you commit things. If the converted file is similar, it will know the two files are related, regardless of whether you use git mv or git add on one file and git rm on the other. (git mv is simply shorthand for those two commands).

But you're talking about subversion specifically, where the svn mv command is recorded in the repository, and I can't answer what the best practice should be, because I dont use subversion anymore, though I'll say that your line of reasoning definitely makes sense.

Title: How to commit a file conversion?


答:
If by "modern" you mean popular (as-in getting most press coverage) then the reason Java is not used is very simple -- because all the "cool kids" are using Ruby (or Python, or Clojure, or Scala, or whatever is "cool" these days).

There is a deeper meaning to this, these same people who use Ruby or Python to write their "modern" web applications are usually really great innovators. People who love solving annoying problems in simple and effective ways while saving time and brain power doing it. Some might say these are qualities of good programmers.

These people usually also create the most press around their projects, which large companies rarely do. Be it by doing lots of open-source, or writing blogs, or whatever.

So the gravitational pull of these people into the world of dynamic languages, where they are offered simpler/smaller/faster/leaner ways to solve problems is easy to understand. Sadly it means that the same people who were great Java developers, mature and abandon the Java bandwagon because it is annoying and hard (for them) to use and solve these same problems.

If creating a simple web application with MVC framework X, requires to write/edit just 100 lines of code in Rails/Django, and contrary to that it requires 10,000 lines of code in Java to do the same thing - it is very apparent why that might seem annoying.

Regarding your statement "I haven't seen anything critical "missing" from Java, preventing me from building the same application."
The question is -- if you had the same amount of experience in Rails/Django/Whatever... how would these two applications Java and non-Java compare to each other, measuring time and effort and any other metrics you can come up with.


问:
Can I use metro style interface in my own web application?
I am wondering if I would need to license the Metro style or if I can just freely use it in my own applications. I mean, is it patented or protected in any way that would prevent me from building my own implementation? I effectively would like to copy the visible part of it.

I like to idea of being able to:

Provide an interface which is used somewhere else (as in 1 less to learn)

Use the interface that has been tested for usability (I personally like it)

Have the possibility of getting free publicity because of implementing full Metro style web application while not associated with Microsoft, etc.

答:
I remember reading about this and shaking my head in disgust: http://pocketnow.com/windows-phone/microsoft-granted-patent-for-its-metro-user-interface

So, no, you can't legally copy their interface and reap the benefits of their UI development. If you are just looking for a side project to work on, I say go for it and have fun. If you are looking to market and sell your application with your Metro interface, I say contact Microsoft and ask about a licence to do it. I wouldn't suggest just going for it as you might find yourself at the end of some legal nastiness if you do.


答:
I would prefer the last solution.

However, regardless of what solution you choose, you should make sure that you record the exact version and arguments of the converter tool in the commit message. The reason for this is that in all three solutions the diff(s) simply won't make sense. You simply cannot sensibly review the commits.

But what you can do, is checkout the old commit, run the tool yourself and verify that its output matches the new commit. That way, you don't have to trust the huge unreadable diff, you only have to trust the tool.

Title: How to commit a file conversion?

Body:
Say you've committed a file of type foo in your favorite vcs:

```<code>$ vcs add data.foo
$ vcs commit -m "My data"
</code>```

After publishing you realize there's a better data format bar. To convert you can use one of these solutions:

```<code>$ vcs mv data.foo data.bar
$ vcs commit -m "Preparing to use format bar"
$ foo2bar --output data.bar data.bar
$ vcs commit -m "Actual foo to bar conversion"
</code>```

or

```<code>$ foo2bar --output data.foo data.foo
$ vcs commit -m "Converted data to format bar"
$ vcs mv data.foo data.bar
$ vcs commit -m "Renamed to fit data type"
</code>```

or

```<code>$ foo2bar --output data.bar data.foo
$ vcs rm data.foo
$ vcs add data.bar
$ vcs commit -m "Converted data to format bar"
</code>```

In the first two cases the conversion is not an atomic operation and the file extension is "lying" in the first commit. In the last case the conversion will not be detected as a move operation, so as far as I can tell it'll be difficult to trace the file history across the commit. Although I'd instinctively prefer the last solution, I can't help thinking that tracing history should be given very high priority in version control. What is the best thing to do here?


答:
Neither. Our problems haven't really changed; the bar for acceptable code has been raised.

To achieve the above you may have to create several classes (e.g. abstract, factory, DAO etc) and Implement several interfaces

You don't have to do that. But if you don't then problems crop up; problems that have always been there. Now though, programmers have enough experience doing it to identify those problems and provide mechanisms to alleviate them (if needed). We learn more about those, and come up with better solutions (see - programmers' views on the singleton for example).

But you also have to realize that introducing programmers to OO (or anything for that matter) will tend to gloss over the exceptional circumstances. It's simply easier to explain the happy path, and worry about the rest once the beginners have that down. There is no silver bullet; so yeah, I suppose things will always seem harder when that idyllic delusion is broken...

Title: Is OOP becoming easier or harder?


问:
Is it possible to know what programming language a web-site uses?
For example, stackexchange.com, without asking the site owner or Google their information about developing the website, is this possible to know what language is used in the back end?

Seems, the website don't have .extension bar, for example .php that can indicated which is developed in PHP, but without the extension, how can I know that?

答: On sites which uses full-blown framework or CMS, sometimes you can try querying the admin page, you'll be presented with a login box and identify what framework it came from because most people don't reskin the admin template. For instance if your site is example.com, try going to example.com/admin/ or example.com/wp-admin/ (wordpress).</p>


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
I don't care if it works on your machine! We are not shipping your machine!

-- Vidiu Platon (whoever that is)

LastEditorDisplayName: Roger Pate


答:
I think its more a case of the documents and examples becoming more realistic.

Early OOP books (particularly early Java books) presented an absurdly simplified view of application programming. The "Debit a bank account with a 10 line Java program" examples was always particularly annoying as I have seen real life examples of this simple task running to 6000 lines of COBOL code (and the Java replacement attempt running to 3500 lines before it was abandoned as unfeasible!).

Thankfully OO books now tend to acknowledge the complexities of real life, and, provide useful examples of how to deal with them.

But if you want to see how to run a bank account in only 15 lines of code functional programming is your man

Title: Is OOP becoming easier or harder?


答:
Unfortunately, I think it is becoming more and more common.

I think that young programmers freshly out of technical school (or where they learn their skills from) simply do not learn older languages such as C, C++, Lisp, OCaml, etc. They simply come out as "c# programmers" or "java programmers", etc. And when they find a job, they do not challenge themselves with learning other languages.

Of course there are some that do, but from those I have worked with, there is a general tendency for the younger programmers to follow this pattern.

Disclaimer: Since I am talking about education, then there can of course be differences from country to country about what is being emphasized in the education.


问:
what is the difference between the below two syntaxes?
1.

```<code> $(function () {
       function foo() { return true; }
       log(bar());                        // getting error
       var bar = function() { return true; };
  });
</code>```

2.

```<code>$(function () {
        function foo() { return true; }
        log(bar());                        // working
        function bar() { return true; };
});
</code>```

in above snippets log is my custom function to log the result.

答:
In the first, you have called an variable as an function.

```<code>long(bar);
var bar=function() {return true;};
</code>```

try this in first one.

Body:
In the first, you have called an variable as an function.

long(bar);
var bar=function() {return true;};

try this in first one.


答: In the second, the function bar() is hoisted to the top of your function block (all functions declared in a block using this syntax are hoisted to the top of the block) and thus exists before you call it in log(bar()).  In the first, the variable bar is not set to your function until after your call to log(bar()).

Title: what is the difference between the below two syntaxes?

Body:
1.

```<code> $(function () {
       function foo() { return true; }
       log(bar());                        // getting error
       var bar = function() { return true; };
  });
</code>```

2.

```<code>$(function () {
        function foo() { return true; }
        log(bar());                        // working
        function bar() { return true; };
});
</code>```

in above snippets log is my custom function to log the result.


问:
How do "custom software companies" deal with technical debt?
What are "custom software companies"?

By "custom software companies" I mean companies that make their money primarily from building custom, one off, bits of software. Example are agencies or middle-ware companies, or contractors/consultants like Redify.

What's the opposite of "custom software companies"?

The opposite of the above business model are companies that focus on long term products, whether they be deployable desktop/mobile apps, or SaaS software.

A sure fire way to build up technical debt:

I work for a company that attempts to focus on a suite of SaaS products. However, due to certain constraints we sometimes end up bending to the will of certain clients and we end building bits of custom software that can only be used for that client.

This is a sure fire way to incur technical debt. Now we have a bit of software to maintain that adds nothing to our core product.

If custom work is a sure fire way to build technical debt, how do agencies handle it?

So that got me thinking. Companies who don't have a core product as the center of their business model, well they're always doing custom software work. How do they cope with the notion of technical debt? How does it not drive them into technical bankruptcy?

答:
This is a somewhat complex question to answer because like many things it really depends on the circumstances of the project, the level of control the contracted company has, whether the custom software has been managed by the contracted company for it's entire life cycle, the amount of "interference" by other people with access to the code base, the attitude of all of the people involved, complexity of the project and methodologies used... I really could go on.

All systems have a degree of technical debt. In some cases this may not be particularly noticeable due to diligent efforts on the part of developers working towards always maintaining a clean code base, however no system is perfect and a major redesign can make a seemingly innocent yet long standing issue become apparent. So how do contracted companies handle this?

In many cases they don't.  Often software will be written by one firm, then modified by another, and it's not unusual to see the code base get really messed up as each company under contract works to a tight deadline and won't justify the time to keep the code clean (and sometimes barely tested) if it means they might risk missing a deadline.

In other cases, you find companies that not only manage their contracted project well, but also somehow find the time to leave the existing code base in a better state than they found it. They do this often with careful planning, identifying sources of technical debt - usually those which will impact new work the most - and they devise strategies to provide test cases and modifications that contribute to managing the technical debt and factor all of this into their project schedule.

Does being a custom software guarantee technical debt as opposed to writing a central product? The short answer is no, however it is likely that technical debt will accrue if it isn't actively dealt with.  This is the same as with any other software project.  If you control the project entirely throughout its life cycle, then you have a better opportunity to deal with technical debt.  If not, then you will need to deal with technical debt that may have accrued from the code that the previous company left behind.

On the other hand, if your question were to ask if writing software regardless of your business model is a guarantee of technical debt. The answer would be Absolutely. The real question is how any company handles technical debt. Let it accrue and deal with it at a scheduled time, or manage a clean code base in an ongoing manner in order to pay off against technical debt as soon as possible? That answer comes down to a company's individual priorities, and whether the technical debt incurred is financially relevant.

OwnerDisplayName: andy


问:
What is the order of diagram drawing in a design?
I'm new with OOP and UML and I have some confusion here. I'd like to know where to start, I mean, somebody comes to you and ask you to do something (involves software design of course), once you have determined what has to be done, what is the order in which you have to start the software architecture? I mean, is it first the use case diagram or the class diagram? or should I draw some diagrams in parallel?

But basically, where should I start? and what UML diagram goes first? Thanks for helping!!

答:
There is no fixed order. It is all based on what you think is most useful to you/your team.

Initially, there should be some collection of requirements. If you start with SW architecture once someone tells you to do a software for X, then you already missed the most important step there.

During the requirements engineering phase, not all UML diagrams make sense yet. But some do make a lot of sense, in particular use-case diagrams. I have often seen use-case diagrams as the basis for discussions from which the requirements are then determined.

Similarly, state machines are already popular on the requirements level as well.

Once you have a set of requirements and actually start thinking about your architecture and later the design, more and more diagrams will start to make sense. Obviously, the class diagram comes in handy on lower levels of detail, but others, like sequence diagrams, may also make sense if you have complex sequences in your architecture.

Are you developing a distributed system, or something where components have to communicate a lot with each other? Try out the communication diagram.

Unless your process somehow requires you to use a specific UML diagram, there is no one forcing you to do so. Always remember that you do not model your software in UML for its own sake. If you don't feel like it'll help you, then simply don't do it.

Obviously, it takes some experience to decide this. I suggest you at least invest time to try out state machine, class, activity, and sequence diagrams, as those are the most popular. If you have enough time, take a look at the others as well.


答:
There's a whole bunch of them. There's an infinity of people who have idiot lecturers who teach C-strings and new and delete, or out-of-date tutorials or bad books, who learn "C++" but actually C, who think the two are pretty close.

Of course, if you're an employer, then saying that they're the same or even similar is a big warning light.


问:
Does a team of developers need a manager?
Background:

I'm currently part of a team of four: 1 manager, 1 senior developer and 2 developers. We do a range of bespoke in-house systems / projects (e.g. 6-8 weeks) for an organisation of around 3500 staff, as well as all the maintenance and support required from the systems that have been created before. There is not enough of us to do all the work that is potentially coming our way - we're understaffed. Management acknowledge this, but budget restraints limit our ability to recruit additional members to the team (even if we make the salary back in savings).

The Change

This leaves us where we are now. Our manager is due to leave his role for pastures new, leaving a vacancy in the team. Management are using this opportunity to restructure our team which would see the team manager role replaced by another developer and another senior developer. Their logic being that we need more developers, so here's a way of funding it (one of the roles is partially funded from another vacant post).

The team would have no direct line manager and the roles and responsibilities would be divided up between the seniors and the (relatively new to post) service manager (a non-technical role with little-to-no development knowledge/experience whose focus is shared amongst a number of other teams and individuals) - who would be our next actual manager up the food chain.

I guess the final question is:

Is it possible to run a development team without an manager? Have you had experience of this? And what things could go wrong / could be of benefit to us?

I'd ideally like to "see the light" and the benefits of doing things this way, or come up with some points for argument against it.

答:
Manager tend to be the missing link between the organisation and your dev team.

They make sure your work is relevant and meets the needs of the
organisation.

Answer to upper management

Manage the schedule so that the project is on time

Make sure that your needs for the project are taken care off.

Smaller teams, with small responsibilities could function without a designated manager. But as the responsibilities become bigger, you'll need someone managing all those risks and problems.

And given your setup, someone on your team will end up doing the manager role even though they are not designated as such. Usually distributed responsibilities don't work well. Depends a lot on how it's distributed and the type of people involved.


问:
Develop for Desktop and mobile use?
I am in the very beginning of developing an app / desktop program. I want it to be cross-platform and possibly also as a tablet version (preferably Android Icecream sandwich).
Note that I need to run it offline.

I thought about the following approaches:

ADOBE Air, since I do not need much performance. Plus I did some web programming in the past which might be of some use. Afaik it would run on OS X and Windows and should run on mobile OSes, too.

Qt. Found some nice Qt based desktop recently and read it also works on android. Plus I like the SDK.

HTML5 / JS. Again my web background should help me here. I wont need no sever side scripts, thus it should work without installing anything but a browser. How easy could this be converted into an Android app?

There might be a plethora of other (better) ways to do it, but I haven't thought of them yet. Can you help out? How would you create such an application. Would it be better to do some pure desktop client and then create tablet versions?

Would you rather start to create a website and worry later on how to turn into an app?

答:
Desktop and touch centric mobile/tablets have different UI paradigms. If you want a usable application across platforms, you'll need to write UI that looks good on each platform.

Problems you'll encounter with desktop apps would be things like keyboard shortcuts,  colour schemes, ui/widget conventions. You could use multiplatform libraries, but there'll always be some quirks here and there. You definitely don't want your app to look or feel foreign. You'll need to look at how to do installation across the many desktops. If you're using things that require admin privileges within your app, things can get more complicated.

Once you get into mobile the UI paradigms and best practices are different. So you might end up being stretched thin. Focus on one platform. Get it working well with a mind on portability. Separate the UI from logic. Once it's good and working on one platform, then spread out to other platform.

Title: Develop for Desktop and mobile use?


问:
Is there a phrase or word to describe an algorithim or program is complete in that given any value for its arguments there is a defined outcome?
Is there a phrase or word to describe an algorithm or program is complete in that given any value for its arguments there is a defined outcome? i.e. all the ramifications have been considered whatever the context?

A simple example would be the below function:

```<code>function returns string get_item_type(int type_no)
{
  if(type_no < 10)
    return "hockey stick"
  else if (type_no < 20)
    return "bulldozer"
  else
    return "unknown"
}
</code>```

(excuse the dismal pseudo code)

No matter what number is supplied all possibilities are catered for. My question is: is there a word to fill the blank here:

```<code>"get_item_type() is ______ complete"
</code>```

?

(The answer is  not Turing Complete - that is something quite different - but I annoyingly always think of something as "Turing Complete" when I am thinking of the above).

答:
you could say it is a pure function

or if there is state to be considered besides the arguments you could say it is deterministic


问:
What's better in terms of user experience - providing an email address or a link to my projects github account?
What's better in terms of user experience?

Provide the user an email account where he can report bugs, or a link to the projects github issues page (which requires a github account but may be easier to submit bugs to)?

EDIT

The application is a Bash script hosted on github. The GNU Coding Standards suggests using an email address, which may or may not an appropriate solution.

Target audience is the CLI power user.

答:
If you tell me your projects' github page, I can see what issues have already been reported, whether a fix has already been contributed, or I can fork the project to contribute a fix. If you just tell me your email address then I can't do any of those things.

Therefore I think it's better to tell me your github project page.


答:
I would definitely do a issue tracker on github instead of email. Two reasons why:

Users could, and should, see if the issue have already been posted.

You have a system that is a lot easier to administrate than an email address.

Title: What's better in terms of user experience - providing an email address or a link to my projects github account?

Body:
What's better in terms of user experience?

Provide the user an email account where he can report bugs, or a link to the projects github issues page (which requires a github account but may be easier to submit bugs to)?

EDIT

The application is a Bash script hosted on github. The GNU Coding Standards suggests using an email address, which may or may not an appropriate solution.

Target audience is the CLI power user.


答:
The best way would be to provide both. The more way the user can send you feedback, the more feedback you'll get. </p>

<p>As was said in a comment, most people won't know what git-hub is or how it works. Nothing prevent you to copy-past the mail received into github to keep a track of the issues.  </p>

Body:
The best way would be to provide both. The more way the user can send you feedback, the more feedback you'll get.

As was said in a comment, most people won't know what git-hub is or how it works. Nothing prevent you to copy-past the mail received into github to keep a track of the issues.


答: The Github page can be more useful, but a lot of people don't even know what Github is. Why not include both?</p>


答:
I'd say neither.

Provide a form where they can report some feedback. Behind the scenes, this form can send you an email, create a github issue, or whatever you want it to do.

You can also provide the github link - an asterisk at the end of the page if the users want more information about the current status of the issues.

I don't think providing an email would add any value over having a contact form, not to mention the overhead of checking your emails.

Edit: this was the answer before you edited. After your edit, my advice would be the following:

Since your audience are power users, they know their stuff. This audience would rather have a link to the github repo. They know where are the issues, can see the code, etc.

Still, I wouldn't give my email address. Github will send you mails when you have new issues. An email is way too personal and - that's my personal opinion - shouldn't be used for public-facing distribution. Managing github issues is way easier than managing your emails.


问:
How do you name your GUI controls?
It's a generally considered a bad practice to use the Hungarian notation, but is common to find GUI controls named userNameTextBox and userNameLabel.

Do you put the control type in it's name? Isn't this a kind of Hungarian notation?

答:
I am using Hungarian notation for GUI elements. It really is the pain when you close QtDesigner, open Visual Studio and when you want to set text on button if you have textbox named username, password, etc. When you use Qt, it is not big problem, because all GUI elements are wrapped inside ui object (ui.username), but when I use Windows Forms, textbox named username only bloats namespace.

In that case, txtUsername, btnLogin, lblStatus, etc. are clearly better options.

Title: How do you name your GUI controls?


问:
Where to put code documentation?
I am currently using two systems to write code documentation (am using C++):

Documentation about methods and class members are added next to the code, using the Doxygen format.  On a server Doxygen is run on the sources so the output can be seen in a web browser

Overview pages (describing a set of classes, the structure of the application, example code, ...) is added to a Wiki

I personally think that this approach is easy because the documentation about members and classes is really close to the code, while the overview pages are really easy to edit in the Wiki (and it's also easy to add images, tables, ...).  A web browser allows you to see both documentations.

My co-worker now suggests to put everything in Doxygen, because we can then create one big help file with everything in it (using either Microsoft's HTML WorkShop or Qt Assistant).  My concern is that editing Doxygen-style documentation is much harder (compared to Wiki), especially when you want to add tables, images, ... (or is there a 'preview' tool for Doxygen that doesn't require you to generate the code before you can see the result?)

What do big open-source (or closed source) projects use to write their code documentation?  Do they also split this up between Doxygen-style and a Wiki?  Or do they use another system?

What is the most appropriate way to expose the documentation?  Via a Web server/browser, or via a big (several 100MB) help file?

Which approach do you take when writing code documentation?

答:
Doxygen allows you to build PDF, HTML, wiki pages, almost everything you can think of.

My personal preference is to have both Doxygen and wiki and a script or something to check when they diverge.

Title: Where to put code documentation?


答:
I avoid using hungarian notation for GUI controls - I would avoid naming a control like `lblFirstName' because I don't really care that it's a label - from a data binding point of view it's just something to bind.

For controls that need a name I usually add the prefix ux for 'user experience'. That makes it clear that the item is intended only for the user to interact with. For example my view model might have a property called FirstName and the view might have a control called uxFirstName. This has the added benefit that all of my named controls are nicely grouped in my IDE.

Title: How do you name your GUI controls?

Body:
It's a generally considered a bad practice to use the Hungarian notation, but is common to find GUI controls named userNameTextBox and userNameLabel.

Do you put the control type in it's name? Isn't this a kind of Hungarian notation?


问:
Why does everybody write to-do comments in capital letters?
I'm doing the same. When there is something "to-do" in my code, I write //TODO .... But I'm curious to know when this started and if there is a reason for writing "to-dos" in all capital letters?

答: Some editors only highlight uppercase TODO items, so it's safer to always use uppercase.</p>


答:
Our team is using Hungarian notation for GUI controls, not for the rest of the code.

Typical example, a label followed by a textbox:

lblFirstName

txtFirstName

Plus it makes it easy to find your textbox, just type "txt" and intellisense will do the rest.

Title: How do you name your GUI controls?


答: In your first code block bar is a function variable that obeys scope. In the second code block is a globally declared function because it is not placed inside a scoped variable.</p>


问:
HTML5 file API or Java bridge to acces to local Files?
I've to access to files on the software user and I don't know if it's better to use a full JS app with HTML5 File Api rules or use Java and communicate with it ?</p>

答:
If you have the option to use the HTML file api and you are not worried about browser compatibility then you should avoid using 3rd party things like java as a far as possible and keep as close as possible to bare bones.

Java requires a JRE to be installed on the client PC, which adds a deployment layer, however simple it may be.


答:
I know people can't stand Hungarian notation overall, but I still find it very useful in a lot of places. For GUI I use wnd prefix at least.

The problem of not using Hungarian notation is simple, once you leave the smooth waters of MSVS, the navigation takes a nose dive. You see some sort of SomeValue = SomeOtherValue and you have no clue what is going on unless you look up every damn thing. Via grep or good old search, that usually kills the productivity right there, IDEs other than QT and MSVS are really bad at lookups.

Title: How do you name your GUI controls?