Implement Java track #933

sit opened this Issue Oct 30, 2013 · 16 comments


None yet

5 participants


It should be simple enough to get people set up with JUnit to run tests.

Happy to get started on this if there is interest.

Minimum Exercises to Implement

The following exercises are required to be created for the path to be launch.

  • bob
  • hamming
  • word-count
  • anagram
  • nucleotide-count
  • phone-number
  • grade-school
  • robot-name
  • etl
  • meetup

Additional Exercises to Implement

After the initial set of exercises the following should be implemented to have a more complete test suite.

  • space-age
  • gigasecond
  • triangle
  • scrabble-score
  • roman-numerals
  • binary
  • prime-factors
  • raindrops
  • allergies
  • strain
  • atbash-cipher
  • accumulate
  • crypto-square
  • trinary
  • rna-transcription
  • sieve
  • simple-cipher
  • octal
  • luhn
  • pig-latin
  • pythagorean-triplet
  • series
  • difference-of-squares
  • secret-handshake
  • linked-list
  • wordy
  • hexadecimal
  • largest-series-product
  • kindergarten-garden
  • binary-search-tree
  • matrix
  • robot-simulator
  • nth-prime
  • palindrome-products
  • pascals-triangle
  • beer-song
  • sum-of-multiples
  • queen-attack
  • saddle-points
  • ocr-numbers
  • simple-linked-list
  • linked-list
  • point-mutations

Not Allowed to Be Implemented

These exercises were inspired by Java Ranch and are not allowed to be implemented.

  • leap
  • grains
  • say
exercism member

Sure! There's one caveat for Java, and that is that we cannot port any of the exercises that are inspired by the JavaRanch Cattle Drive (leap, grains, and say). Other than that, it's all fair game.


@sit I updated your original post and added checkboxes for all the exercises that are currently defined across all the tracks. This is generally in the order defined by the ruby track.


@kytrinyx what would be a minimum number of exercises necessary to take a track live?

I'm assuming that you have good insight to the number of completed exercises by users in a track. We could probably go live with a track after it has a number of assignments that 80% of the people would complete.


@burtlo Thanks!

In addition, I guess there will be the task of adding help blurbs etc. to the website. Is there any client-side work needed?

exercism member

@burtlo It looks like 10 exercises is a decent number to get started.

We need:

  • An icon in frontend/app/css/style.css
  • A help file: lib/app/views/setup/$LANGUAGE.erb
  • An entry in lib/exercism/curriculum.rb
  • A curriculum definition in lib/exercism/curriculum/$LANGUAGE.rb

I'll add this to the CONTRIBUTING file.

I can't think of any client-side work that needs to be done.


Sit, do you need any help? I can write some of these if you want as well.

sit commented Nov 4, 2013

@sentientmonkey @burtlo et al,

I started off with Bob on the java branch on my fork of the repo. We can either merge them into that branch and then have @kytrinyx merge it all once it's done, or we can do it incrementally onto a Java branch here. Either way, you should be able to start with what I have to port the individual exercises and we can figure out the workflow as we go.

exercism member

Just send pull requests to master here with any ported exercises. As long as the curriculum isn't included in the exercism curriculum it won't go live.

@sit sit added a commit to sit/ that referenced this issue Nov 5, 2013
@sit sit java: Start track with Bob
This is the complete skeleton for enabling Java, from curriculum
through the first exercise. Java is listed in the main curriculum.rb
but commented out; we will activate once there are a sufficient body
of exercises ported.

The java.png icon is taken from,
released under a freeware license.

Describe how to minimally set-up Java and JUnit. (Future work may
try to see if we can get Locale.additional_files working and provide
build integration via Gradle or Maven.)

The BobTest is a straight up port of the Python Bob.

This starts the path of fixing #933.

Looking at how other Languages exercises are setup, shouldn't we make java & gradle as pre-requisite setup. Therefore the assignment project just need build.gradle buildfile without gradle binaries and batch/shell scripts as part of assignment.

Apology for cross posting from the Pull Request #1046. Just want to start conversation regarding this and I'm worried that Pull Request was already closed, so I move the post here.

sit commented Dec 5, 2013

@wdjunaidi: I think the less work needed to get started, the better. Many Gradle projects (including my production code at work) use the Gradle wrapper instead of having developers install Gradle locally, which simplifies upgrades etc. Including these files simplifies things and should work across all platforms (so long as java is installed).


I agree the less work needed is better. However, if I understand it correctly, current implementations has 2 options:
1. Every assignment has it's own copy of gradle wrapper checked in with it. Which from coding point of view failed the DRY principle. Secondly, just because github host the open source project for free that we should take advantage of it like this.
2. I see that you started creating _template folder which contains the wrapper, but the wiki documentation still mention about user has to manually copy those into their exercises folder. This does not seems like less work for me. At least if they have to install gradle, they only need to do it only once..not counting if they already have it on their system.

If the intention is to have exercism fetch command to automatically copy the _template folder for user, than it is great. Until such feature exist, it is better to ask user to install gradle than having them copy those folder manually for each exercises. From UX point of view, it will be more consistent. Earlier user are asked to install gradle and use the project as is, when smart fetch is available later user doesn't have to install gradle, but neither user has to go through manual copy step.

sit commented Dec 5, 2013

Thanks for raising these points, @wdjunaidi. Let me see if I can address them all. I think you have two main points:
1. Simple/consistent UX
2. Avoiding duplication of build-y stuff.

In terms of the UX, there is no need for the user to manually download the files or copy them. (I didn't write any wiki pages; which ones are you referring to?) My understanding of how the system works is that each end user simply runs exercism fetch and the exercism client will download everything (all the non-DRY copies of the gradle wrapper etc) into each exercise's directory. @kytrinyx, please correct me if this is incorrect. So all anyone would have to do is exercism fetch; cd exercise; ./gradlew check which is uniform UX across all exercises.

The _template folder is for developers only. It is intended to simplify creating new exercisms and indeed yes, the current intent is not DRY and replicates the process for each folder. But arguably each exercise is a separate project and the Gradle model is in fact for each separate project to have a separate set of wrapper files.

The usage of _template is documented in the commit that uses the _template folder; I apologize if the message in the parent commit that introduced _template was confusing about who has to do the copying.

In terms of duplication (e.g., GitHub hosting us for free), I think you are worried about repository bloat and asking GitHub to store many copies of certain files. Fortunately, Git is very efficient at finding duplicate content and storing only one copy of it. You can see this for yourself by looking into Git's internal representation of the source:

$ git ls-tree -r HEAD assignments/java/ | grep gradle-wrapper.jar
100644 blob 667288ad6c2b3b87c990ece1267e56f0bcbf3622    assignments/java/_template/gradle/wrapper/gradle-wrapper.jar
100644 blob 667288ad6c2b3b87c990ece1267e56f0bcbf3622    assignments/java/bob/gradle/wrapper/gradle-wrapper.jar
100644 blob 667288ad6c2b3b87c990ece1267e56f0bcbf3622    assignments/java/phone-number/gradle/wrapper/gradle-wrapper.jar
100644 blob 667288ad6c2b3b87c990ece1267e56f0bcbf3622    assignments/java/word-count/gradle/wrapper/gradle-wrapper.jar

As you can see, the SHA hash for all of the gradle-wrapper.jar files is the same showing that they all refer to the same object in the repository.

In terms of multiple copies of Gradle on the end-user machine, the Gradle wrapper installs the Gradle binaries into ~/.gradle and any projects that share the same Gradle version use the same download. That is, if you've installed Gradle 1.8 once for one project, any other project that uses Gradle 1.8 will use the same binaries. There is no excessive duplication on the user side either, and no manual steps for the user.

Along the lines of #1065, it would be interesting to have some sort of "common" project overlay that the exercism server side applies to generate the final set of files sent to each client. My inclination would be to hold off on cooking that up for now, as I'm not sure how to manage different overlays, such as common per-exercise data/code and common per-language files, and making a framework useful across all language/exercises. But maybe @kytrinyx wants to weigh in here.


Thanks for the comprehensive response. You definitely addressed my concerns, which raised out of my own ignorance of how git and gradle wrapper work :-P

Yes, I must have read the comment for _template folder and thought of it as wiki page.

sit commented Feb 5, 2014

Once @kytrinyx merges #1360, we will have the first ten exercises completed. What remains would be to:

  • take a pass over the ten exercises and standardize on things like test naming and assert style
  • maybe update to current Gradle
  • check exercises that may need updating for consistency with other langs (possibly grade school or rna transcription, I don't recall)
  • add the track and announce
  • port more exercises :-)
exercism member

Very cool! RNA Transcription did get tweaked, I'm not sure about Grade School. They don't need to be consistent across languages, but they do need to match the README. I try to make the README generic enough that each language could solve the problem in a way that is appropriate to that language.

@kytrinyx kytrinyx referenced this issue in exercism/xjava Feb 28, 2014

Implement Java Exercises #3

36 of 53 tasks complete
exercism member

Superseded by exercism/xjava#3

@kytrinyx kytrinyx closed this Feb 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment