Hacker News new | past | comments | ask | show | jobs | submit | MH15's comments login

Zach Lieberman https://x.com/zachlieberman does his work in C++ with https://openframeworks.cc/

In a similar vein to "use strict" we could create a new directive that disallows JS features like var, prototype, == (in favor of ===). Modules with this new directive at the top of the file would be executed under these new rules. You'd be able to create new (maybe lighter weight) JS interpreters that only target this subset.

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


I don’t think anyone uses var anymore. Linters and prettier are doing a good job keeping codebase consistent. Operator == has a valid use case (null or undefined check) but rarely allowed as well.

But I wouldn’t mind to have language without legacy.


It's kinda ironic to post that on a site that uses var in its javascript


I use var, together with let and const, where appropriate. What’s the problem with var I don’t get it.


var is global scope, const is block scoped...

  <script>
  var x = 1;
  if(x < 5) {
    // now y is global (window.y can be accessed everywhere)
    // using const y = x * 2 would be inaccessible outside the if block
    var y = x * 2;
    console.log('double x is: " + y);
  }
  </script>
Besides that, var is "pulled" upwards, as if it was the first line in the function. That may have side effects.


I know how var works.


No offense, just trying to help... :-)


prototype is super useful


Good vibe-check on my day to day work in web tech. Sometimes I wonder how web deployments would work if we still deployed quarterly, yearly, etc.


Where I work now basically does quarterly deployments. We service enterprises that generally outsource their development work. So we deploy pretty regularly to a staging environment and deliver documentation weeks/months before we actually deploy it. The exception to that rule is for hotfixes, which is also extremely rare. Like 2-5 times per year.


Something (unrelated) that surprised me here is that the author has two decades of posts on this blog, leading back to their first post about a new version of C# (https://codeblog.jonskeet.uk/2005/09/)

Personally as a younger software guy I had no idea that C# had type inference back in 2005- an interesting perspective shift!


jon skeet is somewhat famous for topping the stackoverflow leaderboards since the beginning of time

https://stackoverflow.com/users?tab=Reputation&filter=all


- Users don’t mark Jon Skeet’s answers as accepted. The universe accepts them out of a sense of truth and justice.

- When Jon Skeet's code fails to compile, the compiler apologises.

- Jon Skeet does not use revision control software. None of his code has ever needed revision


Replace “Jon Skeet” with “Fabrice Bellard” and you’ve got yourself a real meme.


type inference in programming languages is more than 50 years old. ML had it in 1973.


jon skeet is one of the most famous programmers of all time. He might not be famous like Knuth is but he is everyday programmer famous.


I'd be curious to read about what percentage of active PHP devs use the recent features. The last time I worked in a PHP codebase (2020?) was half PHP 5 (bad) and half PHP 7 (much nicer). Curious if there's any real info out there on this


I work on multiple projects from PHP 5.2 to PHP 8.3 and everything in between.

Statistics based on packagist(composer)

https://stitcher.io/blog/php-version-stats-january-2024

Statistics based on web servers in the wild

https://w3techs.com/technologies/details/pl-php

https://w3techs.com/technologies/history_details/pl-php


PHP 5 is as close to phased out as it gets at this point. No doubt it's still in a lot of legacy enterprise codebases (lots of breaking changes going from 5 to 7 or 8), but outside of that no one is using it.


php 7 has been released 9 years ago.


Yeah, and I just finished porting an enormous amount of production code from PHP 5 to 7.x before fully moving it to 8. There are so many breaking changes in each major version, when you have a lot of live projects and clients don't have the budget to pay you to upgrade them, they can lay stagnant for years until way past EOL. It would have been nice to know, for instance, that future versions of PHP would throw warnings about undeclared variables or unaccessible named properties of "arrays" - which could previously be relied upon to be false-ish. That's a major pain point in code bases that treated arrays as simply dynamic objects that could be checked or defined at will. Lots of isset() and !empty() and other BS. Fine, but it takes time to sit down and check it all. I really preferred it when it let you just screw up or try to access a null property or define a variable inside a block and access it later without throwing any errors at all. Nothing about its actual functionality has changed in that regard; it's just errors you have to suppress or be more verbose to get around. In PHP 8 you can still do this:

`if ($a) { $previouslyUndefined = 2; } if ($previouslyUndefined) { echo "yeah"; }`

PHP still knows what $previouslyUndefined is or isn't at the second if statement, but it'll throw an error now in the first statement if you hadn't declared it outside the block. Why? Who cares? Scope in PHP is still understood to be inline, not in block; there is no equivalent to let vs var in JS. Stop telling me where I can check a variable if you're not enforcing various kinds of scope.


Your $previouslyUndefined thing as something that's changed, as far as I know, isn't true? Unless I've missed some very recent change.

If $a is true, that snippet will just execute with no errors. If $a is false you'll get a warning trying to check $previouslyUndefined in the second if. That behavior's been the same for a very long time. The blocks don't matter for scope but the fact that you never executed the line that would have defined the variable does.

Similarly, warnings on accessing array keys that don't exist, that's been a thing forever too. Pretty sure both go back with the same behavior to PHP 4, and probably earlier.


>Why? Who cares?

I do, if I typoed previouslyUndefined the first time. I get it adds boilerplate, but it also catches stupid bugs


The Laravel ecosystem folks seem to be always up to date in recent PHP developments. At least, that's my impression.


Drupal is very hot on attributes, has fiber support, uses readonly (a PHP 8.2 feature) extensively, enums are used -- overall it's fairly up to date.


Symfony also does a great job adding polyfills way ahead of a PHP release , eg https://github.com/symfony/polyfill-php84


Yes, and this is incredibly annoying. Many packages add them as a dependency, and then you get subtle bugs because of it. Or worse, they add a dependency for the polyfill that is related to an extension and suffer performance issues when the extensions are not installed; yet no warning is output.


There was a similar implementation of this idea a year back, but it was open source/indie. Anyone know what it was?


Remember than LangChain raised $10m a few months ago https://blog.langchain.dev/announcing-our-10m-seed-round-led... (wait, over a year ago!)


Irvine, CA has an outdoor advertising ban. Driving the 405 through OC you quickly see the difference.


MATLAB is not open source, or even free.


There was something on Show HN that did this with some promise recently, can't find it now



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: