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
fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

NihilCredo posted:

i vote for 'use elm'. echinopsis, you're making a clicker game for fun and learning. fun and learning is exactly what elm is suitable for and does very well

you'll never use elm for actual pays-the-bills stuff (and you shouldn't), but the experience of setting up a clean finite state machine, covering every possible edge case whether you like it or not, and then binding it to a view is invaluable

yep

Adbot
ADBOT LOVES YOU

echinopsis
Apr 13, 2004

by Fluffdaddy
what I don't find compelling about elm is that I don't know anything about it

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



that code is a crime!!! lol

echinopsis
Apr 13, 2004

by Fluffdaddy
I really wish I can learn to use something like a dictionary. there are functions in that code that exist to act like a dictionary, they take a string and then I loop through every item in the array searching for a match for the string, and return some bullshit. it feels like a tragic solution to what feels like it should have a much simpler solution

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine
what you really need is a finite state machine and algebraic data types mate

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

my homie dhall posted:

what you really need is a finite state machine and algebraic data types mate

been saying this

mystes
May 31, 2006

You could just use typescript but maybe elm isn't actually a bad idea because it will force you to do some stuff correctly

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

or use purescript ftw

mystes
May 31, 2006

Don't encourage self harm

echinopsis
Apr 13, 2004

by Fluffdaddy

my homie dhall posted:

what you really need is a finite state machine and algebraic data types mate

wtf ok imma boot up wikipedia and read some mf words

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

mystes posted:

You could just use typescript but maybe elm isn't actually a bad idea because it will force you to do some stuff correctly

“doing stuff correctly” here means “having fun writing it” I think

someone else is making a game in JS too: https://youtu.be/m8SmXOTM8Ec?si=doqLt-ikHrXF2jUR

Cybernetic Vermin
Apr 18, 2005

echinopsis posted:

every time I dive back into this I have to half rel-earn js

tbf having programmed professionally for 20 years this more or less remains standard operating procedure when i switch back into something after a break. you'll learn it 10x faster this, and eventually fast enough that it isn't *that* distinguishable from knowing.

tef
May 30, 2004

-> some l-system crap ->
turns out knowing the right way to build an app doesn't give you any more motivation to write the code

if anything, knowing the chore ahead is a good deterrent

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

tef posted:

turns out knowing the right way to build an app doesn't give you any more motivation to write the code

if anything, knowing the chore ahead is a good deterrent

back when i was contributing to elm, i had a good working thing w/ a computer science nerd where i (self taught hobbyist who had a lot of ideas) would write a bunch of bad code that basically worked, and then that guy (computer science nerd who had no ideas) would simply rewrite all my stuff the Correct Way

crazypenguin
Mar 9, 2005
nothing witty here, move along

Sagacity posted:

hdym

it was started in 2018, there have been a ton of previews, how is this "it's here"?

oh, my mistake.

I just assumed I would have noticed, but it seems its been in preview since java 19 a year ago and I hadn't noticed

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
lol i posted this in the bwm thread

i wouldn’t say that java is just doing the hip new thing. if anything, i think that would be async/await. instead, they’re taking a strong stance of committing to their older, arguably simpler programming model by trying to make threads more scalable

the “some weird thing blocked an os thread and our perf cratered / we deadlocked” problem is inevitable. os threads are a precious resource, and it sucks to block them. any technology that tries to create scalable concurrency will involve m-n scheduling and will be susceptible to the problem. and if you deliberately don’t build that into the language, people will build libraries to pool your non-scalable concurrency primitives, and those pools will be susceptible to the problem. java’s opt-in approach for their scalable threads seems like a reasonable, conservative way to introduce the tech into the system without forcing problems on people

i’m still not sure it’s the best thing overall, but I understand it

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

echinopsis posted:

every time I dive back into this I have to half rel-earn js

echi try this poo poo out, you might like it:
https://www.executeprogram.com/courses/modern-javascript

it teaches some of the nicer stuff that has become available in all browsers (and been available for quite a while at this point) and it does spaced recall testing so that you can learn a thing and have it reinforced.

it's also a nice way to give some money to the guy who made the "javascript wat" presentation, if you want the premium account

crazypenguin
Mar 9, 2005
nothing witty here, move along
(what's the bwm thread?)

yeah, I'm not disputing they probably chose right for java, but their proposal for it was basically "babby's first criticism of async/await" followed by "there are no problems in Ba Sing Se with green threads!"

the first one irked me, the second has me really suspicious. "pretend the problems don't exist" isn't usually a good engineering strategy.

That could have been irrational exuberance with the initial proposal, but the final JEP still has threads getting pinned and blocked with no real options presented for dealing with it. (Despite there being a solution for IO blocking seemingly hidden away inside the runtime.)

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



bwm = bad with money:
https://forums.somethingawful.com/showthread.php?threadid=3878671

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

crazypenguin posted:

(what's the bwm thread?)

the bad with money thread in bfc, which you can find by searching the entire forums for a thread with a million posts that doesn’t have “bad with money” in the title

(it actually is in bfc atm, currently called “bulbs worth millions”)

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

my assumption is that java's new green threads are being pushed exclusively by low-latency hedge funds with deep pockets to drive JEPs, which is not inherently a bad thing but does mean that it might not be a general solution for everyone

oh nice, I wondered what gary bernhardt was up to these days

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
the project loom stuff was built because java did not want to adopt async/await since it requires a completely different ecosystem next to your regular ecosystem, like in other languages

in some ways this has already happened in java too, with the god awful reactive programming libraries that have popped up

what loom enables users to do is to simply take an application like netty, which serves network requests using an ordinary thread pool, and have it use a green thread pool instead, where it suddenly handles (tens of) thousands of requests per second

Sapozhnik
Jan 2, 2005

Nap Ghost
itym jetty

netty is the one where it's all non-blocking and you write network applications as if you were performing interrupt-driven i2c transactions on a bare-metal microcontroller, pounding nails into your dick in black-and-white infomercial hellworld while screaming at the heavens that there has got to be a better way!!

Sapozhnik
Jan 2, 2005

Nap Ghost
also i'm a filthy pervert who loves writing bare-metal interrupt-driven i2c drivers in c, it gets me really hot and bothered

please pay me six figgies to do it. rust is for cowards and c++ is revolting. only c.

Armitag3
Mar 15, 2020

Forget it Jake, it's cybertown.


Sapozhnik posted:

also i'm a filthy pervert who loves writing bare-metal interrupt-driven i2c drivers in c, it gets me really hot and bothered

please pay me six figgies to do it. rust is for cowards and c++ is revolting. only c.

don't get addicted to SIGs, kids

echinopsis
Apr 13, 2004

by Fluffdaddy

prisoner of waffles posted:

echi try this poo poo out, you might like it:
https://www.executeprogram.com/courses/modern-javascript

it teaches some of the nicer stuff that has become available in all browsers (and been available for quite a while at this point) and it does spaced recall testing so that you can learn a thing and have it reinforced.

it's also a nice way to give some money to the guy who made the "javascript wat" presentation, if you want the premium account

thankyou very much this looks good and is something achievable

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

echinopsis posted:

JavaScript code:
// struct for accumulated data (I expect to add more as time goes on)
function structOfGameState(state, numberTimesCommitted, datetimeCrimeWillEnd, datetimeCrimeStarted) {
    // state refers to where the crime is at
    // 0 = ready to run
    // 1 = running
    // 2 = completed but haven't collected resources
    // 3 = unavailable (need more noto)
    this.state = state;
    this.numberTimesCommitted = numberTimesCommitted;
    this.datetimeCrimeWillEnd = datetimeCrimeWillEnd;
    this.datetimeCrimeStarted = datetimeCrimeStarted;
}

for (let gameStateDataIndex = 0; gameStateDataIndex < setOfCrime.length; gameStateDataIndex++) {
    gameState[gameStateDataIndex] = new structOfGameState(0, 0, 0);
}

i'm just going to use this as an example, but you don't need to use "new" here, instead you can just use an object literal:

JavaScript code:
for (let gameStateDataIndex = 0; gameStateDataIndex < setOfCrime.length; gameStateDataIndex++) {
	gameState[gameStateDataIndex] = {
		state:0,
		numberTimesCommitted: 0,
		datetimeCrimeWillEnd: 0,
	}
}
or, if you want to use a function to create your objects (which is fine):

JavaScript code:
// struct for accumulated data (I expect to add more as time goes on)
function structOfGameState(state, numberTimesCommitted, datetimeCrimeWillEnd, datetimeCrimeStarted) {
	// using shorthand object notation
	return {
		state,
		numberTimesCommitted,
		datetimeCrimeWillEnd,
		datetimeCrimeStarted
	}
}

function structOfGameStateButWithOldNotation(state, numberTimesCommitted, datetimeCrimeWillEnd, datetimeCrimeStarted) {
	// using the traditional notation
	return {
		state: state,
		numberTimesCommitted: numberTimesCommitted,
		datetimeCrimeWillEnd: datetimeCrimeWillEnd,
		datetimeCrimeStarted: datetimeCrimeStarted
	}
}


for (let gameStateDataIndex = 0; gameStateDataIndex < setOfCrime.length; gameStateDataIndex++) {
    gameState[gameStateDataIndex] = structOfGameState(0, 0, 0); // no "new" operator, just a function call
}

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
gentle request to take specific stuff like "help me with my game" to its own thread plz & thank

echinopsis
Apr 13, 2004

by Fluffdaddy
noted

echinopsis
Apr 13, 2004

by Fluffdaddy

Wheany posted:

i'm just going to use this as an example, but you don't need to use "new" here, instead you can just use an object literal:

JavaScript code:
for (let gameStateDataIndex = 0; gameStateDataIndex < setOfCrime.length; gameStateDataIndex++) {
	gameState[gameStateDataIndex] = {
		state:0,
		numberTimesCommitted: 0,
		datetimeCrimeWillEnd: 0,
	}
}
or, if you want to use a function to create your objects (which is fine):

JavaScript code:
// struct for accumulated data (I expect to add more as time goes on)
function structOfGameState(state, numberTimesCommitted, datetimeCrimeWillEnd, datetimeCrimeStarted) {
	// using shorthand object notation
	return {
		state,
		numberTimesCommitted,
		datetimeCrimeWillEnd,
		datetimeCrimeStarted
	}
}

function structOfGameStateButWithOldNotation(state, numberTimesCommitted, datetimeCrimeWillEnd, datetimeCrimeStarted) {
	// using the traditional notation
	return {
		state: state,
		numberTimesCommitted: numberTimesCommitted,
		datetimeCrimeWillEnd: datetimeCrimeWillEnd,
		datetimeCrimeStarted: datetimeCrimeStarted
	}
}


for (let gameStateDataIndex = 0; gameStateDataIndex < setOfCrime.length; gameStateDataIndex++) {
    gameState[gameStateDataIndex] = structOfGameState(0, 0, 0); // no "new" operator, just a function call
}

i’ll have a look at these later and get my head around them. something satisfying I get when coding is discovering a new and significantly better approach to making something work.


here’s a question : in unreal engine blueprints there’s this thing called select

let’s say I needed to plug a float into a function, select means I plug the select into the float input and then put multiple float options into the select, and then something like a boolean or integer index or even an enumeration, and then at run time the float is chosen from the options depending on the indexing input

I use it all the time because it feels clean.

and I’ve just thought about it and think I know how you could do it in js but would feel ugly and spose pointers would also be helpful achieving this .. just thinking out loud



coz of the nodes, the select node doesn’t really messy up the code, in fact it makes it clearer than the top example using branch

I spose in-line it might make for some gnarly to pull apart code and more challenging to work out what’s going on later sitch

echinopsis
Apr 13, 2004

by Fluffdaddy
I am realising now looking at those examples that there is a performance price to pay, at least in those blueprints. but I can imagine how pointers wouldn’t introduce that issue

anyway lol what am I talking about I’ve never used a pointer in my life

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

you mean you want to map it? can use an array or object for that depending on what keys you want. for zero-based integers:

code:
const select = [“red”, “blue”, “green”, “butts”];

…

let colourIndex = 3;
let colour = select[colourIndex]; // “butts”

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

echinopsis posted:


let’s say I needed to plug a float into a function, select means I plug the select into the float input and then put multiple float options into the select, and then something like a boolean or integer index or even an enumeration, and then at run time the float is chosen from the options depending on the indexing input


sounds to me like a switch statement https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch

echinopsis
Apr 13, 2004

by Fluffdaddy

Subjunctive posted:

you mean you want to map it? can use an array or object for that depending on what keys you want. for zero-based integers:

code:
const select = [“red”, “blue”, “green”, “butts”];

…

let colourIndex = 3;
let colour = select[colourIndex]; // “butts”

:chanpop:

amazing

redleader
Aug 18, 2005

Engage according to operational parameters
"i want to make my game better"
"learn and rewrite it in some fly-by-night hipste plang"

MononcQc
May 29, 2007

redleader posted:

"i want to make my game better"
"learn and rewrite it in some fly-by-night hipste plang"

this is the PL thread, the advice is gonna be PL related.

like you’re going to some blockchain shop and act surprised they try to sell you blockchains

echinopsis
Apr 13, 2004

by Fluffdaddy
doesn’t pl just mean programming language not plang?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

rotor posted:

gentle request to take specific stuff like "help me with my game" to its own thread plz & thank

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
i am happy that echi wants to learn to program but there really is an entire subforum for this

Adbot
ADBOT LOVES YOU

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

rjmccall posted:

i am happy that echi wants to learn to program but there really is an entire subforum for this

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