In some time, I'll fork JS and make my own language based on it, but simpler. This is how variables will be defined:
// was
const path = 'https://example.com/test/spec'
let result = await test.me()
result = await test.me.again()
// becomes
the path = https://example.com/test/spec
a result = await test.me()
result = await test.me.again()
Using quotes for strings is plenty annoying and I wish JS could infer what I mean to define a string, since https://example.com/test/spec would throw anyway.
Then we've learned to use consts but I'm more at ease with lets now because typing const every time is just long. It's all about simplicity and shortness. The less the better. In fact, I tried to skip defining vars altogether which is actually pretty nice. Then you see that const is actually 5 letters and is so-so long. Ofc it gives you anxiety in tests that a variable might leak out of the test case scope without const, but hey it's so much fun without all these rules.
Further, if statements:
// was
if (test == 'ok') { await fetch('https://hello.world') }
// also was
if (test == 'ok') await fetch('https://hello.world')
// became
if test == ok await fetch https://hello.world
Always having to put () brackets after if is really annoying me. Whereas the curly braces can be skipped, for some reason the () can't and I don't see why. If there's a logical expression after if surely in many cases it's possible to deduct what the human meant. Same goes for variables of functions I guess. Just cut all that punctuation crap out of the language. That's what I call style.
Surely a language can accommodate for simple syntax like this. I'd also remove all imports to cut the chore and make installed packages' API global variables. Then I don't have to waste my life on bloody imports.
Nice outlook on this.
I guess params are encapsulated in () so it belongs to that function call... How would you know when to stop reading into the fetch? E.g. method, headers etc etc?
Having a nice global or env setup prior gives you a chance to write nicer syntax, cause I'm totally together with you on this!
E.g.
test === OK ? fetch(URL) : null
OK being a const we can define that equals "ok" etc etc.
To me that's pretty clean, but I totally get where you're coming from
obv not for all function params, it was pretty random actually and came up when writing the post without prior though. you'd know by line breaks i guess. there must be cases when it's possible to know like there's no expression following a statement of a variable that fits into the function's api (counting the number of args) so it must be an arg. in other cases a warning can be given
+1 for :ternary?, you can also do like
condition && fetchaka JSX style.if (typeof a == 'string') fetchcan becomea && a['toUpperCase'] && fetchwhich isn't shorter but i heard someone say typeof is slow, so it's just a though experiment, although this becomes unreadable.Yeah that's very true. You probably could build a new library around what you're describing... I'd be very interested in seeing how it goes if you dive deeper into it!!
Yeah the && is good, I tend to only use this with booleans as it reads perfectly with properly named vars and makes sense eg.
!fetched && fetch(URL)
+1
Let me know if you go ahead id love to follow it!
no not library my friend, a language :D when i get my first million i'll take some time off and do it :P and make it run on a new runtime rather than node as well I don't like how node is trademark. it's basically all because JavaScript is a trademark and I was looking for ways around it ) With the runtime, i had an idea that you could actually port node's api onto a headless browser like chrome since it's got all javascript and you don't even need libraries for networking like just do fetch lol so much simpler. but it takes 140 mb of ram against that of 5 of node, and to run a tcp server you need to run a chrome app, which are actually being depreraced without an alternative to tcp server, which is essential for node. but again, it would be fun just to try it. it's because i don't like node belonging to near form. i don't like to depend.
one gotcha with && is doing
array.length && <div/>(or any var of number type not just length) which can result in printing actual0so you're right to use with only with booleans )