21 ms·
Are there any languages where code-style is required to be a certain way? or it won't compile. I mean full authoritarian about everything, not just based around
by have_faith 9y ago
Are there any languages where code-style is required to be a certain way? or it won't compile. I mean full authoritarian about everything, not just based around white-space like python.
- arghwhat 9y agoSome have little that can differ, such as assembly, but not that I know of at least. Some define a "proper" way, though (PEP-8, gofmt, and doesn't rust also have a rustfmt?).
- steveklabnik 9y agorustfmt exists, and has come a long way recently, but is not quite ready to be distributed with Rust by default yet. Soon though!
- mrec 9y agoI think the original question was about full-on enforcement of style rules as grammatical rules, by the compiler, as proposed by Ken Arnold in his 2004 essay Style is Substance [1]. AFAIK nothing like that is remotely on the cards for rustfmt. [1] http://www.artima.com/weblogs/viewpost.jsp?thread=74230 http://www.artima.com/weblogs/viewpost.jsp?thread=74230
- steveklabnik 9y agoAbsolutely.
- mmarx 9y agoThe gnat Ada compiler has style warnings, which, together with -Werror, ensure that you don't write non-conforming code.
- Athas 9y agoYes, old fixed-format languages like FORTRAN and RPG (the older versions). Everything had to be written in specific columns, due to their punched card heritage.
- mmarx 9y agoFixed-format FORTRAN isn't actually that rigid. The first six columns have special semantics, but apart from that, the compiler is not going to enforce a certain style.
- user5994461 9y agopython indent wrong and it doesn't run.
- _asummers 9y agoGo uses gofmt, which pretty much achieves what you're looking for. Lisp code, emacs generally will generally just clean up idiomatically though that's less what you're looking for.
- xyzzy_plugh 9y agoThis is where Go really dropped the ball. They had the perfect opportunity to move lint and fmt (and vet and the rest) into the compiler. I don't for the life of me understand why they did not.
- nitrogen 9y agoMany teams configure their CI systems to fail builds if they don't pass style checks. This can be great if there's some situational flexibility since no autoformatter is smarter than a human that knows the code, but terrible if there's a formatter (like prettier) that defines only one true format and sometimes gets things horribly wrong.