11.9 C
New York
Thursday, December 8, 2022

Rust Programming Language Announces New Team to Evolve Official Coding Style – developers.slashdot.org

Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!




The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
…. there shouldn’t be an “official” coding style. If you want to make people write code in a specific layout then enforce it in the language parser like Python with its whitespace, otherwise butt out and let people make their own choices.
Ok guy whos never worked in a team before.
Style guides are good things. Theres nothing more incomprehensible than code maintained by 4-5 people each with their own whackadoodle idea of how to format code.
Source code formatting is very low on my list of factors for maintainable and reliable code. Put whatever you want in the .editorconfig file to end the bike-shedding, and start writing code.
Style guides are more than just source code formatting.
They encode naming conventions, higher level constructs (e.g. JavaBeans), comment styles, etc.
Things are much easier to understand when there’s consistency.
Format-Style-Syntax. Pretty important in system level coding.
The point of a coding style is to promote easier understanding of the code for humans while making it easier to spot errors. There are times where “special case” formatting makes the code much easier to understand and requiring it to be formatted in a way that makes it harder to understand is stupid.
Also, if your language requires compliance to an official style guide, it’s garbage.
But auto formatters are always zero exception. Make a readable table, with one item per row and columns that line up, and then the auto-formatter will come pack everything to the line length limit and wrap it where ever. Becomes unreadable.
I think the reason some people need zero-exception strict style guides is that they can’t actually write code in any kind of style themselves. Don’t even know what the space bar, tab key, and enter key are for. The must have an auto formatter do this for them. It’s l

With the ubiquitous use of widescreen displays, I always turn off line length in all code formatting tools I use anyway.

With the ubiquitous use of widescreen displays, I always turn off line length in all code formatting tools I use anyway.
That’s you being short-sighted. They’re not ubiquitous, and even if they were, assuming all of them are in use in landscape mode is just as silly and restricting on those of us preferring more vertical than horizontal space.
I for one have one 5:4, three 4:3, and no widescreens in use. But even if, my default xterm size would still be 80 columns, possibly switchable to 132.
The reasons to stick with 80 columns have little to do with the display: Very long lines aren’t easy to read, the optimum seems to be a
You can mark sections of code that avoid autoformatting. And it’s certainly useful at times, when e.g. a table layout for constants work out great.
Style guides are good things.
I don’t entirely agree. Automatic style enforcement is a good thing. They are great at squelching the vast amounts of tedious bikeshedding that goes on arguing about style minutiae on every single PR.
Theres nothing more incomprehensible than code maintained by 4-5 people each with their own whackadoodle idea of how to format code.
For me only if it’s truly whackadoodle. GNU style guide, lookin’ at you…
As a certified old fart by the standards of IT, I’ve worked in enough differ
As a certified old fart by the standards of IT, I’ve worked in enough differently formatted codebases that I just forgot to care any more.
This is pretty much me as well. Where I work we have an “official” corporate style guide which I follow for new projects, but we also do a lot of sustainment work on stuff that came from acquired companies that did things their own way, and no one’s going to go back through and change thousands of lines in an established avionics firmware package that was tested and sig
Where I work we have an “official” corporate style guide which I follow for new projects, but we also do a lot of sustainment work on stuff that came from acquired companies that did things their own way, and no one’s going to go back through and change thousands of lines in an established avionics firmware package that was tested and signed off years ago just to make it jive with the style guide.
I too work on a codebase that’s been amalgamated from a bunch of in house teams, predating the current guides pl
Where I’ve worked with project with extensive style guides, apart from what is enforced by a style linter, just leads to continual argy-bargy in code reviews. So tedious. Who can remember all
I was working into teams probably before you were born feotus. I’m simply saying the language authors should stay out of it.
No, they shouldn’t stay out of it.
Almost every project in the real world has a coding style standard, and you’re stuck adjusting to that no matter what.
Every time you switch jobs or even projects within one company, now you’ve got to adapt to a different set of rules even if you’re using the same language. That’s a royal pain in the ass. It’s better to just have one universal coding standard. An added advantage is that only one small team of language developers have to waste time haggling over exactly what
There’s no point having freeform languages if you have One True Coding Style. Also certain coding styles such as mil spec ones can be rather awkward and wouldn’t be popular in commercial enviroments.

There’s no point having freeform languages if you have One True Coding Style

There’s no point having freeform languages if you have One True Coding Style
Why not? Take the example of Go, one of the most recent popular languages. It has one true coding style, and that gets enforced by the formatter utility, not the compiler. It was created by industry bigwigs with decades of experience. What makes you think that they are wrong and you are right?

Also certain coding styles such as mil spec ones can be rather awkward and wouldn’t be popular in commercial enviroments.

Also certain coding styles such as mil spec ones can be rather awkward and wouldn’t be popular in commercial enviroments.
At least the military gave up on creating new programming languages out of whole cloth and then foisting them on everyone, but they obviously have more work to do.
Sure, people who work together closely should use a common coding style. But the style shouldn’t be enforced by the language; it should be the choice of the team, company or project, based on their own culture, history, the tool sets they use, general company-wide rules and so on. There are many factors that drive the choice of a particular coding style for a particular project, and the language team has access to none of them.
In the end, all the language team should do is suggest some guidelines, while ma
…. there shouldn’t be an “official” coding style. If you want to make people write code in a specific layout then enforce it in the language parser like Python with its whitespace, otherwise butt out and let people make their own choices.
Why not? Why not have an official style used internally by the team to ensure consistency?
And then use the official style in the documentation when showing examples, as well, so all the examples have a uniform look.
Just because the language lets you put brackets and brace
Being verbose while trying to figure out web standards in a language that changes to accommodate web standards? Every time a new library is thought up your old logic blows up. I’m not a java person though….to me java is actually all style and politics. But then you don’t write device drivers with it either…..
Hopefully we can finally be treated like adults and have tabs be the default.
Clinging to the argument of universal formatting is weak. We have good tools and deserve a world that can better cater to the end user-preferences. gofmt has done the world a service by demonstrating how practical and scalable this choice was.
Also, accessibility matters [reddit.com].
I almost want to sponsor a study to see how much more energy and cumulative storage is required for spaces vs. tabs. Those extra bytes aren’t free!
(I’ve never encountered, in more than twenty years of software development, a serious issue arising because code “wasn’t readable due to formatting”. Maybe I’m spoiled by working with people who can understand code regardless of an odd space here or there? Or perhaps because we relied on static checkers and actually read warnings, and had robust unit and integra

I’ve never encountered, in more than twenty years of software development, a serious issue arising because code “wasn’t readable due to formatting”.

I’ve never encountered, in more than twenty years of software development, a serious issue arising because code “wasn’t readable due to formatting”.
Indeed, a good programmer will be amendable to variation, but there is research that has quantified the level to which this slows down a developer and it’s not nothing, increasing inverse to experience (sorry I don’t have enough time to dig it up right now). Further, it’s important to consider that in today’s world, developers work on more codebases and their positions are more fluid than ever before. The person that wrote a project may not even be on the team a year later, and no one knows the skill level
By all means do the math, but from a practical standpoint it just doesn’t matter. You can always just convert (which can probably be distilled to a single command or click in your IDE) and then convert back again, so you can work with whatever your preference is.
I prefer to use all spaces and no tabs, unless I’m using a word processor or other DTP software and I am defining my own tabs for columnar purposes. Then the tab key does what I actually want it to every time, and I can also have half-indents if I w

Hopefully we can finally be treated like adults and have tabs be the default.

Hopefully we can finally be treated like adults and have tabs be the default.
That link is very sobering. Unfortunately, the summary makes it clear that tabs are out.
From your link, for the benefit of others who won’t bother to click:

Nobody talks about the real reason to use Tabs over Spaces
i’ve been slightly dismayed, that in every tabs-vs-spaces debate i can find on the web, nobody is talking about the accessibility consequences for the visually impaired

let me illustrate with a quick story, why i irrevocably turned from a spaces to tabs guy

        i recently worked at a company that used tabs

        i created a new repository, and thought i was being hip and modern, so i started to evangelize spaces for the ‘consistency across environments’

        i get approached by not one, but TWO coworkers who unfortunately are highly visually impaired,
        and each has a different visual impairment

                one of them uses tab-width 1 because he uses such a gigantic font-size

                the other uses tab-width 8 and a really wide monitor

                these guys have serious problems using codebases with spaces, they have to convert, do their work, and then unconvert before committing

                these guys are not just being fussy — it’s almost surprising they can code at all, it’s kind of sad to watch but also inspiring

        at that moment, i instantaneously conceded — there’s just no counter-argument that even comes close to outweighing the accessibility needs of valued coworkers

[…]

is there really any reason, in favor of spaces, that counter balances the negative consequences for the visually impaired?

cheers friends,

Chase

Nobody talks about the real reason to use Tabs over Spaces
i’ve been slightly dismayed, that in every tabs-vs-spaces debate i can find on the web, nobody is talking about the accessibility consequences for the visually impaired
let me illustrate with a quick story, why i irrevocably turned from a spaces to tabs guy
        i recently worked at a company that used tabs
        i created a new repository, and thought i was being hip and modern, so i started to evangelize spaces for the ‘consistency across environments’
        i get approached by not one, but TWO coworkers who unfortunately are highly visually impaired,
        and each has a different visual impairment
                one of them uses tab-width 1 because he uses such a gigantic font-size
                the other uses tab-width 8 and a really wide monitor
                these guys have serious problems using codebases with spaces, they have to convert, do their work, and then unconvert before committing
                these guys are not just being fussy — it’s almost surprising they can code at all, it’s kind of sad to watch but also inspiring
        at that moment, i instantaneously conceded — there’s just no counter-argument that even comes close to outweighing the accessibility needs of valued coworkers
[…]
is there really any reason, in favor of spaces, that counter balances the negative consequences for the visually impaired?
cheers friends,
Chase
It’s much harder to convert spaces to tabs than it is to convert tabs to spaces.
I just had some beers so I’m not going to think about regular expressions right now and embarrass myself, but it seems pretty simple to use one of them to do that job and only convert the leading however many spaces to tabs, as many times as necessary per line.
More relevantly though, with modern coding standards checkers you can just have the code indented automatically and consistently to whatever standard is defined. So it’s a good reason to either follow an established format, or establish one and write
The problem is that the number of spaces per tab can vary. With tabs to spaces, it’s a preference set once. With spaces to tabs, well, it’s anyone’s guess. You could lean on pretty printers I guess, but you give up any advantage there might be for occasionally breaking convention for readability.
The AC’s claim was “There’s zero reason to use tab characters” On the contrary. If you want to lean on automatic formatting to suit individual developer preferences, using spaces never makes sense. Tabs have cl

I can see absolutely no reason to prefer spaces for indenting.

I can see absolutely no reason to prefer spaces for indenting.
It lets you do half-indents, which are sometimes preferable for style reasons. Again, as long as formatters exist, it’s irrelevant what your preference is. Pick one and use it, then run it through the formatter when you’re done.

as long as formatters exist, it’s irrelevant what your preference is

as long as formatters exist, it’s irrelevant what your preference is
I very strongly disagree, for reasons I’ve already stated. You should as well, for the reason you’ve just given.

It lets you do half-indents, which are sometimes preferable for style reasons.

It lets you do half-indents, which are sometimes preferable for style reasons.
While I have no idea under what circumstance you’d want a ‘half indent’, it seems to me that the old rule of tabs for intending, spaces for alignment would solve that problem very neatly.
“especially trying to line things up vertically”
The answer there is that a text file is a bad format for non-text. Use a tool appropriate to the task.
That isn’t a problem if we’re talking about code. The rule was always tabs for indenting, spaces for alignment.
I too bemoan the overtaking of software by the space cadets.
Lost in this debate as always, as each camp attempts to place blame on the other, is where the blame really ought to be: The editor.
I get the universal formatting argument. My tab expansion may not be yours. The other side doesn’t get the ease of editing argument–the cursor tapping through all your spaces is annoying.
The solution is simple: When loading the file, the editor should analyze the indentation and check to see that it follows a patt
I propose a similar, yet different solution: auto-format to your preference on pull / clone / checkout ( IDE formatter ) and auto-format to the guidelines on commit ( commit hooks ?).
Best of both worlds.
Yes! A source control script might be an even better option, since AFAIK you could deliver this feature to almost everybody with just a few source control systems, whereas there are a lot more editors. If you patch svn, git, and good ol’ cvs, you cover what… 95% or more of developers? Sure there is probably a long tail of version control systems too, but if you got a feature like that in to the top 3 the rest would catch up. Additionally they tend to be F/OSS whereas MS’s development environment is cl
Rust only has two major issues: Its conceptual design, and its implementation.
I like how “some people from an esoteric language have decided to extend an existing style guide to cover new language features” is considered as newsworthy here.
Can I also submit an article whenever I plan to cut my toenails or swipe my terrace?

Can I also submit an article whenever I plan to cut my toenails or swipe my terrace?

Can I also submit an article whenever I plan to cut my toenails or swipe my terrace?
Sure, if your toenails are being used in the Linux kernel.
Rust isn’t that esoteric. I’ve tried it twice. The first time I bounced (poor language documentation), Recently I tried again, and this time I managed it. Well, in the sense that I could actually do what I tried to do. But the libraries I need still aren’t present. I’d do better with go, though I hate their development environment. Eventaully, though, I narrowed things down to Python or Java, because of the ability to have the same program run on different systems. Currently I’m trying Java, even th
Tuples, when I got around to researching that point, didn’t seem to have ANY advantage over the custom class. And a few disadvantages (like not being able to choose the variable names).
Fine, but don’t put too much effort into it. Let organizations define their own style rules, and automate them using standard tools.
Different groups have different ideas, and sometimes genuinely different needs.
They chose to codify using spaces versus tabs for indenting, which just reeks of amateur hour. It’s what drives me crazy about Python, where it’s even worse when people do that because of the silly way Python treats whitespace as flow control. Merging different codebases is a nightmare. With tabs, no one cares that your editor is setup for 4 spaces per tab and theirs is set up for 2, it all just looks like everyone thinks it should and it works. Spaces are inflexible, and there’s no good argument I can make
Amateur hour to enforce spaces? In all my 20yr professional life as a developer I’ve only ever seen enforced spaces. I don’t think “amateur” is the word you’re aiming for.
The ewhac 2021 C Coding Style Guide. [ewhac.org] Adopt no substitutes.
I’ve been fiddling with Rust off and on for the last year, and I’m still trying to work out how I want the code to look. Naturally, my preferences are informed by my preferences in C coding style, but one principle, I think, stands above all others:
Don’t make me hunt for important things.
Rust’s syntax is very fiddly and has lots of details, most of which are significant. It will be a challenge to work out a style that lets all of those det

Don’t make me hunt for important things.

Don’t make me hunt for important things.
One of the fundamental principles: Make everything important obvious. If it is not by itself, add something to make it as obvious as it should be. That is, for example, why an emergency shut-off is a big red button easily visible and usually breaking the aesthetics.

Rust’s syntax is very fiddly and has lots of details, most of which are significant.

Rust’s syntax is very fiddly and has lots of details, most of which are significant.
That does not sound good. In fact is sounds like an accident waiting to happen, especially in this combination. Second-system-effect?
Because that one is wayyy more important than some technical details, right?
Seriously, all this shows is how immature that language is.
Unenforced code style boosts creativity and personal expression (art).
I know this is just a guide, but, if you want to recommend or enforce a style, make it part of the language definition; that’s not difficult.
As several people have already said, you can always run a program you don’t like through a formatter to achieve any desired format, and there are probably programs to rename non-global variables to conform to your chosen convention.
As also said, this is all bike-shedding; the real thing that needs control, and is hard, is stopping bad programmers writing bad code. Som
Anyone that sits down and thinks “the best use of project time is to write a document telling everyone else to type their code the way I like it” should be removed from the project and never, ever, allowed back in.
We’re not punching Fortran into cards anymore; our team can use the style that we like and you can stuff yours where the sun never shines (Belfast).
I have seen arguments, I literately asked my professor, but never gotten a real reason.
Tabs, by definition are literally the exact thing you want for indentation, they are indentation by definition. A system and program independent universally recognized indentation. Any uses of spaces is literally just hacked together sort of tab emulation. At the end of the day it looks identical, but is just harder to work with, transfer files between people, needs way more back end coding to work right, and literally bl
I see.
While your code might look stupid to you on your peer’s computer, Would it not look good to him?
Or is it that 4 spaces looks better in notepad or Microsoft Office than 1 tab?
The problem is that tabs are historically 8 spaces but people want to use them to mean 4 spaces sometimes and this only causes problems.
If you use tabs and want them to work reliably they have to be 8 spaces, and 4 spaces seems to be the optimal indent level for code.
There may be more comments in this discussion. Without JavaScript enabled, you might want to turn on Classic Discussion System in your preferences instead.
433 People Won the Philippines Lottery. Was it Luck – or Cheating?
Why Hurricane Ian Killed So Many People
System going down at 5 this afternoon to install scheduler bug.

source

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles