r/programming • • Sep 29 '23

Was Javascript really made in 10 days?

https://buttondown.email/hillelwayne/archive/did-brendan-eich-really-make-javascript-in-10-days/
617 Upvotes

295 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Sep 29 '23

[deleted]

7

u/EagleCoder Sep 29 '23

Yeah, this is annoying with the JS hate. Don't be surprised when you write bad code.

8

u/florinp Sep 29 '23

Don't be surprised when you write bad code

this is a good motto for any badly designed programming language : blame the user.

5

u/fire_in_the_theater Sep 29 '23

js doesn't have native int handing anyways, it works if u just do

['10', '10' , '10'].map(Number)

11

u/EagleCoder Sep 29 '23

'Array.map' takes a callback with three parameters: value, index, and self. '[].map(parseInt)' using the index as the radix is exactly what the code says to do, not some "bad design" or whatever. The result is the programmer's fault.

3

u/Ipsider Sep 29 '23

Bad code in this context doesn’t mean wrong use cases or syntax errors. It’s about unintuitive semantics. And that’s still a good example for that.

3

u/EagleCoder Sep 29 '23

C#'s 'Select' has an overload that passes the element index to the callback, so if you directly passed a function that takes a second ('int') parameter like in the JavaScript example, you'd get the same behavior.

This is neither unintuitive nor unique to JavaScript. It's probably not even uncommon. As a developer, you need to understand how the language works before blaming it for your own mistakes.

3

u/[deleted] Sep 29 '23

'Array.map' takes a callback with three parameters: value, index, and self.

Which is a wart in of itself.

7

u/EagleCoder Sep 29 '23

No, it isn't, lol. Those last two parameters can be very useful sometimes.

3

u/[deleted] Sep 29 '23

Key word being "sometimes". Sane languages have separate APIs for those cases.

4

u/EagleCoder Sep 29 '23

I have a decade of professional experience using JavaScript and this has literally never been an issue for me or anyone I have ever worked with. It's purely a made-up problem that people who simply dislike JavaScript pretend is even remotely valid.

3

u/EagleCoder Sep 29 '23

C#'s 'Select' would behave exactly the same way if called in this way.

2

u/vilos5099 Sep 29 '23

There are so many better examples you can use if you want to show off the warts of JavaScript. This is literally just a user error.

1

u/PrimozDelux Sep 29 '23

This is insanity

-4

u/florinp Sep 29 '23

you don't understand the point: Javascript should not let you call a function with less parameters (except in the case of default parameters or in a language with curring

It is a bad design

6

u/EagleCoder Sep 29 '23

It's not calling a function with fewer parameters (although that is also possible to do). It's just passing parameters that the programmer is free to ignore. When mapping an array, you do not always need all three parameters. It's very convenient and useful to be able to pass functions that only take the item, for example.

JavaScript simply isn't a strongly-typed language that checks these things. That is completely valid design choice whether you agree with it or not. It can be extremely useful not to be restricted by strict typing.

0

u/florinp Sep 29 '23

JavaScript simply isn't a strongly-typed language that checks these things

as Python. But Python reject this.

→ More replies (2)
→ More replies (1)

-1

u/florinp Sep 29 '23

They're using parseInt wrong

try this in a programming language at your choice and see if this an user error or an language designe error

9

u/vilos5099 Sep 29 '23 edited Sep 29 '23

Regardless of the programming language one uses they should accept that they each have their own syntaxes and standard library. There is nothing wrong with parseInt, it's very well documented and the additional parameters are not gotchas if you use your eyes and actually read.

-1

u/florinp Sep 29 '23

this sounds like Stockholm Syndrome

4

u/vilos5099 Sep 29 '23 edited Sep 29 '23

I've spent 3 years professionally programming in Python and 4 at a TypeScript house. I was also doing plenty of JavaScript at both places for our web apps. Both languages have their pros and cons, and most of the warts people bring up with JS hardly come up in day-to-day development.

Python isn't without its faults too, though they're less often with the syntax and more with the standard library (urllib is gross) and performance. Working with asynchronous code is much more of a pleasure in JavaScript.

How much JavaScript or even TypeScript have you used to have such strong opinions on the matter? If your answer is, "I don't use it because it sucks" then you really have nothing to contribute to any discussion on the matter.

2

u/florinp Sep 29 '23

"I don't use it because it sucks"

Did you see in my written opinions such phrase ? Or did I give some concrete examples ?

The point is about language itself not libraries.

4

u/vilos5099 Sep 29 '23

Okay, you're not denying that you haven't used it. That's fine, but then stop acting like you have a knowledgeable opinion on the language.

The point is about language itself not libraries.

A language's standard library is typically treated as part of the language by its users, but if you want to draw a distinction to better serve your baseless point then go for it. That includes things such as parseInt by the way, which you seem very opinionated about.

0

u/florinp Sep 29 '23

Okay, you're not denying that you haven't used it. That's fine, but then stop acting like you have a knowledgeable opinion on the language.

I've use it for some years . And I am force to use it right now.

And this is not a good argument. You don't need to use everything extensively to know if something is bad. It depends of the context.

For example I didn't wrote single line in Python, Java, Scala before I've had to be productive from the first days. But I knew the languages principal characteristics : dynamic/static, imperative/functional, single dispatch, etc.

→ More replies (6)
→ More replies (1)

0

u/wnoise Sep 29 '23 edited Oct 02 '23

There's nothing wrong with parseInt. There is something wrong with map blithely doing slightly different things based on the number of arguments that the function passed in takes. Javascript's map should be three different functions -- map, mapWithIndex, and mapWithIndexAndArray (though I'm not sold on the names).