4 ms·
Your comment about syntax sounds like you just want everything to look like C.
by ufo 9y ago
Your comment about syntax sounds like you just want everything to look like C.
- luckydude 9y agoYes, precisely. C, for the most part (function pointers are an exception) has a pleasant syntax. Go didn't like semicolons and other stuff that it found unneeded, but mostly took a lot of syntax from C so it's easy to read Go code even without understanding the language. Rust kind of went in a different direction. Why? Understanding C syntax is pretty basic, there are a lot of C like languages. Why not be another one? Personally, if every language was just a C variant I'd be happier. It would feel like "OK, I've got the basics down, let's go explore this dialect that added garbage collection and strings as real types" rather than "I want strings as real types, darn it, I need to go learn this Tcl language". That might be an extreme way to make my point, but I think it's clear, right?
- jjuel 9y agoWhat about the people that don't like the C style syntax? I think there is room for many different types of syntax. Just stick to the style of languages you like and ignore the ones you don't. Pretty simple.
- ufo 9y agoOther than its ubiquity, there are lots of bad thigns about C's syntax: * Assignment as an expression is bug-prone * The precedence for the binary operators is wonky * Optional braces in if statements make the grammar ambiguous and is also bug prone (the infamous Apple goto bug) * The type-declaration syntax is convoluted and people need tools like cdecl to understand the more tricky ones. * The cast syntax is ambiguous and resolving this ambiguity relies on adding dirty hacks to the lexer to tell the parser about type names.
- p0nce 9y ago> Assignment as an expression is bug-prone Can be fixed without syntax change other than returning void. > The precedence for the binary operators is wonky But that's the precedence everyone is accustomed with. D enhance this by forbidding some non-parenthesized dangerous expressions. > Optional braces in if statements make the grammar ambiguous and is also bug prone (the infamous Apple goto bug) I've definately seen such bugs. > The type-declaration syntax is convoluted and people need tools like cdecl to understand the more tricky ones. This is fixed in languages that still feel C-like in syntax. > The cast syntax is ambiguous and resolving this ambiguity relies on adding dirty hacks to the lexer to tell the parser about type names. Yup.
- p0nce 9y agoWhat is the added value of things not looking like C?
- luckydude 9y agoYeah, exactly the right question. To me, C is like English, everyone has learned how to speak it. Creating some new syntax is a little like switching to a different language. I find that difficult and annoying. Here's an example. When I was doing the GUI tools for BitKeeper 20 years ago I used Tcl because Tk was (and still is so far as I can tell) the best gui toolkit around. But Tcl? Holy moly, what a miserable language (with apologies, and respect to John O, it's miserable). So I got some compiler people to make a second, parallel, compiler that took what looked like C as input and compiled it down to Tcl byte codes. Pingo! All the power of Tk but with a C-like language on top. And you can call the tcl library code and it can call you. All open source at http://little-lang.org http://little-lang.org I wish someone would take the ideas there and make a gcc/clang dialect that had all C stuff but added in a ref counter and real strings, etc.