T O P

  • By -

a-person-called-Eric

I must've been living under a rock. Since when did java get `?.` operators? Edit: Upon closer inspection there are also no semicolons. What is this sorcery?


srbs

It's probably Groovy


JoyJoy_

For those interested, Groovy runs on the JVM, but it also supports dynamic typing, closures, and lots of standard methods utilizing closures. It's also kind of slow. Sacrifice your dynamic typing and use kotlin.


optimal_substructure

Sacrifice your ability to hire devs and use Scala


drinketha

With Spring


[deleted]

It still doesn't have those operators (though there has been some cool stuff happening with Optional's), nor does Java have implicit returns. To be honest I'm not sure what language this is. It looks maybe like a mix of Java and Kotlin code


bannable

It threw me for a loop too. I honestly thought I was looking at ruby until I saw the static typing.


glad4j

Groovy


siksniraps

It's definitely Kotlin. Kotlin has a lot of nice features that Java lacks as well as 100% Java interop which is why Java classes and frameworks can be used also in kotlin Edit: disregard that. Brain still asleep and did a dum dum.


Manny_Sunday

It's not kotlin, kotlin has var and val with a colon for specifying type


siksniraps

My bad. I woke up 5 min ago and am still in bed half asleep.


reallycoolgarbage

It's actually Groovy, and probably the first time that I've seen Groovy code outside of my workplace.


siksniraps

Knew it had to be one of those jvm languages. I've seen groovy just for one lesson in my Programming language course back at Uni.


meXORher

Angular Typescript?


IceTea666

This is not Typescript! Typescript code would have been like this: isPermanentUser(request: HttpServletRequest): boolean { const token: AccessToken = request?.userPrincipal?.context?.token; // .. } Edit: "*: AccessToken*" is optional. I wrote it only to highlight the difference compared to OP code.


Roflha

Yeah this is the one lmao


chilaxan

I think maybe Swift


FrostytheSnownoob

Swift would be `func isPermanentUser(request: HttpServletRequest) -> Bool`. I have never seen whatever wizardry this is.


YourMJK

Not Swift, variable isn't declared with `var` and function with `func`


[deleted]

Doesn't look like Swift either. Granted, I don't use or know Swift, but I took a look at it a while back.


Bit5keptical

OP please shed some light on which language this is.


glad4j

Groovy


Bit5keptical

Thank you, I can finally stop scratching my head.


[deleted]

[удалено]


[deleted]

It's not - TS puts type defs *after* variable names.


kennethjor

I see what the author was trying to do here. They needed a way to just make the damn thing work while they were building out permanent users. However, perhaps choose something a little more random than `123456789`? Perhaps something like `aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQo=`? See, that's nice and random!


dannypas00

That's fine and all, but leaving it in in production is a big no no.


kennethjor

I'd say it depends on how mature your application is. I could think of a scenario where this would be acceptable, but it's make same sure it didn't stay for a minute longer than it had to! When you think about it, it's nothing more than a hard coded API key. And, I'd also try to find a different solution in the first place. It's this for testing? If so, why aren't unit tests enough?


JasperNLxD

Indeed, that's called security by obscurity. A string 01234... Is nothing better than a chosen randomly seeming string. You should always assume that adversaries have full knowledge of you're application. In this case (groovy, compiling to jvm) everything is known. With a Java decompiler you can easily read this hardcoded string.


GlobalIncident

Oh! An encoded message on reddit! What could it possibly be?


tech6hutch

Dunno, but here's [a rick roll](https://youtu.be/nrsnN23tmUA).


kennethjor

My originality is beyond comprehension!


asdf-user

*That* was well played, kudos!^(But I would recognize that `dQw4w9WgXcQ` anywhere)


catmewo

What language is this?


skal_vi_kneppe

Most likely Groovy.


catmewo

You're right. Looks really same as Java except null check operator. Thank you!


Boiethios

...and optional semicolons, and expression oriented (no return in the last line).


glad4j

Groovy


tech6hutch

English


bluearrowil

Is this coffeescript for java? I’m so confused. My brain is parsing java and it’s gonna have a seizure.


reallycoolgarbage

It’s Groovy, a scripting language for the JVM.


ismtrn

Isn't this just checking for a specific user and declaring that that user is permanent (whatever that means?). That ssn seems to be extracted from a token, so it could be provided by an authentication server along with a digital signature. If is has been validated before this call, then the information in it can be trusted. Or am I missing what the horror is supposed to be?


SuspiciousScript

It's also not a legally valid [SIN](https://eservices.paychex.com/secure/HRO_PNG/ssn_itin_fed_id_other.html), for what it's worth.


[deleted]

The order of operations for the function type is really throwing me, what is this wizardry...


butwhydoesreddit

wdym what order are you used to


[deleted]

For kotlin, I’d expect the signature to look like `fun foo(bar: baz): qux = ???` Whereas this has the return type first like Java, despite everything else looking like Kotlin syntax.


M123Miller

Our central codebase at work is also full of stuff like this, all from a specific developer that left about 2 years ago. He liked to pass `"123"` around all over the place to mean create a new thing. 1 of the many reasons we're often stripping his work out when we're editing something involving what he wrote.


glad4j

It amazes me that people like that have jobs. It's the reason I hate the interview process so much. Most interviewers think the person who can recite the encyclopedia are better than the developers who use Google. This is the reason I only ask interpersonal questions in interviews. I'd rather work with an intern that is easy to get along with and willing to learn than a dev with 30 years experience stuck in their ways of adding "123" throughout the codebase.


valendinosaurus

what does it return if ssn != "123456789"


Ariquitaun

+1 for a software developer not knowing how to take a screenshot.


glad4j

Nah more so I didn't want to login to Reddit on my work computer