10 ms·
Coding Intentionally in Bash Grains
- marsrover 8y agoI just want to point out that it's really annoying that the "Available language tracks" on the front page are completely random and change on reloads. It's already hard enough to figure out where the language I'm curious about is, even worse when it changes after I click a new page. Also, clicking "explore languages" at the bottom of the blog does nothing.
- Tushon 8y agoFWIW, the logged in view of this is an alpha-sorted list, basically this view https://exercism.io/tracks https://exercism.io/tracks I would guess the design choice on the front page change on reloads to try to surface something potentially interesting to everyone, but I am not affiliated with them/have no additional insight. I can see how it would be frustrating. They must have removed the link you are referencing, because I don't see it now. Clicking it from the front page works (probably because it is an anchor link).
- ihid 8y agoThe "explore languages" link is now fixed. Thanks :) Feel free to open an issue at https://github.com/exercism/exercism https://github.com/exercism/exercism for the random language order. If there's consensus then it's an easy one to change.
- hnruss 8y agoExpressing the intent of the code significantly improves maintainability. I think it's important to realize that the problem of missing intent is often only noticed upon review of the code. So in my opinion, the moral of the story isn't simply "design with intent", it's "get your code reviewed".
- 01100011 8y agoOften it makes it through review just fine. It's usually not discovered until someone unfamiliar with the problem or complete set of initial circumstances is exposed to the code, at which time their main focus is on fixing/enhancing the code and not changing its readability or documenting intent. The new dev vomits out some code to meet their deadline and now the code is even more convoluted than it was to begin with. In a perfect world, readability would be one criteria during reviews, unfortunately it is often overlooked.
- cellularmitosis 8y agoI think exercism.io is hugely valuable for solving three problems: - Where can I find a set of practice problems which will force me to really engage with learning a new language? - Given a specific problem, what does the solution look like in various langauges? - Given a specific language, what do the solutions to a variety of problems look like? Unfortunately, exercism's web interface is really only set up to cater to the first of those. So I made an couple of indexes to solve for the other two: https://gist.github.com/cellularmitosis/ae76bb09973f55418d97cab3cd0cb86e https://gist.github.com/cellularmitosis/ae76bb09973f55418d97... https://gist.github.com/cellularmitosis/2aec8d88a76771452f3562f3d8b2e253 https://gist.github.com/cellularmitosis/2aec8d88a76771452f35...
- codezero 8y agoI was really into exercism before they changed the interface. And I know that change is good, but the peer mentorship I got when the previous interface existed was decent, and at least pretty consistent. With the new interface, I need to wait for official mentors, and while some have been way above and beyond, the dearth of reactions from anyone for long periods can be a real downer. I preferred the semi-OK amateur mentorship over the wildly inconsistent/non-existent mentor assistance. There was one mentor that I would have happily paid directly to keep giving me feedback, but there was no mechanism in exercism for me to make that offer, even if exercism took a cut. Also in the old interface, the community solutions were sorted by recency, so it was easier to interact with other fellow learners, and the new interface is not that, I'm not sure what the order is, but it's of no use for me to comment on a piece of code submitted two years ago.
- ihid 8y ago> I preferred the semi-OK amateur mentorship over the wildly inconsistent/non-existent mentor assistance. Just to chime in with data here, there is 5x more feedback per day on the new system than there was with the old system. Depending on the track, you'll get feedback in 3hrs to 7days (very occasionally longer), so it is definitely inconsistent in that respect, but you will get feedback. In the old system, you'd get feedback at all in under 10% of submissions. > There was one mentor that I would have happily paid directly to keep giving me feedback, but there was no mechanism in exercism for me to make that offer, even if exercism took a cut. In the future we'll be adding the ability to "pair" mentor/mentees who have both rated the other highly, so this will sort-of happen for you.
- cpursley 8y agoI'm basically stuck on the Elixir track waiting for a mentor... I'd be glad to pay per puzzle or a subscription to get faster feedback. Please, exercism. Take my money.
- bdcravens 8y agoPerhaps connect up with someone on codementor.io to review what you've done?
- daotoad 8y agoThe code presented in the article doesn't communicate the problem. It communicates a clever optimization that will break if the spec changes at all. This code should be readable enough to give you an idea what is happening and how to change it. my $board-depth = 8; my $board-width = 8; my $squares = $board-depth * $board-width; my @grains-per-square = ( 1 .. $squares ).map({ 2 ** ($_-1) }) say [+] @grains-per-square; Which if you read Perl6 says number of squares, and in each one put 2^n-1 grains, then add them all up. Hint: `[]` is the reduction metaoperator, it lets you specify an operator to use when reducing a list. [+] means "add it up". It finishes basically instantly, and while Perl6 has gotten a lot faster, it is not a fast language (yet?). So no need to optimize this. I mean you write the code and then marketing will have a poorly specified variation like "double only the odd ones". If you implemented this as `2^64-1` then you are starting from scratch. For the above the map only needs a tweak: map({ $_ %% 2 ?? $_ :: 2**(n-1) }) Or whatever it turns out that marketing meant. In the article, I didn't see informational intentionality, I saw premature optimization and obfuscation.
- reallydude 8y agoSimilarly, in your code, theres nothing about rows or columns inherent to the problem. There is a reference concept of a (standard) chess board that is really there to be 64 tiles in a linear set. I wouldnt add things that arent necessary or prematurely optimize for nonexistent future requests.
- colordrops 8y agoOrthogonal to your content, but perl6 allows "-" in variable names? ugh. I get that the "$" delineates a variable, but on first read it looks like "board minus depth".
- eridius 8y agoSince this is using Bash, it might be nice to mention that you can't use Bash's built-in math evaluation to solve the problem because Bash uses fixed-width integers and therefore let 2**64==0
- rgoulter 8y agoOn the one hand, the article's title that "solutions should be written in such a way that the intent is clear" makes sense for code which needs to be read and maintained. e.g. Martin Fowler suggests even 1 line of code methods can be useful if they describe a distinct intent. https://martinfowler.com/bliki/FunctionLength.html https://martinfowler.com/bliki/FunctionLength.html But I don't think the point is well made with a contrived whiteboard-interview style problem.
- ken 8y agoYou can do this in any area. In "Without Limits" [1], Bill Bowerman calls a team meeting at 7:27, specifically so everyone is sure to show up on time. [1]: https://www.youtube.com/watch?v=yuAtOMGyUx8 https://www.youtube.com/watch?v=yuAtOMGyUx8