Earlier quoted context omitted.
So this is basically the google CEO saying "a quarter of our terminal inputs is written by a glorified tab completion"?
I'm sorry but I don't understand how people say LLMs are simply "tab completion". They allow me to do much more than that thanks to all the knowledge they contain. For instance, yesterday I wanted to write a tool that transfers any large file that is still being appended to to multiple remote hosts, with a fast throughput. By asking Claude for help I obtained exactly what I want in under two hours. I'm no C/C++ exper…
Google CEO says more than a quarter of the company's new code is created by AI
721–730 of 1001 posts
Re: Google CEO says more than a quarter of the company's new code is created by AI
#722Re: Google CEO says more than a quarter of the company's new code is created by AI
#723Earlier quoted context omitted.
Writing a prime-number factorization function is hardly "leetcode".
I didn't say it's hard, but it's most definitely leetcode, as in "pointless algorithmic exercise that will only show you if the candidate recently worked on a similar question". If that doesn't satisfy, here's a similar one at leetcode.com: https://leetcode.com/problems/distinct-prime-factors-of-prod... I would not expect a programmer of any seniority to churn stuff like that and have it working without testing.
Testing for small prime factors is easy - brute force is your friend. Testing for large prime factors requires more effort. So the first trick is to figure out the bounds to the problem. Is it int32? Then brute-force it. Is it int64, where you might have a value like the Mersenne prime 2^61-1? Perhaps it's time to pull out a math reference. Is it longer, like an unbounded Python int? Definitely switch to something like the GNU Multiple Precision Arithmetic Library.
In this case, the maximum value is 1,000, which means we can enumerate all distinct prime values in that range, and test for its presence in each input value, one one-by-one:
# list from https://www.math.uchicago.edu/~luis/allprimes.html
_primes = [
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131,
137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,
199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271,
277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353,
359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677,
683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769,
773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859,
863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953,
967, 971, 977, 983, 991, 997]
def distinctPrimeFactors(nums: list[int]) -> int:
if __debug__:
# The problem definition gives these constraints
assert 1
That worked without testing, though I felt better after I ran the test suite, which found no errors. Here's the test suite: import unittest
class TestExamples(unittest.TestCase):
def test_example_1(self):
self.assertEqual(distinctPrimeFactors([2,4,3,7,10,6]), 4)
def test_example_2(self):
self.assertEqual(distinctPrimeFactors([2,4,8,16]), 1)
def test_2_is_valid(self):
self.assertEqual(distinctPrimeFactors([2]), 1)
def test_1000_is_valid(self):
self.assertEqual(distinctPrimeFactors([1_000]), 2) # (2*5)**3
def test_10_000_values_is_valid(self):
values = _primes[:20] * (10_000 // 20)
assert len(values) == 10_000
self.assertEqual(distinctPrimeFactors(values), 20)
@unittest.skipUnless(__debug__, "can only test in debug mode")
class TestConstraints(unittest.TestCase):
def test_too_few(self):
with self.assertRaisesRegex(AssertionError, "size out of range"):
distinctPrimeFactors([])
def test_too_many(self):
with self.assertRaisesRegex(AssertionError, "size out of range"):
distinctPrimeFactors([2]*10_001)
def test_num_too_small(self):
with self.assertRaisesRegex(AssertionError, "num out of range"):
distinctPrimeFactors([1])
def test_num_too_large(self):
with self.assertRaisesRegex(AssertionError, "num out of range"):
distinctPrimeFactors([1_001])
if __name__ == "__main__":
unittest.main()
I had two typos in my test suite (an "=" for "==", and a ", 20))" instead of "), 20)"), and my original test_num_too_large() tested 10_001 instead of the boundary case of 1_001, so three mistakes in total.If I had no internet access, I would compute that table thusly:
_primes = [2]
for value in range(3, 1000):
if all(value % p > 0 for p in _primes):
_primes.append(value)
Do let me know of any remaining mistakes.What kind of senior programmers do you work with who can't handle something like this?
EDIT: For fun I wrote an implementation based on sympy's integer factorization:
from sympy.ntheory import factorint
def distinctPrimeFactors(nums: list[int]) -> int:
distinct_factors = set()
for num in nums:
distinct_factors.update(factorint(num))
return len(distinct_factors)
Here's a new test case, which takes about 17 seconds to run: def test_Mersenne(self):
self.assertEqual(distinctPrimeFactors(
[2**44497-1, 2,4,3,7,10,6]), 5)Re: Google CEO says more than a quarter of the company's new code is created by AI
#724Earlier quoted context omitted.
Also if your code gets sent to someone else's cloud?
Have you ever had your code repository hosted by Github, Bitbucket, Gitlab or similar? If so, all your code is sent to cloud.
Re: Google CEO says more than a quarter of the company's new code is created by AI
#725I work for Google, and I just got done with my work day. I was just writing I guess what you'd call "AI generated code." But the code completion engine is basically just good at finishing the lines I'm writing. If I'm writing "function getAc..." it's smart enough to complete to "function getActionHandler()", and maybe suggest the correct arguments and a decent jsdoc comment. So basically, it's a helpful productivity…
I'm working on a CRM with a flexible data model, and ChatGPT has written most of the code. I don't use the IDE integrations because I find them too "low level" - I work with GPT more in a sort of "pair programming" session: I give it high level, focused tasks with bits of low level detail if necessary; I paste code back and forth; and I let it develop new features or do refactorings. This workflow is not perfect but…
There is this tool Aider. Takes your prompt, adds code files (sometimes not all of your code files but files it figures relevant) and prepares one long prompt, sends it to an LLM, receives the response, and makes a git commit based on the response. If you rather review git commits, it can save you the back-and-forth copy-pasting. https://aider.chat/
Re: Google CEO says more than a quarter of the company's new code is created by AI
#726Earlier quoted context omitted.
Why remove the comment that summarises the intent for humans? The compiler will ignore your comment anyway, so it's only there for the next human who comes along and will help them understand the code
Next human will put the code in a prompt and ask what it does. Chinese Whispers.
Re: Google CEO says more than a quarter of the company's new code is created by AI
#727Earlier quoted context omitted.
Why remove the comment that summarises the intent for humans? The compiler will ignore your comment anyway, so it's only there for the next human who comes along and will help them understand the code
It's often unnecessarily verbose. If you read a comment and glance at the code that follows, you'll understand what it is supposed to do. But the comment you're giving as an instruction to an LLM usually contains information which will then be duplicated in the generated code.
Re: Google CEO says more than a quarter of the company's new code is created by AI
#728Earlier quoted context omitted.
This is exactly how I’ve used copilot for over a year now. It’s really helpful! Especially with repetitive code. Certainly worth what my employer pays for it. The general public has a very different idea of that though and I frequently meet people very surprised the entire profession hasn’t been automated yet based on headlines like this.
Because you are using it like that doesn't mean that it can't be used for the whole stack and on its own and the public including laymen such as the Nvidia CEO and Sam think that yes, we (I'm a dev) will be replaced. Plan accordingly my friend.
Re: Google CEO says more than a quarter of the company's new code is created by AI
#729Earlier quoted context omitted.
Yes. Most AI hype is this bad. They have to justify the valuations.
"tab completion good enough to write 25% of code" feels like a pretty good hit rate to me! Especially when you consider that a good chink of the other 75% is going to be the complex, detailed stuff where you probably want someone thinking about it fairly carefully.
I feel it's a bit like the old "measuring developer productivity in LoC" metric.
As I hinted at in another comment, in Java if you had a "private String name;" then the following:
/**
* Returns the name.
* @return The name.
*/
public String getName() {
return this.name;
}
and the matching setter, are easy enough to generate automatically and you don't need a LLM for it. If AI can do that part of coding a bit better, sure it's helpful in a way, but I'm not worried about my job just yet (or rather, I'm more worried about the state of the economy and other factors).Re: Google CEO says more than a quarter of the company's new code is created by AI
#730Earlier quoted context omitted.
You generally don’t write those by hand though. I’m pretty sure around 50% of the code I write is already auto-complete, without any AI.
Simply strech your definition of AI and voilá, you are writing it with AI.