7 ms·
What was it about JavaScript that wanted you to leave programming? I'm just curious.
by tfleming 6y ago
What was it about JavaScript that wanted you to leave programming? I'm just curious.
- airstrike 6y ago0.1 + 0.2 → 0.30000000000000004
- dkulchenko 6y agoThat's not unique to JS. $ irb irb(main):001:0> 0.1 + 0.2 => 0.30000000000000004 irb(main):002:0> $ iex Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe] Interactive Elixir (1.10.2) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> 0.1 + 0.2 0.30000000000000004 iex(2)> $ python Python 2.7.17 (default, Dec 2 2019, 13:23:33) [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.12)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 0.1 + 0.2 0.30000000000000004 >>>
- yellowapple 6y agoInterestingly, though, some languages get it right: northrup@Topaz:~/Desktop$ perl -de1 Loading DB routines from perl5db.pl version 1.55 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(-e:1): 1 DB<1> say 0.1 + 0.2 0.3 […] northrup@Topaz:~$ csi CHICKEN (c) 2008-2019, The CHICKEN Team (c) 2000-2007, Felix L. Winkelmann Version 5.1.0 (rev 8e62f718) linux-unix-gnu-x86-64 [ 64bit dload ptables ] #;1> (+ 0.1 0.2) 0.3 […] northrup@Topaz:~$ sbcl This is SBCL 1.5.8, an implementation of ANSI Common Lisp. More information about SBCL is available at <http://www.sbcl.org/>. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. * (+ 0.1 0.2) 0.3
- reitzensteinm 6y agoUnless they're using an alternate exact representation for floats by default, that's just rounding them when printing.
- yellowapple 6y agoThat's a fair point about the Perl example, but Scheme and Common Lisp (including both Chicken and SBCL, last I checked) support (if not outright require) full numeric towers with rational number types, so these are indeed exact representations (unless you explicitly request binary floats for e.g. performance reasons) and not just rounding during printing. There are lots of other examples of doing it "right" (using more suitable numeric types) over at https://0.30000000000000004.com/ https://0.30000000000000004.com/ (alongside a bunch of examples that, to your point, just round, or to the GP's point, just stick to binary floats).
- dnautics 6y agoIt depends. Do you want deterministic compute time? Then you have to settle for something inaccurate.
- reitzensteinm 6y agoI am aware of numeric towers and actually checked whether that was going on. sbcl 1.4.16 uses single floats: https://ideone.com/ruw5qi https://ideone.com/ruw5qi I don't know enough about Scheme to dig under the covers to see how it's being represented internally.
- verandacoffee 6y agosbcl (and other Common Lisps) uses what you want it to use: read-default-float-format (setf read-default-float-format 'single-float) (+ 0.1 0.2) => 0.3 (setf read-default-float-format 'double-float) (+ 0.1 0.2) => 0.30000000000000004 On LispWorks 7.0 I get 0.30000000000000005 for double-float. Hmm.
- 6y ago
- airstrike 6y agoI know, it was just a tongue-in-cheek comment but oh well
- deleted 6y ago[deleted]
- aportnoy 6y agoThat’s because you are running it on hardware implementing IEEE 754 floating point.
- tomg 6y agoAs someone considering leaving the web development industry after 12 years: JavaScript is a never ending grind. Callbacks, then Bluebird, then Promises, then a sync await. a new testing framework every six months. a new web framework every couple of years. aimless, massive changes to the language (classes in a prototyped language? Why not). JavaScript then coffeescript then three versions of typescript. too many UI libraries to mention. JavaScript on the server? the people making the most popular web framework abandoned it 5 years ago but who cares?! paradigms that make no sense (react morphing from a UI library to the full app). a million ways to manage state. then you have a few big players calling all the shots (FB, MS). I guess we use functional components now. Eurasia has always been at war with Oceana. It’s tiring. I’ve spent my entire career doing this stuff; and I’m never quite good enough before The Next Big Thing comes along. I know things change over time everywhere, but it’s hard to imagine anything moving faster with less purpose than the JS ecosystem. (Apologies for typos and grammar; I’m on my phone)
- jeremy_k 6y ago'JavaScript is a never ending grind' - Wow no better way to summarize it than that. The funny thing is that I've always felt that Javascript the language is pretty straight forward and easy to comprehend. As someone who primarily writes Ruby and really appreciates the functional style of writing code, Javascript lends itself to that style very easily. But the ecosystem around is just that never ending grind. At my last job, over the 3 or so years I was working fully stack, it was just a constant churn. Start with React / Redux / SRR / Jest / Mocha / (probably some other testing frameworks) / Flow. By the end none of the original testing frameworks were being used. React had introduced Hooks, which I actually like, but it was a whole new paradigm to learn again. Flow was out and we needed to migrate to Typescript as quick as possible. And this is just the React ecosystem! React has its place and I'm definitely comfortable working with it (also writing 0 tests cause I have no idea where to even start for that) but I'm looking forward to the day maybe simple web apps get back to simple setups. Projects like LiveView[0] for Phoenix really give that hope. [0] - https://github.com/phoenixframework/phoenix_live_view https://github.com/phoenixframework/phoenix_live_view
- 6y ago
- awayfrommypc 6y ago12+ years PHP and simple JavaScript programmer here. I loved programming and building websites. Then I got into modern JavaScript with Reactjs, Nodejs, TypeScript, and other mess. Initially, I was excited because that's what everyone was and still is talking about and I love learning new things. But it is too ugly in JavaScript land. People make fun of PHP but with PSR standards it is easy to enforce coding standards. In JavaScript land, everyone has their own standards, no easy way to enforce them, but most people don't follow their own standards. It is ugly spaghetti code mostly. Debugging tool is browser which makes it nearly impossible to troubleshoot when you are dealing with tons of minimized libraries. And even when you are dealing with simplest tasks JS developers start looking for libraries instead of just writing 5 line function. I was ready to leave programming for management or other jobs but changed my mind and learning embedded systems, game dev, and some other cool techs. Hoping to transition to robotics or something else soon.