6 ms·
Python is one of the most widely used languages out there and doesn't have C-like syntax really
by skohan 6y ago
Python is one of the most widely used languages out there and doesn't have C-like syntax really
- chrisseaton 6y agoThere's not many examples beyond this though... it does seem to be the case that people either choose C syntax for successful languages, or those languages are successful possibly because of C. Why did Rust move from an ML syntax to a C syntax?
- dragonwriter 6y ago> There's not many examples beyond this though... Ruby, though still in the Algol-derived syntax family, is even less C-like than Python.
- skohan 6y agoThat's true, and that's probably why even though I have had to modify ruby code and write simple scripts at various points in my career, I never got to the point where I fully grep the syntax. Maybe that's why C-like syntax is so popular.
- steveklabnik 6y agoWe wanted to cater to an audience of systems programmers, so we tried to stick to a familiar syntax where possible.
- skohan 6y agoI know this opinion will not be received well, but I'm really sorry this extended to things like semicolons, snake_case, and the overloading of the term vector to refer to variable length arrays. I'm a big fan of many of the decisions made in Rust, but those are things which I wish we could have let die in the systems programming language of the last decades.
- steveklabnik 6y agoIt's cool. I strongly prefer those things. That's why no single language will ever rule them all.
- skohan 6y agoTo each his own, but out of curiosity what do you like about using the term Vec for dynamically-sized arrays? To me it just seems that it's an inaccurate usage of a term with a precise mathematical meaning (what is a vector of strings exactly?), and as somebody who works with linear algebra a lot in code, it's a frequent point of consternation to have this built into two of the most relevant languages for achieving high performance.
- chrisseaton 6y ago> what is a vector of strings exactly? You can have a vector of integers, a vector of real-numbers, why do you think a vector of strings doesn't make any sense? Strings can be given a well-defined ordering. You can think about strings as a points along a string-line, if you want to. For example - Java often names packages using co-ordinates (vectors) in an n-dimensional string space. Seems to make sense to me?
- skohan 6y agoMaybe in some technical way this is correct, but when I'm pushing a string onto a vector of strings, I'm not thinking about conceptually adding a dimension to my vector in string space. And how would you compute the cross product of <"foo", "bar", "baz"> and <"apple", "orange", "banana"> exactly?
- chrisseaton 6y ago> And how would you compute the cross product of <"foo", "bar", "baz"> and <"apple", "orange", "banana"> exactly? How would you compute the cross product of <NaN, NaN, NaN> and <NaN, NaN, NaN>? Some vectors don't have a useful result for cross product, even if they contain 'numbers' and even if you can get some kind of result out. Same with dot product of a string. Doesn't make much sense... so probably don't do it.
- skohan 6y agoWell it makes sense to converge towards something right? Unless a programming language is using a radically different paradigm, like Lisp or Prolog, or if it is purely a syntax experiment, why not go with a C-like syntax and have every programmer in the world be able to instantly ready your code and basically understand what's going on.
- SomeoneFromCA 6y agoI'd say, no it is simplified C-like syntax in disguise.
- cies 6y agoI agree. Although Python is the best kinda counter example. If you remove semicolons and use indentation over curlies in C it will look pretty pythonesque.
- dahfizz 6y agoPython is not exceptionally C-like, but a typical python script is readily understood by someone familiar with C. Smalltalk, on the other hand is not. This LOC is from the wikipedia example page: #($a #a "a" 1 1.0) There's no way a C programmer can know what that means without looking it up.
- mumblemumble 6y agoThis comment makes me feel a little bit sad. It doesn't take too much breadth of knowledge to recognize those all as different kinds of literal syntax, even if you don't know the exact details. #(...) for some sort of collection, probably a list or vector, $a and #a for different kinds of atomic value, even if it's hard to guess whether any one of them represents a symbol, a character literal, a perl-style variable reference, or something else. If such prosaic syntax is really so unfamiliar-looking nowadays, it really speaks to a major gap in how people are taught about programming. Comparable to if it were common for younger mechanical engineers to not even recognize a slide rule when they see one.
- skohan 6y agoIs that a typical line of smalltalk? I mean if this is representative I can understand why C-like syntax won. Surely a language with descriptive names, and a call syntax resembling: subject.verb(arguments) Is more intuitive than the example you've given. Of course it's also quite possible to write an equally cryptic line of C code.
- scroot 6y agoNo, this is not a typical line of Smalltalk. That would be considered a very sloppy array indeed. I think it's just there to demonstrate the different literal notations in the language. Smalltalk is actually quite readable in practice, though the keyword syntax seems to throw off experienced programmers from other languages. It's worth noting that the language was originally tested on children, so it was also designed to be easy to read and learn. The equivalent of your C code above could be something like: MyObject doSomethingWith: anArgument
- dragonwriter 6y agoPython, like C, has basically Algol-derived syntax (it's not far from the Pascal-inspired pseudocode that was dominant form of pseudocode for a long time); Smalltalk does not. It's not a direct linear descendant of C the way C++, Java, C#, and lots of other relatively recent languages are, but it's still a lot closer to C than Smalltalk is.