News for hackers. Stuff that matters.
Re:Git's list of banned C functions by IgorPartola on Thursday March 04, 2021 @04:32PM (#26348670)
This is a lot like how in JavaScript you have footguns like the with statement or in Python 2 where you have Unicode issues, etc. I am sure we could definitely a new C standard that excludes these functions as obsolete, but the linked header file is a pretty sensible interim solution. C is an old language and it’s kind of amazing that code written 30 years ago can still by and large be compiled by a modern compiler. Ever try to run 3 year old React projects using today’s React? :)
Re:Git's list of banned C functions by ggregoire on Thursday March 04, 2021 @05:00PM (#26349025)
> in JavaScript you have footguns like the with statement

I've been coding in JS on a daily basis for more than 10 years and today I learned there is a `with` statement in JS.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Edit: well, seems like it's been deprecated/forbidden since ES5 (2009), so it makes sense I've never seen it.

Re:Git's list of banned C functions by UncleMeat on Thursday March 04, 2021 @06:34PM (#26350060)
An old grad school connection of mine wrote a formal semantics for ES5 and couldn't explain what "with" did in words.
Re:Git's list of banned C functions by 1f60c on Thursday March 04, 2021 @07:11PM (#26350452)
This is JavaScript, so there are probably tons of weird edge cases, but basically, within a with (expr) { … } block, everything defined on expr is put in scope:

  with (Math) with (console) log(PI)
It reminds me a bit of Clojure's doto.
Re:Git's list of banned C functions by kaba0 on Friday March 05, 2021 @11:02AM (#26358313)
Or java’s static import
Re:Git's list of banned C functions by GordonS on Thursday March 04, 2021 @05:54PM (#26349657)
And me around 20 years - also never even heard of the `with` statement! I think to qualify as a footgun, people actually need to be using it in the real world.
Re:Git's list of banned C functions by IgorPartola on Thursday March 04, 2021 @07:05PM (#26350369)
I have seen it in the wild. I first learned of it from Douglas Crockford’s JavaScript the good parts. He also had some things to say about the new keyword and prototype inheritance and how we should stop using them. Ironically while he was dismissed on that suggestion then, VueJS has pretty much implemented exactly what he has in mind in their V3.
Re:Git's list of banned C functions by javbit on Thursday March 04, 2021 @06:45PM (#26350166)
It should be called something like appendixgun then because you don't use it but it still has a chance of causing needless suffering and pain.
Re:Git's list of banned C functions by astrange on Thursday March 04, 2021 @08:20PM (#26351151)
The appendix is a reservoir of gut bacteria in case you lose yours in an infection or by taking too many antibiotics.
Re:Git's list of banned C functions by azernik on Thursday March 04, 2021 @09:17PM (#26351671)
There are lots of more conventional footguns in JS, though - everything about the Date object/class, for example.
Re:Git's list of banned C functions by bsimpson on Thursday March 04, 2021 @06:16PM (#26349873)
Was also popular in ActionScript, the JS cousin that powered dynamic Flash content:

    with (myShape.graphics) {
      beginPath();
      setFill(0xFF0000);
      moveTo(6, 9);
      // ...
    }
Re:Git's list of banned C functions by viklove on Thursday March 04, 2021 @04:39PM (#26348770)
It amuses me that HN hates JS so much, that even a topic about problems with C turns into a JS-bashing thread.

Also, I just want to remind you that JS isn't just React. There are plenty of libraries written in C that introduce breaking changes over the course of 3 years. Nothing will stop people from finding ways to complain about JS though, I know. The hate-boner is very real.

Re:Git's list of banned C functions by GordonS on Thursday March 04, 2021 @05:59PM (#26349722)
I've been a long-time Javascript hater. Probably didn't help that I started out 20 years ago, and dealing with cross-browser support was a big issue. And of course, let's so no more about Internet Explorer shudder. And then NPM - a direct result of JavaScript's anaemic standard library.

Anyway, things have changed a lot, and I recently worked on my first ever web app with native ES6 - no transpiling to ES5! It was... not nearly as bad as it used to be! Modules are a thing, and the language has evolved with things like async/await, evolved for the better, I think. The standard library is still horribly anaemic though - the number of "helper" functions needed is ridiculous.

But still, I would no longer classify myself as a hater. Progress at last :)

Re:Git's list of banned C functions by ggregoire on Thursday March 04, 2021 @06:49PM (#26350210)
If static-typing is your thing, you should give a try to TypeScript. It's easily the biggest game changer that happened to the JS world in the recent years.
Re:Git's list of banned C functions by mannerheim on Thursday March 04, 2021 @07:22PM (#26350567)
There are some JS problems that TypeScript doesn't solve, like Array.prototype.sort and .map, but it's still quite nice.
Re:Git's list of banned C functions by lliamander on Thursday March 04, 2021 @05:33PM (#26349428)
I appreciate Javascript's LISPy qualities, but it has an inordinate number of footguns and a relative lack of standard, stable libraries. Coming from languages like Java and Erlang that are relatively scrupulous about such things is a bit jarring.

I do like Typescript though, as it adds some really nice ergonomics.

Re:Git's list of banned C functions by sadgrip on Thursday March 04, 2021 @04:43PM (#26348812)
I think in most cases it's probably not hate but a deep, deep love.
Re:Git's list of banned C functions by jrimbault on Thursday March 04, 2021 @05:08PM (#26349126)
JavaScript, LISP under C disguise. No wonder it's "popular" on HN.

Assorted musing : Rust, OCaml under C disguise.

Re:Git's list of banned C functions by orwin on Thursday March 04, 2021 @05:30PM (#26349384)
I think most people on HN like Javascript, or at least its idea? I mean, its a very C-like functionnal language, especially since ES6 put Js on the right road (for me at least)?
Re:Git's list of banned C functions by IgorPartola on Thursday March 04, 2021 @07:08PM (#26350412)
It looks similar, but it isn’t. You can’t blow your stack in JavaScript while in C that’s practically a language feature and a design goal.
Re:Git's list of banned C functions by detaro on Thursday March 04, 2021 @04:44PM (#26348834)
Because individual libraries choosing to change quickly is comparable to language stability how? The relevant comparison would be "run a 3y old react app (or a 20 year old website using JS) in a modern browser or interpreter"
Re:Git's list of banned C functions by _the_inflator on Thursday March 04, 2021 @04:56PM (#26348974)
Yes, and it would still run fine I guess. I think only eval() changed over time. APIs and so on are still the same except for some Netscape stuff.
Re:Git's list of banned C functions by IgorPartola on Thursday March 04, 2021 @07:06PM (#26350386)
Insofar as stdlib for C is a library, I think it’s not the worst comparison.