Syntax refers to the set of rules that define how to write a correctly structured program in a language. It explicitly does not deal with the program's meaning or interpretation.
2
votes
1answer
40 views
Objective C - nested messages … confusion about
Wonder if anyone could shed some light on this messaging construct:
The documentation says that messages appear btwn brackets [] and
that the msg target/object is on the left, whilst the msg itself ...
31
votes
2answers
1k views
Why do bitwise operators have lower priority than comparisons?
Could someone explain the rationale, why in a bunch of most popular languages (see note below) comparison operators (==, !=, <, >, <=, >=) have higher priority than bitwise operators (&, |, ...
1
vote
1answer
49 views
Helper Methods Placement
Here's a question that's always bugged me. I'm going to use java as an example because I've almost never run into a problem in java where I didn't need to use helper methods in its class structure.
...
3
votes
2answers
653 views
Why do more languages not support ===
I mean it as it is used in JavaScript. Just curious why this is not supported in more languages? Like Java for example does not have it? Seems to be a very useful operator to have.
43
votes
7answers
2k views
Why are semicolons and commas interchanged in for loops?
In many languages (a wide list, from C to JavaScript):
commas , separate arguments (e.g. func(a, b, c)), while
semicolons ; separate sequential instructions (e.g. instruction1; instruction2; ...
26
votes
9answers
1k views
What is the difference between “Syntax” and “Syntactic Sugar”
Background
The Wikipedia page on Syntactic Sugar states:
In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. ...
2
votes
2answers
122 views
When to (enforce) linting in a software project
I'm heading a new team of developers working on a software project that makes use of continuous integration (circleci) w/ a pretty fleshed out suite of busterjs unit/integration/acceptance tests. Our ...
39
votes
11answers
11k views
What's the difference between syntax and semantics?
I've always thought that referring to the syntax of a language was the same as referring to the semantics of a language. But I've been informed that apparently that's not the case. What's the ...
4
votes
6answers
1k views
Is there a language that transcompiles to C with a better syntax? [closed]
CoffeeScript is a language with a very clean Ruby-like syntax that transcompiles to JavaScript. Does the same thing exists with C? Then writing more readable and as fast as original C programs would ...
41
votes
4answers
16k views
Why do programming languages, especially C, use curly braces and not square ones? [closed]
The definition of "C-Style language" can practically be simplified down to "uses curly braces ({})." Why do we use that particular character (and why not something more reasonable, like [], which ...
2
votes
3answers
511 views
Checking “instanceof” rather than value using a switch statement
Is there some syntax (other than a series of if statements) that allows for the use of a switch statement in Java to check if an object is an instanceof a class? I.e., something like this:
switch ...
20
votes
11answers
1k views
Is there a language out there in which parameters are placed inside method name?
in JavaScript:
function getTopCustomersOfTheYear(howManyCustomers, whichYear) {
// Some code here.
}
getTopCustomersOfTheYear(50, 2010);
in C#:
public List<Customer> ...
6
votes
4answers
387 views
Backquoted symbols, good or bad?
I'm designing a programming language which has three kinds of quoted entities: strings and characters as in C, and symbols (interned strings intended for use as lookup keys and such) which I consider ...
11
votes
4answers
633 views
Why store a function inside a python dictionary?
I'm a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me ...
9
votes
8answers
999 views
Rigorous Definition of Syntactic Sugar?
It seems like in language holy wars, people constantly denigrate any feature they don't find particularly useful as being "just syntactic sugar". The line between "real features" and "syntactic ...
70
votes
15answers
4k views
Why do memory-managed languages retain the `new` keyword? [closed]
The new keyword in languages like Java, Javascript, and C# creates a new instance of a class.
This syntax seems to have been inherited from C++, where new is used specifically to allocate a new ...
7
votes
3answers
428 views
Why can't we write nested shorthand functions in Clojure?
I tried to evaluate a Clojure expression with nested shorthand functions today, and it wouldn't let me.
The expression was:
(#(+ % (#(+ % (* % %)) %)) 5) ; sorry for the eye bleed
The output was:
...
97
votes
12answers
8k views
Why are statements in many programming languages terminated by semicolons?
Is there a reason that a semi-colon was chosen as a line terminator instead of a different symbol?
I want to know the history behind this decision, and hope the answers will lead to insights that may ...
2
votes
1answer
166 views
Are there studies about foo/bar/baz and how they inhibit or facilitate comprehension?
Preface
foo,bar,baz are instantly recognizable signifiers of example or pseudo code. Their popularity seems to be a strong indication that the programming community accepts them as a good way to ...
8
votes
8answers
713 views
How important is it to learn makefiles? [closed]
I work in c++ mostly as a hobby (I'm still in school and therefor don't have a real job). The IDEs generate the makefile for me and so I'm wondering if it's worth learning how to make them myself. By ...
2
votes
1answer
149 views
How are “Json.org”-like specs graphs called and how can I generate them?
In http://www.json.org Douglas Crockford shows the specs of the JSON format in two interesting ways:
In the right side column he lists a text spec that looks like a YACC or LEX listing.
In the main ...
2
votes
2answers
104 views
How to programmatically construct textual query
Here is a query language, more specifically, it's JQL, you can use it in Jira, to search for issues, it's something like SQL, but quite simpler.
My case is that, IÂ need to construct such queries ...
2
votes
5answers
375 views
Why do node packages put a comma on a newline?
I'm learning node.js and am trying out Express. My first app had this code:
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = ...
1
vote
8answers
973 views
Do you use i-->0 for backward loops?
Some people write
for (int i=N; i-->0; ) doSomething(i);
instead of
for (int i=N-1; i>=0; --i) doSomething(i);
for backward loops. The --> "operator"1 looks very confusing at the first ...
1
vote
3answers
206 views
Syntax Memorization [duplicate]
Possible Duplicate:
Programmers forgetting syntax
Do programmers need a good memory?
I'm a new web developer. I began learning HTML/CSS around June of this year. I picked them up ...
2
votes
2answers
246 views
Why do different languages have different syntaxes? [closed]
It seems like if every language had the same core syntax but different semantics and features, new programmers or those learning a new language could focus on the theory and more abstract concepts of ...
20
votes
4answers
2k views
What's the difference between implementing an Interface explicitly or implicitly?
In Visual Studio I can right-click on an interface and choose to Implement Interface, or Implement Interface Explicitly.
public class Test : ITest
{
public string Id // Generated by Implement ...
10
votes
8answers
1k views
Why isn't functional language syntax more close to human language?
I'm interested in functional programming and decided to get head to head with Haskell. My head hurts... but I'll eventually get it...
I have one curiosity though, why is the syntax so cryptic (in lack ...
1
vote
3answers
210 views
How can you learn names of methods or classes of a framework or an API?
I've been programming C++ for a year now. I've gone through the language features and I've written good programs with it, so I decided to move on to OpenGL. At first it seemed confusing. As I kept ...
16
votes
11answers
1k views
Is there a language offering LISP-like macros with a more complex syntax?
LISP's macros are extremely powerful constructs, and the inability to introspect and modify the program itself beyond the method signature level has always struck me as a limitation. Yet I favour ...
13
votes
9answers
1k views
Teaching kids to program - how to teach syntax?
I've been spending this week teaching kids (11-18) to program. Teaching them the core concepts and the logic has been going fine, but I've noticed one snagging point for them all: syntax.
I feel like ...
4
votes
3answers
333 views
Omit terminating semicolon in a tag - a good idea?
It's possible to omit the terminating semicolon in a tag.
Example:
<table>
<th><td>Name</td><td>Email</td>
<? foreach ($receivers as $receiver): ?>
...
3
votes
5answers
314 views
Confusion regarding def function within Python
I've been learning Python for about 2 months now (Started with Learn Python The Hard Way, now reading Dive Into Python), and within both books, I still seem to be confused over this one bit of code.
...
10
votes
9answers
796 views
Should programming languages be strict or loose?
In Python and JavaScript, semi-colons are optional.
In PHP, quotes around array-keys are optional ($_GET[key] vs $_GET['key']), although if you omit them it will first look for a constant by that ...
11
votes
6answers
772 views
What do you think of this new if-then syntax
I was just thinking of something that would be really cool to have in my if-elif-else controls.
if condition:
stuff()
elif condition:
otherstuff()
then:
stuff_that_applies_to_both()
...
28
votes
14answers
4k views
Why is there still case sensitivity in some programming languages?
I don't see any use for case sensitivity in a programming language, apart from obfuscating code.
Why implement this in a programming language?
Update:
It looks like someone you know made a ...
8
votes
9answers
923 views
How should I pronounce the :: and -> in PHP?
When I read these lines aloud to someone:
$controller->process();
UserManager::getInstance();
How should the -> and :: be pronounced? Reading the characters themselves in cumbersome and I ...
5
votes
2answers
166 views
Can the Clojure set and maps syntax be added to other Lisp dialects?
In addition to create list using parentheses, Clojure allows to create vectors using [ ], maps using { } and sets using #{ }.
Lisp is always said to be a very extensible language in which you can ...
2
votes
2answers
186 views
What defines a language as a scripting language? [duplicate]
Possible Duplicate:
What is the main difference between Scripting Languages and Programming Languages?
I'd like to know what defines a language as a scripting language compared against ...
3
votes
2answers
194 views
Are “backwards” terminators for if and case unique to shell scripting?
In bash at least, if and case blocks are closed like this:
if some-expr
then
echo "hello world"
fi
case $some-var in
[1-5])
do-a-thing
;;
*)
do-another-thing
esac
as opposed to the ...
1
vote
2answers
314 views
What are complete programming languages with a minimal syntax and how is that important? [closed]
With minimal syntax I mean a language that could be entirely described with the least words possible, but complete enough to make any kind of program.
5
votes
1answer
139 views
Pythonesque global variable assignment
I'm designing a language with Pythonesque syntax, including casual creation of variables by assignment. I'm wondering at the moment exactly how to deal with assignment to global variables (and ...
15
votes
10answers
2k views
'<' versus '!=' as condition in a 'for' loop?
Say you have the following forloop*:
for (int i = 0; i < 10; ++i) {
// ...
}
which it could commonly also be written as:
for (int i = 0; i != 10; ++i) {
// ...
}
The end results are ...
3
votes
3answers
206 views
Eliminating tab characters in a new language
I'm working on a new programming language, which determines structure with indentation instead of braces in the manner of Python and CoffeeScript. Obviously placing lines indented with spaces next to ...
0
votes
2answers
88 views
Reinforcing Syntax Elements
I am currently learning Javascript, and there is one element of the syntax that I can just not seem to nail down. That element is adding semicolons at the end of each line. I have learned Python and ...
4
votes
5answers
287 views
How to remember the details (Core APIs) of one computer language?
I found my self often paused to check a certain usage of one core API when writing either javascript or Ruby. I am wondering how the other guys doing? Is it necessary to remember every Core API ...
0
votes
1answer
139 views
Syntax logic suggestions
This syntax will be used inside HTML attributes. Here are a few examples of what I have so far:
<input name="a" conditions="!b, c" />
<input name="b" />
<input name="c" />
This ...
27
votes
36answers
3k views
What syntax element do you hate most in a programming language you use frequently? [closed]
No matter how much you love a programming language, there are always a few details in it that aren’t quite as nice as they could be.
In this question, I would like to specifically focus on syntax ...
49
votes
6answers
2k views
Why the Select is before the From in a SQL Query? [closed]
This is something that bothered me a lot at school.
5 years ago, when I learned SQL, I always wondered why we specify first the fields we want and then where we want them from.
According to my idea, ...
0
votes
6answers
380 views
Syntax for goto labels
In C, C++ and some dialects of BASIC, goto labels are declared with the syntax label:. I'm working on a language that uses name: type as the syntax for variable declarations, so I'd prefer if possible ...
