Live data from Hacker News

Amazon CodeGuru – Preview

aws.amazon.com

201–209 of 209 posts

Re: Amazon CodeGuru – Preview

#201
post #172

Earlier quoted context omitted.

No, that's not the same. This is github, http://aws.amazon.com is explicitly AWS.

https://reactjs.org/ >Copyright © 2019 Facebook Inc. Does the (sub)domain something is hosted on actually matter when the ownership situation is the same?

It does, it means it was created for the use of AWS. That means the primary reason for the patches it is to make sure it will work well on AWS.

While the product is free it doesn't mean the patches will be beneficial anywhere else, in fact if it will work better anywhere it would be merged back to OpenJDK and we wouldn't need the fork.

Same thing with Amazon Linux, sure you can use it on premise, but it is tuned to work best on AWS and might actually work worse outside than other distros.

Re: Amazon CodeGuru – Preview

#202

Earlier quoted context omitted.

Now that I think of it, if it's paid by lines of code, it perversely incentives people to minimize the lines of code, no? Does it count white space and comments? Can I minify my code before passing it to this, then unminify it?

Many languages can have code written in them minimized down to a single line. I guess they must have a character count number equals a line qualifier somewhere.

But even then, still pushes people to shorten variable names and other kind of minification.

Re: Amazon CodeGuru – Preview

#203
post #110

One of their screenshot examples flags inefficient code in crypto libraries, and the suggested "fix" is "Evaluate switching to the Amazon Corretto Crypto Provider ACCP". I don't know enough about the subject matter area to know whether that's the right move, but it's interesting that CodeGuru is apparently, among other things, an opportunity to pay Amazon to upsell you on replacing some of your code with one of the p…

ACCP is an Apache licensed crypto library that has a standard JCA/JCE interface, meaning it's a drop-in replacement for the standard java crypto.

https://github.com/corretto/amazon-corretto-crypto-provider

They claim to be 25% faster than standard implementation: https://aws.amazon.com/blogs/opensource/introducing-amazon-c...

Re: Amazon CodeGuru – Preview

#204
post #201

Earlier quoted context omitted.

https://reactjs.org/ >Copyright © 2019 Facebook Inc. Does the (sub)domain something is hosted on actually matter when the ownership situation is the same?

It does, it means it was created for the use of AWS. That means the primary reason for the patches it is to make sure it will work well on AWS. While the product is free it doesn't mean the patches will be beneficial anywhere else, in fact if it will work better anywhere it would be merged back to OpenJDK and we wouldn't need the fork. Same thing with Amazon Linux, sure you can use it on premise, but it is tuned to w…

As someone else pointed out, AWS does consistently upstream things to OpenJDK and is in fact regularly one of the largest contributors.

Additionally, the entire thing, again, is open source and with a permissive license meaning nothing is stopping anyone from forking it and doing what they'd wish with it.

You are in fact right that it was created to work well with AWS, but I fail to see how that is 'lock in', since most of those benefits are probably benefits on any modern cloud - since AWS does not generally run on a particularly unique architecture.

Re: Amazon CodeGuru – Preview

#205

Disclaimer: I work at AWS on an unrelated team. I was not involved in development of this product. Opinions stated are my own, and not necessarily a reflection of my employer. Nothing here is being posted in any sort of official capacity. There's lots of focus here in the comments on the code reviewer portion, but one of the things I'm most excited about is the profiler - https://aws.amazon.com/codeguru/features/ I d…

A profiling tool I want to try out—it seems almost magical—is Coz. It can estimate the effect of speeding up any line of code. It does this by pausing (!) other threads, so it gives a 'virtual' speed up for that line. What's interesting is that this technique correctly handles inter-thread effects like blocking, locking, contention, so it can point out inter-thread issues that traditional profilers and flame graphs s…

I have never heard of this kind of profiling before, thanks for sharing

Re: Amazon CodeGuru – Preview

#206

Earlier quoted context omitted.

I think this does what you mention and not the former. I would imagine this works best when you have a codebase that heavily utilizes the AWS SDK so it can internally 'paint a picture' of what's going on and provide better architectural decisions and other best practices. How well it works is beyond me though

Bullshit. You are vastly overestimating the "intelligence" of this overpriced linter. It mechanically detects patterns. See this example: https://d1.awsstatic.com/re19/Screenshot_Catch-Code-Issue_2%... The kind of human-level artificial intelligence that you're suggesting this would have, is science fiction.

Well I stand corrected, would've expected more from a company that knows all the best practices for their own services

Re: Amazon CodeGuru – Preview

#207
import android.util.Log;

import android.accounts.Account; import android.app.Activity; import android.content.Intent; import android.content.IntentSender; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import android.content.res.Resources; import android.os.Bundle; import android.support.annotation.NonNull; import android.util.Base64;

import com.google.android.gms.common.api.Result; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GoogleApiAvailability;

import com.google.android.gms.auth.api.signin.GoogleSignIn; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; import com.google.android.gms.auth.api.signin.GoogleSignInClient; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.android.gms.auth.api.signin.GoogleSignInStatusCodes; import com.google.android.gms.common.api.ApiException; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task;

import java.security.MessageDigest; import java.security.NoSuchAlgorithmException;

public class GoogleLogin { / Responses supported by this class / public static final int GOOGLE_RESPONSE_OK = 0; public static final int GOOGLE_RESPONSE_CANCELED = 1; public static final int GOOGLE_RESPONSE_ERROR = 2; public static final int GOOGLE_RESPONSE_DEVELOPER_ERROR = 3;

/* Debug output tag / private static final String TAG = "UE4-GOOGLE";

// Output device for log messages. private Logger GoogleLog; private Logger ActivityLog;

/* Is this a shipping build / boolean bShippingBuild = false; /* Has init been called succesfully / public boolean bInitialized = false; /* Has onStart() been called / public boolean bStarted = false;

/* * Activity needed here to send the signal back when user successfully logged in. / private GameActivity activity;

/* Name of game package / private String packageName; /* Android key from Google API dashboard / private String clientId; /* Backend server key from Google API dashboard / private String serverClientId; /* Unique request id when using sign in activity / private static final int REQUEST_SIGN_IN = 9001; /* Google API client needed for actual sign in */ private GoogleSignInClient mGoogleSignInClient;

public GoogleLogin(GameActivity activity, final Logger InLog, String inPackageName, String BuildConfiguration) { this.activity = activity;

  GoogleLog = new Logger(TAG);
  ActivityLog = InLog;

  packageName = inPackageName;
  bShippingBuild = BuildConfiguration.equals("Shipping");
 } 

 public boolean init(String inClientId, String inServerClientId)
 {
  if (bShippingBuild)
  {
   GoogleLog.SuppressLogs();
  }

  boolean bClientIdValid = (inClientId != null && !inClientId.isEmpty());
  boolean bServerIdValid = (inServerClientId != null && !inServerClientId.isEmpty());
  if (bClientIdValid && bServerIdValid)
  {
   GoogleLog.debug("init");

   boolean bIsAvailable = isGooglePlayServicesAvailable();
   GoogleLog.debug("Is Google Play Services Available:" + bIsAvailable);
   if (bIsAvailable)
   {
    GoogleLog.debug("packageName: " + packageName);
    clientId = inClientId;
    GoogleLog.debug("GoogleSignIn clientId:" + clientId);
    serverClientId = inServerClientId;
    GoogleLog.debug("GoogleSignIn serverClientId:" + serverClientId);

    // Configure sign-in to request the user's ID, email address, and basic
    // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
      .requestIdToken(serverClientId)
      .requestProfile()
      //.requestServerAuthCode(serverClientId)
      .requestEmail()
      .build();

    // Build a GoogleSignInClient with the options specified by gso.
    mGoogleSignInClient = GoogleSignIn.getClient(activity, gso);
    
    bInitialized = true;
    PrintKeyHash(packageName);
   }
  }
  else
  {
   GoogleLog.debug("clientId: " + inClientId + " or serverClientId: " + inServerClientId + " is invalid");
  }

  GoogleLog.debug("init complete: " + bInitialized);
  return bInitialized;
 }

 public void onStart()
 {
  GoogleLog.debug("onStart");
  bStarted = true;
 }

 public void onStop()
 {
  GoogleLog.debug("onStop");
 }

 public void onDestroy()
 {
  GoogleLog.debug("onDestroy");
 }

 public int login(String[] ScopeFields)
 {
  GoogleLog.debug("login:" + ScopeFields.toString());

  int resultCode = GOOGLE_RESPONSE_ERROR;

  Intent signInIntent = mGoogleSignInClient.getSignInIntent();
  if (signInIntent != null)
  {
   GoogleLog.debug("login start activity:");
   activity.startActivityForResult(signInIntent, REQUEST_SIGN_IN);
   resultCode = GOOGLE_RESPONSE_OK;
  } 
  else 
  {
   GoogleLog.debug("getSignInIntent failure:");
   nativeLoginComplete(GOOGLE_RESPONSE_ERROR, "");
  }

  return resultCode;
 }

 public int logout()
 {
  GoogleLog.debug("logout");

  mGoogleSignInClient.signOut()
   .addOnCompleteListener(activity, new OnCompleteListener()
   {
    @Override
    public void onComplete(@NonNull Task task) 
    {
     boolean bWasSuccessful = task.isSuccessful();
     GoogleLog.debug("onSignOut Complete success:" + bWasSuccessful);
     nativeLogoutComplete(bWasSuccessful ? GOOGLE_RESPONSE_OK : GOOGLE_RESPONSE_ERROR);
    }
   });

  return GOOGLE_RESPONSE_OK;
 }

 public void onActivityResult(int requestCode, int resultCode, Intent data) 
 {
  GoogleLog.debug("onActivityResult: " + requestCode + " result: " + resultCode);
  // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
  if (requestCode == REQUEST_SIGN_IN) 
  {
   GoogleLog.debug("onActivityResult REQUEST_SIGN_IN");
   GoogleLog.debug("data: " + ((data != null) ? data.toString() : "null"));

   if (resultCode == Activity.RESULT_OK)
   {
    GoogleLog.debug("signing in");
   }

   Task completedTask = GoogleSignIn.getSignedInAccountFromIntent(data);
   try
   {
    // Try to access the account result
    GoogleSignInAccount account = completedTask.getResult(ApiException.class);
    
    // Signed in successfully
    GoogleLog.debug("Sign in success");
    PrintUserAccountInfo(account);
    nativeLoginComplete(GOOGLE_RESPONSE_OK, getLoginJsonStr(account));
   }
   catch (ApiException e)
   {
    // The ApiException status code indicates the detailed failure reason.
    // Please refer to the GoogleSignInStatusCodes class reference for more information.
    GoogleLog.debug("Sign in failure:" + GoogleSignInStatusCodes.getStatusCodeString(e.getStatusCode()));
    if (e.getStatusCode() == GoogleSignInStatusCodes.DEVELOPER_ERROR)
    {
     nativeLoginComplete(GOOGLE_RESPONSE_DEVELOPER_ERROR, "");
    }
    else
    {
     nativeLoginComplete(GOOGLE_RESPONSE_ERROR, "");
    }
   }

   GoogleLog.debug("onActivityResult end");
  }
 }

 private String getLoginJsonStr(GoogleSignInAccount acct)
 {
  if (acct != null)
  {
   return "{\"user_data\":" + getUserJsonStr(acct) + "," +
     "\"auth_data\":" + getAuthTokenJsonStr(acct) + "}";
  }

  return "";
 }

 private String getUserJsonStr(GoogleSignInAccount acct)
 {
  if (acct != null)
  {
   return "{\"sub\":\""+ acct.getId() + "\"," +
     "\"given_name\":\"" + acct.getGivenName()  + "\"," +
     "\"family_name\":\"" + acct.getFamilyName() + "\"," +
     "\"name\":\"" + acct.getDisplayName() + "\"," +
     "\"picture\":\"" + acct.getPhotoUrl() + "\"" + "}";
  }
  return "";
 }

 private String getAuthTokenJsonStr(GoogleSignInAccount acct)
 {
  if (acct != null)
  {
   return "{\"access_token\":\"androidInternal\"," +
     "\"refresh_token\":\"androidInternal\"," +
     "\"id_token\":\""+ acct.getIdToken() + "\"}";
  }
  return "";
 }

 public void PrintUserAccountInfo(GoogleSignInAccount acct)
 {
  GoogleLog.debug("PrintUserAccountInfo");
  if (acct != null)
  {
   GoogleLog.debug("User Details:");
   GoogleLog.debug("    DisplayName:" + acct.getDisplayName());
   GoogleLog.debug("    Id:" + acct.getId());
   GoogleLog.debug("    Email:" + acct.getEmail());
   GoogleLog.debug("    Account:" + acct.getAccount().toString());
   GoogleLog.debug("    Scopes:" + acct.getGrantedScopes());
   GoogleLog.debug("    IdToken:" + acct.getIdToken());
   GoogleLog.debug("    ServerAuthCode:" + acct.getServerAuthCode());
  }
  else
  {
   GoogleLog.debug("Account is null");
  }
 }

 private boolean isGooglePlayServicesAvailable() 
 {
  GoogleApiAvailability apiAvail = GoogleApiAvailability.getInstance();
  int status = apiAvail.isGooglePlayServicesAvailable(activity);
  GoogleLog.debug("isGooglePlayServicesAvailable statusCode: " + status);
  if (status == ConnectionResult.SUCCESS) 
  {
   return true;
  } 
  else 
  {
   return false;
  }
 }

 public void PrintKeyHash(String packageName) 
 {
  try 
  {
   PackageInfo info = activity.getPackageManager().getPackageInfo(
     packageName,
     PackageManager.GET_SIGNATURES);
   for (Signature signature : info.signatures) 
   {
    MessageDigest md = MessageDigest.getInstance("SHA");
    md.update(signature.toByteArray());
    GoogleLog.debug(Base64.encodeToString(md.digest(), Base64.DEFAULT));
   }
  } 
  catch (PackageManager.NameNotFoundException e) 
  {
   GoogleLog.debug("NameNotFoundException:" + e);
  } 
  catch (NoSuchAlgorithmException e) 
  {
   GoogleLog.debug("NoSuchAlgorithmException:" + e);
  }
 }

 // Callback that notify the C++ implementation that a task has completed
 public native void nativeLoginComplete(int responseCode, String javaData);
 public native void nativeLogoutComplete(int responseCode);
}

Re: Amazon CodeGuru – Preview

#208
post #119

Earlier quoted context omitted.

If you relieve the programmer of thinking where his error is and give him the fix, the programmer will not bother to reason out what the solution is, he will simply expect it from you.

Do you really think that what we do and don't have to think about today is at some holy division of things that are best left automated (e.g. garbage collection, platform independence, serialization) and things we have to do by hand? Why is this particular point in time special? It's a spectrum. Now isn't special.

I think if you provide an IDE that solves everything it will become like a calc, when people stoped making mental excersices in favor of typing the problem and get the insntant result of it.

Re: Amazon CodeGuru – Preview

#209
post #144

Earlier quoted context omitted.

WhatsApp? Similar story, no AWS.

I think people tend to forget how often WhatsApp experienced outages in the early days.

This actually speaks volumes. Yes, people forget. Yes, it’s possible to suffer severe growing pains and still get acquired for $$$$. No, you don’t need to start with everything-AWS to ensure 99.9-whatever% uptime. People forget.
Post reply on HN