News for hackers. Stuff that matters.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by a3n on Wednesday May 20, 2015 @08:39PM (#9580336)
What a strange language, that so much sage wisdom involves what parts of it you shouldn't use. (Former C++ programmer, a long time ago, before the "don't use these parts" advice became a thing.)
Re:Why should I have written ZeroMQ in C, not C++ (2012) by derefr on Wednesday May 20, 2015 @08:52PM (#9580371)
There was a post here recently, explaining type systems are effectively about restricting you from encoding nonsensical constructions. C is ASM with the ability to encode some nonsensical ASM instruction-sequences removed, etc.

The weird thing about C++—and the reason it didn't just absorb/replace C—is that it gives you the ability to encode strictly more nonsensical things than C does. In that sense, C looks more like the descendant of C++ than the other way around!

Re:Why should I have written ZeroMQ in C, not C++ (2012) by pjmlp on Thursday May 21, 2015 @02:19AM (#9581218)
> The weird thing about C++—and the reason it didn't just absorb/replace C—is that it gives you the ability to encode strictly more nonsensical things than C does. In that sense, C looks more like the descendant of C++ than the other way around!

Yet the most famous current C compilers are all written in C++.

If it wasn't the rise of open source and its community attachment to C, mainly in GNU and BSD circles, C would have been long replaced except for the embedded space.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by gridspy on Wednesday May 20, 2015 @08:52PM (#9580375)
Yes, it shares that 'feature' in common with JavaScript.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by bajsejohannes on Wednesday May 20, 2015 @08:58PM (#9580394)
No, actually, it doesn't. C++ is a huge language, javascript is a relativly small one. I know it's funny to compare the size of "Javascript the good parts" with "Javascript the definitive guide", but that's can be attributed to writing style more than percentage of language covered.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by MaulingMonkey on Wednesday May 20, 2015 @11:01PM (#9580737)
> No, actually, it doesn't.

Perhaps less in what features to avoid, but there's plenty of hidden gotchas to avoid in JavaScript still.

https://www.youtube.com/watch?v=et8xNAc2ic8 https://dorey.github.io/JavaScript-Equality-Table/

> C++ is a huge language, javascript is a relativly small one.

C++'s ISO/IEC 14882:2003 weighs in at 786 pages, compared to ECMA-262 (5.1 Edition)'s 258 pages (measuring by PDF reader). A ~3x difference, but not quite the order of magnitude I'd expect from huge vs small.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by furyofantares on Wednesday May 20, 2015 @11:33PM (#9580814)
And we share 50% of our DNA with a tree...

That's not meant to be snarky, but what's is the minimum size of a language spec? I don't know the answer, but I'd think the delta over that would be the better comparison. For example if you can't really spec a language in less than 200 pages then C++'s spec is more like 10 times as big as JavaScript.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by kibwen on Thursday May 21, 2015 @12:33AM (#9580977)
"Number of pages in specification" is a rather useless metric to use to compare languages, since there are so many variables. And not just things like point size or margins or what have you, but the contents themselves vary. Some specifications include an EBNF grammar, others may try to describe it via natural-language rules, and others may just say "see the reference implementation". Some specifications include documentation on the language's standard library (the scope of which is a factor that itself varies greatly from language to language), and some of these will go into differing amounts of detail (e.g. providing upper bounds for computational complexity of algorithms). Some languages will go into great detail about memory models (especially low-level ones), while others will wave it away as an implementation detail.

TL;DR: don't trust anyone who tries to use the length of a specification as a comparable proxy for complexity. I can write a 10,000-page standard for Scheme if you hire me to.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by MaulingMonkey on Thursday May 21, 2015 @05:06AM (#9581641)
> "Number of pages in specification" is a rather useless metric to use to compare languages, since there are so many variables.

How would you prefer to compare language sizes? Gut feel? Surely that's even worse.

I'll certainly admit that - like LOC measurements - it's a metric one can't take too seriously on it's own. On the other hand, it's a useful starting point for discussing said variables.

For example, when I was eyeballing the Javascript standard (I've already read the C++ standard a decent bit), I saw it (like C++'s) defines a grammar, and includes some core library bits (e.g. the Object type.) On the other hand, I didn't see the full browser DOM API you'd use when writing most Javascript - but then again, you don't see any modern graphics or UI widget APIs in the C++ standard either.

This was enough to convince me that they were comparable enough for an orders-of-magnitude comparison, at least. My gut reaction was that C++'s standard might be more detailed - but that'd be biased in my favor, further undermining the argument that Javascript is significantly smaller than C++.

> I can write a 10,000-page standard for Scheme if you hire me to.

But can you find a 10,000 page standard, for any language? Eventually everyone hits a limit to what they consider worthwhile to write, short of perverse incentives.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by kibwen on Saturday May 23, 2015 @09:33PM (#9595032)

  > How would you prefer to compare language sizes? Gut 
  > feel? Surely that's even worse.
Why is it necessary to compare "language sizes" at all? Nobody has ever demonstrated that the "size" of a language (by any definition) has any measurable effect on the quality of the software written in that language. It's as pointless as the classic vim vs. emacs argument.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by MaulingMonkey on Monday May 25, 2015 @01:55AM (#9598835)
> Why is it necessary to compare "language sizes" at all?

It seems relevant in the context of how difficult it is to master a given language, which spawned this thread of debate. Do you disagree that language size is any sort of barrier?

Again, only one metric, to be taken with a measure of salt. But would you prefer we compare languages based on gut feel? Or is comparing languages unnecessary as well?

> It's as pointless as the classic vim vs. emacs argument.

Understanding the merits of vim vs. emacs informs you which you might prefer. The answer to that argument, over which is "ultimately better" is certainly pointless. You can simply choose whichever works best for you, especially as you can change your mind mostly at will.

But people don't simply have the choice of "choose whichever works best for you" when it comes to programming languages on a team project. Nor are languages as fungible as editors when it comes to changing your mind - switching languages mid-project is a massive time sink, and frequently fatal to the project.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by bjterry on Wednesday May 20, 2015 @11:53PM (#9580872)
The scheme R5RS standard is 50 pages, and is considered quite small for any real language. The Haskell 2010 Language Report is 239 pages. The Forth ANSI standard is 220 pages and is a seemingly simple language.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by bremac on Wednesday May 20, 2015 @11:47PM (#9580853)
Scheme has the smallest (useful) language specs that I know of. For example, R5RS is 48 pages (44 if you exclude the back matter.)
Re:Why should I have written ZeroMQ in C, not C++ (2012) by MaulingMonkey on Thursday May 21, 2015 @04:46AM (#9581602)
I imagine Brainfuck could be reasonably specced in around 5-10 pages, based on the size of the Wikipedia description.

EDIT: Said Wikipedia page was sufficiently detailed for me to implement a Brainfuck -> MSIL compiler without additional external references, which I was able to verify worked with a Mandelbrot renderer.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by waps on Thursday May 21, 2015 @12:32AM (#9580974)
Here is one of the smallest useful (ie. turing complete) language's full specification :

> Subtract and branch if not equal to zero[edit] > The SBNZ a,b,c,d instruction ("Subtract and Branch if Not equal to Zero") subtracts the contents at address a from the contents at address b, stores the result at address c, and then, if the result is not 0, transfers control to address d (if the result is equal zero, execution proceeds to the next instruction in sequence).

This is all of it.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by pjmlp on Thursday May 21, 2015 @02:26AM (#9581236)
> C++'s ISO/IEC 14882:2003 weighs in at 786 pages,

Including the standard library.

I don't know about JavaScript, but at least Python, Java and C# are actually quite more when including the standard library.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by bkjelden on Wednesday May 20, 2015 @11:52PM (#9580864)
The big thing javascript has going for it are the browser's dev tools, though.

I've done both and hunting things down in chrome's dev tools is orders of magnitude easier than figuring out what is going on in your c++.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by vitaut on Thursday May 21, 2015 @01:54AM (#9581174)
With great power comes great responsibility.