Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on What is Backus–Naur form as applied in computer programming?

Parent

What is Backus–Naur form as applied in computer programming?

+3
−1

What is Backus–Naur form as applied in computer programming?

From Wikipedia

In computer science, Backus–Naur form (/ˌbækəs ˈnaʊər/) or Backus normal form (BNF) is a metasyntax notation for context-free grammars, often used to describe the syntax of languages used in computing, such as computer programming languages, document formats, instruction sets and communication protocols. They are applied wherever exact descriptions of languages are needed: for instance, in official language specifications, in manuals, and in textbooks on programming language theory.

If I understand this correctly, this is a standardization for writing pseudo code.

Is that correct?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

> this is a standardization for writing pseudo code. Yes, > for context-free grammars What I... (3 comments)
Post
+9
−0

For writing pseudocode? No. BNF is a notation—in practice, a family of similar notations, like how Markdown is a family of similar markup languages—for defining grammars.

In software development and computer science, a grammar is a set of rules for determining whether a sequence of symbols (characters, words, or any other small units of data) uses correct syntax for a given language. Most programming languages have their syntax specified by a grammar, and that grammar is often defined using some variation of BNF notation (although many programming languages impose additional constraints on the rules that BNF may be ill-suited to represent). But a grammar could also be used to define valid data file formats, communication protocols, or many other applications where symbols are being strung together in restricted ways to represent information.

BNF can be used formally, for example, as a way to represent a grammar to a program that will then use that grammar to parse or verify data. Or BNF can be used informally, as a way to communicate to humans what sorts of inputs will be accepted by a program or library. The latter use of BNF might be considered a form of pseudocode. But to say that BNF is a standard for writing pseudocode would be like saying that Markdown is a standard for writing blog posts—the application exists, yes, but it's a rather limited view of the concept.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

@#53410 please read the following thread and say there if you agree with elgonzo https://software.... (12 comments)
@#53410 please read the following thread and say there if you agree with elgonzo https://software....
deleted user wrote over 2 years ago

r~~‭ please read the following thread and say there if you agree with elgonzo

https://software.codidact.com/comments/thread/6233

r~~‭ wrote over 2 years ago

I didn't see the comments that were deleted in that thread, but in my opinion elgonzo's initial comment is absolutely correct, both with respect to the facts of the matter and with respect to the advice that ought to be given to a junior JavaScript developer who posted the code you did.

With respect to this question and answer, don't get too hung up on the fact that elgonzo mentioned BNF. The convention of square brackets to denote optional elements is present in some variants of BNF, but not most; and I've seen that convention used in much documentation that otherwise has nothing in common with BNF. It's a questionable choice to use it where it could be confused with a JavaScript array, but the library author presumably expected a JavaScript developer to immediately recognize that line as invalid JavaScript and to reach for more creative interpretations.

deleted user wrote over 2 years ago

r~~‭ I don't understand, do you think that I don't understand JavaScript fundamentals just because I didn't recognize that this was pseudocode?

deleted user wrote over 2 years ago · edited over 2 years ago

Furthermore, now I do know that this was brackets pseudocode and have learned to recognize such pseudocode (call it BNF or otherwise) so by that logic now I do know the fundamentals of JavaScript syntax.

r~~‭ wrote over 2 years ago

Frankly, yes, it is evident that you are still learning JavaScript. There's nothing wrong with that—we're here on this site to learn and to help others learn! And you're right that you will eventually master the language by making mistakes and remembering what you learn from them. But don't be over-confident and assume that your most recent mistake is the last one you needed to make before reaching mastery. Nobody here is interviewing you for a job; you have nothing to prove to anyone except yourself. Which will help you learn more, humility or defensiveness?

The clues that tell me that the line is pseudocode have nothing to do with the brackets, by the way. Do you know what they are?

deleted user wrote over 2 years ago

r~~‭ I am not a JavaScript master or expert, but I disagree that I don't know the fundamentals of JavaScript syntax because I know what is assignment, comparison, variable, procedure, array, object, property, method, setTimeout(), setInterval() etc. are and have written many JavaScript codes which just work:

https://github.com/benaharoni/javascript

const iframes = iFrameResize() AND the brackets tell me this is a pseudocode.

r~~‭ wrote over 2 years ago

Looks like a nice set of notes. When you have learned JavaScript, you will be able to do more than enumerate things that you have gotten to work; you will also be able to explain why something doesn't work.

There is nothing invalid or pseudocode-ish about const iframes = iFrameResize(). That could easily be actual code. So can the brackets; as you surely know, square brackets are used in actual code to express array literals.

r~~‭ wrote over 2 years ago

The clues that tell me that the mentioned line is not actual JavaScript are the following:

  • css selector—there is no JavaScript syntax that allows two words, outside of a string literal, to appear next to each other with no punctuation between them, unless one of the words is a keyword (which neither css nor selector is).

  • [css selector] || [iframe]—taken literally, and ignoring the previous issue, this is the or-ing of two array literals, which is valid syntax but nobody would ever do it in real code. Arrays are always truthy, so the second array would never matter.

These specific clues are not facts that JavaScript developers memorize; they are instead straightforward consequences of the fundamentals of syntax and the logic primitives, which JavaScript developers do memorize. You should ask yourself why you missed both of them, if you know everything you claim to know.

deleted user wrote over 2 years ago

r~~‭ I can explain why something doesn't work to some extent.

I agree that I missed the issue about css selector but that's because I just copy-pasted the file without deepening in in.

I didn't understand the second thing you wrote about arrays, what will people never do in real life coding?

deleted user wrote over 2 years ago

r~~‭ I misunderstand why the fact that array is always truthy, should hinder any attempt to pass two or more arrays as arguments.

r~~‭ wrote over 2 years ago

Comments aren't for extended conversation. If you have more questions about JavaScript that aren't duplicates of your previous questions, and you can make the effort to make them good questions (i.e., you've researched them elsewhere, you've experimented on your own, you've read any relevant error messages, and you can clearly state what it is you still need help with) please make new posts and I or someone else will be happy to answer there.

deleted user wrote over 2 years ago

I will leave this community for good today. I thank you for pointing out that I lack only some or most JavaScript fundamentals, but not all. I greatly respect that.

Goodbye and all best.