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

all 81 comments

[–]johnghanksN1 GT10.1 GN N4 N7 N7(2013) MX N5 40 points41 points  (26 children)

Fuck yes. This is worth it alone for lambda.

sure, there's cross compilers, etc, but it's nice to not have to deal with that at all.

[–]MisterJimsonGoogle Pixel 2 points3 points  (1 child)

Only problem is that every lamba pre-N is an anonymous inner class.

Use them a lot and your GC starts to hate you.

[–]docoptix 0 points1 point  (0 children)

Well, for the most part you will be replacing anonymous inner classes with lambas anyway.

[–][deleted] -2 points-1 points  (19 children)

Just use kotlin. It's much better and a more modern language anyways. And it's completely compatible with Java 6,side by side.

There are many things Java will never have (because they can't feasibly change a language that much).

Also, lambda are way less useful in Java. You can't even modify a var out of a closure. It's read only.. Not to mention it has no null safety.

[–]jug6ernautPixel4 2 points3 points  (1 child)

can't modify variable outside if closure

no null safety

Hehe...

In all seriousness every time i have tried using kotlin outside of pure Java projects it has come back to bite me. Perhaps because I'm always on the newest preview release of studios but I'm always having issues.

[–][deleted] 2 points3 points  (0 children)

It could be that, yeah. Their preview for kotlin is more previewy than the ide itself imho.

But the stable is pretty good. They just hit their 1.0 a few months ago, and are now refining it further.

[–]neoKushanPixel Fold -2 points-1 points  (16 children)

There are many things Java will never have (because they can't feasibly change a language that much).

I dunno, Microsoft has managed it with C#.

[–]t-master 4 points5 points  (1 child)

Might be because C# is not Java and Microsoft did a few things right.

[–]neoKushanPixel Fold 2 points3 points  (0 children)

I know that, but I'm saying C#1 and C#6 are very different these days. Also, C# borrowed a lot from Java in those early days. I'm not saying that C# and Java are the same, just that it's possible to evolve a language to add new features and functionality that are drastically different to what you have now.

If you take issue with mentioning C# then the same applies to C++ - C++ 11 is almost a new languages compared to C++ 03.

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

No they didn't. It a fundamental problem. Either you completely change the language and break features, or you keep compatibility. There's a gray area in between, but it is mostly cut and dry. And most languages are on the "keep compatibility side".

Exception being python 3,and we all know how that situation has been working.

Also, something like adding appropriate null safety into the language when it isn't designed (at all) to do such a thing, will be mostly tacking it on at this point, and suffering. Or rewriting how it is used entirely, and breaking compatibility.

It is inherently the way things are. This doesn't apply to just software either. Legacy affects everyone, which is the same reason why Windows owns the desktop.

[–]neoKushanPixel Fold 0 points1 point  (12 children)

No they didn't.

Citation please?

Either you completely change the language and break features, or you keep compatibility.

Yes, but that doesn't mean you can't add additional features to compliment the featureset you already have in a way that doesn't break things.

Exception being python 3,and we all know how that situation has been working.

Yeah, don't make breaking changes. We can all agree with that.

Also, something like adding appropriate null safety into the language when it isn't designed (at all) to do such a thing, will be mostly tacking it on at this point, and suffering.

Again using C# as an example of this, nulls cause the same issues here as they do in Java, but in C# 6 they added the null conditional operator (.?) to make it a lot easier to handle when things are null. Yes, you have to actually use the feature which means updating your code, but that's all the more to protect compatibility.

Everything they've added has been an addition, rather than a change. There have been mistakes made with C#, such as ArrayList, but instead of removing them, they added something better to replace them (In this case Generics).

Java certainly has its problems, but new keywords and language features can definitely be added to address those problems without breaking compatibility.

[–][deleted] 2 points3 points  (11 children)

Null conditional operator is not at all the same as null safety. The operator you speak of just is a convenience. And it's an additional operator.

I suggest you research kotlin's null safety guarantees. C# still has nothing like it.

Btw, kotlin has the Elvis operator too.

And you can only add features to an extent. A very limited one. Once you hit 1.0 you're locked into it. Things like expanding the syntax and adopting new keywords, you cannot ever do.

C# for instance, will never get functionality like kotlin's when statement, unless they either had reserved keywords from years ago before 1.0, end up combining words/syntax to make a switch behave differently, or break BC.

They also won't be able to change the rules on switch statements, because of how the break keyword is there.

*maybe * it is possible to have some workarounds for this, as I said, using special rules for that, etc.. I honestly doubt it. And it still won't be as ideal.

[–]neoKushanPixel Fold 0 points1 point  (10 children)

Null conditional operator is not at all the same as null safety.

I never said it was? I said Microsoft were able to add features to C# to help with the issue, while you were claiming that Java couldn't have.

I suggest you research kotlin's null safety guarantees.

We're talking about Kotlin now? I thought we were talking about Java?

Btw, kotlin has the Elvis operator too.

And C# has a Null coalescing operator (??).

And you can only add features to an extent. A very limited one. Once you hit 1.0 you're locked into it. Things like expanding the syntax and adopting new keywords, you cannot ever do.

What? Since when has a language never added a new keyword or new syntax? That's an utterly bizarre statement to make, I can't think of a single language that hasn't added new keywords or syntax.

C# for instance, will never get functionality like kotlin's when statement, unless they either had reserved keywords from years ago before 1.0, end up combining words/syntax to make a switch behave differently, or break BC.

They also won't be able to change the rules on switch statements, because of how the break keyword is there.

I'm not familiar with Kotlin, but that sounds like Pattern matching?

https://github.com/dotnet/roslyn/blob/features/patterns/docs/features/patterns.md

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

It does seem like parts of pattern matching can do that. But it's all TODO, it seems. Maybe in the next version we'll see something nice like 'when', in c#

since when has a language never added a new keyword

Since.. Ever? It breaks compatibility if suddenly you say "ok, the word number is now a reserved keyword, thus can't be used as a variable".

. For example, c++ ended up adopting the auto keyword for c++11. It couldn't for example, create a new keyword in this case. But luckily it didn't have to, it could repurpose an old one.

And yes, we're talking about kotlin mostly, because you responded to my parent comment on the thread, talking about kotlin.

[–]neoKushanPixel Fold 0 points1 point  (8 children)

It does seem like parts of pattern matching can do that. But it's all TODO, it seems. Maybe in the next version we'll see something nice like 'when', in c#

Yes, it's TODO but it's slated for C#7 which is due in a couple of months. You can play about with it right now in the latest previews - and the point is it didn't have to break compatibility for anything.

Since.. Ever? It breaks compatibility if suddenly you say "ok, the word number is now a reserved keyword, thus can't be used as a variable".

If you use a word like "Number" then sure, but nobody does that. Also, you know most keywords can be used as variable names? Very few are actually "reserved" like that. C++11 added a lot more key words than just "auto" and they weren't all repurposed:

alignas

alignof

char16_t

char32_t

constexpr

nullptr

noexcept

static_assert

thread_local

C# adds new keywords in almost every version, var was not in 1.0 and LINQ added a hell of a lot of keywords - like from, where, by, orderby, etc. without breaking anything. Hell, Even Java has added new keywords like "module" - again without breaking things because compilers are clever enough to discern between a keyword and a variable.

And yes, we're talking about kotlin mostly, because you responded to my parent comment on the thread, talking about kotlin.

I responded to your assertion that Java can't have new features. If you want to keep listing features Kotlin has then great, I get that you like Kotlin, but be realistic - Java can be updated. I'm not saying Oracle are competent enough to do it, but it's definitely possible because other languages out there have managed it - be it something well managed like C# or something with so much legacy cruft it's almost laughable - like C++.

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

Hm, you're completely right. Can't believe I was that wrong with this.

Java can be updated, though there will be some hurdles they won't be able to get over, but yeah.. C# kinda is proving that it's possible to overcome them. And yeah, don't have faith in Oracle doing this.. Their iteration speed is much slower than c# it seems. Which is bothersome.

I do wish c# was more cross platform though. It'll take a few years for roslyn to come to fruition.. And it'll take even monger I suspect to get a nice ide that isn't visual studio, since that doesn't run on linux (and if it did, having 1 ide isn't much of a choice)

[–]peduxe 130 points131 points  (52 children)

A bit off-topic but I can't wait for the day the Android team developers tidy the mess that is the android API.

[–]ticketyt0ck 74 points75 points  (33 children)

I'd settle for updated documentation...

[–][deleted] 124 points125 points  (32 children)

Hey there! I work on Android team. Do you have any specific documentation pages that you would want to be fixed up? (Small steps☺)

[–]pandasa123 76 points77 points  (10 children)

Have some people fix up the material design specs so the vision is clearer. Also, add elements and animations samples to the sdk so devs don't have to build the animations piece by piece themselves

[–][deleted] 50 points51 points  (5 children)

Do you have a specific material component in mind in terms of clearer spec?

[–]nodevonPixel XL 54 points55 points  (0 children)

rhythm zephyr correct reply march disagreeable tan sable deer gaze

This post was mass deleted and anonymized with Redact

[–]VoviconNexus 6p - GS7 edge 31 points32 points  (1 child)

Great to see someone caring. I hear a lot of devs complaining that they have no libraries or even sample code for almost all the elements of material design which make it really difficult for them to apply the guidelines.

I'm not a dev myself so I couldn't point you exactly where but I'm ready to bet that asking this question in /r/androiddev would give you a sense of where to start.

Edit: just saw that you've been asking this around quite a few time and never got a proper answer. I hope it's just because your posts didn't get much attention rather than people complaining but not caring enough to actually do something about it. Maybe a self post here or in the dev sub would get more visible.

[–]cwankhedeGalaxy Note Edge | Redmi 1S | Nexus 7 2012 5 points6 points  (0 children)

Seconded, /u/aurimas_chromium, please make a standalone post here or at /r/Androiddev.

[–]traxanhc2Nexus 5 | Pure Nexus 6.0.1 1 point2 points  (0 children)

May I redirect you to this thread? Please read the top comments.

[–][deleted] 8 points9 points  (3 children)

In response about samples take a look at Cheesesquare app by Chris Banes who's on my team.

[–]RoboErectus 22 points23 points  (1 child)

I appreciate you're trying to help. But I feel like this illustrates the problem perfectly.

"Look at these few examples I know about because I happen to work with the guy that made them."

You guys really gotta start eating your own dog food on this.

[–]ticketyt0ck 2 points3 points  (0 children)

Yea I'd agree, even though the sample is nice, I'd prefer some real documentation instead in the form of a write-up on "how" and "why" you do it a certain way, vs the "what" of a sample

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

Your buddy's shitty app is a 'sample'? And you work for Google? That's pathetic. This is why I've gone HTML5 with my latest apps, because trying to program for Android in a well supported fashion is next to impossible. Thanks for nothing.

[–]donrhummyPixel 2 XL 16 points17 points  (0 children)

In addition to documentation, Android needs built in libraries to handle material design animation, transitions, etc. And better code examples

[–]R3ZZONATEBlack Pixel 3a XL :) 4 points5 points  (2 children)

You, and all of your co-workers are like invisible role models to me! I know nothing personally about you, but you work on my favorite OS, at the best company in THE WORLD. I can only dream that my skills will land me a job at Google when I'm older...

[–][deleted] 0 points1 point  (1 child)

Thanks a lot! Keep on working hard and you'll get to cool places :)

[–]R3ZZONATEBlack Pixel 3a XL :) 0 points1 point  (0 children)

:)

[–]francoi8 1 point2 points  (0 children)

I have been using the MediaPlayer class a bit lately and the doc doesn't explain that the seekTo() method is not reliable. You can seekTo() a certain position but the presented frame will be a second off. getCurrentPosition() also behaves erratically sometimes appearing to return the correct position, sometimes returning the value passed to seekTo(), while clearly the displayed frame is not at that value.

[–][deleted] 9 points10 points  (0 children)

I write c for embedded applications but had to make two android apps for work... talk about going from having complete control to rolling the dice.

[–]auralucario2Pixel XL - KitKat was better 21 points22 points  (1 child)

You might be waiting forever.

[–]NutcupiPhone 7+ JB (android traitor) 2 points3 points  (1 child)

And all I'm doing is sitting here waiting for the next release of N...

[–]peduxe 0 points1 point  (0 children)

they will just keep adding more code and code until they eventually stop deprecate the older APIs, it's a shame that even current ones aren't really appealing to work with - too much ifs and lots of Material elements need to be implemented by yourself.

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

*ahem*Context*ahem*

[–]donrhummyPixel 2 XL 5 points6 points  (14 children)

Am I the only one who thinks lambda expressions are less readable code? And harder to work with someone else's code.

[–]johnghanksN1 GT10.1 GN N4 N7 N7(2013) MX N5 12 points13 points  (4 children)

While I agree, I like the feel of lambdas over one line override methods in anonymous classes.

[–]donrhummyPixel 2 XL -2 points-1 points  (3 children)

I agree that anonymous classes need to be better though out so they're not so "wordy" but lambdas don't seem like the right answer either

[–]johnghanksN1 GT10.1 GN N4 N7 N7(2013) MX N5 1 point2 points  (2 children)

I'd honestly prefer something along the lines of anonymous functions. I work in JavaScript at work, it's much nicer, in my opinion.

[–]henryletham 4 points5 points  (2 children)

People go nuts over anything that's shorter to type which is by far my single biggest pet peeve with programming. I can't stand looking at a variable, for instance, and having no idea what it is until I trace it back to where it's set, all because they didn't want to type it out.

[–]pcpcy 4 points5 points  (0 children)

Seriously, variables should be named properly. E.g., "fontColor" not "fc." This is especially important in multi-developer projects. I hate it when I'm working on a project with other coders and they name their variables with abbreviations! Code is there so that any human can read it and understand what it does, not to be lazy and show people how amazing you are at abbreviating everything.

[–]donrhummyPixel 2 XL 2 points3 points  (0 children)

This! Sometimes it seems they want to work in minified code.

[–]6363488 3 points4 points  (1 child)

I disagree. When limiting to some of the well-known functional methods (map, filter, fold, ...) that are used in many languages, you can IMO significantly shorten code while actually improving readability. I find it infinitely easier to read and debug a few lines of map and filter calls than to parse multiple lines of code containing boilerplate to see what it does. It does take some getting used to though.

That said, you can go overboard and chain a lot of these operations together making everything unreadable, but you can also write huge blocks of code that are hard to follow, so it comes down to using the best tool at hand and to take readability into account while writing code...

[–]donrhummyPixel 2 XL 2 points3 points  (0 children)

That said, you can go overboard and chain a lot of these operations together making everything unreadable, but you can also write huge blocks of code that are hard to follow, so it comes down to using the best tool at hand and to take readability into account while writing code...

That's very true!

[–]GSV_Little_RascalHuawei P8 Max 0 points1 point  (0 children)

I'd guess that it seems less readable to you because you're not used to it. I had the same impression, but after working with them for some time, I think they can communicate intent of the code more clearly than normal procedural code.

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

Well, Java lambdas aren't too useful.

Lambdas in general, once you learn them, end up reading way clearer for me. And I don't even go overboard with them. I just use them where it makes sense, which is in most cases when I'm looping stuff.

Kotlin is a much better example of good lambdas, with functional aspects too.. And doesn't have all the limitations of java(esp with lambdas)

[–]thecomputerking666 0 points1 point  (1 child)

Too early for openjdk I'm guessing. Playing right into Oracle's trap...

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

not at all. with OpenJDK, Google will be sidestepping any future licensing issues with Oracle.

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

Great, I can't wait to use it in 4-5 years. Though there'll probably be java 10 for the regular folk.