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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Fo: An experimental language which adds generics on top of Go

165 点作者 polymathist将近 7 年前

15 条评论

gtt将近 7 年前
I liked certain aspects of Go, but lack of generics was a deal-breaker for me. You approached it a way better than I (and many others) did. Instead of arguing on forums you started writing code.
评论 #17296685 未加载
评论 #17306558 未加载
kodablah将近 7 年前
For generics:<p>How do recursive types and self-referencing types work? What about generic types that themselves require generic types? Can type constraints be applied? What do generics look like on interfaces? How about in slices? When compiled, are specialized functions written or is the code shared? How is runtime reflection for type params implemented?<p>Also, oblig ref of a now-defunct lang on top of Go: <a href="https:&#x2F;&#x2F;oden-lang.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;oden-lang.github.io&#x2F;</a><p>Finally, good work, I hope it was fun! Don&#x27;t take criticisms too seriously, they are good things (as opposed to silence) and par for the course on this site.
polymathist将近 7 年前
Author here. I&#x27;ve been working on Fo part time for 4 months. Feel free to ask me anything.
评论 #17296510 未加载
评论 #17296898 未加载
评论 #17296299 未加载
评论 #17295569 未加载
评论 #17297826 未加载
评论 #17296577 未加载
评论 #17295642 未加载
jstimpfle将近 7 年前
Nice work. But, serious question - When going with parameterized types I know from Haskell how you always end up needing one more language extension and always end up banging your head against the wall that separates types and values a little more. At least if you&#x27;re not a math genius, but probably even then.<p>And from Java I know that there&#x27;s a pretty trivial example that showcases how its Generics implementation is unsound when mixed with inheritance.<p>And I know that the Go maintainers have been hesitant for a long time because they didn&#x27;t know a good version of Generics to add.<p>So, is there any version that just works, and never leads the user down any rabbit holes? And that doesn&#x27;t lead to ever increasing type boilerplate?<p>Because I&#x27;ve been super happy ever since I decided that worrying about occasional usage of void pointers in C is just not worth my time. And where configurability is really needed, function pointers are totally fine - I don&#x27;t think there is any need for static polymorphic dispatch (function pointers are probably even preferable, to avoid bloated machine code).
评论 #17298328 未加载
评论 #17297780 未加载
评论 #17298364 未加载
symlock将近 7 年前
The only time I find I need generics is when I&#x27;m prototyping things and making lots of changes. Node, Ruby, &amp; Python are great for this. In fact, PHP&#x27;s associative array is really powerful&#x2F;sloppy since it can be used as a list, hash&#x2F;dictionary, iterable, or object.<p>That aside, I don&#x27;t think I&#x27;ve ever <i>really</i> been bothered by the lack of generics for actual work code.
评论 #17298191 未加载
dagss将近 7 年前
Has anyone worked on Lisp-like macros in Go? Executing code at compile time to emit AST and compile it.. That is what I feel is really missing. Even with strictly a compile-time phase (no run-time macro evaluation) it could be quite useful.<p>Starting with generics seem to lead down the dark path of C++ template metaprogramming..<p>I would rather do something like<p>type StrBox = MakeBoxType!(string)<p>...and have clean hygienic macros to generate my &quot;generic&quot;. Syntax candy can be added to that to get generics...but starting with generics and only supporting that went really really badly for the C++ ecosystem.
评论 #17298210 未加载
weberc2将近 7 年前
This is suuuper cool. I&#x27;ve thought of doing something similar for a while, but I tried approaching it from the &quot;generate Go&quot; angle. I also found the Go syntax too tedious to write a parser for (because I&#x27;ve never written a parser before, nor any kind of compiler, so the learning curve was too steep). So I was just going to try to build a simple, expression-based language that compiled to (and interoped with) Go. Unfortunately, I ran out of steam because the learning curve was so steep.
评论 #17296594 未加载
bigato将近 7 年前
You really missed the opportunity here to call your language Foo
评论 #17296477 未加载
评论 #17297823 未加载
评论 #17297154 未加载
评论 #17297551 未加载
jcelerier将近 7 年前
but go already has generics <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;5penft&#x2F;parallelizing_enjarify_in_go_and_rust&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;5penft&#x2F;parallelizing_...</a>
评论 #17296303 未加载
sagichmal将近 7 年前
C++ style (compiler) or Java style (boxing) implementation?
评论 #17296276 未加载
gliese1337将近 7 年前
Is there any support for bounded type variables? Or plans to add them?
评论 #17305585 未加载
jeffrallen将近 7 年前
Should be called mofo.
评论 #17300377 未加载
stunt将近 7 年前
Nice work!
tonyedgecombe将近 7 年前
Interesting, now all you need to do is add exceptions :)
评论 #17296648 未加载
评论 #17296273 未加载
评论 #17296257 未加载
gggguil将近 7 年前
Shouldn&#x27;t it have been called Ho ?
评论 #17296324 未加载