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
gonadic io
Feb 16, 2011

>>=

floatman posted:

Can I use JavaScript in a PDF to expose a REST interface to access the pdf data?
It would be cool if I could just turn on directory browsing on a web service and "update my webservice" by using PUT requests to drop in restful pdf files.

http://pugo.org/project/pshttpd/

it seems likely

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

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




that code is surprisingly short & clean

Aramoro
Jun 1, 2012





CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Krankenstyle posted:

do not tempt the gods

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Symbolic Butt posted:

I had a similar experience, the build system was too complicated back then and I had limited time so I decided to just go back to regular javascript

this is also me every time I've ever thought "oh man I'm totally going to use typescript on this next project" before just going back to jarvascript.

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
god I loving hate js

Arcsech
Aug 5, 2008

Symbolic Butt posted:

I had a similar experience, the build system was too complicated back then and I had limited time so I decided to just go back to regular javascript

that’s how I feel every time I try to do nodejs, and then I go back to Java

AWWNAW
Dec 30, 2008

more than once I’ve installed docker on a machine only so I could install node in a container. as to not sully my development environment

Sapozhnik
Jan 2, 2005

Nap Ghost
The build system is you run "yarn run tsc" idk what's difficult about this

If you are using it with a react web app then you run "yarn run parcel" instead

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
why does javascript, an interpreted language whose linkage model is "everything in one global scope as though it were a single file", have a build system

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
because it's a bad language for idiots

Carthag Tuek
Oct 15, 2005

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



ugh i cant wrap my head around how to structure my python module. i keep wanting to split classes out into their own files, but it makes imports super hosed up

im too used to java i think

is there a good primer/example project that i can look at?

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

DELETE CASCADE posted:

why does javascript, an interpreted language whose linkage model is "everything in one global scope as though it were a single file", have a build system

hey you can totally skip the build system if you don't want compile-time checks or dependency management

turns out those two things are kinda important for projects bigger than 'punch the monkey'

Chalks
Sep 30, 2009

DELETE CASCADE posted:

why does javascript, an interpreted language whose linkage model is "everything in one global scope as though it were a single file", have a build system

because someone decided that manually maintaining every single dependency by copying and pasting js files around was bad

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Soricidus posted:

urgh lua is aggressively terrible in every way possible. dear everybody in the world: i know it's easy to embed lua but please have some consideration for your users and pick literally anything else instead. scheme, javascript, python, gently caress even perl would be better, goddamn this language is bad

any time you have a choice of what to embed, scheme is the correct choice

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Chalks posted:

because someone decided that manually maintaining every single dependency by copying and pasting js files around was bad

isn't that more of a package managers job

im mostly just glad I don't have to do webdev beyond some very basic things

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED

Krankenstyle posted:

ugh i cant wrap my head around how to structure my python module. i keep wanting to split classes out into their own files, but it makes imports super hosed up

im too used to java i think

is there a good primer/example project that i can look at?

hosed up how, like you get ImportErrors because your two modules now depend on each other? you should fix that circular dependency anyway as it'll lead to fewer headaches later. if you just mean you have a lot of imports and it's slower or something, don't worry about it

but for the former, you basically have two options:

- make your modules smaller / have them do less. if A depends on B which depends on A, take out one of the dependencies (ideally both) and put them in a separate module C, which depends on both A and B

- make your modules bigger / have them do more. if the previous thing doesn't work, you can just combine the modules into one big one

obviously the right choice depends on your exact code, and i'm not exactly sure what you expect to learn from the design of a completely different project

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat

Chalks posted:

because someone decided that manually maintaining every single dependency by copying and pasting js files around was bad

that's basically what npm does, since it's copying a dependency to every project. and those dependencies can change between runs of "npm install" because the entire js ecosystem is a broke mess.

it's a poo poo system.

Chalks
Sep 30, 2009

Private Speech posted:

isn't that more of a package managers job

im mostly just glad I don't have to do webdev beyond some very basic things

package manager to grab your dependencies, build system to turn them into something that isn't 100,000 separate files i guess

honestly, the fact that javascript is completely unsuitable for even slightly complex projects is precisely why you need poo poo like build processes and typescript piled on top. they're all layers of engineering trying to hide the fact that you're using javascript

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

CRIP EATIN BREAD posted:

that's basically what npm does, since it's copying a dependency to every project. and those dependencies can change between runs of "npm install" because the entire js ecosystem is a broke mess.

it's a poo poo system.

nobody sane will claim that npm is good

nobody honest will claim that it's "basically" the same as "manually maintaining every single dependency by copying and pasting js files around"

VikingofRock
Aug 24, 2008




Krankenstyle posted:

ugh i cant wrap my head around how to structure my python module. i keep wanting to split classes out into their own files, but it makes imports super hosed up

im too used to java i think

is there a good primer/example project that i can look at?

IMO don't split classes into their own files, for exactly the reasons you are experiencing. Think of a module instead as a "unit of functionality", with related classes being in the same module. This "relation" can be pretty broad: for example in the python standard library most of the collections api is in a single module, with only collections.abc getting a submodule. Also, don't be afraid to have functions which aren't a part of a class.

For examples of code organization for sizeable python projects, I think both youtube-dl and the cpython standard library implementation are pretty reasonable. If anyone else has good examples though definitely post them.

Soricidus
Oct 21, 2010
freedom-hating statist shill
lua status: wait, gently caress, all the people saying lua doesn't have native 64-bit integers are talking about old versions.
in lua 5.3 numbers flip between 64-bit int and double as required, so all my problems are due to believing outdated information :negative:

Carthag Tuek
Oct 15, 2005

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



thx re python

gonna separate out a chunk of code on a branch and see if it makes stuff clearer

Arcsech
Aug 5, 2008

Soricidus posted:

lua status: wait, gently caress, all the people saying lua doesn't have native 64-bit integers are talking about old versions.
in lua 5.3 numbers flip between 64-bit int and double as required, so all my problems are due to believing outdated information :negative:

that's another hosed up thing about lua: the community is stuck on the lowest common denominator of lua 5.1 because luajit has a spat with lua or something and wont roll in changes from 5.2+, but everybody uses luajit because its a bazillion times faster

Falcorum
Oct 21, 2010
lua's great if you're doing simple things in it, it's not great as an alternative to something like python. not that python's good, lua's just not good in that situation either

also nim's great and I wish I had an excuse to write things in it, in terms of "languages that let me do dumb poo poo in fun ways" it even manages to rank higher than D, the language with 3 separate ways of doing metaprogramming.

Falcorum fucked around with this message at 22:14 on Feb 6, 2019

aardvaard
Mar 4, 2013

you belong in the bog of eternal stench

every time i google how to do something in lua the first result is the official wiki saying there's no built-in way to do it but here's five solutions from the community each of which have slightly different behavior

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Sapozhnik posted:

The build system is you run "yarn run tsc" idk what's difficult about this

If you are using it with a react web app then you run "yarn run parcel" instead

~/src/poo poo % yarn run tsc
yarn run v1.12.3
error Couldn't find a package.json file in "/Users/turdshunter/src/poo poo"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

Krankenstyle posted:

thx re python

gonna separate out a chunk of code on a branch and see if it makes stuff clearer

the second you want to do differentiated files / folders with anything python you should look to another language

I've been there and its not pretty and your imports will continue to look like satan took a poo poo all over them. Hell at one point even "import *" began looking good

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE

Sapozhnik posted:

The build system is you run "yarn run tsc" idk what's difficult about this

If you are using it with a react web app then you run "yarn run parcel" instead

naw dude, if you need to support IE 11 or older (and of course you need to) you need to first compile typescript to es6/es7/esnext/whateverthefuck so you can actually use things you probably want, and then transpile that output to es5 with babel. then you need to minify it of course. dehumanize yourself and face to webpack, and i hope you like long compile times

things are actually easier these days than they used to be, but gently caress, c++ has less complicated and more user-friendly build systems than javascript does

TheFluff fucked around with this message at 23:50 on Feb 6, 2019

Sapozhnik
Jan 2, 2005

Nap Ghost

Finster Dexter posted:

~/src/poo poo % yarn run tsc
yarn run v1.12.3
error Couldn't find a package.json file in "/Users/turdshunter/src/poo poo"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

PS C:\Users\james> mkdir WELLACTUALLY
PS C:\Users\james> cd .\WELLACTUALLY\
PS C:\Users\james\WELLACTUALLY> yarn add -D typescript
yarn add v1.13.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
+- typescript@3.3.1
info All dependencies
+- typescript@3.3.1
Done in 0.43s.
PS C:\Users\james\WELLACTUALLY> yarn run tsc --init
yarn run v1.13.0
warning package.json: No license field
$ C:\Users\james\WELLACTUALLY\node_modules\.bin\tsc --init
message TS6071: Successfully created a tsconfig.json file.
Done in 0.35s.
PS C:\Users\james\WELLACTUALLY> echo "const you: string = 'tedious bore'; console.log(you);" > pedantry.ts
PS C:\Users\james\WELLACTUALLY> yarn run tsc
yarn run v1.13.0
warning package.json: No license field
$ C:\Users\james\WELLACTUALLY\node_modules\.bin\tsc
Done in 1.65s.
PS C:\Users\james\WELLACTUALLY> type pedantry.js
"use strict";
var you = 'tedious bore';
console.log(you);

Sapozhnik
Jan 2, 2005

Nap Ghost
quite a roundabout way for me to go about signing my own posts but you get the idea

(i'm actually defending javascript. look what you made me do)

Sapozhnik
Jan 2, 2005

Nap Ghost

NihilCredo posted:

nobody sane will claim that npm is good

nobody honest will claim that it's "basically" the same as "manually maintaining every single dependency by copying and pasting js files around"

npm is indeed bad which is why you should use yarn instead. it'll actually make an effort not to randomly replace poo poo with different versions unless you explicitly ask it to do an upgrade (as in, it will maintain a list of urls of specific releases for all your deps as well as hashes for those releases in a file in source control). then again npm has been getting better about this as well lately, supposedly.

DELETE CASCADE posted:

why does javascript, an interpreted language whose linkage model is "everything in one global scope as though it were a single file", have a build system

there's modules now. even web browsers support them (though you shouldn't really be making use of this support). only thing that's dragging its feet is node itself for some reason. modules are actually scoped as well, so you're not just #include-ing poo poo

that being said you probably don't want your live web application to be deployed as 1000+ separate files that the web browser has to download, which brings us to

TheFluff posted:

naw dude, if you need to support IE 11 or older (and of course you need to) you need to first compile typescript to es6/es7/esnext/whateverthefuck so you can actually use things you probably want, and then transpile that output to es5 with babel. then you need to minify it of course. dehumanize yourself and face to webpack, and i hope you like long compile times

things are actually easier these days than they used to be, but gently caress, c++ has less complicated and more user-friendly build systems than javascript does

TS transpiles all the way down to ES3 by default. or it can strip out the type definitions and otherwise emit your code as verbatim ~*modern javascript*~, or anything in between, depending on how you set up your tsconfig.json. it does more or less the same thing as babel so you don't actually need to use babel.

for web applications parcel does all the typescript and babel and whatever other crap for you all fully preconfigured. if you need to support old IE then you'll have to add a "browserlist" list of strings to package.json explicitly stating what browsers you want to target, otherwise it will target the least common demoninator that currently has a 98% worldwide browser install base. this is even decently documented on parcel's website

https://parceljs.org/javascript.html#default-babel-transforms

but yeah parcel's usually as simple as invoking it against an entry point like src/index.html (which in turn will contain some <script> tags pointing to some js or ts files in your source tree or whatever) and it'll make a dist/ output directory with a single js file, single css file (including css module support), patched-up html file, it'll use babel to patch in things like your live API URL from your project's .env file, and so on.

Parcel's conventions and operations are mostly non-negotiable though, so if you have particularly strong opinions on how the build output should look then yeah you're going to have to actually deal with programming some garbage like Gulp and Webpack or whatever... or, you could not care, use the defaults, and get on with your life.

Can't speak to long compile times because I've only really used this for a medium-sized hobby project but Parcel is pretty good about incrementally recompiling stuff so it hasn't been an issue for me.

like I've accepted that I'm probably going to get savagely owned for posting all of this, but hopefully the information in these posts will get through to at least one person who has been ordered to do a javascript thing and they'll maybe make use of it to lessen the misery they inflict on themselves and any subsequent people that have to maintain the result (again, please use react. and please don't use redux with react).

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Sapozhnik posted:

PS C:\Users\james> mkdir WELLACTUALLY
PS C:\Users\james> cd .\WELLACTUALLY\
PS C:\Users\james\WELLACTUALLY> yarn add -D typescript
yarn add v1.13.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
+- typescript@3.3.1
info All dependencies
+- typescript@3.3.1
Done in 0.43s.
PS C:\Users\james\WELLACTUALLY> yarn run tsc --init
yarn run v1.13.0
warning package.json: No license field
$ C:\Users\james\WELLACTUALLY\node_modules\.bin\tsc --init
message TS6071: Successfully created a tsconfig.json file.
Done in 0.35s.
PS C:\Users\james\WELLACTUALLY> echo "const you: string = 'tedious bore'; console.log(you);" > pedantry.ts
PS C:\Users\james\WELLACTUALLY> yarn run tsc
yarn run v1.13.0
warning package.json: No license field
$ C:\Users\james\WELLACTUALLY\node_modules\.bin\tsc
Done in 1.65s.
PS C:\Users\james\WELLACTUALLY> type pedantry.js
"use strict";
var you = 'tedious bore';
console.log(you);

ng new

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE
you can target es3 with tsc all you want but it will not polyfill es6+ stuff. there are a few specific exceptions like generators/iterators (with --downlevelIterators) but in general if you want to target es5 you gotta write es5, but with types. the compiler can usually deal with syntactic sugar like the spread operator, and it will handle scoping issues caused by es5's lack of lexical scoping and arrow functions, but if you want to use things like Array.find() or String.repeat(), well, that's a type error. those are the easy ones since the compiler will actually catch them, but there's a number of subtle gotchas associated with this of course, so if you don't want your site to just say "undefined is not a function" in some browsers, you still need babel. js is still js.

in a mature application webpack builds take several minutes, and you can't do incremental builds for deploys or in ci because they're not reproducible. various webpack tools have their own caches because they're dog slow, but good luck figuring out why the cache keeps getting invalidated. then one fine day you wonder why node_modules is over a gigabyte, you go digging and find it's mostly Babel cache files, because of course it's enabled by default, puts poo poo in node_modules by default and never cleans up after itself. gently caress js tooling.

TheFluff fucked around with this message at 10:13 on Feb 7, 2019

Osmosisch
Sep 9, 2007

I shall make everyone look like me! Then when they trick each other, they will say "oh that Coyote, he is the smartest one, he can even trick the great Coyote."



Grimey Drawer

TheFluff posted:

in a mature application webpack builds take several minutes
Interesting, I wonder what causes this for you. For what it's worth, this has not been our experience (pushing 100k LoC) - more like 30s for total dev rebuild, ~50s for extremely-uglified production. And then a couple seconds for partial rebuilds which is the most relevant since that's where the dev friction mostly lives anyway.

Compared to java WAR building and the like, our js has actually been the least time-consuming aspect of pushing stuff to servers.

e: not to say that all's good in js land of course

Carthag Tuek
Oct 15, 2005

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



Boiled Water posted:

the second you want to do differentiated files / folders with anything python you should look to another language

I've been there and its not pretty and your imports will continue to look like satan took a poo poo all over them. Hell at one point even "import *" began looking good

figured out a way to abstract all the messy file/resource access stuff into a Workspace object so the other objs don't have to care about path configurations, json parsing, etc.

much neater! :cool:

Aramoro
Jun 1, 2012




Osmosisch posted:

Interesting, I wonder what causes this for you. For what it's worth, this has not been our experience (pushing 100k LoC) - more like 30s for total dev rebuild, ~50s for extremely-uglified production. And then a couple seconds for partial rebuilds which is the most relevant since that's where the dev friction mostly lives anyway.

Compared to java WAR building and the like, our js has actually been the least time-consuming aspect of pushing stuff to servers.

e: not to say that all's good in js land of course

Yeah out Webpacking doesn't take anything like that long. Our full build is about 20 mins from scratch. The Webpacking part is barely noticeable, especially compared to the SASS bits that take ages.

Xarn
Jun 26, 2015

Aramoro posted:

Yeah out Webpacking doesn't take anything like that long. Our full build is about 20 mins from scratch. The Webpacking part is barely noticeable, especially compared to the SASS bits that take ages.

:catstare:

I can build our C++ app from scratch about 10 times in 20 minutes.

Aramoro
Jun 1, 2012




Xarn posted:

:catstare:

I can build our C++ app from scratch about 10 times in 20 minutes.

We have a pretty big build. Ear with 5 WAR's, about 550mb total.

Adbot
ADBOT LOVES YOU

Zlodo
Nov 25, 2006

Aramoro posted:

Yeah out Webpacking doesn't take anything like that long. Our full build is about 20 mins from scratch. The Webpacking part is barely noticeable, especially compared to the SASS bits that take ages.

lmao

I work on one of those lardass open world AAA game and our compilation time is 20min

Zlodo fucked around with this message at 14:12 on Feb 7, 2019

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