Go Precompiler

xuanbao · · 1007 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m new in go and I am having problems at writing objects (maybe because of the different syntax). Then I realize wouldnt it be easier to make a command line tool that takes code in a syntax similar to Java or other OO langauge and convert into go code. </p> <p>I made some research on how it would work and I think a precompiler similar to Sass/Scss would work.</p> <p>What do you guys think? Is it a good idea?</p> <hr/>**评论:**<br/><br/>mistretzu: <pre><p>it&#39;s not a good idea.. it takes more time to write that tool than to learn Go syntax which is quite easy and predictable.. </p></pre>NotWhisperer: <pre><p>I see. Now that I think about, if I had spend as much time researching about the Go syntax than researching this, I would already have good grasp of the syntax. Too much coffee I guess.</p></pre>drvd: <pre><blockquote> <p>Is it a good idea?</p> </blockquote> <p>No. This is a very bad idea.</p></pre>cafxx1985: <pre><p>And this is a really bad answer.</p> <p>(by not giving any rationale for it you&#39;re being dogmatic and condescending -- and this is particularly bad since OP is clearly a beginner)</p></pre>kor_the_fiend: <pre><p>Spend your time learning and practicing the syntax. Once you&#39;ve mastered it, you&#39;ll be glad you did. It&#39;s a really expressive and readable syntax and I now prefer it over more traditional c-style formatting.</p></pre>Loves_Portishead: <pre><p>For code generation there is `<code>//go:generate</code> already, if you look into the tools like <code>gofmt</code> there is already code for manipulating the ASTs/etc.</p> <p>If you look into tooling such as <code>grpc</code> you will see that generating stubs from simplified representations <em>in order to speed up the initial development</em> is already a common paradigm.</p> <p><strong>Edit:</strong> Down-votes for answering a beginners question? Are we so insecure that we don&#39;t even want to give someone the tools to look at solving their own problems? Nobody says you have to use whatever he may come up with.</p></pre>TheRealMrTux: <pre><p>I wouldn&#39;t say, this is a bad idea in general. It might not be useful to anyone (including yourself), but might be a great little project to learn something about go and precompilers. Just take it as an exercise.</p></pre>PaluMacil: <pre><p>I don&#39;t think you should use it, but I do think writing compilers, parsers, etc is a very good academic challenge, and writing one would probably be a fun experience. By the time you&#39;re done, you&#39;ll know the Go way to do things. ;) @Loves_Portishead mentioned go generate, and that could be a way to call your tool.</p></pre>shovelpost: <pre><p>Take a step back and try to read the Go code and say out loud what you read. You&#39;ll find that it reads much better than most other languages.</p> <p>For example:</p> <pre><code>var s string // A variable s of type string var string s // Variable string s? </code></pre> <p>Try this with more complex code too.</p> <p>Once you realize how great it is, you might even have a hard time going back.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1007 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传