October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 25 October 2016 at 22:53:54 UTC, Walter Bright wrote: > It's a small bit, but the idea here is to eliminate if conditionals where possible: > > https://medium.com/@bartobri/applying-the-linus-tarvolds-good-taste-coding-requirement-99749f37684a#.nhth1eo4e > > This is something we could all do better at. Making code a straight path makes it easier to reason about and test. > > Eliminating loops is something D adds, and goes even further to making code a straight line. > > One thing I've been trying to do lately when working with DMD is to separate code that gathers information from code that performs an action. (The former can then be made pure.) My code traditionally has it all interleaved together. I'd like to point to Joel Spolsky excellent article "Five Worlds" - http://www.joelonsoftware.com/articles/FiveWorlds.html TL;DR: Joel Spolsky argues that different types("worlds") of developments require different qualities and different priorities, both from the code and the process. Because of that, advice given by experts of one world does not necessary apply to other worlds, even if the expert is really smart and experienced and even if the advice was learned with great pain. Linus Torvald is undoubtedly smart and experienced, but he belongs to the world of low-level kernels and filesystems code. Just because such code would be considered "tasteless" there doesn't mean it's tasteless everywhere. |
October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Idan Arye | On Thursday, 27 October 2016 at 14:54:59 UTC, Idan Arye wrote:
>
> I'd like to point to Joel Spolsky excellent article "Five Worlds" - http://www.joelonsoftware.com/articles/FiveWorlds.html
>
> TL;DR: Joel Spolsky argues that different types("worlds") of developments require different qualities and different priorities, both from the code and the process. Because of that, advice given by experts of one world does not necessary apply to other worlds, even if the expert is really smart and experienced and even if the advice was learned with great pain.
>
> Linus Torvald is undoubtedly smart and experienced, but he belongs to the world of low-level kernels and filesystems code. Just because such code would be considered "tasteless" there doesn't mean it's tasteless everywhere.
Not easy to be smart with Javascript ;)
|
October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 25 October 2016 at 22:53:54 UTC, Walter Bright wrote:
> It's a small bit, but the idea here is to eliminate if conditionals where possible:
>
> https://medium.com/@bartobri/applying-the-linus-tarvolds-good-taste-coding-requirement-99749f37684a#.nhth1eo4e
Dunno, I wouldn't expect an edge case to fall into the common flow of the code.
|
October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Thursday, October 27, 2016 15:42:53 Chris via Digitalmars-d wrote:
> Not easy to be smart with Javascript ;)
Sure, it is. Avoid it. ;)
- Jonathan M Davis
|
October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Thursday, 27 October 2016 at 15:54:59 UTC, Jonathan M Davis wrote:
> On Thursday, October 27, 2016 15:42:53 Chris via Digitalmars-d wrote:
>> Not easy to be smart with Javascript ;)
>
> Sure, it is. Avoid it. ;)
>
> - Jonathan M Davis
I wish I could! I wish we had DScript for browsers!
|
October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On Thursday, 27 October 2016 at 16:01:26 UTC, Chris wrote:
> On Thursday, 27 October 2016 at 15:54:59 UTC, Jonathan M Davis wrote:
>> On Thursday, October 27, 2016 15:42:53 Chris via Digitalmars-d wrote:
>>> Not easy to be smart with Javascript ;)
>>
>> Sure, it is. Avoid it. ;)
>>
>> - Jonathan M Davis
>
> I wish I could! I wish we had DScript for browsers!
I am hoping that when asm.js is more mature, then we can use the llvm back end to write at least part of front end in D. Would need runtime ported of course.
|
October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc Attachments:
| On 10/27/2016 07:12 PM, Laeeth Isharc wrote:
> On Thursday, 27 October 2016 at 16:01:26 UTC, Chris wrote:
>> On Thursday, 27 October 2016 at 15:54:59 UTC, Jonathan M Davis wrote:
>>> On Thursday, October 27, 2016 15:42:53 Chris via Digitalmars-d wrote:
>>>> Not easy to be smart with Javascript ;)
>>>
>>> Sure, it is. Avoid it. ;)
>>>
>>> - Jonathan M Davis
>>
>> I wish I could! I wish we had DScript for browsers!
>
> I am hoping that when asm.js is more mature, then we can use the llvm back end to write at least part of front end in D. Would need runtime ported of course.
I consider native compiler from D to WebAssembly to be one of possible unique breakthrough points for D in coming years.
|
October 27, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Thursday, 27 October 2016 at 16:14:03 UTC, Dicebot wrote:
> On 10/27/2016 07:12 PM, Laeeth Isharc wrote:
>> On Thursday, 27 October 2016 at 16:01:26 UTC, Chris wrote:
>>> On Thursday, 27 October 2016 at 15:54:59 UTC, Jonathan M Davis wrote:
>>>> On Thursday, October 27, 2016 15:42:53 Chris via Digitalmars-d wrote:
>>>>> Not easy to be smart with Javascript ;)
>>>>
>>>> Sure, it is. Avoid it. ;)
>>>>
>>>> - Jonathan M Davis
>>>
>>> I wish I could! I wish we had DScript for browsers!
>>
>> I am hoping that when asm.js is more mature, then we can use the llvm back end to write at least part of front end in D. Would need runtime ported of course.
>
> I consider native compiler from D to WebAssembly to be one of possible unique breakthrough points for D in coming years.
Can't wait for this to happen!
|
October 28, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 25 October 2016 at 22:53:54 UTC, Walter Bright wrote:
> Eliminating loops is something D adds, and goes even further to making code a straight line.
A problem for myself and probably many programmers, is some of the tricks like what Linus did simply doesn't come to mind because it's not something we'd seen before so we can't model after it, and also that you sort of follow the same logic of how you'd resolve it because that's how you were taught to resolve it or it's how you know to resolve it.
Often when I go for code I start with commenting the steps/breakdown, then I write each section, refactoring and cleaning up and shortening naturally are last, but once code is working it doesn't usually change too much even if there can be improvement.
Hmm what we really need is something like a good 100 examples of good 'tasty' code, good code in a variety of code, something digestible and even explained down for those not following the full logic if how/why it works, perhaps even bad examples to work up from.
|
October 29, 2016 Re: Linus' idea of "good taste" code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Thursday, 27 October 2016 at 16:14:03 UTC, Dicebot wrote:
> On 10/27/2016 07:12 PM, Laeeth Isharc wrote:
>> On Thursday, 27 October 2016 at 16:01:26 UTC, Chris wrote:
>>> On Thursday, 27 October 2016 at 15:54:59 UTC, Jonathan M Davis wrote:
>>>> On Thursday, October 27, 2016 15:42:53 Chris via Digitalmars-d wrote:
>>>>> Not easy to be smart with Javascript ;)
>>>>
>>>> Sure, it is. Avoid it. ;)
>>>>
>>>> - Jonathan M Davis
>>>
>>> I wish I could! I wish we had DScript for browsers!
>>
>> I am hoping that when asm.js is more mature, then we can use the llvm back end to write at least part of front end in D. Would need runtime ported of course.
>
> I consider native compiler from D to WebAssembly to be one of possible unique breakthrough points for D in coming years.
I asked Kai at dconf about what would be involved in porting to wasm, but I think he misheard me, as his answer was just generically about what was involved in porting to a new platform.
Any thoughts on how much work is involved to port the runtime? And what other changes might be involved? The chap that used the C backend for LLVM wrote a little mini runtime but I guess didn't have to worry about the version blocks in the compiler front end as much. (don't recall what architecture he pretended to be compiling to).
Glibc has obviously already been ported to run in browser by emscripten.
|
Copyright © 1999-2021 by the D Language Foundation