TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Predicting Variable Types in Dynamically Typed Programming Languages

61 点作者 gauravanand25超过 6 年前

4 条评论

satyanash超过 6 年前
&gt; <i>...allows programmers to write code quickly by not requiring to declare the types of each variable which are determined at run-time based on the values assigned to that variable, thereby increasing programmer productivity</i><p>Modern compilers for statically typed languages are really good at inferring types of various identifiers based on multiple hints in a deterministic way (see Kotlin, Swift etc). Mentioned statically typed languages C,C++ and Java are pretty old and therefore carry some baggage of verbosity that is no longer needed.<p>&gt; <i>...since the variable types are not declared in the source code, the source code becomes difficult to understand and extend</i><p>&gt; <i>For programmers working on the large code base written in dynamic languages, it is hard to understand the control flow of the program if the types are not available at the compile time.</i><p>Dynamic languages as a result of their &quot;dynamicness&quot; tend to allow much better expression of control flow when compared to static languages. Only recently available statically typed languages have targeted expressiveness as a first class goal in designing the language. In fact, statically typed languages are notorious for obtuse control flows as a result of their type enforcement (see C, C++, Golang)
评论 #18945745 未加载
评论 #18945737 未加载
评论 #18947324 未加载
评论 #18944714 未加载
评论 #18945630 未加载
评论 #18963906 未加载
评论 #18946240 未加载
phoe-krk超过 6 年前
How does this relate and compare to actual type inference? For example, Common Lisp implementation SBCL is able to infer types pretty nicely now and it doesn&#x27;t need neural networks for &quot;predicting&quot; the types with some kind of chance.
评论 #18944712 未加载
评论 #18945709 未加载
评论 #18945458 未加载
sifoobar超过 6 年前
Snigl [0] traces the code before running it; simulating stack contents and inferring generic calls based on that information as far as possible, among other things.<p>It&#x27;s not perfect, but it&#x27;s the only way I&#x27;ve found that makes sense in combination with Forth-like stack semantics where function parameters are never specified explicitly. And that runs fast enough to make sense in an interpreted language. I also like that it&#x27;s implemented as a transformation on VM code, which makes it flexible and easy to debug.<p>[0] <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;sifoo&#x2F;snigl#tracing" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;sifoo&#x2F;snigl#tracing</a>
mlevental超过 6 年前
kind of cool but why is the model trained on such a small data set? why not train it on a bunch of codebases that use type hints?