11 ms·
Pff, these are nothing. Buckle up! * 1-based indexing is superior to 0-based indexing. * If you use spaces to indent code, or in any way rely on a fixed width
by dTal 6y ago
Pff, these are nothing. Buckle up!
* 1-based indexing is superior to 0-based indexing.
* If you use spaces to indent code, or in any way rely on a fixed width font to "line things up", you have a fundamental misunderstanding.
* Relatedly, the 80 column "rule" is as stupid in code as it would be in prose. Use your aesthetic sense.
* Vim and Emacs both have terrible user interfaces, and are an inferior experience to even a normal text editor let alone a decent IDE. Users have Stockholm Syndrome.
* For beginners, BASIC is great and Python is terrible.
* There are many languages with a 'mystique', like Lisp and APL. The correlation between 'mystique' and practical utility is inverse.
* Source code should liberally use Unicode symbols.
* Sigils to indicate variable type are actually pretty great, especially if enforced by the compiler. (See above regarding BASIC)
Let the flames begin!
- iab 6y agoI’m triggered
- dpedu 6y agoCan you elaborate on the fixed-width fonts point?
- gsoto 6y agoAs long as source code resides in plaintext files, writing in columns (i.e. vertically aligning blocks of text) seems like an excessive endeavor with little gain. We are not typesetting; formatting resources should be kept to a minimum to make the code easy to handle in plaintext. Fortunately, code is restricted enough that we can do pretty well without those. You don't write spaces to align text in Word: it's a nightmare to maintain and the software provides better tools for that purpose. Why do we still write code as if we were using a typewriter? You may think you are improving readability by aligning columns of text, but then, the impossibility of standardizing such baroque formatting rules goes against that. Furthermore, you are preventing people from using a variable-width font, which is actually better for readability.
- colejohnson66 6y agoSo you’re against any indentation? I don’t think you’ll find many programmers at all who agree with that statement.
- gsoto 6y agoIndentation is OK, sure. I was talking about aligning stuff on the middle of a line. I find tabs better for indentation but in practice end up using spaces.
- Izkata 6y agoI believe you'd like elastic tabstops: http://nickgravgaard.com/elastic-tabstops/ http://nickgravgaard.com/elastic-tabstops/
- gsoto 6y agoI love them! It's a shame they didn't really catch on.
- drdec 6y agoIf you are interested in experimenting with non-fixed width fonts for programming, you could try Source Insight. I was at a company that used it for a while and surprisingly, I didn't miss using fixed width fonts at all.
- 908B64B197 6y ago> Relatedly, the 80 column "rule" is as stupid in code as it would be in prose. Use your aesthetic sense. Horizontal scrolling is almost always a bad experience for the user. But 80 is way too restrictive. I'd say no more than half a standard monitor wide is the character limit. What's a standard monitor depends on what's used by the devs writing the code of course. > Source code should liberally use Unicode symbols. Give it a few years. But make sure there's a good normalization (there are several ways to print the same glyph on the screen that are different bytes in memory)
- spideymans 6y agoThe 80 column “rule” also discourages the use of descriptive naming, which IMO is far more important to readability than short lines. Also 80 columns is near impossible to adhere to for more verbose language.
- skrtskrt 6y agoFor both Python and Go I use descriptive (often long) names and ~90-char line limit, and use linebreaks liberally to reconcile the two
- bjourne 6y agoDescriptive naming usually isn't. E=m*c^2 or objectEnergyInJoule = massOfObjectInKilograms * speedOfLightInVacuum^2 ?
- DangitBobby 6y agoNow imagine that you're not looking at a famous equation and you tell me which one you would rather have to sus out the intention of. a = b/c or numApples = numBananas/apple BananaConversionRate
- bjourne 6y agoThe first one, no question about it.
- recursive 6y agoSpaces for indentation work perfectly fine without fixed-width fonts. If you indent code with leading spaces, things will "line up" with any font. By the way, what's the misunderstand with lining things up?
- rhn_mk1 6y agoI'll demonstrate using periods due to the forum eating spaces. The parts after the dots line up in a monospaced font. Fixed width:.good Flexible:....not good .............so not good
- recursive 6y agoThis doesn't make any sense. Indented code does not have non-whitespace characters to its left.
- rhn_mk1 6y agoSure it does. const ONE = 1; const MILLION = 1_000_000; Even without non-whitespace it's a problem: def foo(arg1, ........arg2, ........arg3)
- recursive 6y agoYour first example isn't what I'd call indentation. "Alignment" maybe. I don't think anyone would expect that to work in a proportional font. For the second one, I'd write it this way. def foo( ....arg1, ....arg2, ....arg3) I prefer that even in a fixed width font.
- rhn_mk1 6y agoThis still matches the parent's picture > If you use spaces to indent code, or in any way rely on a fixed width font to "line things up", you have a fundamental misunderstanding. As long as the limitations of lining things up "exactly" are avoided, spaces shouldn't be any different than whatever way comes from true understanding.
- gsoto 6y agoCan I marry you? I will add: * Tabs > spaces * Proportional > monospaced * White background > dark theme
- pc86 6y agoThough I hate what you say, I will defend to the death your right to say it. But holy cow the white background made me angry hahah
- seph-reed 6y agoWhite background if there's a window near-by. Dark background if in a dimly lit space. I don't know if I use tabs or spaces anymore. I hit tab, but my IDE just sort of makes it up from there. Works well enough.
- colejohnson66 6y agoVisual Studio (not Code) handles it quite nicely. If you hit tab and it replaces it with 4 spaces, then you backspace, it removes the 4 spaces as if they were a tab. So it saves with spaces, but treats them like tabs.
- godshatter 6y agoI've been switching over to tabs to mark indentation levels and spaces for alignment after that. I used to use all spaces. Disagree completely on the proportional fonts, but maybe I just haven't tried one. Code presentation is important to me, since it makes it really easy to grok the structure of what's going on and to find some simple errors if you align certain things together.
- MeinBlutIstBlau 6y agoFluorescent white is for accountants and managers.
- Retardo_88 6y ago"For beginners, BASIC is great and Python is terrible." I am curious about this. Do you mind elaborating?
- worik 6y agoWhat was your first language? Mine was Basic. Pascal was the first language I was taught in. I still have not (after 40 years) learnt Python... Hang on, when did Python start....That long
- dTal 6y agoConsider the the classic koan: 10 PRINT "Retardo_88" 20 GOTO 10 To fully grok this, the concepts you need are: the idea that you can instruct a computer to do things, the notion of source code as a list of such instructions which will normally be executed one at a time, in order, and - crucially - that the instructions can reference other instructions and that this is the fundamental leap that makes computers interesting. In other words, Turing Machines 101. It's a perfect demonstration. Now consider the simplest equivalent program in Python: while(true): print("Retardo_88") In addition to all of the insights mentioned above, you need the concept of higher order control flow statements, the concept of nested execution, the concept of boolean literals, the concept of a function call... there are so many questions that are hard to answer. Why do I need parentheses? Why do I need the colon? What's the deal with the indent? What gives with the weird grammar of "while true"? Etc... It gets worse the moment you want to do anything nontrivial and have to wrestle with objects, methods, and dot-syntax. BASIC sends the message that computers are simple, easy to grok things that follow simple, logical rules; Python sends the message that they are a bottomless well of dizzying complexity.
- lninyo 6y agoAs a perpetual beginner, I feel BASIC is under-rated. We should use BASIC to start children off with computing. They'll learn the hairy stuff in due time, but the key is to get them hooked early; and BASIC does an awesome job of that.
- centimeter 6y ago
- AnimalMuppet 6y agoYeah, let's use Unicode symbols. That lets us, for example, make it a challenge for others to figure out how to type stuff that they need to type. It lets us create variables that use characters that have almost exactly the same appearance as latin characters, but aren't. For bonus hilarity, create two versions of the same variable name, one with a non-latin-but-similar-appearance character, and the other with the latin character. No thanks. Hard pass.
- lacker 6y agoYou could also use six different “right arrow” Unicode symbols, and have them each mean multiple different things, automatically inferred by the compiler depending on context! See the Lean mathlib ;-)
- na85 6y agoIndeed. If there's no button to type it directly on my keyboard, I'm not interested in having it in my code.
- worik 6y agoNot all keyboards are the same... !@#$%^&*()_+}
- na85 6y agoThat's why I said my keyboard. I'm not aware of any keyboards that would let you type the arcane runes used in APL without resorting to ALT-sequences or the Compose Key. On a related note, if I could get a keyboard with an extra 50-60 keys that would send the proper scan codes to type unicode characters in one keypress that would be awesome.
- jazzyjackson 6y agoI'm a big fan of unicomp keyboards, heavy steel buckling spring keyboards still made in kentucky. They make one with 24 function keys I suppose you could map. https://www.pckeyboard.com/page/product/UB40B5A https://www.pckeyboard.com/page/product/UB40B5A Then there are the point of sale keyboards, this one has 60 keys you insert your own paper labels. https://www.officedepot.com/a/products/361528/CHERRY-SPOS-Small-Point-of-Sale/ https://www.officedepot.com/a/products/361528/CHERRY-SPOS-Sm...
- lacker 6y agoHave you tried formatting tools like prettier / black / gofmt / rustfmt? I used to have lots of tabs vs spaces type opinions but now “use a formatting tool and stop arguing about it” has replaced all of my style opinions. Once you have more than one person working on a project it’s just so nice to never have a stupid argument about formatting again.
- kortex 6y agoAgreed. It's a controversial opinion that opinionated languages/formatters are the way to go. :)
- catears 6y agoIt will always baffle me how some programmers believe that meetings are the bane of their existance because "they only waste time", while at the same time they can entertain the "tabs vs. spaces" (or "vim vs. emacs") discussion for hours. I don't care about the indentation method, I just want to press Tab, or Ctrl+S and have it do the right thing. Not waste any brainpower thinking about it.
- galkk 6y agoNow we're talking! Although given that I, random internet stranger, agree on 6 out of 8 of your points, it mean that they aren't too unpopular. :)
- bryanrasmussen 6y ago>Although given that I, random internet stranger...it mean that they aren't too unpopular. :) there is a common perception that programmers often don't get statistics. Not that I do either, but just saying.
- galkk 6y agocontroversial opinion: the need of statistics and hard math for programmers is overrated :)
- bryanrasmussen 6y agoreally controversial opinion: the abilities of programmers to use statistics and math is just right!
- na85 6y ago>If you use spaces to indent code, or in any way rely on a fixed width font to "line things up", you have a fundamental misunderstanding. What if I just like the aesthetics of consistently-indented code?
- cannam 6y agoI agree with every item in principle, and disagree with every one in practice. Here's to a better world!
- leetcrew 6y agoI pretty much agree with all of these but two. > 1-based indexing is superior to 0-based indexing. this breaks the identity `arr[idx] == *(arr + idx)`. as a c++ (and sometimes c) dev, I tend to consider "index" and "offset" to be functionally equivalent. hard pass. > If you use spaces to indent code, or in any way rely on a fixed width font to "line things up", you have a fundamental misunderstanding. I find "lining things up" to be pretty helpful for spotting mistakes in tedious code (eg, matrix initialization) where you have a bunch of similar lines of code in a row. am I missing your point, or do you just not agree this is useful?
- ghaberek 6y ago> this breaks the identity `arr[idx] == (arr + idx)`. as a c++ (and sometimes c) dev, I tend to consider "index" and "offset" to be functionally equivalent. hard pass. And I think that's the problem. Programmers have collectively conflated the concept of "offset from the address" and "position in the list" as the same concept, and they're not the same thing. Both concepts have their uses but they're separate distinct concepts. C and C++ don't index* a list, they simply offset it, and too many other languages that don't care about in-memory addresses or offsets have carried the concept from offset over to index erroneously.
- leetcrew 6y agoI can see how in a higher-level language it might make sense to use 1-based indices. this is, after all, how humans typically count. I just don't agree with it as a general statement over all programming languages. in low-level contexts where you are working directly with memory, it is quite natural for indices (or idx * element_size) to be equivalent to offsets.
- kaba0 6y agoDepending on the context of the program, both can be more comfortable. Pointers/enumerators? 0-based Heavy math problem? 1-based I believe there is a few languages which can let you set it
- 6y ago
- mhh__ 6y ago> Vim and Emacs both have terrible user interfaces, and are an inferior experience to even a normal text editor let alone a decent IDE. Users have Stockholm Syndrome. Well yeah, the UI isn't great. The whole point is to make it your UI, no? I agree that Python isn't great for beginners, but I don't think BASIC is great either beyond a simple introduction to how we make computers do our bidding.
- JimTheMan 6y agoI learnt C as a first language, but think Python is a great language for beginners! Forces okayish formatting, error codes are pretty readable, good library support for doing everyday useful things (for people not in the cs community), you don't have to strictly worry about type for your tiny scripts... Why do you think it's not great? (in all sincerity)
- mhh__ 6y agoPython teaches people that Python is a good way to do software. The indentation is nice, but the language is not much more high-level than C, teaches bad habits by not thinking in types and granular interfaces, and encourages a counterproductive style of defensive programming - i.e. C++ is an awful language, but at least I can encode basic information about my code in the type system. Python trades that away so I have to write tests for the entire surface area - inside and out - of my code. If there is something fundamentally wrong with my code, tell me now, not when it's half way through a job or worse attached to spending money. You can write bad code in any language, but bad languages influence the way you think about programming. For example, C++ encourages you to think about side-effects in the language like SFINAE, D encourages you to metaprogram everything, Rust encourages you to think like a compiler (lifetimes), Haskell teaches you how to manage stateful code in a controlled and measured manner, etc. etc. In conclusion, Python is not a terrible place to start (JS takes that award to my eye), but the progression to writing genuinely reliable and fast code is too obfuscated. I'd rather we teach people C. C requires a helping hand, you can fumble around with Python.
- commandlinefan 6y ago> 1-based indexing is superior to 0-based indexing. “Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.” - Stan Kelly-Bootle
- pjlegato 6y agoClojure is a highly practical Lisp that retains most of the Lisp mystique. Previous Lisps were impractical largely due to lack of libraries, but Clojure comes with first class Java interop out of the box. But you still get macros.
- deleted 6y ago[deleted]
- user-the-name 6y ago"Give your controversial opinion" always, always just leads to to people saying the thing they know people they like will agree with and, and that they imagine people they dislike will disagree with. In practice, they end up just saying things that are entirely uncontroversial and immensely boring. You, though, you're getting there.
- voldacar 6y ago>The correlation between 'mystique' and practical utility is inverse. lol tell that to the banks and trading firms that pay Arthur Whitney millions for his APL interpreter that looks like something out of the IOCCC
- voxl 6y ago* 1-based indexing is superior to 0-based indexing. 1-based indexing is a special case of 0-based indexing. * If you use spaces to indent code, or in any way rely on a fixed width font to "line things up", you have a fundamental misunderstanding. Fundamental misunderstanding of what? Not having shit PRs on Github? * Relatedly, the 80 column "rule" is as stupid in code as it would be in prose. Use your aesthetic sense. Yeah okay true * Vim and Emacs both have terrible user interfaces, and are an inferior experience to even a normal text editor let alone a decent IDE. Users have Stockholm Syndrome. Also true * For beginners, BASIC is great and Python is terrible. The language for a beginner is irrelevant, the only metric that matters is: Are you enjoying your coding experience? Keeping students coding is all that matters the language is irrelevant. * There are many languages with a 'mystique', like Lisp and APL. The correlation between 'mystique' and practical utility is inverse. This is almost a tautology, of course mystique will lead to less practical utility because their is simply less interest, less tooling, and less understanding about how to use the tool. * Source code should liberally use Unicode symbols. Someone has never looked at Agda source code before and it shows. * Sigils to indicate variable type are actually pretty great, especially if enforced by the compiler. (See above regarding BASIC) Gross.
- flippinburgers 6y agoVim is not a gui aka no user interface. I know you are joking though: vim > emacs > any IDE!
- umanwizard 6y agoemacs is essentially a framework for building custom IDEs.
- justincredible 6y agoThe command line is a user interface.
- ordu 6y ago> Let the flames begin! Yeah, it seems that your evil plan works. People just can't stand it despite your clearly stated intent.
- cambalache 6y ago> 1-based indexing is superior to 0-based indexing. Yes! But programmers are weird like that,I understand the rationale in case of C(Nothing that couldnt be solved then and there) but for high level or scientific computing? How many off by one bugs caused by this? > If you use spaces to indent code, or in any way rely on a fixed width font to "line things up", you have a fundamental misunderstanding. Agree, that's one of the things I hate about python, the indentation are probably the worst solution to the problem of scoping code. > Relatedly, the 80 column "rule" is as stupid in code as it would be in prose. Use your aesthetic sense. Agree > Vim and Emacs both have terrible user interfaces, and are an inferior experience to even a normal text editor let alone a decent IDE. Users have Stockholm Syndrome. Agree, both are very good pieces of software but I feel 99% of the new people swearing by them just do it to try to appear l33t > For beginners, BASIC is great and Python is terrible. In 1995? Perhaps. Now? Hell, no. > Source code should liberally use Unicode symbols. Hell no. > There are many languages with a 'mystique', like Lisp and APL. The correlation between 'mystique' and practical utility is inverse. More or less, great, but difficult, programming languages would never become mainstream, and like good old Joe Stalin used to say "quantity is a quality on its own" > Let the flames begin! As always with these type of comment OP is not as alone as they think they are.
- umanwizard 6y agoNot sure why 1-based indexing is more logical in high-level or scientific computing. The concept of x[k] meaning the object k spaces away from the beginning of x is very general, and still intuitively meaningful in languages without pointer arithmetic.
- cambalache 6y ago> Not sure why 1-based indexing is more logical in high-level or scientific computing. Because mathematics and physics use 1-based array index since ever? I first learned about matrices in math classes, then in numerical methods (All 1-based) and then we programmed in Fortran (1-based). It is not that is more logical, it is just a convention. But I have seen wayyyy more people complaining about 1-based index languages than about 0-based languages.
- pgcj_poster 6y ago> the 80 column "rule" is as stupid in code as it would be in prose I follow the 80-column rule in prose.
- otabdeveloper4 6y agoEmacs was a godsend for my 16 year old self. It's an immensely self-documenting and self-explanatory system, and vastly different in that regard than anything else. (Though once you go down the rabbit hole you eventually start to realize that elisp is a crappy way to program and the whole thing has a big-ball-of-mud architecture... Oh well.) Point is, your preconceptions, from the heights of your experience, of what "newbies" find intuitive are likely very wrong.
- anonytrary 6y agoI know you're joking, but the key difference is that OP's "controversial opinions" are high impact, whereas yours are not (e.g. spaces vs. tabs, 1-based vs. 0-based indexing). I don't think most of the opinions in the post are that controversial. Everyone who has ever worked for a fast-growing business knows it's OK to write garbage code sometimes, that some engineers 10x others, that unit tests are good, that SQL is to be treated as code, etc.
- lionkor 6y agozero index makes sense because (and i will use C syntax here) a[b] is equivalent to *(a + b) with a being a pointer and b an integer. this can be seen as well in the fact that a[b] is equivalent to b[a] where in both cases a is a pointer and b is an integer. Thus, the index into an array is fundamentally the same as an offset into that array. Usually, in languages that do use 1-based indexing (like in pascal strings), the 0th byte is used for something else. The point being that thinking in terms of 1-based indices means that you have to use a system where addr+0 is invalid, and the first element of an array at address X is X+1. Now you could just shift everything by 1 and just declare that +1 means +0, but then you lose all meaning to the offset vs index and ahhhhhh
- isogon 6y agoIn my view, the fact that a[b] is equivalent to *(a + b) in C and C++ (in most languages with arrays the latter notation is meaningless) is a sort of a neat coincidence which we shouldn't feel bound to in language design in general. There are many reasons to depart from this idea in languages far removed pointer arithmetic. For example, Julia has 1-based indexing and I appreciate it for that when doing computational mathematics. It is closer to familiar notation: A[1][1] is the element of matrix A in row 1 and column 1. In a language with zero-based indexing, it is sometimes easier for me to allocate an extra row and column, wasting memory, than to shift indices and risk an inevitable off-by-one somewhere.