Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

Suspicious Dish posted:

var number = 3..minos(1, 5);

... perfect!

-3..minos(-5, -1);

:v:

Adbot
ADBOT LOVES YOU

Linear Zoetrope
Nov 28, 2011

A hero must cook
code:
print("Enter the value you'd like", x, "to be clamped to")
x = int(input())

VikingofRock
Aug 24, 2008




Ranzear posted:

code:
Number.prototype.minos = function(min, max) {
  if(min === undefined)
    min = -Infinity;
  if(max === undefined)
    max = Infinity;
  return 1*Math.min(Math.max(this, min), max).toFixed(2);
};
This is mostly for trimming floats to keep my json netcode lighter, but yeah, it belongs here.


It'd totally do this too. I did have to convince someone that Javascript has 'Infinity' one time...

Holy cow, minos has some labyrinthine logic!

Nova69
Jul 12, 2012

Osmosisch posted:

From my experience, unless you're making huge pages with lots of bindings (which makes Angular 1 performance tank), there's no tangible benefit and a ton of work involved.

The learning cliff of Angular >1 sucks and the documentation is at least as terrible as 1.x's (which is impressively bad already).

This is the first job I've landed in since graduating from uni with a CompSci degree, and the first time I've had more than a breif encounter with webdev, every developer in this team is full-stack so i've had to dive straight itno it.

After doing Angular, Jasmine, and other stuff like that for a few months now, is it just me, or is webdev tooling/libraries/frameworks a nightmare-fuel minefield?

Soricidus
Oct 21, 2010
freedom-hating statist shill

Nova88 posted:

This is the first job I've landed in since graduating from uni with a CompSci degree, and the first time I've had more than a breif encounter with webdev, every developer in this team is full-stack so i've had to dive straight itno it.

After doing Angular, Jasmine, and other stuff like that for a few months now, is it just me, or is webdev tooling/libraries/frameworks a nightmare-fuel minefield?

nope, that's a good description of it. let's take some rudimentary tools that were designed for laying out styled text documents and simplistic data entry forms, throw in a scripting language cobbled together by one guy in an afternoon based on some wacky ideas he thought were cool at the time, and try to use this rickety pile of hacks to replace actual operating systems and purpose-built gui toolkits designed by responsible adults with decades of experience ... what could possibly go wrong?!

pigdog
Apr 23, 2004

by Smythe

Soricidus posted:

purpose-built gui toolkits designed by responsible adults

what are those?

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Soricidus posted:

nope, that's a good description of it. let's take some rudimentary tools that were designed for laying out styled text documents and simplistic data entry forms, throw in a scripting language cobbled together by one guy in an afternoon based on some wacky ideas he thought were cool at the time, and try to use this rickety pile of hacks to replace actual operating systems and purpose-built gui toolkits designed by responsible adults with decades of experience ... what could possibly go wrong?!

Yeah tbh it can take me a week of doing front end js to do something that I could do in a day using WPF, and I have way more experience using front end js than WPF.

Volguus
Mar 3, 2009

Soricidus posted:

nope, that's a good description of it. let's take some rudimentary tools that were designed for laying out styled text documents and simplistic data entry forms, throw in a scripting language cobbled together by one guy in an afternoon based on some wacky ideas he thought were cool at the time, and try to use this rickety pile of hacks to replace actual operating systems and purpose-built gui toolkits designed by responsible adults with decades of experience ... what could possibly go wrong?!

Nothing goes wrong, why do you ask? Everything is peachy. Of course, during the evolution of said ecosystem we come to discover patterns, ideas and workflows that have existed for decades in other UI systems and we happily reinvent the wheel and proclaim it to be the best thing since slice bread. See Redux/Flux -> Windows messaging system.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

Suspicious Dish posted:

inclusive ranges... adding or subtracting 1 from a number?
There are two issues there. First, a good helper shouldn't require the programmer to utilize tricky gyrations like offsets to achieve a basic effect; that results in confusing and, often, incorrect code. Second, it doesn't work.

While it's true that [0,2) is the same as [0,2-1] for the integers, the coder making the request for [0,2) may not have any information a priori about the calls being made into the function she's writing. It may only be known that "my range starts at 0, the next starts at 2, and I have to operate within that range". This happens in physical simulations, GIS data analysis, and probably graphics as well, where the actual step size is controlled by some outside process that makes changes to achieve some overall threshold. What's really needed is [0,2-epsilon] for all epsilon greater than zero.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Volguus posted:

I understand tree-shaking, that's perfectly reasonable. I don't understand the rest. It does minification, it adds the templates to the generated javascript, you can add the uglify plugin, fine, but ... then what? I mean .. that's all?

I am not sure about tree-shaking as being available in the current ecosystem (angular 1.6, gulp and friends etc.) but the rest surely are. I think I had too high expectations from something called AoT compiler. Then again, this is javascript so printing "Hello World" on the terminal is seen as the second coming in the "community".

Yeah, I thought maybe this was the equivalent of server-side rendering but for Angular, but no, it's just webpack but for angular and oh you get to maintain two different index files! One for dev and one for prod, because the bundle has to be bootstrapped differently :toot:

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Bruegels Fuckbooks posted:

Yeah tbh it can take me a week of doing front end js to do something that I could do in a day using WPF, and I have way more experience using front end js than WPF.

Me too, but in my case it would be 90% getting the goddamn tooling configured and 10% actually writing the thing.

I find HTML/CSS/JS to be pretty excellent for UIs. I never really found this to be the case until I started using React + Redux.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Thermopyle posted:

I find HTML/CSS/JS to be pretty excellent for UIs. I never really found this to be the case until I started using React + Redux.

I agree until there's a form involved. Everything around HTML forms is hilariously bad compared to .Net's native UI toolkits.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Munkeymon posted:

I agree until there's a form involved. Everything around HTML forms is hilariously bad compared to .Net's native UI toolkits.

Yeah, I guess that's true. I just never write a UI that's for windows only.

NtotheTC
Dec 31, 2007


I just wish people would stop innovating (as much) and start improving. If you develop something cool in the JS ecosystem stop and make it better, more stable, and more generic. Don't try and develop the next esoteric cool thing.

Volguus
Mar 3, 2009

NtotheTC posted:

I just wish people would stop innovating (as much) and start improving. If you develop something cool in the JS ecosystem stop and make it better, more stable, and more generic. Don't try and develop the next esoteric cool thing.

Not only that, but also learn the concept of backwards-compatibility. No, hiding behind "semver" when you remove poo poo does not cut it. APIs get deprecated in version 2.0 and are removed in version 15.0 not in 2.1 like a lot of libraries and frameworks do. It's loving insane. Then again, like you said, 15.0 will never happen since there'll be a new shiny thing to chase after.

Nova69
Jul 12, 2012

It also seems like the de facto package manager changse every year, and because of this, you end up having to maintain npm, bower, and tons of other package manager configs in your project, when they really could all be done by one of them.

Nova69 fucked around with this message at 16:02 on Oct 26, 2017

iospace
Jan 19, 2038


NtotheTC posted:

I just wish people would stop innovating (as much) and start improving. If you develop something cool in the JS ecosystem stop and make it better, more stable, and more generic. Don't try and develop the next esoteric cool thing.

I have a friend who has that entire attitude. "This language is bad, use this one. It's that other language but better!"

Would it surprise you if I said they were also really big on functional programming too?

iospace fucked around with this message at 15:56 on Oct 26, 2017

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


There is a global market for three, perhaps four programming languages.

Jeb Bush 2012
Apr 4, 2007

A mathematician, like a painter or poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas.

Doc Hawkins posted:

There is a global market for three, perhaps four programming languages.

and all four of them are derivatives of javascript

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Doc Hawkins posted:

There is a global market for three, perhaps four programming languages.

Just wondering, but how are you defining 'global market' there? Or am I missing a joke :ohdear:

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
I still use jQuery. Only because it was big the last I wanted to learn anything about JavaScript. I have no idea how much of a horror this is.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop

lifg posted:

I still use jQuery. Only because it was big the last I wanted to learn anything about JavaScript. I have no idea how much of a horror this is.

It's a horror on the Q&A forums for sure, where half the JavaScript questions you Google up depend on this weird library instead of on modern built-in language features that do the same thing concisely

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

PhantomOfTheCopier posted:

There are two issues there. First, a good helper shouldn't require the programmer to utilize tricky gyrations like offsets to achieve a basic effect; that results in confusing and, often, incorrect code. Second, it doesn't work.

subtracting two numbers is a "tricky gyration"? did you graduate kindergarten?

PhantomOfTheCopier posted:

While it's true that [0,2) is the same as [0,2-1] for the integers, the coder making the request for [0,2) may not have any information a priori about the calls being made into the function she's writing. It may only be known that "my range starts at 0, the next starts at 2, and I have to operate within that range". This happens in physical simulations, GIS data analysis, and probably graphics as well, where the actual step size is controlled by some outside process that makes changes to achieve some overall threshold. What's really needed is [0,2-epsilon] for all epsilon greater than zero.

someone that's good enough to understand clamping to an exclusive range with a defined step size should be more than smart enough to understand the concept of subtracting a single step size to create a new bound.

maybe i'm not being imaginative enough i can't think of a place where having a *clamp* with an unspecified inclusive upper bound would be useful.

"what's the highest number going to be in your data set?"
"i don't know, it's slightly smaller than 2500" ???

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Munkeymon posted:

Or am I missing a joke :ohdear:
It's a reference to a quote by the guy running IBM back during the very, very early days of electronic computers, similar to Bill Gates' "640k ought to be enough for anybody" thing in that they're both out of context but quoted frequently.


lifg posted:

I still use jQuery. Only because it was big the last I wanted to learn anything about JavaScript. I have no idea how much of a horror this is.
jQuery comes from an era when everything it wanted to do was done differently and with different bugs in every browser. This is no longer the case. Everything it does is now done the same way in every browser. You should know how to do everything jQuery does in plain vanilla Javascript, but there is zero harm in continuing to use jQuery for stuff, even for new stuff. If you're using jQuery to do a thing and don't know how to do it by hand, go do it by hand at least once.

Modern trendy Javascript is all about bleeding edge broken poo poo with a dependency graph twenty nodes deep. That crowd tends to look down on older, stable libraries, and you can tell them to get hosed as long as you can prove you know what you're doing.

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun

lifg posted:

I still use jQuery. Only because it was big the last I wanted to learn anything about JavaScript. I have no idea how much of a horror this is.
I don't do front-end stuff, so whenever I have to do front-end work, I'm glad if I can either use plain Javascript, or just JQuery. I refuse to be drawn into a world where I have to understand this giant framework and keep track of how it keeps track of state in my brain when I just have to add one goddamn bit of functionality; sometimes, backend devs DO have to touch the front end, and digging through a morass of frameworks and tooling to change a button is nightmarish.

Dumb Lowtax posted:

It's a horror on the Q&A forums for sure, where half the JavaScript questions you Google up depend on this weird library instead of on modern built-in language features that do the same thing concisely
This is a gigantic pain in the rear end.

Ranzear
Jul 25, 2013

VikingofRock posted:

Holy cow, minos has some labyrinthine logic!

This guy gets it.

It's more for:
code:
Tank.x.minos()
Tank.y.minos()
Tank.v.minos(-0.5 * Tank.type.topspeed, Tank.type.topspeed)
Which saves like ... 30 irrelevant float bytes in json per tank per update. It's just a general 'hang this on values that will hit the netcode' use.

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

Thermopyle posted:

Me too, but in my case it would be 90% getting the goddamn tooling configured and 10% actually writing the thing.

I find HTML/CSS/JS to be pretty excellent for UIs. I never really found this to be the case until I started using React + Redux.

I just read up on both these things, and all it's doing is making me miss proper MVC separation. You don't realise how much it helps until you're working in a codebase that's just a hodgepodge where any and all of model/view/control might be changed wherever.

E: Speaking of which, is it even possible to keep MVC separation when all your stuff is based on jQuery widgets?

Joda fucked around with this message at 21:22 on Oct 26, 2017

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


"Spookylang stands behind but one goal: to be the scariest programming language."

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

pigdog posted:

what are those?
WPF (rip 2006-2012)

Carbon dioxide
Oct 9, 2012

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe
Hey man, you gotta save them clock cycles. O(sqrt(n)) ain't no joke.

I'm disappointed in their lack of commitment, though. I'd have expected every number from 0 to the upper limit of an unsigned 64 bit int.

CPColin
Sep 9, 2003

Big ol' smile.
I want to see the unit test for that code.

canis minor
May 4, 2011

Joda posted:

I just read up on both these things, and all it's doing is making me miss proper MVC separation. You don't realise how much it helps until you're working in a codebase that's just a hodgepodge where any and all of model/view/control might be changed wherever.

E: Speaking of which, is it even possible to keep MVC separation when all your stuff is based on jQuery widgets?

You can have MVC/OO with JS (and OO in CSS - BEM). I don't know how to feel about needing a framework to achieve MVC in JS, but I like both Angular and React, so...

The way I used to do it is have models as separate JS files - for example: Button object in "button.js". All elements that would have to be Buttons would have class "js-button", so there would only be a need for one call of $("[class*='js-']") to transform given element into widget (+ when inserting elements, but that's a separate matter). Data that would be required for specific widgets would be passed via "data-button" - for example - if button on click would have to gain class, it would have `data-button="toggleClass: 'active'"` (via pseudo-JSON). But in the end - DOM element would have a JS object associated with it, that would control its actions.

This way Models,Controllers|Whatevs(JS) have separation of concerns from Views (HTML, or if you're more adventurous - JS templates). It might be a naive (and probably coding horror as well) approach though. There were also some edge cases with bindings - after clicking this button, window needs to play this music and flash: you can't pass this sort of behaviour as string, so you'd still end up with JS functions being part of Model in a View.


This is commitment.

canis minor fucked around with this message at 22:40 on Oct 26, 2017

VikingofRock
Aug 24, 2008




CPColin posted:

I want to see the unit test for that code.

Java code:
@Test
public void testIsPrime() {
    for (long n = 0; n < 1000; ++n) {
        List<long> factorsIfPrime = new ArrayList<long>();
        factorsIfPrime.add(n);
        if MyClass.isPrime(n) {
            assertThat(TestHelper.primeFactors(n), equalTo(factorsIfPrime));
        }
        else {
            assertThat(TestHelper.primeFactors(n), not(equalTo(factorsIfPrime)));
        }
    }
}

VikingofRock fucked around with this message at 22:58 on Oct 26, 2017

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

quote:

Java code:
case 0: isPrime = true; break;
case 1: isPrime = true; break;

:mad:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

canis minor posted:

This is commitment.

yeah, commitment to being :wrong:

Linear Zoetrope
Nov 28, 2011

A hero must cook

Rubellavator
Aug 16, 2007

Why not use a massive array of booleans if you're gonna hardcore like that.

Linear Zoetrope
Nov 28, 2011

A hero must cook

Joda posted:

Hey man, you gotta save them clock cycles. O(sqrt(n)) ain't no joke.

I'm disappointed in their lack of commitment, though. I'd have expected every number from 0 to the upper limit of an unsigned 64 bit int.

I don't know if it actually happened, but I heard a tale once of someone who tried that in Java (well, not max int64, but very large) and managed to overflow the relative jump range on the processor and break the JVM.


My programming headcanon is that programs punished and executed by Vigil come back in this.

Linear Zoetrope fucked around with this message at 23:26 on Oct 26, 2017

Adbot
ADBOT LOVES YOU

Eleeleth
Jun 21, 2009

Damn, that is one suave eel.

Joda posted:

Hey man, you gotta save them clock cycles. O(sqrt(n)) ain't no joke.

This is why you use idle time to calculate primes out to your available memory limit, then just check them by referencing that array, obviously.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply