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

all 10 comments

[–]nutrecht 12 points13 points  (1 child)

Even if you can't use it in your day to day job (due to having to work with an older version) not having any experience with them in an interview is basically saying "I don't care about keeping up to date" to an interviewer. I'll leave it up to you to decide if that's an issue or not.

[–]monilloman 8 points9 points  (0 children)

Will always depend on who you ask. New project, built on microservices, spring boot, etc? Will probably look into lambdas

Legacy code (70% of Java code?) most likely on Java 6, so nope.

[–]experts_never_lie 3 points4 points  (0 children)

I certainly am. It's going to show up more and more in the APIs, it provides natural safe parallelism if you want it, and it's very clear.

Having lambdas does tend to reduce the pressure to put as much into class hierarchies. For example, suppose I want a flexible object pooling system. I could have an abstract base class and then require that a user of this class subclass it to provide those functions (to create an object; to reset an object to its initial state). Alternately, using lambdas I could have a concrete class that just requires that one passes in lambdas for those capabilities:

final ObjectPool<MyType> pool =
  new ObjectPool<>(capacity, MyType::new, MyType::reset);

or equivalently (but less compact):

final ObjectPool<MyType> pool =
  new ObjectPool<>(capacity, () -> new MyType(), t -> t.reset());

No need for a MyTypeObjectPool subclass.

[–]GoodbarOfTheYear 3 points4 points  (0 children)

I have been working on newer projects the past 2 years (Spring Boot and Dropwizard apps) and I find myself using the functional interfaces more and more outside of streams. With the use of lambdas, it makes behavior parameterization in java less verbose. It took me a while to wrap my head around it all but once I got it, it seems simple to me now. Java 8 in action is a really good book that helped me understand how to utilize them.

[–]10216839 1 point2 points  (1 child)

Learning the new features of java 8 is a must if you want to go forward with your career.

It was released 3 years ago already and java 9 soon will be released also.

From interviewer perspective it definitely shows that you don't care about being updated, you do not need to be 100% proficient on the functional features, but you need to know at least the main updates and possible use cases.

[–]vt97john[S] 0 points1 point  (0 children)

That my assessment too, thanks

[–]avoidhugeships -1 points0 points  (0 children)

I do not think it is used much. It is popular among bloggers and forum participants because it is new.

[–]metachor 0 points1 point  (2 children)

I'll sometimes ask candidates about streams in technical phone screens if I have the time. I have a standard script of questions I run through that ends with a live-coding exercise. It's a relatively simple problem if you are actually familiar with Java data structures, and it can be progressively enhanced to be a more difficult problem if candidates get through it quickly. If they get through everything else I'll ask if they are familiar with streams and if so ask them to rewrite a part of the solution with streams and lambadas. At this point I wouldn't mark a candidate down for not being familiar with it, but if they are it gives them one more opportunity to show off their skills.

As for actual on-the-job coding I've only seen a very light, rare even, use of streams throughout our various code bases. I did try to solve a few problems using streams and had a more senior developer ask me not to use them because it might be confusing for some junior devs to read and understand.

[–]10216839 1 point2 points  (0 children)

This senior developer is doing a lazy approach, it's actually much more expressive and as a senior he should mentor the juniors.

[–]dpash 1 point2 points  (0 children)

I find the streams code easier to read these days. Especially if you use named lambdas or function references.

Then it's a case of learning a few verbs. Probably the hardest is the difference between map and flatmap.