As a programmer, I often look at some features of the language I'm currently using and think to myself "This is pretty hard to do for a programmer, and could be taken care of automatically by the machine".
作为一名程序员,我经常看一下我目前正在使用的语言的一些功能,并自己思考“这对于程序员来说很难做到,并且可以由机器自动处理”。
One example of such a feature is memory management, which has been automatic for a while in a variety of languages. While memory management is not that hard to do manually most of the time, doing it perfectly all the way through your application without leaking memory is extremely hard. Automation has made it easy again so that we programmers could concentrate on more critical questions.
这种特征的一个例子是存储器管理,它在各种语言中已经自动化了一段时间。虽然内存管理在大多数情况下并不难以手动完成,但在不泄漏内存的情况下在应用程序中完美地完成它非常困难。自动化使其变得简单,以便我们的程序员可以专注于更关键的问题。
Are there any features that you think programming languages should automate because the reward/difficulty ratio is just too low (say, for example concurrency)?
是否有任何您认为编程语言应该自动化的功能,因为奖励/难度比太低(例如并发)?
This question is intended to be a brainstorm about what the future of programming could be like, and what languages could do for us to let us focus on more important tasks, so please post your wishes even if you don't think automation is practical/feasible. Good answers will point to stuff that is genuinely hard to do in many languages, as opposed to single-language pet-peeves.
这个问题旨在成为关于编程未来的头脑风暴,以及我们可以让我们专注于更重要任务的语言,所以即使您认为自动化不实用,也请发表您的意愿/可行。好的答案将指出在许多语言中真正难以做到的事情,而不是单一语言的宠儿。
16 个解决方案
#1
Whatever the language can do for me automatically, I will want a way of doing for myself.
无论语言能够自动为我做什么,我都想要一种为自己做的事情。
#2
Concurrent programming/parallelism that is (semi-)automated, opposed to having to mess around with threads, callbacks, and synchronisation. Being able to parallelise for loops, such as:
兼容(半)自动化的并发编程/并行,与必须乱用线程,回调和同步相反。能够并行化循环,例如:
Parallel.ForEach(fooList, item =>
{
item.PerformLongTask();
}
is just made of win.
只是赢了。
Certain languages already support such functionality to a degree, however. Notably, F# has asynchronous workflows. Coming with the release of .NET 4.0, the Parallel Extensions library will make concurrency much easier in C# and VB.NET. I believe Python also has some sort of concurrency library, though I personally haven't used it.
但是,某些语言已在某种程度上支持此类功能。值得注意的是,F#具有异步工作流程。随着.NET 4.0的发布,Parallel Extensions库将使C#和VB.NET中的并发变得更加容易。我相信Python也有某种并发库,但我个人还没有使用它。
What would also be cool is fully automated parallelism in purely functional languages, i.e. not having to change your code even slightly and automatically have it run near optimally across multiple cores. Note that this can only be done with purely functional languages (such as Haskell, but not CAML/F#). Still, constructs such as example given above would be very handy for automating parallelism in object-oriented and other languages.
同样很酷的是纯函数式语言中的全自动并行性,即不需要稍微更改代码并自动使其在多个内核之间以最佳方式运行。请注意,这只能使用纯函数语言(例如Haskell,而不是CAML / F#)来完成。尽管如此,上面给出的示例构造对于面向对象和其他语言中的并行化自动化非常方便。
I would imagine that libraries, design patterns, and even entire programming languages oriented towards simple and high-level support for parallelism will become increasingly widespread in the near future, as desktop computers start to move from 2 cores to 4 and then 8 cores and the advantage of automated concurrency becomes much more evident.
我认为,随着桌面计算机开始从2个内核转移到4个内核,然后是8个内核,所以图书馆,设计模式,甚至是面向简单和高级别并行支持的整个编程语言将在不久的将来变得越来越普遍。自动并发的优势变得更加明显。
#3
exec("Build a system to keep the customer happy, based on requirements.txt");
#4
In Java, create beans less verbosely.
在Java中,不那么冗长地创建bean。
For example:
bean Student
{
String name;
int id;
type1 property1;
type2 property2;
}
and this would create a bean private fields, default accessors, toString, hashCode, equals, etc.
这将创建一个bean私有字段,默认访问器,toString,hashCode,equals等。
#5
In Java I would like a keyword that would make the entire class immutable.
在Java中,我想要一个使整个类不可变的关键字。
E.g.
public immutable class Xyz {
}
And the compiler would warn me if any conditions of immutability were broken.
如果任何不可变性条件被打破,编译器会警告我。
#6
Concurrency. That was my main idea when asking this question. This is going to get more and more important with time, since current CPUs already have up to 8 logical cores (4 cores + hyperthreading), and 12 logical cores will appear in a few months. In the future, we are going to have a hell of a lot of cores at our disposal, but most programing languages only make it easy for us to use one at a time.
并发。在提出这个问题时,这是我的主要想法。随着时间的推移,这将变得越来越重要,因为当前的CPU已经拥有多达8个逻辑内核(4个内核+超线程),并且在几个月内将出现12个逻辑内核。在未来,我们将拥有大量核心供我们使用,但大多数编程语言只能让我们一次只使用一个。
The Threads + Synchronization model that is exposed by most programming languages is extremely low level, and very close to what the CPU does. To me, the current level of concurrency language support is roughly equivalent to the memory management support in C: Not integrated, but some things can be delegated to the OS (malloc, free).
大多数编程语言公开的Threads + Synchronization模型都是极低级别的,并且与CPU的工作非常接近。对我来说,当前的并发语言支持水平大致相当于C中的内存管理支持:未集成,但有些东西可以委托给OS(malloc,free)。
I wish some language would come up with a suitable abstraction that either makes the Threads + Synchronization model easier, or that simply completely hides it for us (just as automatic memory management make good old malloc/free obsolete in Java).
我希望某种语言能够提供一个合适的抽象,使得Threads + Synchronization模型更容易,或者只是完全隐藏它(就像自动内存管理在Java中使旧的malloc / free过时一样)。
Some functional languages such as Erlang have a reputation of having good multithreading support, but the brain-switch required to do functional programming doesn't really make the whole ordeal much easier.
一些函数式语言(如Erlang)具有良好的多线程支持声誉,但进行函数式编程所需的大脑转换并不能使整个考验变得更加容易。
#7
.Net:
A warning when manipulating strings with methods such as Replace
and not returning the value (new string) to a variable, because if you don't know that a string is immutable this issue will frustrate you.
使用诸如Replace之类的方法操作字符串时的警告,而不是将值(新字符串)返回给变量,因为如果您不知道字符串是不可变的,则此问题会让您感到沮丧。
#8
In C++, type inference for variable declarations, so that I don't need to write
在C ++中,键入变量声明的推断,这样我就不需要编写了
for (vector<some_longwinded_type>::const_iterator i = v.begin(); i != v.end(); ++i) {
...
}
Luckily this is coming in C++1x in the form of auto
:
幸运的是,它以c ++ 1x的形式出现在auto中:
for (auto i = v.begin(); i != v.end(); ++i) {
...
}
#9
Coffee. I mean the language is call Java - so it should be able to make my coffee! I hate getting up from programming, going to the coffee pot, and finding out someone from marketing has taken the last cup and not made another pot.
咖啡。我的意思是语言叫做Java - 所以它应该能够煮我的咖啡!我讨厌从节目中起床,去咖啡馆,找到营销人员已经拿走了最后一杯而没有再做一个底池。
#10
Persistence, it seems to me we write far too much code to deal with persistence when this really should be a configuration problem.
持久性,在我看来,当这真的应该是一个配置问题时,我们写了太多的代码来处理持久性。
#11
In C++, enum-to-string.
在C ++中,枚举到字符串。
In Ada, the language defines the 'image attribute of an enumerated type as a function that returns a string corresponding to the textual representation of an enumeration value.
在Ada中,该语言将枚举类型的图像属性定义为返回与枚举值的文本表示相对应的字符串的函数。
C++ provides no such clean facility. It takes several lines of very arcane preprocessor macro black magic to get a rough equivalent.
C ++没有提供这样的清洁工具。它需要几行非常神秘的预处理器宏黑魔术来获得粗略的等效物。
#12
For languages that provide operator overloading, provide automatically generated overloads for symmetric operations when only one operation is defined. For example, if the programmer provides an equality operator but not an inequality operator, the language could easily generate one. In C++, the same could be done for copy constructors and assignment operators.
对于提供运算符重载的语言,仅在定义一个操作时为对称操作提供自动生成的重载。例如,如果程序员提供了相等运算符而不是不等运算符,则该语言可以轻松生成一个。在C ++中,可以对复制构造函数和赋值运算符执行相同的操作。
I think that automatically generating one-side of a symmetric operation would be nice. Of course, I would definitely want to be able to explicitly say don't do that when needed. I guess providing the implementation of both sides with one of them being private and empty could do the job.
我认为自动生成对称操作的单侧会很好。当然,我肯定希望能够明确地说不要在需要时这样做。我想提供双方的实施,其中一个是私人和空的可以完成这项工作。
#13
Everything that LINQ does. C# has spoiled me and I now find it hard to do anything with collections in any other language. In Python I use list comprehensions a lot, but they are not quite as powerful as LINQ. I haven't found any other language that makes working with collections as easy as in C#.
LINQ所做的一切。 C#已经破坏了我,我现在发现很难用任何其他语言的集合做任何事情。在Python中,我经常使用列表推导,但它们并不像LINQ那么强大。我还没有找到任何其他语言使得使用C#中的集合变得简单。
#14
In Visual Studio environment I want "Remove unused usings" to run across all file in the project. I find it a significant loss of time to have to manually open each individual file and call this operation of a file basis.
在Visual Studio环境中,我希望“删除未使用的使用”以在项目中的所有文件中运行。我发现必须手动打开每个单独的文件并调用此文件操作是一个重要的时间。
#15
From a dynamic languages perspective, I'd like to see better tool support. Steve Yegge has a great post on this. For instance, there are lots of cases where a tool could look inside various code paths and determine if the methods or functions existed and provide the equivalent of the compiler smoke test. Obviously, if you're using lots and lots of truly dynamic code, this won't work, but the fact is, you probably aren't, so it would be pretty nice if Python, for instance, would tell you that .ToLowerCase() wasn't a valid function at compile time, rather than waiting until you hit the else clause.
从动态语言的角度来看,我希望看到更好的工具支持。 Steve Yegge在此发表了一篇很棒的文章。例如,在很多情况下,工具可以查看各种代码路径,并确定方法或函数是否存在,并提供编译器冒烟测试的等效项。显然,如果你使用了大量真正的动态代码,这将无法正常工作,但事实是,你可能不会,所以如果Python会告诉你的那样会很好.ToLowerCase ()在编译时不是有效函数,而是等到你触及else子句。
s = "a Mixed Case String"
if True:
s = s.lower()
else:
s = s.ToLowerCase()
#16
Easy: initialize variables in C/C++ just like C# does. It would have saved me multiple sessions of debugging in other people's code.
简单:像C#一样在C / C ++中初始化变量。它本可以在其他人的代码中保存多个调试会话。
Of course there would be a keyword when you specifically do not want to init a var.
当然,当你特别不想初始化var时会有一个关键字。
noinit float myVal; // undefined
float my2ndVal; // 0.0f
#1
Whatever the language can do for me automatically, I will want a way of doing for myself.
无论语言能够自动为我做什么,我都想要一种为自己做的事情。
#2
Concurrent programming/parallelism that is (semi-)automated, opposed to having to mess around with threads, callbacks, and synchronisation. Being able to parallelise for loops, such as:
兼容(半)自动化的并发编程/并行,与必须乱用线程,回调和同步相反。能够并行化循环,例如:
Parallel.ForEach(fooList, item =>
{
item.PerformLongTask();
}
is just made of win.
只是赢了。
Certain languages already support such functionality to a degree, however. Notably, F# has asynchronous workflows. Coming with the release of .NET 4.0, the Parallel Extensions library will make concurrency much easier in C# and VB.NET. I believe Python also has some sort of concurrency library, though I personally haven't used it.
但是,某些语言已在某种程度上支持此类功能。值得注意的是,F#具有异步工作流程。随着.NET 4.0的发布,Parallel Extensions库将使C#和VB.NET中的并发变得更加容易。我相信Python也有某种并发库,但我个人还没有使用它。
What would also be cool is fully automated parallelism in purely functional languages, i.e. not having to change your code even slightly and automatically have it run near optimally across multiple cores. Note that this can only be done with purely functional languages (such as Haskell, but not CAML/F#). Still, constructs such as example given above would be very handy for automating parallelism in object-oriented and other languages.
同样很酷的是纯函数式语言中的全自动并行性,即不需要稍微更改代码并自动使其在多个内核之间以最佳方式运行。请注意,这只能使用纯函数语言(例如Haskell,而不是CAML / F#)来完成。尽管如此,上面给出的示例构造对于面向对象和其他语言中的并行化自动化非常方便。
I would imagine that libraries, design patterns, and even entire programming languages oriented towards simple and high-level support for parallelism will become increasingly widespread in the near future, as desktop computers start to move from 2 cores to 4 and then 8 cores and the advantage of automated concurrency becomes much more evident.
我认为,随着桌面计算机开始从2个内核转移到4个内核,然后是8个内核,所以图书馆,设计模式,甚至是面向简单和高级别并行支持的整个编程语言将在不久的将来变得越来越普遍。自动并发的优势变得更加明显。
#3
exec("Build a system to keep the customer happy, based on requirements.txt");
#4
In Java, create beans less verbosely.
在Java中,不那么冗长地创建bean。
For example:
bean Student
{
String name;
int id;
type1 property1;
type2 property2;
}
and this would create a bean private fields, default accessors, toString, hashCode, equals, etc.
这将创建一个bean私有字段,默认访问器,toString,hashCode,equals等。
#5
In Java I would like a keyword that would make the entire class immutable.
在Java中,我想要一个使整个类不可变的关键字。
E.g.
public immutable class Xyz {
}
And the compiler would warn me if any conditions of immutability were broken.
如果任何不可变性条件被打破,编译器会警告我。
#6
Concurrency. That was my main idea when asking this question. This is going to get more and more important with time, since current CPUs already have up to 8 logical cores (4 cores + hyperthreading), and 12 logical cores will appear in a few months. In the future, we are going to have a hell of a lot of cores at our disposal, but most programing languages only make it easy for us to use one at a time.
并发。在提出这个问题时,这是我的主要想法。随着时间的推移,这将变得越来越重要,因为当前的CPU已经拥有多达8个逻辑内核(4个内核+超线程),并且在几个月内将出现12个逻辑内核。在未来,我们将拥有大量核心供我们使用,但大多数编程语言只能让我们一次只使用一个。
The Threads + Synchronization model that is exposed by most programming languages is extremely low level, and very close to what the CPU does. To me, the current level of concurrency language support is roughly equivalent to the memory management support in C: Not integrated, but some things can be delegated to the OS (malloc, free).
大多数编程语言公开的Threads + Synchronization模型都是极低级别的,并且与CPU的工作非常接近。对我来说,当前的并发语言支持水平大致相当于C中的内存管理支持:未集成,但有些东西可以委托给OS(malloc,free)。
I wish some language would come up with a suitable abstraction that either makes the Threads + Synchronization model easier, or that simply completely hides it for us (just as automatic memory management make good old malloc/free obsolete in Java).
我希望某种语言能够提供一个合适的抽象,使得Threads + Synchronization模型更容易,或者只是完全隐藏它(就像自动内存管理在Java中使旧的malloc / free过时一样)。
Some functional languages such as Erlang have a reputation of having good multithreading support, but the brain-switch required to do functional programming doesn't really make the whole ordeal much easier.
一些函数式语言(如Erlang)具有良好的多线程支持声誉,但进行函数式编程所需的大脑转换并不能使整个考验变得更加容易。
#7
.Net:
A warning when manipulating strings with methods such as Replace
and not returning the value (new string) to a variable, because if you don't know that a string is immutable this issue will frustrate you.
使用诸如Replace之类的方法操作字符串时的警告,而不是将值(新字符串)返回给变量,因为如果您不知道字符串是不可变的,则此问题会让您感到沮丧。
#8
In C++, type inference for variable declarations, so that I don't need to write
在C ++中,键入变量声明的推断,这样我就不需要编写了
for (vector<some_longwinded_type>::const_iterator i = v.begin(); i != v.end(); ++i) {
...
}
Luckily this is coming in C++1x in the form of auto
:
幸运的是,它以c ++ 1x的形式出现在auto中:
for (auto i = v.begin(); i != v.end(); ++i) {
...
}
#9
Coffee. I mean the language is call Java - so it should be able to make my coffee! I hate getting up from programming, going to the coffee pot, and finding out someone from marketing has taken the last cup and not made another pot.
咖啡。我的意思是语言叫做Java - 所以它应该能够煮我的咖啡!我讨厌从节目中起床,去咖啡馆,找到营销人员已经拿走了最后一杯而没有再做一个底池。
#10
Persistence, it seems to me we write far too much code to deal with persistence when this really should be a configuration problem.
持久性,在我看来,当这真的应该是一个配置问题时,我们写了太多的代码来处理持久性。
#11
In C++, enum-to-string.
在C ++中,枚举到字符串。
In Ada, the language defines the 'image attribute of an enumerated type as a function that returns a string corresponding to the textual representation of an enumeration value.
在Ada中,该语言将枚举类型的图像属性定义为返回与枚举值的文本表示相对应的字符串的函数。
C++ provides no such clean facility. It takes several lines of very arcane preprocessor macro black magic to get a rough equivalent.
C ++没有提供这样的清洁工具。它需要几行非常神秘的预处理器宏黑魔术来获得粗略的等效物。
#12
For languages that provide operator overloading, provide automatically generated overloads for symmetric operations when only one operation is defined. For example, if the programmer provides an equality operator but not an inequality operator, the language could easily generate one. In C++, the same could be done for copy constructors and assignment operators.
对于提供运算符重载的语言,仅在定义一个操作时为对称操作提供自动生成的重载。例如,如果程序员提供了相等运算符而不是不等运算符,则该语言可以轻松生成一个。在C ++中,可以对复制构造函数和赋值运算符执行相同的操作。
I think that automatically generating one-side of a symmetric operation would be nice. Of course, I would definitely want to be able to explicitly say don't do that when needed. I guess providing the implementation of both sides with one of them being private and empty could do the job.
我认为自动生成对称操作的单侧会很好。当然,我肯定希望能够明确地说不要在需要时这样做。我想提供双方的实施,其中一个是私人和空的可以完成这项工作。
#13
Everything that LINQ does. C# has spoiled me and I now find it hard to do anything with collections in any other language. In Python I use list comprehensions a lot, but they are not quite as powerful as LINQ. I haven't found any other language that makes working with collections as easy as in C#.
LINQ所做的一切。 C#已经破坏了我,我现在发现很难用任何其他语言的集合做任何事情。在Python中,我经常使用列表推导,但它们并不像LINQ那么强大。我还没有找到任何其他语言使得使用C#中的集合变得简单。
#14
In Visual Studio environment I want "Remove unused usings" to run across all file in the project. I find it a significant loss of time to have to manually open each individual file and call this operation of a file basis.
在Visual Studio环境中,我希望“删除未使用的使用”以在项目中的所有文件中运行。我发现必须手动打开每个单独的文件并调用此文件操作是一个重要的时间。
#15
From a dynamic languages perspective, I'd like to see better tool support. Steve Yegge has a great post on this. For instance, there are lots of cases where a tool could look inside various code paths and determine if the methods or functions existed and provide the equivalent of the compiler smoke test. Obviously, if you're using lots and lots of truly dynamic code, this won't work, but the fact is, you probably aren't, so it would be pretty nice if Python, for instance, would tell you that .ToLowerCase() wasn't a valid function at compile time, rather than waiting until you hit the else clause.
从动态语言的角度来看,我希望看到更好的工具支持。 Steve Yegge在此发表了一篇很棒的文章。例如,在很多情况下,工具可以查看各种代码路径,并确定方法或函数是否存在,并提供编译器冒烟测试的等效项。显然,如果你使用了大量真正的动态代码,这将无法正常工作,但事实是,你可能不会,所以如果Python会告诉你的那样会很好.ToLowerCase ()在编译时不是有效函数,而是等到你触及else子句。
s = "a Mixed Case String"
if True:
s = s.lower()
else:
s = s.ToLowerCase()
#16
Easy: initialize variables in C/C++ just like C# does. It would have saved me multiple sessions of debugging in other people's code.
简单:像C#一样在C / C ++中初始化变量。它本可以在其他人的代码中保存多个调试会话。
Of course there would be a keyword when you specifically do not want to init a var.
当然,当你特别不想初始化var时会有一个关键字。
noinit float myVal; // undefined
float my2ndVal; // 0.0f