Live data from Hacker News

Python's pre-declared constants are kinda weird

sebsite.pw

121–130 of 234 posts

Re: Python's pre-declared constants are kinda weird

#121

Python is just such a weird language in general despite its popularity that I honestly cannot recommend anyone who starts programming to choose Python as their first language, contrary to popular sentiments. I mean, I was one of the first person to start using Python when I was in grad school almost a decade ago when everybody else in my field was still using Matlab for their lab code, for the simply reason that Nump…

> I honestly cannot recommend anyone who starts programming to choose Python as their first language, contrary to popular sentiments

> I think it may be better off to skip Python altogether and write your code in a statically typed language to begin with

Having a good REPL is a huge advantage for beginners (and expert users too), but I'm not aware of any (popular) statically-typed languages with a good REPL.

Despite Python's many faults, it's easy to install (especially on Windows), it has a large standard library, there are third-party packages available for essentially everything, it comes with a user-friendly REPL out-of-the-box, and it gives comprehensible error messages. I'm not really aware of any other (popular) languages with all these attributes.

Re: Python's pre-declared constants are kinda weird

#122

Python is just such a weird language in general despite its popularity that I honestly cannot recommend anyone who starts programming to choose Python as their first language, contrary to popular sentiments. I mean, I was one of the first person to start using Python when I was in grad school almost a decade ago when everybody else in my field was still using Matlab for their lab code, for the simply reason that Nump…

I hate Python and I'm onboard with putting it down in many ways, but significant whitespace isn't weird in a first programming language. It's only weird if you've absorbed from some other language the convention that whitespace shouldn't be significant.

Re: Python's pre-declared constants are kinda weird

#123
post #114

Earlier quoted context omitted.

I think Python remains a very good intro language for getting kids in the door because it doesn’t demand too much tedious stuff, is flexible, and lets people actually solve problems rather than doing computer science. In my experience the difficulty is understanding what exactly is important when teaching someone something new. And it largely depends on the goals. What you’d teach some biology undergrad is going to b…

What is the best language for controls and embedded, in your opinion? I assume from your comment that it's not a great choice as a first language to teach newbies, but I've never done anything in the field of robotics or embedded stuff, so I'm quite ignorant in that area.

If I'm not allowed to toot my own horn, I think for controls, you probably should not start with choosing a programming language, the first step is learning control theory and automata theory, you kinda have to understand feedback control/PID/steady state/jitter/hysteresis and the like. Python has never had great control libraries to begin with as far as I can remember (my info could be a bit outdated though), so the paid option is still Matlab/Simulink as it is their last niche really.

Embedded firmware, probably C/C++/Rust. Not the answer you want to hear, but these are the languages for bare metal applications. Of course, if you are just using an Arduino/Pi, just use their SDK for their hardware on whichever language they support.

Those two fields are just not very friendly towards beginners in general.

Re: Python's pre-declared constants are kinda weird

#124
post #104

Earlier quoted context omitted.

> JS is a lot less weird than Python. I challenge you to find Python behaviors as weird and off-putting as anything here: https://wtfjs.com/

I clicked on half a dozen of these at random and none of them are weird. For example, why would you expect `Boolean("false")` to equal `false`? It's a string, and bears no relation to the Boolean type. [0] [0] https://wtfjs.com/wtfs/2014-10-07-true-equals-false

What about the fact that there isn't a single 'parseInt' function in JS that can reliably only convert number strings to numbers?

They each have different quirks (some will parse 'a123' as 123, others will handle scientific notation etc). The only reliable way of doing this is doing a regex followed by parseInt... which is definitely a footgun IMO.

Re: Python's pre-declared constants are kinda weird

#125
post #114

Earlier quoted context omitted.

I think Python remains a very good intro language for getting kids in the door because it doesn’t demand too much tedious stuff, is flexible, and lets people actually solve problems rather than doing computer science. In my experience the difficulty is understanding what exactly is important when teaching someone something new. And it largely depends on the goals. What you’d teach some biology undergrad is going to b…

What is the best language for controls and embedded, in your opinion? I assume from your comment that it's not a great choice as a first language to teach newbies, but I've never done anything in the field of robotics or embedded stuff, so I'm quite ignorant in that area.

None of them. Walks away. Stops. Turns. All of them.

It depends. If you're a teen I'm mentoring, you're probably starting with some Scratch to drive Lego robots around. Then on to Python to drive the same robots around but now with more fun!. Probably because you absolutely couldn't stand the standard line follower solution of jittering back and forth and you sniffed out the existence of better control loops you cannot realize in Scratch. If you're on the FIRST Robotics team you're probably doing Java or Python, mainly because that's just what we've geared up for (and this is really the core theme for me at least: at introductory levels, what really matters most is whatever is most readily accessible to you and whatever kit you already have).

If you're doing your own stuff and you're a newbie with absolutely no opinions on where you started or what you were trying to do, you'd probably start poking around with an Arduino or similar, so you could write MicroPython (it's Python but you squint your eyes a bit!) or C. There's so many great kits for beginners.

In the context of my comment: what I meant is that you wouldn't decide, "the professionals do it in C++, C, or Rust, so we'll start with one of those." I'm going to give you a recorder (Python) before I hand you bagpipes (C++).

Re: Python's pre-declared constants are kinda weird

#127
post #114

Earlier quoted context omitted.

What is the best language for controls and embedded, in your opinion? I assume from your comment that it's not a great choice as a first language to teach newbies, but I've never done anything in the field of robotics or embedded stuff, so I'm quite ignorant in that area.

If I'm not allowed to toot my own horn, I think for controls, you probably should not start with choosing a programming language, the first step is learning control theory and automata theory, you kinda have to understand feedback control/PID/steady state/jitter/hysteresis and the like. Python has never had great control libraries to begin with as far as I can remember (my info could be a bit outdated though), so the…

Yeah! Like when helping teens set up PID controllers for their CAN-bussed robot, it was very much a "we've got a lot of example working Java code with a PID Controller library already. So we're using that." The language itself is so inconsequential at the early stage, that you really just pick whatever gets in your way the least.

Re: Python's pre-declared constants are kinda weird

#128

Python is just such a weird language in general despite its popularity that I honestly cannot recommend anyone who starts programming to choose Python as their first language, contrary to popular sentiments. I mean, I was one of the first person to start using Python when I was in grad school almost a decade ago when everybody else in my field was still using Matlab for their lab code, for the simply reason that Nump…

> I honestly cannot recommend anyone who starts programming to choose Python as their first language, contrary to popular sentiments > I think it may be better off to skip Python altogether and write your code in a statically typed language to begin with Having a good REPL is a huge advantage for beginners (and expert users too), but I'm not aware of any (popular) statically-typed languages with a good REPL. Despite…

> Having a good REPL is a huge advantage for beginners (and expert users too), but I'm not aware of any (popular) statically-typed languages with a good REPL.

scala's repl is decent. It has its annoyances, but so does python's (white space sensitivity + repl + terminal emulators stuck in the late mid century don't mix).

Post reply on HN