after several months do you (still) find it annoying that types come after (not before, like C)?

xuanbao · · 44 次点击    
<p>So this is a simple question - it would be better for people to answer either way. (So that answers don&#39;t self-select just for people who are/aren&#39;t annoyed by it.)</p> <p>Question: if you have programmed in Go for several months (i.e. written at least thousands or tens of thousands of lines of Go) - do you (still) find it annoying that Go&#39;s type declarations go after, not before as with other languages?</p> <p>Simple question, simple answer. (By the way my expectation is that most answers would be &#39;not at all, got totally used to it.&#39;)</p> <hr/>**评论:**<br/><br/>adelowo: <pre><p>When I started around 5 months ago, it was a little bit weird but I read a blog post by Rob pike on this -- &gt; <a href="https://blog.golang.org/gos-declaration-syntax" rel="nofollow">https://blog.golang.org/gos-declaration-syntax</a> - and I have been fine with it since then</p></pre>throwawaybeginr: <pre><p>I&#39;m also fine with it. It&#39;s just still &#34;a little weird&#34; for me and I&#39;m just curious if it will stop being &#34;a little weird&#34; for me after a few months. Thanks for your reply!</p></pre>shazow: <pre><p>It hasn&#39;t been weird for me after a few months, but it&#39;s definitely frustrating when I switch between Go and C... especially when writing inline C and they&#39;re in the same file. :S</p> <p>(Edit: To clarify, I do prefer the Go way at this point.)</p></pre>throwawaybeginr: <pre><p>Thanks for this reply.</p></pre>TheRealMrTux: <pre><p>It&#39;s the other way around for me. I was forced to write some java the past weeks and found myself writing types after the variable name. We had good laugh after</p></pre>throwawaybeginr: <pre><p>Thanks for this feedback. So writing go is totally natural for you. Could I ask if that extends to every part of the language? (every syntactical portion). For example slices seem a bit weird for me still, etc. To you is everything natural now?</p></pre>TheRealMrTux: <pre><p>I am by no means an go expert. I guess, the language you&#39;re writing the most in l, feels the most natural to you. What part of slices seem weird to you? Writing in go is a great experience and I like every part of the language, even though I still discover new things every now and then.</p></pre>metamatic: <pre><p>I&#39;ve done the same thing, written types after variable names in other languages.</p> <p>Slices seem natural enough to me because back in the day I implemented a similar data structure for lists (arbitrary-sized arrays) in object-oriented Pascal. </p> <p>The way slices work is basically how you make lists work without the overheads of linked-list traversal; the only thing that&#39;s weird compared to other languages is that the details are visible to the programmer.</p></pre>sh41: <pre><p>Please compare <a href="https://cdecl.org/?q=char+%28*%28*x%28%29%29%5B5%5D%29%28%29" rel="nofollow">cdecl.org</a> vs <a href="https://godecl.org/?q=var+x+func%28%29+%2A%5B5%5D%2Afunc%28%29+rune" rel="nofollow">godecl.org</a> and tell me which you&#39;d rather deal with on a daily basis.</p></pre>md2perpe: <pre><p>Why should it be annoying? I think that it&#39;s as natural to have the type after the variable as before it (or around it as often is the case in C). In Pascal one writes for example &#34;var x : integer;&#34; and in Haskell one writes &#34;x :: Integer&#34;.</p></pre>throwawaybeginr: <pre><p>I guess because I didn&#39;t write Pascal or Haskell. I&#39;ll take your reply as &#34;totally natural since day 1&#34; for you :)</p></pre>justinisrael: <pre><p>I&#39;ve been writing production Go for a couple years now, and started coding Go back when it was pre 1.0. I honestly don&#39;t care about the types being before or after. It is just the way Go does it vs another language. That being said, if I write a bunch of Go and then have to jump into a C++ project, I will end up writing the type after the name and then get confused for a second when it complains. </p></pre>throwawaybeginr: <pre><p>I&#39;d like to ask you this same thing (copied from another comment):</p> <blockquote> <p>can you do me a favor and as you write your next program, tell me the last few syntax errors you make - whatever they are. Even if you leave off a bracket or brace or something.</p> <p>you can reply at any time. (i.e. if you&#39;re not writing anything now.)</p> </blockquote> <p>you could take a few days to get back to me. I&#39;m just curious what things still stick with people after a few months. even if it&#39;s something mundane like parentheses, etc.</p> <p>thanks.</p></pre>justinisrael: <pre><p>I can tell you one I make all the time. I always accidentally type :+ instead of := because of poor timing with the key combinations. But other than that, I usually have no problem with syntax. It&#39;s such a small spec, there isn&#39;t too much for me to mess up. I switched to C++ and accidentally defined the return type of a function at the end before the braces. </p></pre>lyfaradey: <pre><p>I&#39;m mostly a Java dev at the office but all personal backend projects write in Go. it&#39;s kinda weird when I write types in Go-style in Java and than scratching my head trying to understand why it&#39;s underlined. :D </p></pre>bobahop: <pre><p>I like its consistency. I think &#34;here is my variable which is a...&#34; and I either infer the type or specify it, so the type is always derived from what comes after it. I&#39;ve found it harder to not immediately type an open parentheses after &#34;if.&#34;</p></pre>Kraigius: <pre><p>Only when I switch language but then I find it more annoying when I start to type without parentheses. :3</p></pre>donglord1337: <pre><p>nope, always been that way for me</p></pre>throwawaybeginr: <pre><p>What are you saying &#34;nope&#34; to, and always been what way to you?</p></pre>donglord1337: <pre><p>if i find it annoying that the type comes after (not before, like C) - it&#39;s always been this way for me.</p></pre>throwawaybeginr: <pre><p>thanks.</p></pre>nevyn: <pre><p>Annoying is the wrong word.</p> <p>Mentally I think of it more like switching between UK/US driving, it takes only a couple of seconds for the thinking part of your brain to accept/know/whatever that the rule is X or Y ... but after years of exposure the non-thinking part of the brain just does things on it&#39;s own sometimes and is wrong, so the thinking part of your brain trusts it a little less.</p> <p>And it&#39;s almost never the order of &#34;data string&#34; vs. &#34;string data&#34; but the parsing order of the type &#34;[]string&#34; vs. &#34;string[]&#34; and sometimes the &#34;x, y string&#34; shortcut. This is esp. annoying with the parsing order because I know it&#39;s not just different but better the non-C way.</p></pre>throwawaybeginr: <pre><p>thanks for this!</p></pre>adiabatic: <pre><p>It was weird for a while, but the rationale made sense. </p> <p>I still tend to get tripped up by omitted types in longer function definitions like <code>f(a A, t, u T, z Z)</code>. I&#39;ll look at something like that and wonder what the type of <code>t</code> should be. </p></pre>holyjeff: <pre><p>No for me go&#39;s way feels more natural.</p></pre>superchalupa: <pre><p>No.</p></pre>PaluMacil: <pre><p>Not even at first (while I do C#, I also do TypeScript which is the same order as Go).</p></pre>BadlyCamouflagedKiwi: <pre><p>Nope.</p> <p>It annoyed me probably more than anything else about the language at first, but at some point I got used to it and now I find it fine. I&#39;m not sure I like it better overall but that&#39;s just taste; it&#39;s certainly at least as good if taken in isolation from previous experience.</p></pre>nhooyr: <pre><p>What&#39;s with all the down votes on the OP?</p></pre>
44 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传