• 0 Posts
  • 34 Comments
Joined 1 year ago
cake
Cake day: July 1st, 2023

help-circle












  • Easy access to small snippets of code you often need, but putting them in their own library would be crazy.

    • Opening a file / db connection
    • parsing xml/json/… ,
    • template for unit tests,
    • import and initialization of framework at work.

    Depending on the IDE snippets can also move parts of the code around: (intellij live templates)

    • variable.notnull -> if (variable != null) {… }
    • “text %s”.format -> String.format(“text %s”,…)



  • The variable is set once, but the if expression is still evaluated every time (unless the compiler can optimize it)

    (edit after skimming the article: yes,using the variable would solve the problem of the last example)

    So there would be the branching overhead in every iteration. But that’s something the cpu branch prediction should cover, especially since the taken branch will be identical in every loop.

    Same also applied to the implied condition to break the for loop (only the first few and last iteration should be wrong predictions)




  • A compiler has mostly fixed rules for translation. The English language often is ambiguous and there are many ways to implement something based on a verbal description.

    Programming by using the ai as a “compiler” would likely lead to many bugs that will be hard to impossible to trace without knowing the underlying implementation. But hitting compile again may lead to an accidental correct implementation and you’d be none the wiser why the test suddenly passes.

    It’s ok as an assistant to generate boilerplate code, and warn you about some bugs / issues. Maybe a baseline implementation.

    But by the time you’ve exactly described what and how you want it you may as well just write some higher level code.