
99-problems in Java 8, Scala, and Haskell - shekhargulati
https://github.com/shekhargulati/99-problems
======
egeozcan
I find the language percentage information (~ Java 57%, Scala 37%, Haskell
5%)[1] a bit scary (and admittedly hilarious), given that I have only serious
experience with Java among the three.

[1]: [http://i.imgur.com/zRwFzSC.png](http://i.imgur.com/zRwFzSC.png)

~~~
stepvhen
Well the 99-problems were originally in Prolog, and many have to do with list
manipulation, something that Haskell has built in. Additionally, Haskell will
benefit from its lazy, functional nature, which makes dynamic programming,
searching, and even some data structures a little cleaner.

I haven't worked with Java in quite a while, but I imagine that it still
requires a lot of boilerplate and set up for trivial things in other
languages. I'm sure if C were also included it would be the most verbose.

~~~
spullara
Java does still include some boilerplate for setting up classes — though that
may go away in 10 when they add scripting. However, it is a lot more terse
than in 7:

    
    
      package com.shekhargulati.ninetynine_problems._02_arithmetic;
    
      import java.util.stream.LongStream;
    
      /**
       * (**) Determine whether a given integer number is prime.
       */
      public class P31 {
    
        public static boolean isPrime(long number) {
            return !LongStream.rangeClosed(2, Math.round(Math.sqrt(number))).anyMatch(n -> number % n == 0);
        }
      }

------
krat0sprakhar
OCaml version:
[https://ocaml.org/learn/tutorials/99problems.html](https://ocaml.org/learn/tutorials/99problems.html)

------
sean_the_geek
Warning:shameless promotion, here's my 'R' take on 99 problems, needs working
on though!
[https://github.com/saysmymind/99-Problems-R](https://github.com/saysmymind/99-Problems-R)

------
cjlarose
Maybe someone who knows more about logic programming can correct me, but it
seems that these are just imperative solutions to problems designed to be
solved in a logical programming context.

For example, take a look at problem 2.07 from the original 99-problems for
[Prolog][1] and compare it to the [Java][2] solution in the linked repo. In
Prolog, you're defining relations, so with GCD defined, you can compute the
GCD (g) given two integers a and b, but you can also compute possible values
for b, given a and g, for example. The Java solution doesn't allow for
anything like that.

So, given the README information, I expected to see the implementations in
different language platforms utilize some prolog-esque logic programming
library (like core.logic for Clojure), but that isn't the case.

[1]: [https://sites.google.com/site/prologsite/prolog-
problems/2](https://sites.google.com/site/prologsite/prolog-problems/2) [2]:
[https://github.com/shekhargulati/99-problems/blob/master/jav...](https://github.com/shekhargulati/99-problems/blob/master/java8/src/main/java/com/shekhargulati/ninetynine_problems/_02_arithmetic/P37.java)

------
agentgt
For the Java version I would seriously consider not using JUnit 4's assertThat
and instead rely on AssertJ [1].

Besides AssertJ being easier to use and IMO more elegant than Hamcrest, JUnit
5 will be removin `assertThat`.

I contemplated filing a bug/request but its more of a conversation point than
an issue.

[1]: [http://joel-costigliola.github.io/assertj/](http://joel-
costigliola.github.io/assertj/)

~~~
coredog64
According to this issue[1], JUnit5 will still allow the use of Hamcrest's
'assertThat' in the next major revision.

[1]: [https://github.com/junit-
team/junit5/issues/147](https://github.com/junit-team/junit5/issues/147)

~~~
agentgt
How is that possibly if Hamcrest isn't going to be put in?

I think you misread that bug report.

    
    
       >Closing this issue since there are no plans to include direct dependencies on third-party assertion libraries within JUnit 5.

------
RodgerTheGreat
K version: [https://github.com/kevinlawler/kona/wiki/K-99%3A-Ninety-
Nine...](https://github.com/kevinlawler/kona/wiki/K-99%3A-Ninety-Nine-K-
Problems)

------
joeblau
I've never used Haskell, but it seems like everything in Haskell can be done
in one line :).

~~~
griffinmichl
It helps that everything in haskell is an expression

~~~
dllthomas
Everything but declarations, anyway.

------
NKCSS
when I read that headline: "... but a B*tch ain't one!"

~~~
parennoob
I'm guessing people are downvoting this comment because they don't want the
Redditization of HN.

If it's any consolation, that was the first thing I thought as well. I even
thought the problems would make some joke reference to the song.

However, it seems as if Werner Hett at the Berner Fachhochschule came up with
this independently of Jay-Z.

~~~
user_0001
Ice-T, Jay-z copied it about 10 years (probably more) later

~~~
lgas
Everyone always forgets about Brother Marquis.

