I took a functional programming in Haskell course first year in Uni without having much previous programming experience at all. Quite early in the course we were tasked with implementing a huge bidirectional graph and an efficient shortest path algorithm for finding the fastest way between any two nodes.
I hadn’t taken any DSA course and was totally unaware of graphs and shortest path algorithms and the course material was pure Haskell syntax.
I failed miserably and so did most of the others.
Capital M is for Mega.
I would use duration_s and duration_ms.
const duration_ms = 1000 * duration_s
And _us for microsec.
const duration_us = 1000 * duration_ms
But then the tool would probably reject my code for not following the naming conventions which ”disallows using underscores in variable names”.
Guess what I wanted to say is that there are always exceptions to the rule and there should always be some way to turn off the automatic checker for certain sections of the code.
I second this. My impressions so far are pretty much the same.
Have been trying to get ChatGPT to generate code for some algorithms that are pretty close to well known implementations but with some twists and it absolutely fails no matter how much I tried to provide hints to change the suggestions it gave me. In the end I just went back to hand coding them since it actually saves me the frustration of trying to get ChatGPT to bend in the direction I need.
Agreed. A comment can also explain things that a function name cannot.
I’m all for splitting code into paragraphs with a well written comment above each.
Of course I also extract functions, but only when there are obvious benefit, like removing repetition.