HNHacker News
TopNewBestAskShowJobs

watergatorman

5 karma · joined December 21, 2018

submissionscomments
watergatorman··on Tell HN: C Experts Panel – Ask us anything about C
Some random thoughts:

I appreciate the original simplicity of K & R, "The C Programming Language", 2nd Edition, and the relatively simple semantics of ANSI C89/ISO C90 compared to C99 and later.

You don't need complex parsing methods for ANSI C89/ISO C90 and you do not need the "lexer hack" to handle the typedef-name versus other "ordinary identifier" ambiguity.

A surprising number of colleges still teach K & R 2nd Edition C.

Whenever someone brags about using recursive-descent parsing methods, I always ask, are they using predictive, top-down parsing, or back-tracking?

I hope C never loses sight of it's roots nor morphs into C++ under the guise of creating a common subset, but which is really a disguised superset of C and C++

Please prevent the ever increasing demand for new features from overwhelming C's simplicity so it can no longer be parsed with simple methods.

watergatorman··on Active Oberon Language Report Update 2019
I have compared both Modula-2 and Oberon-2 to Go, but have not compared Active Oberon to Go.

This was for purposes of creating a top-down, predictive, recursive descent parser for Go.

I am curious on how Go is being parsed. LR, LL, or ?

I am also curious about the CellType and PortType of Active Oberon. Do these correspond to Go's ChannelType and possibly to OCCAM and CSP Send and Receive Channels?

watergatorman··on Rob Pike on the reasons for Go’s success
IMHO, Oberon-2 WithStmt has much cleaner syntax than Go TypeSwitchStmt.

WithStmt is easier to parse, more general and it doesn't need the Primary "." "(" "type" ")" at the beginning which appears only needed to distinguish Go ExpressionSwitchStmt from Go TypeSwitchStmt.

wgator2

watergatorman··on Ask HN: Why is this C Programming Book Worth $674.99
Try this, it is highly recommended: "C Programming: A Modern Approach," 2nd Edition by K. N. King is selling for 111 USD, covering C89/C99 but the First Edition, covering C89 is only 60 USD

But if you want his "Modula-2: A Complete Guide", its only $300 new!

watergatorman··on The Programming Language Oberon (2016)
You possibly can use command-line redirection but whether OBNC can read directly from console output, I am not sure.
watergatorman··on The Programming Language Oberon (2016)
If I use module Out to write to STDOUT, is there a way for OBNC Oberon to Read the contents in that console window, so it can be treated as input.
watergatorman··on Ask HN: How do you memorize syntax?
You don't, at least if the syntax/semantics is as complex as Python!

Recommendation:

Find a subset grammar for Python, by doing a search on computer science classes on university sites. You will find the published Python subset grammars probably too small for your purposes, but they are a start.

See if any of those subset grammars meet your needs.

IF not, remove from the published official Python grammar, various features that you do not need or are not easily understood. I recommend you keep the production rule for "class"

When you get a subset grammar that meets your needs, it will have to be well-formed, meaning it passes reachability, derivability, and non-circularity tests, has no undefined non-terminals, and is complete with a start (i.e., goal symbol.

You should then remove left-recursion and left-factor the grammar so it is LL(1).

Run your grammar through some of the on-line syntax checking sites to be sure the grammar is unambigous and is LL(1). You can use the online Grammophone tool from the University of Calgary to check your subset grammar.

After the grammar passes the LL(1) tests, find a top-down, predictive, compiler-generator that generates recursive-descent parsers, and not tables. The compiler-generator will also perform tests on your grammar and let you know what needs fixing.

I forgot to mention that you will also need to define the lexical tokens needed for the scanner portion before you can generate your scanner and parser modules.

After you generate the scanner, parser, and a main module to call them, you will have created a fast syntax checker for your subset grammar.

Run the fast syntax checker, preferably within a program editor or IDE, as you write your Python programs

You can also create "template editing macros" that will insert into your editor, portions of a Python program, but with portions elided, that you gradually fill-in. Also, you can add syntax-highlighting to your editor.

watergatorman··on Test of HN to See If This Displays Unicode 1F801 (UpArrow)
Yes, it displays correctly in HN. Now I can submit some content that best uses UpArrow for synthesized attribute in AG. Thank you HN for supporting Unicode!
watergatorman··on Ancient Roots of BNF
Interesting article.

There is both left and right recursion in the definition of <number>, but this EBNF (Wirth notation) uses iteration only:

number = digit { digit } [ "." digit { digit } ] .

watergatorman··on C Constructs That Don't Work in C++
Josh Lospinoso, the author of this blog, has now corrected this to read "pointer to const int"

C declaration syntax confounds even the experts.

I highly recommend this article to all interested in C and C++, and programming languages generally.

watergatorman··on C Constructs That Don't Work in C++
"... const int* x_ptr_3 = &x; // (3) ... Finally, we see the preferred approach, which is taking a const pointer (3)"

Not a const pointer, but a pointer to const int.

watergatorman··on Ask HN: Why Rust is becoming popular?
Rust popular?

Tiobe language rankings for May 2019:

Rust is ranked 34th at 0.335%, below Lisp and Prolog. Go is ranked 19th at 1.114%. C is ranked 2nd at 14.233%

Rust does not have a stable, standard BNF grammar specification. The language reference document for Rust has 33 or 34 unspecified missing language definitions [see "FIXME" sections].

watergatorman··on Should C Programmers Learn C++, Go or Rust? (2018)
C++ is a huge and complex language compared to C. [Compared size of the standard reference document for each.]

C++ is complex to parse. Clang and Gcc use back-tracking to parse C++ and there can be long compilation times.

Tiobe language rankings for May 2019:

Rust is ranked 34th at 0.335% below Lisp and Prolog

Go is ranked 19th at 1.114%.

In complexity and size, Go language is closer to C programming language than either Rust or C++. [Rust and C++ are much larger languages than Go.]

Lastly, Rust does not appear to have a standard BNF grammar specification and I counted around 33 FIXME unspecified sections in the reference document for Rust. I haven't even discussed the number of unstable features in Rust. in the Ref

watergatorman··on On the Design of Machine Independent Programming Languages [pdf]
Dijkstra's timeless advice.

Also recommend:

"On the Design of Programming Languages" N. Wirth

CS-TR-73-403 "Hints on programming language design" C.A.R. Hoare

"The Essence of Programming Languages" Niklaus Wirth

watergatorman··on Niklaus Wirth, 1984 ACM Award Recipient Interview
Interview is dated March 13, 2018:

Niklaus Wirth 1984 ACM Turing Award Recipient Interviewed by Elina Trichina March 13, 2018 Federal Institute of Technology (ETH) Zurich, Switzerland

watergatorman··on Context Coloring
Doesn't say what tool was used to do the syntax highlighting colorization. Or was it done by hand?
watergatorman··on Should C Programmers Learn C++, Go or Rust? (2018)
A limited comparison of C, C++, Go, Rust:

Go and C seem to have a large number of available software tools.

Based on the "size" of the reference documentation alone, C and Go appear to be the simplest to learn for beginners.

A beginner coming from a C background might choose to learn the "Go" language, of the 3 available choices: C++, Rust, and Go.

Other than it's declaration syntax, Go appears to have been designed to be the most familiar to a C programmer.

C++ is very large and complex, just look at the size of the reference documentation. The 4th edition of "The C++ Programming Language" doesn't even have an "Appendix A: Grammar" anymore.

Rust doesn't appear yet to be stable enough to even specify a BNF for it's grammar.

Of course, there are other programming languages out there that maybe are even better for a C programmer to learn, but we were not asked for our opinion of other PLs.

watergatorman··on *p+++=0x20, for when you are converting an uppercase string to lowercase
Assume ASCII characters: ORD('a') - ORD ('A') = 32

IF ('A' <= ch) & (ch <= 'Z') THEN ch := CHR(ORD(ch) + 32) END

watergatorman··on How I'm still not using GUIs in 2019: A guide to the terminal
You need to look at TUIs (Text User Interfaces).
watergatorman··on How I'm still not using GUIs in 2019: A guide to the terminal
Answering my own question, Geany has "Sending text through custom commands" and ability to add custom commands via "Send Selection to->Set Custom Commands"

But it looks like this just replaces the selected text so it may be more for formatting.

I prefer a new window to open so the selected text isn't altered.

I know I can program vEdit+ to do this, but that is not Linux.

watergatorman··on How I'm still not using GUIs in 2019: A guide to the terminal
I generally agree with Lucas' sentiments re GUIs and in his other article "In Praise of Plain Text."

But I currently select portions of text with a mouse by highlighting it, and then execute programs that accept that selection as input.

I no longer am limited to entire text that would be written to StdOut or piped or redirected and so could be treated as complete text files.

I can currently select and execute programs in a GUI in just 2 steps, using a mouse.

Admittedly, I integrated the <program to execute> into the GUI, but it was relatively simple.

To do this in Linux it looks like I would need to run a port of Plan9's Acme or the Wily editor.

The port of Plan9 is way more than I need, so I will look at Wily.

Maybe there are some other Linux editors that will do what my GUI currently does?

watergatorman··on Ford Stole Tech for Best-Selling Trucks from MIT, Professors Say
I am not taking sides, because today's Ford Co is not saddled with Henry Ford's controversies, and both MIT and Ford are large organizations. I don't know who is right, a jury might decide.

There is an interesting movie, "Flash of Genius," about Robert Kearns, an inventor and his interactions with Ford over the "delayed windshield wiper."

I won't reveal any details over the movie plot but there is a short scene where Kearns is lecturing his engineering students about engineering ethics, which reminds me of a documentary by PBS: "NOVA: Holocaust on Trial" (2000)

I cannot find this last movie anywhere, but <youtube> has it available. Should be mandatory viewing for engineers, but it is difficult to watch or listen to the details.

watergatorman··on Ask HN: Why build compilers in Rust instead of C?
I found a LALR grammar for Rust on GitHub, compatible with Bison.

But it does not closely track the published Rust Grammar nor syntax rules in the Rust Reference. (See Rust-lang DOT org site.)

Although perhaps a Rust grammar could be extracted from the syntax rules in the Reference doc, it may be incomplete. For example, how do "as-yet-undocumented features" affect the current syntax rules in the Rust Reference?

So for now, it looks like C is easier to parse than Rust.

watergatorman··on Ask HN: Why build compilers in Rust instead of C?
I looked at the Rust site and their published grammar. It is VERY incomplete, missing entire productions.

I cannot determine if the syntax of Rust is "better" than that of C.

At least the ISO "C" std. organization publishes a complete syntax of their language.

Perhaps someone knows where there is a complete grammar for the Rust language?

I cannot find one.

watergatorman··on Study claiming certain languages lead to more buggy code than others debunked
The authors of the "debunking" study suggest that the use of specific (complex?) programming language features might account for a greater number of bugs.

Too many uncontrolled factors (programmer's experience level with a given language, etc).

watergatorman··on Bjarne Stroustrup warns of dangerous future plans for his C++ (2018)
See: Niklaus Wirth "On The Design of Programming Languages" Procedures of the IFIP Congress 74, pp. 386-393 <PLHistoryGoodDesign.PDF>
watergatorman··on Bjarne Stroustrup warns of dangerous future plans for his C++ (2018)
See: "Hints on programming language design" by C.A.R. Hoare Report Number: CS-TR-73-403 Stanford University, Department of Computer Science <CS-TR-73-403.pdf>

Simplicity, readability, and so much more.

watergatorman··on Ask HN: Which new programming language are you planning to pick up in 2019?
Embedded C++ (EC++)

I know, Bjarne Stroustrup seems to hate EC++ and claims it is dead, but tell that to game developers and the NASA Curiosity Mars Rover. You can't tell that to Opportunity, which does appear dead, but Embedded C++ is not to blame, just some dust storms on Mars.

watergatorman··on The Most Popular Programming Languages
There is only a single combined percentage for C/C++ and not a percentage for C and C++ separately.

Just curious as I have never seen TIOBE or other sites lump those into a single category.

watergatorman··on Cdecl – Turns English phrases into C declarations
Ok, I got it now. Thanks. My faulty understanding.

I believe you have a clean, readable syntax for C declarations.

The Go Programming Language's declaration syntax is very similiar, except that "star" is retained and acts just as your "&"

I don't have a complete list, but have been looking at classifying programming languages into one of 2 categories:

Category 1 declaration syntax: Type identifier ;

or

Category 2 declaration syntax: identifier Type ; with perhaps a colon or other punctuation between the identifier and Type.

Page 1 of 2Next →