Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

01-05-2018 , 03:20 PM
Quote:
Originally Posted by Grue
I got a unsolicited job offer (to interview) at Reddit just because of my game Two months too late oh well.
Wait why is it two months too late? If it's a clear step-up, you should go for it, unless you have some non-work related reason why you can't.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-05-2018 , 03:50 PM
I start a new full time job at a fortune 50 in a lead engineer role on Monday.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-05-2018 , 04:11 PM
Quote:
Originally Posted by blackize5
I personally like let for objects and arrays that will be modified. That way let signifies "this thing changes"
ya this is how I learned. let or const.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-05-2018 , 04:24 PM
Quote:
Originally Posted by Grue
I start a new full time job at a fortune 50 in a lead engineer role on Monday.
Clearly the timing could have been better but I don't think it's a big deal or anything if you have to leave the new job in a couple of months - just leave it out of your future resume.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-05-2018 , 04:28 PM
Quote:
Originally Posted by Grue
don't use const for objects or arrays unless you're actually reassigning them.
May I ask why you suggest this? I would think that "const" would mean "constant" and therefore an immutable global value.

I consider "let" local to the function, meaning that it is a temporary, immutable value within a function that is destroyed once it is used, then reinitialized in a function when the function is called again, and would never be global.

"Var" seems to be well, a variable, which ought to be modified either within the function or the global space.

Is there any intrinsic difference between these keywords in JS outside of aliases for var to show intent?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-05-2018 , 04:37 PM
Its just the way JS decided to add const and let. If you try to reassign a const variable JS will throw an error. It has no problem with adding a property to an object or pushing a value into an array made with const. Therefore people just use const for those. shrug?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-07-2018 , 03:27 PM
If you really want to make an object immutable you can do the following

Code:
Object.freeze(myObject)
If you try to modify it after that, you will receive an error
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-07-2018 , 03:29 PM
Quote:
Originally Posted by Craggoo
If you really want to make an object immutable you can do the following

Code:
Object.freeze(myObject)
If you try to modify it after that, you will receive an error
Doesnt help on nested objects. There is no good immutable solution in native js yet

Also, do you receive an error? I dont in the console, it just doesnt update it
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-07-2018 , 05:24 PM
They cold called you just from the game?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-07-2018 , 05:50 PM
I guess? On reread it looks like they expected me to want to move to SFO? uh no. Who said side projects are useless huh. Though I guess its not easy to make something that gets as much traffic as this thing. Not that I did anything of any talent, I just used an permissive license game and its art. Meh.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-07-2018 , 07:13 PM
Quote:
Originally Posted by PJo336
There is no good immutable solution in native js yet
My understanding is no, and is why stuff like typescript became popular.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 12:36 AM
I thought the whole point of objects was to be mutable. Why would you want an immutable object?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 12:49 AM
Immutable objects from what I've learned basically means they are immutable in transfer, and once they arrive, you make a copy of it, versus making changes to it directly, to avoid a lot of bad-data related errors.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 01:04 AM
Quote:
Originally Posted by Larry Legend
Immutable objects from what I've learned basically means they are immutable in transfer, and once they arrive, you make a copy of it, versus making changes to it directly, to avoid a lot of bad-data related errors.
isn't that the basic concept of why you pass objects as const in C++? this sounds right but I'm a donk.

edit: nevermind, i'm an idiot that's not why. been programming too much java in the last year
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 01:06 AM
my schedule this quarter is:

embedded systems with a 2 unit lab
computational geometry
networking

sounds like a nightmare, i googled computational geometry and still dont really know what it is

i guess this is what happens when your very expensive school only offers like 8 classes per quarter and you've taken most of them because you're at the end of your major
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 06:35 AM
Quote:
Originally Posted by jmakin
isn't that the basic concept of why you pass objects as const in C++? this sounds right but I'm a donk.

edit: nevermind, i'm an idiot that's not why. been programming too much java in the last year
The idea of immutability comes up more in const object methods in C++.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 11:33 AM
My graduate work was mostly in computational geometry and graph theory. One of my favorite fields.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 12:16 PM
FWIW I can't think of too many places I would need or want an object to be immutable. But maybe it's just the way I program.

Case in point - all express middlware has this method signature: function myMiddleWare(req, res, next)

You'd think the express req and res maybe should be immutable? But the way you pass stuff from middleware to middleware (to avoid effing up the method signature) is by tacking things on to res.locals. Also my framework tacks stuff on to req object. But it could use res.locals if req was immutable.

Personally I like the flexibility.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 07:33 PM
I played a bit with Grobner bases a few years ago (part of computational algebraic geometry.) They are quite powerful. I ended writing some C to solve a particular example that interested me, although it failed to find a solution after a few days running.

Last edited by river_tilt; 01-08-2018 at 07:57 PM. Reason: Splelpibg
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 08:26 PM
Quote:
Originally Posted by daveT
I thought the whole point of objects was to be mutable. Why would you want an immutable object?
Maybe you're honing in on a specific meaning of the word "object" in which case I get what you're saying, but for anyone interested, https://en.wikipedia.org/wiki/Persistent_data_structure

In redux in js (which I think is similar paradigm as om in clojure and CQRS) your entire app's state is supposed to be immutable. This allows you to do stuff like 'undo' functionality trivially and helps debugging because you can see exactly what your update functions are changing in your state.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 08:37 PM
Quote:
Originally Posted by daveT
"Var" seems to be well, a variable, which ought to be modified either within the function or the global space.

Is there any intrinsic difference between these keywords in JS outside of aliases for var to show intent?
yes, let and const actually have traditional block scope while var has function scope.

Code:
{ let x = 5}
x //undefined
{ var x = 2 }
x === 2 //true
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 10:29 PM
Quote:
Originally Posted by daveT
I thought the whole point of objects was to be mutable. Why would you want an immutable object?
Wait, wat? Doing anything in multithreaded environment is much simpler with immutable objects.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 11:08 PM
Quote:
Originally Posted by suzzer99
FWIW I can't think of too many places I would need or want an object to be immutable. But maybe it's just the way I program.

Case in point - all express middlware has this method signature: function myMiddleWare(req, res, next)

You'd think the express req and res maybe should be immutable? But the way you pass stuff from middleware to middleware (to avoid effing up the method signature) is by tacking things on to res.locals. Also my framework tacks stuff on to req object. But it could use res.locals if req was immutable.

Personally I like the flexibility.
Spoken like a guy who has never had to deal with threads
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 11:36 PM
Quote:
Originally Posted by suzzer99
FWIW I can't think of too many places I would need or want an object to be immutable. But maybe it's just the way I program.

Case in point - all express middlware has this method signature: function myMiddleWare(req, res, next)

You'd think the express req and res maybe should be immutable? But the way you pass stuff from middleware to middleware (to avoid effing up the method signature) is by tacking things on to res.locals. Also my framework tacks stuff on to req object. But it could use res.locals if req was immutable.

Personally I like the flexibility.
I think the opposite: it's hard to find legitimate places where objects should be mutable. Performance, which is rarely an issue, is one.

Theoretically, express (and koa) absolutely should have been designed with immutable response objects. A middleware would then modify and return a copy. This, it turns out, probably is a place where performance needs conflict with the correct design. Unless (maybe) you were using something like Immutable.js to implement it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
01-08-2018 , 11:37 PM
Quote:
Originally Posted by daveT
I thought the whole point of objects was to be mutable. Why would you want an immutable object?
This is incorrect.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m