用于非常大的列表的 Web 编程语言?
根据您的经验,用于处理非常大的列表(即数万个电子邮件地址)的排序和比较的最佳网络编程语言是什么?
我最熟悉PHP。我认为它可以完成工作,但我不确定其他语言以及是否可能有下注者追求者。
谢谢!
In your experience, what is the best web programming language used to handle sorting and comparison of very large lists (ie tens of thousands of email addresses)?
I am most familiar with PHP. I think that it could get the job done, but I'm unsure of other languages and if there might be a bettor suitor.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
是否可以在数据库内部进行排序?它们旨在进行动态排序和比较。我建议您转向让数据库处理此类活动的模型。
如果由于某种原因你真的不能使用数据库,那么你应该关注算法而不是语言。根据其他标准(个人熟悉程度、它是否支持您的其他任务、是否有活跃的支持社区等)选择一种语言,并根据该语言的怪癖找出最佳算法。例如,根据 https://stackoverflow.com/ 中的一些讨论questions/309300/defend-php-concince-me-it-isnt-horrible,PHP的递归性能比较差。
但认真地说,为此使用数据库。
Is it possible to do the sorting inside of a database? They are designed to do dynamic sorting and comparison. I would suggest you move to a model that lets the DB handle this sort of activity.
If you really really can't use a DB for some reason then you should focus on algorithms over languages. Pick a language based on other criteria (personal familiarity, does it support your other tasks, does it have an active support community, etc etc) and figure out the best algorithm given that language's quirks. For instance, according to some of the discussion in https://stackoverflow.com/questions/309300/defend-php-convince-me-it-isnt-horrible, PHP has relatively poor recursion performance.
But seriously, use a database for this.
我会将电子邮件存储在数据库中,并使用 SQL 执行排序和搜索。这就是数据库的设计目的,它们将拥有智能解决方案,其性能将超越大多数人用代码编写的任何内容。
I would store the emails in a database, and use SQL to perform sorts and searches. That is what databases were designed for, and they will have intelligent solutions that will outperform anything most people could write in code.
这不取决于编程语言,而是取决于逻辑,比如索引或表模式和缓存机制。
This doesn't depend on the programming language , it depends on the logic ,lets say be it indexes or table schemas and caching mechanism.
语言通常不太重要。太。选择您最舒服的一个。
最终产品是由建造者而不是工具塑造的。
Language usually doesn't matter TOO much. Pick the one you are comfortable most with.
The final product is shaped by the builder, not the tools.
您还可以使用前缀树数据结构 trie - 用于在内存中排序。
电子邮件地址具有限制性字符集(
az
、0-9
、_
、.
等),因此trieNode 只会包含这些字符。这个关于 trie 的topcoder 教程是一个很好的起点如果您还不了解 trie。您必须遍历所有字符串才能构建特里树。
搜索/比较需要 O(l) 时间,其中 l 是要比较的字符串的长度。
排序需要您使用 DFS(深度优先搜索)遍历 trie 树的所有 trieNode - O(|V| + |E|) 时间。
You can also use a trie which is a prefix tree data structure - for sorting in memory.
Email addresses have restrictive character set (
a-z
,0-9
,_
,.
etc.), so the trieNode would only have those characters. This topcoder tutorial on trie is a good starting point if you don't already know about trie.You have to go through all the strings to construct the trie.
Searching / Comparison takes O(l) time where l is the length of the string you are comparing.
Sorting requires you traversing all the trieNodes of the trie tree using DFS (depth first search) - O(|V| + |E|) time.
你最快的方法是编译cgi。
Your fastest would be a compiled cgi.