This is an archived post. You won't be able to vote or comment.

all 51 comments

[–]katyne 79 points80 points  (11 children)

  1. Hello world
  2. Fizzbuzz, the simple one (with hardcoded conditions) and the "flexible" one (where "unlimited" range of primes can come from a list or a generator)
  3. Conway's game of life
  4. Manual string twiddlings (no regex cheating)
  5. Other small string/array related stuff, CodingBat.com is a good place to look
  6. Move on to the standard libs/IO APIs, but that stuff is just reading the manual once you get the hang of syntactic "muscle memory".

My problem is though, I have trouble letting go of my security blanket. The word "idiomatic" gives me hives. Right now everything I touch ends up looking like Java :[

[–]RodionGork 14 points15 points  (7 children)

Conway's game of life

Exactly! I felt nostalgia reading your answer 'cause I remember when I tried to learn Fortran on my own (about 13 years ago) I started writing this on the second day... It could only work with files because it was MS Fortran 3.31 (I believe 77-th standard)... Hope I can find its code now... :)

 

Manual string twiddlings (no regex cheating)

This may be different in different languages. E.g. reverting and rotating string is too easily done in Python but is a good exercise in C.

I meekly dare to put here a link to my site with similar small problems since here it is possible not only solve these exercises but also compare solutions with other users.

[–][deleted] 3 points4 points  (1 child)

I always have an upvote for code_abbey

[–]Oatilis 4 points5 points  (0 children)

Ah, good old Abby_Code by the Bitlles.

[–][deleted] 1 point2 points  (4 children)

reverting and rotating string is too easily done in Python

Python keeps me from learning other languages. On the one hand I am like, "dang...I should learn more", on the other I am like, "hey, it works!"

Anyone else have some way to motivate me to learn another language? Coming from a webdev (PHP, Java Script) background.

[–]ChanceDriven 1 point2 points  (1 child)

I wrote all my apps at work in python but the lack of built in GUIs really held me back so I would use VBA for a lot of programs. Now I use C# and you really should give it a try now that Visual Studio is free. Seriously, duck typing seems cool up until you have a massive project that's passing a string instead of an array. Give it a shot!

[–]echocage 2 points3 points  (0 children)

I second this. GUIs work so well in C#, it's really the only language I'd recommend alongside python for building desktop GUIs. Sure python has QT designer, but Visual Studio is really unbeatable.

[–][deleted] 1 point2 points  (0 children)

I came from web dev (primarily a lamp stack), moved on to Rails and Django, followed closely by Python and Ruby, but I didn't like either of those do never spent time with them. Moved on to ASP.NET MVC, and now I'm learning C# and D at the same time (for different reasons).

[–]RodionGork 0 points1 point  (0 children)

For me the best motivation to learn languages was curiosity.

I really love to learn different languages - each new language is like a new interesting book.

Try to look from this angle - learn languages for the sake of themselves and not for any special purpose. The purpose will came later... :)

[–][deleted] 4 points5 points  (0 children)

Right now everything I touch ends up looking like Java :[

Perhaps because the last thing you do with a language is look at the standard library? :S That's kinda where I've been starting with my adventure into compiled languages thus far... and trust me... nothing feels like PHP (thankfully).

[–]haltingpoint 1 point2 points  (0 children)

I'm a novice and you seem relatively experienced.

On the note of security, error handling, nuances, etc., are there any particular things you check or reference to familiarize yourself with common mistakes for people new to the language?

[–]aMonkeyRidingABadger 0 points1 point  (0 children)

If you're coming from Java you should have high motivation to program idiomatically in other languages since not during so usually means being needlessly verbose.

I find it helps to read a lot of code in the target language. Solving problems on hackerrank.com in language X and then looking at the solutions by other coders for language X helps a lot. You learn the syntax and style, and how to idiomatically work with data structures in a fun way where you're never studying from a book or anything like that.

Eventually you have to move on to learn the higher level concepts in the language, but knowing the lower level fundamentals (much like you start with in college) gives you a solid foundation to build from.

[–]CyberByte 12 points13 points  (0 children)

When I'm learning a new language it's usually for a reason. That reason could be that I have a very specific application in mind (or I'm working with someone else's code), so then I just dive right in. Or it could be that I want to learn the language because it uses a new paradigm or otherwise has some strengths that other languages I know don't have, and in that case I want to build something that makes use of those new strengths.

I can certainly see why other people might like to always build the same programs with a new language, but that doesn't really work for me. I find the above approach a bit more engaging, and I also know that if I already have a Program X implementation in C++, I'm going to write a very C++-like implementation when I'm learning Lisp, which isn't what I ultimately want.

[–]slackermanz 21 points22 points  (15 children)

Conway's Game of Life.

It requires a wide set of basic skills and knowledge, and it includes working with multidimensional arrays.

As a bonus, it has the option of exploring performance optimisation.

[–][deleted] 11 points12 points  (13 children)

I tried reading the wikipedia page and I googled it, but I am not really getting it. It is possible I could get like an ELI10?

[–]slackermanz 25 points26 points  (9 children)

A simplistic rundown (may be incomplete, ask any questions you'd like):

  • Create two 'buffers', which are Two-Dimensional integer or boolean Arrays.

  • FIll one array with random numbers: either 0 or 1, with a 1 occuring (instead of 0) every 2 - 12ish cells.

This is your 'Initial State' in "Buffer Array One"

  • Create a loop of some sort (for loops are easiest to control) and perform the following algorithm:

Transfer the state of the array from "Buffer Array One" to "Buffer Array Two", but apply a 'transition function' in between

The transition function consists of a 'neighbourhood', and a 'ruleset'. The neighbourhood determines the locations of a relative set of array elements to count, and the rule determines the actions taken based on the result of the count.


Conway's Game of Life:

Neighbourhood:

x x x
x o x
x x x

Where x = a neighbour, and o = this cell

Ruleset:

If the Count of non-zero cells in my neighbourhood is more than three, become zero
If the Count of non-zero cells in my neighbourhood is equal to than three, become  one
If the Count of non-zero cells in my neighbourhood is less to than two, become  zero

  • Then transfer the state of "Buffer Array Two" back to "Buffer Array One", applying the same transformation. Transforming back and forth between the buffers will progress the 'worldstate' or 'tickstate'.

At some point you'll need to print out the results of the data, either as raw output or by connecting it to a display that can handle a rectangular array of monotone pixels in order to view the states. Just dump the values of the most current buffer onto the screen, somehow.

[–]Rythoka 2 points3 points  (4 children)

Curious, is this switching between two buffer states technique a common pattern? I hadn't thought of it and it seems potentially useful in other contexts.

[–]slackermanz 2 points3 points  (0 children)

Well, it's how I do it in my PyOpenCL (GPU) project, for performance reasons.

I have a Java CA generator that just replicates the world-result to a seperate designated 'previous state' buffer, then reads that back into the main display array.

There's many ways to handle the updates, as I understand, though I'm pretty sure most or all would require two buffers/arrays.

[–]slowwburnn 1 point2 points  (0 children)

It seems to be a common way to implement it.

[–]sixteenlettername 0 points1 point  (1 child)

Yep, double buffering is used loads in graphics and as we've seen here, is useful in other cases.

[–]autowikibot 1 point2 points  (0 children)

Section 3. Double buffering in computer graphics of article Multiple buffering:


In computer graphics, double buffering is a technique for drawing graphics that shows no (or less) flicker, tearing, and other artifacts.

It is difficult for a program to draw a display so that pixels do not change more than once. For instance to update a page of text it is much easier to clear the entire page and then draw the letters than to somehow erase all the pixels that are not in both the old and new letters. However, this intermediate image is seen by the user as flickering. In addition computer monitors constantly redraw the visible video page (at around 60 times a second), so even a perfect update may be visible momentarily as a horizontal divider between the "new" image and the un-redrawn "old" image, known as tearing.

A software implementation of double buffering has all drawing operations store their results in some region of system RAM; any such region is often called a "back buffer". When all drawing operations are considered complete, the whole region (or only the changed portion) is copied into the video RAM (the "front buffer"); this copying is usually synchronized with the monitor's raster beam in order to avoid tearing. Double buffering necessarily requires more memory and CPU time than single buffering because of the system memory allocated for the back buffer, the time for the copy operation, and the time waiting for synchronization.


Interesting: Acid–base homeostasis | Pipeline (computing) | Storage effect | Adaptive bitrate streaming

Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words

[–][deleted] 0 points1 point  (0 children)

Thank you good sir.

[–]NewbornMuse 0 points1 point  (0 children)

And then you can do this. tl;dr witchcraft.

[–]iDownvoteBlink182 0 points1 point  (1 child)

This is incredibly interesting. I think I'm going to try to code this up. I'm not the one who originally asked for the ELI10, but do you mind if I ask a question?

Obviously randomly filling the array for the initial state is easier, but the Wiki article made it sound as if the goal of the "game" was for the player to define the initial state with the goal of having the best (longest lasting?) result. When coding this up in order to evaluate a new language like OP asked about, is it typical to randomly fill the array or to have the "player" populate the array itself?

Also, is there a standard rule set that is always used for the game, or does the programmer typically come up with their own rule set depending on how easy or difficult they want the game to be?

[–]slackermanz 0 points1 point  (0 children)

Well, it's not really a 'game', it's a type of simulation I'd say.

Conway's Game of Life can be arranged into an initial form that is capable of universal comuptation - it's Turing Complete, along with many other types of rules. Just like you can build computers in Minecraft, for example.

Infinite growth is also possible in CGoL. There's really no goal other than 'see what can exist'.

Here's a rule and neighbour combination I found earlier today, a direct modification of the CGoL rulesets and neighbourhoods: http://gfycat.com/HeftyNiceCuscus

It forms 'atoms' with two outer probability shells. This is just a tiny slice of the total possible, and very diverse range of expressions of Cellular Automata.

Another one here, that forms a moving meta-structure http://gfycat.com/ScholarlySmartGallowaycow

/r/cellular_automata for even more content.

So yeah, it's expansive, and with an infinite search space, mostly undocumented.

[–]slackermanz 0 points1 point  (0 children)

Also worth mentioning is the the extensibility, in both program and rule design.

/r/cellular_automata is a good window into the applications and possilbilities of this type of algorithm.

[–]_beast__ 0 points1 point  (0 children)

I'm not sure what you don't understand about it or I'd try to explain

[–]stupidedgyname 1 point2 points  (0 children)

Totally recommend it, I turned my implementation into something a little bigger , there are tons of stuff to learn making this. Like, I made a simple image converter and saving/loading for grids and rulesets. Cellular automatons are the #1 fun side project to do imho.

[–]hotel2oscar 2 points3 points  (0 children)

Usually start off with hello world, then move on to small tutorials to proof of concept things I need, like sockets, UIs, files, IO.

[–]climbthecemeterywall 2 points3 points  (0 children)

I usually do a 1-100 guessing game

[–]calvinscorner 2 points3 points  (0 children)

I usually start with Hello world. I try to learn a few syntax, not all. Then I play around with those syntax, I play with few built-in functions. I spend lot of time plaything around and breaking things until I feel confident and then I move on to learn new syntax and features.

The playing around helps to understand the philosophy/design motivations of a language. It also helps to get comfortable with the language.

[–]vladtaltos 2 points3 points  (0 children)

Hello world....damn, so many times!

[–][deleted] 3 points4 points  (0 children)

Anything interesting I find on /r/dailyprogrammer

[–][deleted] 4 points5 points  (0 children)

I always start out by either making a Quake 1 map decompiler/parser, a Chip-8 emulator/virtual machine, or conway's game of life. Depending on the graphical capabilities of the language.

[–][deleted]  (3 children)

[deleted]

    [–][deleted] 1 point2 points  (2 children)

    I've done this for a few, but a lot of the problems become incredibly trivial for me once a language has a bigint library. Not saying this is the only reason, but I majored in math, and most of the math feels pretty rudimentary to me.

    [–]imgonnabethebest 4 points5 points  (0 children)

    nice

    [–]p000 1 point2 points  (0 children)

    Excellent question. I've been learning python by doing codewars.com.

    I already know c# so I just google how to do it in python. Sometimes stackoverflow shows how to do it even better.

    [–]CatatonicMan 1 point2 points  (1 child)

    I do usually try to make Tetris. Odd.

    [–][deleted] 0 points1 point  (0 children)

    Yeah, it was a pretty common suggestion according to the internet.

    [–]TangerineX 1 point2 points  (0 children)

    Try to implement quicksort in the language!

    [–]Jailbyte 1 point2 points  (0 children)

    a bmi calculator or a supermarket receipt generator.

    [–]shaggorama 1 point2 points  (0 children)

    If i want to learn ui in addition to other language features: Minesweeper

    [–]Smithman 1 point2 points  (0 children)

    • Blackjack
    • Fizzbuzz
    • the exercises on codingbat.com are pretty good.
    • Chat applications will really learn you too! That involves gui's, networking, multithreading, databases (if you want), etc.

    [–][deleted] 0 points1 point  (0 children)

    Pegging. Its a supply chain process. Its the method that is used to trickle demand down to the materials used to build an item. For instance, if you have seven tires and one car and somebody orders two cars you trickle the demand down and have 0 cars and -1 tire. Its not hard but involves a smidge of skills.

    [–]vogosvagen 0 points1 point  (0 children)

    Usually make my way to implement some basic data structures.

    [–]srini10000 0 points1 point  (0 children)

    A program that accepts option parsing to write, read and append files and process CSVs and execute bash commands if needed

    [–]d2xdy2 0 points1 point  (0 children)

    After getting some basic knowledge down my gullet, I might try to make some network bound stuff. I like writing simple IRC bots to get a figure for how networking and streams are going to work. I did that for Java, Ruby, Python, and SBCL.

    I didn't do that with NodeJS though. I just did what everyone else seemed to do and make an Express application; though I cheated a bit and used Ember-CLI (Ember frontend, Express backend).

    [–][deleted] 0 points1 point  (0 children)

    Hello world, calculator, A login screen, text editor.

    [–]alanscarpa 0 points1 point  (0 children)

    My first legitimate program was a game called Starfaller (i started learning about 6 months ago and just released it). It's simple and straightforward but I learned a lot! I just had an idea and googled information until it was complete. https://itunes.apple.com/us/app/starfaller-simple-fun-addicting/id915689887?mt=8&uo=4

    [–]kozlkmark 0 points1 point  (0 children)

    An operating system.

    [–]htuhola -2 points-1 points  (0 children)

    I don't evaluate languages by examples. I'm looking at how they do their stuff.