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
piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



abraham linksys posted:

is there a comprehensive overview of typescript that I'm missing? like http://www.typescriptlang.org/Handbook doesn't even tell you the syntax for a loving hash map (which is apparently { [key:string]:Type; })

yeah good luck with that. I tend to piece together stuff from their github wiki, their blog posts (for newer features), and whatever I can google or see is done on the roadmap

it is a kind of lovely situation not gonna lie

Adbot
ADBOT LOVES YOU

abraham linksys
Sep 6, 2010

:darksouls:

piratepilates posted:

yeah good luck with that. I tend to piece together stuff from their github wiki, their blog posts (for newer features), and whatever I can google or see is done on the roadmap

it is a kind of lovely situation not gonna lie

i'm gonna retreat back to regular ol javascript, then

for as undeveloped as facebook's non-react projects tend to be the flow documentation is way better than this

JewKiller 3000
Nov 28, 2006

by Lowtax
if you want a typescript syntax cheat sheet you can try googling for "typescript syntax cheat sheet" although the results will probably be for a pre-1.0 version because gently caress you

if you want a "comprehensive overview" then you get to read the spec, sorry

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



abraham linksys posted:

i'm gonna retreat back to regular ol javascript, then

for as undeveloped as facebook's non-react projects tend to be the flow documentation is way better than this

:shrug: does flow need that much?


also the syntax for a Map is:

code:
let map = new Map<IKeyType, IValueType>();

Mahatma Goonsay
Jun 6, 2007
Yum
I guess I'll stick with good old
code:
 (1 + "1") * 3 === 33 
js then.

abraham linksys
Sep 6, 2010

:darksouls:

piratepilates posted:

also the syntax for a Map is:

code:
let map = new Map<IKeyType, IValueType>();

meant map in the traditional "object literal" sense not es6 maps

other big reason i'm thinking of dropping typescript is that i don't understand how to use it with immutable.js and neither does the rest of the internet, as far as i can see

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



abraham linksys posted:

meant map in the traditional "object literal" sense not es6 maps

other big reason i'm thinking of dropping typescript is that i don't understand how to use it with immutable.js and neither does the rest of the internet, as far as i can see

how so? they have a typescript definition file in their repo and short instructions on using it.

and object literals should have been covered in the tutorial or handbook

akadajet
Sep 14, 2003

MALE SHOEGAZE posted:

i'm flying with es6 now and dang it's really really nice. honestly it's pretty decent scripting language. i could see using it over ruby or python. having JS's first class functions along with like...usable templating and finally a decent syntax for anonymous functions is pretty usable and fun.

there's lots of good poo poo in modern javascript. and we're getting some good web frameworks these days.

akadajet
Sep 14, 2003

Mahatma Goonsay posted:

I guess I'll stick with good old
code:
 (1 + "1") * 3 === 33 
js then.

ask a dumb question in javascript and get a dumb answer. seems to work fine.

abraham linksys
Sep 6, 2010

:darksouls:

piratepilates posted:

how so? they have a typescript definition file in their repo and short instructions on using it.

and object literals should have been covered in the tutorial or handbook

so when you make a redux app using an immutable reducer you usually want to define your state tree as an immutable Record, something like

code:
import * as I from 'immutable';

const Ball = I.Record({
  x: null,
  y: null,
})

const State = I.Record({
  balls: I.List(),  // you'd populate this with new Ball()s
});
a record provides accessors for all defined fields (so you don't have to use .get()), throws an error if you set() an undefined field, and provides default values for various fields.

my thought was "okay, well this is obviously a case where it'd be fantastic to have real typing! I could say that Ball has "x" and "y" fields that are numbers, and that the "balls" List can only contain Ball() instances." and I can find no way of doing this in Typescript, and googling only turns up issues that seem to indicate that this not possible

Bloody
Mar 3, 2013

akadajet posted:

there's lots of good poo poo in modern javascript. and we're getting some good web frameworks these days.

couple thousand more frameworks and it might be usable

akadajet
Sep 14, 2003

Bloody posted:

couple thousand more frameworks and it might be usable

ember and react are all the frameworks u need

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Mr Dog posted:

Yeah if it were up to me then I'd change Java to (A) make byte unsigned and if I get a B then (B) make "final" the default state of affairs that you have to opt out of.

i understand that rust got this right and you have to use "mut" to declare mutability, with immutability being the default. if im wrong someone correct me

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





i'm writing a thing using elm for the front end and i need a backend to pair it with. i was considering typescript but i can't find any node http frameworks that work well with it except maybe express. should i just use servant (haskell) or rust's sinatra clone instead?

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



the talent deficit posted:

i'm writing a thing using elm for the front end and i need a backend to pair it with. i was considering typescript but i can't find any node http frameworks that work well with it except maybe express. should i just use servant (haskell) or rust's sinatra clone instead?

why the hell you gonna use node.js when you can play with rust instead

abraham linksys
Sep 6, 2010

:darksouls:
why would you use rust for an http server when you could use any number of more mature options which, actually, includes node.js

never heard a good argument for rust web services. backend services, sure, but your actual endpoint logic?

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



because rust is cool as poo poo and when else do you get a chance to use it

Bloody
Mar 3, 2013

Cool as poo poo in a literal sense

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





piratepilates posted:

because rust is cool as poo poo and when else do you get a chance to use it

i'm already implementing viewstamped replication and pacifica in rust for fun, the elm thing is a prototype for a startup i maybe want to do

Gul Banana
Nov 28, 2003

rjmccall posted:

this is essentially what i was saying, thx

smh is actually particularly hilarious about this because its generics system is generative, not applicative, so invoking the same functor twice with the same arguments gives you different types

O_O
how do you refer to the type later? can you 'save' it in an alias or something? and who the heck wanted an imperative *type system*

Gul Banana fucked around with this message at 03:17 on Mar 22, 2016

Gul Banana
Nov 28, 2003

also, typescript is extremely good but what it's good *for* is building Large Applications. when your team develops a bunch of components in typescript then they all get checking when referring to each *other* and the save-you-from-errors thing works.

it's not particularly great for using external libraries, although for a few key ones (react, with typed jsx/tsx!) it is useful. large componentised applications or internal libraries tend to want to avoid dependencies anyway.

another way of putting it: typescript is mediocre if you want to buy into the 'JavaScript ecosystem', which is an insane thing to do. it's very good if what you want is to write code that runs in a browser.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

the talent deficit posted:

i'm writing a thing using elm for the front end and i need a backend to pair it with. i was considering typescript but i can't find any node http frameworks that work well with it except maybe express. should i just use servant (haskell) or rust's sinatra clone instead?

everyone seems to use either haskell or elixir

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

comedy option: https://github.com/NoRedInk/take-home which is all elm all the time

MeruFM
Jul 27, 2010
i wrote a web thing in rust but then stopped. the interesting thing about it seems to be getting it to compile anything non-trivial but then not creating anything meaningful. It just felt tedious after the initial hump.

abraham linksys
Sep 6, 2010

:darksouls:

Gul Banana posted:

another way of putting it: typescript is mediocre if you want to buy into the 'JavaScript ecosystem', which is an insane thing to do.

lol

FamDav
Mar 29, 2008

Gul Banana posted:

also, typescript is extremely good but what it's good *for* is building Large Applications. when your team develops a bunch of components in typescript then they all get checking when referring to each *other* and the save-you-from-errors thing works.

it's not particularly great for using external libraries, although for a few key ones (react, with typed jsx/tsx!) it is useful. large componentised applications or internal libraries tend to want to avoid dependencies anyway.

another way of putting it: typescript is mediocre if you want to buy into the 'JavaScript ecosystem', which is an insane thing to do. it's very good if what you want is to write code that runs in a browser.

I know some people working on a ipython-but-DAG notebook using typescript and they're p happy with it.

Soricidus
Oct 21, 2010
freedom-hating statist shill

CPColin posted:

So type "final" when you declare the variable?

10 PRINT "Why do A when you can just do B?"
20 PRINT "B is bad because [explanation]. A doesn't have that problem."
30 PRINT "So just do C then?"
40 PRINT "C is bad because [explanation]. A doesn't have that problem."
50 PRINT "So just do B then?"
60 GOTO 20

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Gul Banana posted:

O_O
how do you refer to the type later? can you 'save' it in an alias or something?

sure, of course. and it'll be in the types of any of the operations on the functor result

quote:

and who the heck wanted an imperative *type system*

i have occasional fantasies of pointing out to bob harper that his language's basic translation model is imperative rather than declarative

i should probably get over it, tbh

crazypenguin
Mar 9, 2005
nothing witty here, move along

rjmccall posted:

i have occasional fantasies of pointing out to bob harper that his language's basic translation model is imperative rather than declarative

I have an extremely vague memory of a conversion about generative functors, where somebody (and I think Harper was there, but I don't know if it was him) basically argued that the reason sml was generative was because of ref cells. So each structure could contain internal state.

Basically, like the value restriction for let generalization, I think they were already aware that imperative mutationy things were driving the design decisions.

CPColin
Sep 9, 2003

Big ol' smile.

Soricidus posted:

10 PRINT "Why do A when you can just do B?"
20 PRINT "B is bad because [explanation]. A doesn't have that problem."
30 PRINT "So just do C then?"
40 PRINT "C is bad because [explanation]. A doesn't have that problem."
50 PRINT "So just do B then?"
60 GOTO 20

10 END

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

crazypenguin posted:

I have an extremely vague memory of a conversion about generative functors, where somebody (and I think Harper was there, but I don't know if it was him) basically argued that the reason sml was generative was because of ref cells. So each structure could contain internal state.

Basically, like the value restriction for let generalization, I think they were already aware that imperative mutationy things were driving the design decisions.

the value restriction is a soundness requirement, it's unavoidable without major language changes. if functors were applicative, you could just say that of course ref cells bound in the structure are the same across bindings

i mean, the implementation still ends up imperative, it's basically lazy caching of functor application, but the language model stays declarative

crazypenguin
Mar 9, 2005
nothing witty here, move along

rjmccall posted:

the value restriction is a soundness requirement, it's unavoidable without major language changes.

changes like removing unrestricted IO and ref cells to make the language pure instead of imperative.

but I think maybe you were making a subtler point that hinges on "language model" vs language, so maybe my point here isn't relevant

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer
so i guess this is what happens when you're so close to the metal that you don't have printf and the owner of the "left-pad" module throws a fit:

https://twitter.com/seldo/status/712414400808755200

https://twitter.com/seldo/status/712414588281552900

https://twitter.com/seldo/status/712416770682781698

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
it's amazing how many levels of hilarity there are to it:

1. people being able to "un-publish" modules at all
2. un-publishing your modules to protest a third party not paying for a lawyer for you
3. the entire js ecosystem depending on a module that's 17 lines of code

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
e nm

JewKiller 3000
Nov 28, 2006

by Lowtax

crazypenguin posted:

changes like removing unrestricted IO and ref cells to make the language pure instead of imperative.

yeah you could do that, but we don't do that because it sucks

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

crazypenguin posted:

changes like removing unrestricted IO and ref cells to make the language pure instead of imperative.

i was thinking more like re-introducing explicit type application :getin:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
wtf is a left-pad

Dylan16807
May 12, 2010

Suspicious Dish posted:

wtf is a left-pad

it puts spaces or zeroes at the left of a string

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
i wrote that last night

code:
    function formatHex(v, w) {
        var S = v.toString(16).toUpperCase();
        while (S.length < w)
            S = '0' + S;
        return S;
    }
why is there an npm module for this and why don't people just write out the two lines of while loop in their own module

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