<p>Here's my problem with learning programming. I understand all the basics. I understand variables, arrays, pointers , loops, deference, incremental, and so on, but I can seem to come up with the words to write a program. How do I come up with those words? For example<br/>
contract mortal {
/* Define variable owner of the type address*/
address owner;</p>
<pre><code>/* this function is executed at initialization and sets the owner of the contract */
function mortal() { owner = msg.sender; }
/* Function to recover the funds on the contract */
function kill() { if (msg.sender == owner) selfdestruct(owner); }
</code></pre>
<p>}</p>
<p>contract greeter is mortal {
/* define variable greeting of the type string */
string greeting;</p>
<pre><code>/* this runs when the contract is executed */
function greeter(string _greeting) public {
greeting = _greeting;
}
/* main function */
function greet() constant returns (string) {
return greeting;
}
</code></pre>
<p>}</p>
<hr/>**评论:**<br/><br/>shovelpost: <pre><p>Well first of all this doesn't look like Go code.</p>
<blockquote>
<p>but I can seem to come up with the words to write a program. How do I come up with those words?</p>
</blockquote>
<p>What words? What are you talking about?</p>
<p>You learn the basic keywords of the language. For example in Go when you want to make a struct you use <code>type XXX struct</code>.</p>
<p>If you are talking about words used to name the XXX struct the that depends entirely on the problem you are trying to solve.</p></pre>epiris: <pre><p>It looks like you need to familiarize yourself with the Go syntax. Luckily it's the simplest language syntactically you're going to find. the golang tour and gobyexample.com site should get you up and running in no time.</p></pre>gott_modus: <pre><blockquote>
<p>Luckily it's the simplest language syntactically you're going to find.</p>
</blockquote>
<p>Bro, do you even Python? Can you Lisp, dawg? </p>
<pre><code> Hey guys I come from Python what's this star thingy it crashed my code
</code></pre></pre>Killing_Spark: <pre><p>Hey guys i come from go and i copied some code from stackoverflow with weird indentation and it crashed my program</p></pre>gott_modus: <pre><p>C'mon: you can do better than that.</p></pre>comrade_donkey: <pre><p>Hello, I come from PHP and what's this bitcoin thing? It says if I don't pay they won't give me back my MySQL server. Also, why do I have to restart Apache every hour?</p>
<p>Hi I come from Haskell and why is my monoid in the category of endofunctors slow?</p>
<p>Howdy I'm a corporate enteprise vice executive Java development engineer and do I really need my IntCreatorFactoryServiceProviderInterface?</p></pre>gott_modus: <pre><p>Well, my point was that Go isn't the simplest syntactical language out there. Java is probably the simplest, if only because Python has weird semantics with scoping and major power features, etc</p></pre>__crackers__: <pre><p>Python's rather more complex than Go these days, tbh. </p>
<p>Decorators, iterators, generators, coroutines, metaclasses.</p>
<p>It is higher-level, though.</p>
<p>Lisp, well, I just can seem to get my head around it. One day, though, and on that day I shall be enlightened.</p></pre>gott_modus: <pre><p>With Python you don't have to worry about memory addressing, though. And the code is fairly terse. To each their own, of course.</p></pre>ChristophBerger: <pre><blockquote>
<p>How do I come up with those words?</p>
</blockquote>
<p>Tip: Read and learn from existing code. Tip inside the tip: Have a look at <a href="http://rosettacode.org/wiki/Rosetta_Code" rel="nofollow">rosettacode.org</a>. They collect code for all sorts of algorithms, data structures, etc. and for all sorts of languages.</p>
<p>Here is the <a href="http://rosettacode.org/wiki/Category:Go" rel="nofollow">Go category</a>, or browse the <a href="http://rosettacode.org/wiki/Category:Programming_Tasks" rel="nofollow">Programming Tasks</a>, or do a search for the particular example you are interested in.</p></pre>gopher1717: <pre><p>If you want to learn the language, take a look at these two very simple tutorials:</p>
<ul>
<li><a href="https://tour.golang.org/welcome/1" rel="nofollow">Go Tour</a></li>
<li><a href="https://gobyexample.com/" rel="nofollow">Go by Example</a></li>
</ul></pre>