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
Bloody
Mar 3, 2013

Bloody posted:

whats the least bad way to write-once run-everywhere apps? react native? this is for like an idiot spare time prototype-tier crud project

bumping this

Adbot
ADBOT LOVES YOU

jesus WEP
Oct 17, 2004


Bloody posted:

bumping this
I’ve heard okay things about avalonia for .net core

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
kotlin multiplatform is good

Share Bear
Apr 27, 2004

i use python and java a lot and this kind of criss cross "everything working and being mostly autogenerated" kind of idea abraham is proposing is wild

i've never not had stuff be somewhat custom, with custom event handlers

i constantly feel like there's a "this is an actual good design! seriously! learn it!" resource or something but it's never shown up in any software i have ever worked on

tak
Jan 31, 2003

lol demowned
Grimey Drawer

RPATDO_LAMD posted:

great idea
where do i find the typed map for my custom Fart object in the go standard library

well you don't obviously

you use a map of your type (key or val or both)

code:

type MyAbstractButtFactoryAdaptor interface {
  Fart()
}

type Fart struct{}

func (f *Fart) Fart() {
  // TODO implement
}

// ...

farts := map[string]*Fart{}

var (
  myFart MyAbstractButtFactoryAdaptor
  ok bool
)
myFart, ok = farts["your posts"]
if !ok {
  panic("FIXME this should never happen")
}

myFart.Fart()

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
and this is better/easier than java... why/how exactly???

Nomnom Cookie
Aug 30, 2009



afaict the idea is that making BlockingQueue a language feature instead of part of the standard library solves all concurrency problems

Nomnom Cookie
Aug 30, 2009



we actually have CSP in jvm land, it's called akka and it's poo poo. no one uses it except for scala weenies, and nobody cares what they think because if they had good opinions they wouldn't be using scala

tak
Jan 31, 2003

lol demowned
Grimey Drawer

DELETE CASCADE posted:

and this is better/easier than java... why/how exactly???

I haven't done much java recently, what would that look like? a map/dict of your own type

Nomnom Cookie
Aug 30, 2009



i did not include kotlin in the list of languages worth using intentionally. kotlin exists to beta test java features, be briefly popular because it has features that java doesn't, and then fade away once java gets a better version of those features. this is the inevitable fate of all non-java languages on the jvm

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

tak posted:

I haven't done much java recently, what would that look like? a map/dict of your own type

i know 0 go but what does
code:
Map<String, Fart> farts = new HashMap<>();
miss that that example has?

tak
Jan 31, 2003

lol demowned
Grimey Drawer
The equivalent in the example is this line:


code:

farts := map[string]*Fart{}

I was just being a smartass

but this would fail to compile if the type didn't match that interface


code:

myFart, ok = farts["your posts"]

tak fucked around with this message at 00:25 on May 9, 2020

abraham linksys
Sep 6, 2010

:darksouls:

jesus WEP posted:

I’ve heard okay things about avalonia for .net core

CRIP EATIN BREAD posted:

kotlin multiplatform is good

honestly, for as much of a loving joke as dart has been for the last decade, flutter seems to be getting some legitimate adoption outside of google. i think right now if i wanted to make a native ios/android app that would be my first stop

react native still seems okay if you can somehow figure out how to share components and logic with a react web app. in practice i have literally never met anyone who has successfully done this for anything but, like, a small module with some helper methods, or a couple components that use react-native-web that all the frontend developers hate. i'm not sure it's worth buying into the react ecosystem otherwise, unless you already know react or want to get some of your frontend team to work on it. at my company which is primarily a native app, we have a react native app because it was the only real shared-code game in town when we decided to combine code, and the apps are still like 50/50 native/react, and we have a split between specialized native devs and frontend devs who have started doing native development

i've built a server-side rendered vue web app, so i've occasionally thought of looking into nativescript w/ vue to build a native app to go with it, but i don't think it has much adoption at all and i'm skeptical i could actually share enough components to matter. it probably would end up being either a wrapped web app with enough of a native facade that apple wouldn't reject it (no idea what their standards are on this atm other than that they get mad if you serve "most" of your app over the web instead of shipping code in the app bundle), or a flutter app. hell maybe now is the time once i get through this stupid go websocket thing, not like i'm doin much else

carry on then posted:

i know 0 go but what does
code:
Map<String, Fart> farts = new HashMap<>();
miss that that example has?

nothing, which is the point, those are equivalent things

however, map is a language construct, and not one defined in userspace like a java HashMap is. you cannot write your own type-safe HashMap implementation in go, because while maps are "generic" in that they can hold a given type as keys or values, you cannot make your data structures that are. which is why go does not have a type-safe equivalent to, say, ConcurrentHashMap - they implemented the stdlib `sync.Map` data structure as a go data structure instead of doing whatever they did to create the language `map` construct, and thus, it is fully untyped.

abraham linksys fucked around with this message at 00:27 on May 9, 2020

Nomnom Cookie
Aug 30, 2009



i'd rather punch myself in the balls pretty hard than try to do websockets in go

Corla Plankun
May 8, 2007

improve the lives of everyone

Bloody posted:

bumping this

i dont think my answer is good but it is at least true: i made a unity app in a day that ran on my linux computer and my phone (and probably windows and mac and ios but i didnt try) and it was very easy. i honestly have no idea how i would otherwise put crap on my phone and unity made it pretty easy

abraham linksys
Sep 6, 2010

:darksouls:

Nomnom Cookie posted:

i'd rather punch myself in the balls pretty hard than try to do websockets in go

really the things that are most important to me about this websockets project (concurrency, building a little json protocol, small http api running alongside so i don't have to do rpc-over-websockets which is the fuckin worst) aren't that bad in go

like... if i did this in kotlin (or java), i'm not sure what i'd do differently. probably would use javalin's small websocket wrapper which gives you regular ol `onConnection/onMessage/onClose` callbacks instead of go's weird goroutine/for-select/channel poo poo, but i'd still have the same problem of stuff being multithreaded by default and that would require some concurrency work

if i did this in python with asyncio, it would be single-threaded making any in-memory state trivial to work with by comparison. so there is that, maybe i should just revisit python for the first time in a minute. honestly i'd probably just use node if i was going a dynamic-typed route though just b/c it's what i'm most familiar with.

tak
Jan 31, 2003

lol demowned
Grimey Drawer

abraham linksys posted:

you cannot write your own type-safe HashMap implementation in go, because while maps are "generic" in that they can hold a given type as keys or values, you cannot make your data structures that are. which is why go does not have a type-safe equivalent to, say, ConcurrentHashMap - they implemented the stdlib `sync.Map` data structure as a go data structure instead of doing whatever they did to create the language `map` construct, and thus, it is fully untyped.
I know what you mean but to be pedantic you can define an interface that wraps a sync.Map and expose a type-safe interface on top of it, if type assertions from interface{} are too scary and you really need a sync.Map instead of a plain map

you probably don't need a sync.Map though

https://golang.org/pkg/sync/#Map posted:

The sync.Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The sync.Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a sync.Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

Shaggar
Apr 26, 2006

Nomnom Cookie posted:

the only languages worth using in 2020 are java, rust, and python

the only language you should be writing new stuff in is c#, but i wouldn't rush to rewrite existing java projects like i would with deprecated languages like ruby and vb or hobbyist languages like python and go.

mystes
May 31, 2006

bob dobbs is dead posted:

watch shaggar shaggar in and add some .net langs

Bloody
Mar 3, 2013

Oh ya I don't care about like nativeness like web view stuff would work

Space Whale
Nov 6, 2014
I just found out python lets you directly gently caress with the stack and frame:

pee lang is stored in the computer's balls



To be a little more serious, does anyone have a link to that talk at dropbox about how pyston optimized out poo poo like monkey patching and how guido got a bit upset about it? Having trouble searching for it.

Space Whale
Nov 6, 2014
I feel bored with C# after 7.5 years of doing it, but more than anything I'm sick of the kind of management that seems to favor MS stuff. I could be totally wrong, but it feels like things are more agile where it's totally open source.

Does this mean go for .NET Core shops or should I try to get into the open sores world? I figured I could gently caress with python again, hence "lol you can directly access the stack and frame lmao"

Also wondering about other languages. I'm pretty open, just want something that will lead to, yanno good environments.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Have you considered landscaping?

Space Whale
Nov 6, 2014

taqueso posted:

Have you considered landscaping?

Yeah but I like paying bills and raking sand is more for me than an income

abraham linksys
Sep 6, 2010

:darksouls:

Space Whale posted:

Also wondering about other languages. I'm pretty open, just want something that will lead to, yanno good environments.

honestly a somewhat lateral move into java would probably give you a lot of backend dev opportunities at a lot of, like, mature startups/web/app companies if that's the sort of environment you're looking for? i think it's pretty common at "hip" places these days as they mature and give up their python monoliths and such. lotta folks writing rewriting their big ol' p-lang mess into services in java (not necessarily even microservices, mind you, just "hey maybe checkout should live in a nice java service that has types and api documentation instead of being split arbitrarily across twenty files across our giant rails codebase"). that's where my company is at and where my friends' companies seem to be headed, and because a lot of folks are coming from the experiences of moving "rapidly" with rails/django/flask/laravel/node/whatever, they gravitate towards "fresher" stacks when it comes to java instead of just falling back on spring and hibernate or whatever (thus why we use kotlin, for example)

go might be an option but i really have no sense of what go looks like in production and who's using it and where. it keeps coming up in like bullshit "languages developers want to learn!!" surveys but i have no idea where it tracks in terms of what companies are hiring for

abraham linksys fucked around with this message at 04:27 on May 9, 2020

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

tak posted:

The equivalent in the example is this
code:
myFart, ok = farts["your posts"]

wait does this mean you have to check that ok variable every single god damned time you take a value out of the map or be subject to surprising downstream errors if the key didn’t have a value

Space Whale
Nov 6, 2014

abraham linksys posted:

honestly a somewhat lateral move into java would probably give you a lot of backend dev opportunities at a lot of, like, mature startups/web/app companies if that's the sort of environment you're looking for? i think it's pretty common at "hip" places these days as they mature and give up their python monoliths and such. lotta folks writing rewriting their big ol' p-lang mess into services in java (not necessarily even microservices, mind you, just "hey maybe checkout should live in a nice java service that has types and api documentation instead of being split arbitrarily across twenty files across our giant rails codebase"). that's where my company is at and where my friends' companies seem to be headed, and because a lot of folks are coming from the experiences of moving "rapidly" with rails/django/flask/laravel/node/whatever, they gravitate towards "fresher" stacks when it comes to java instead of just falling back on spring and hibernate or whatever (thus why we use kotlin, for example)

go might be an option but i really have no sense of what go looks like in production and who's using it and where. it keeps coming up in like bullshit "languages developers want to learn!!" surveys but i have no idea where it tracks in terms of what companies are hiring for

Seems like all the fad chasers want to go with Go for some reason over Java, C#, or whatnot. I don't get why because lolgenerics but I've been keeping a tab on Go.
Rust seems promising but portability and, well, like you say, wanna do vs can get paid to do. Also, Elixir.

Honestly the big thing I want is just maturity from management. No egos, no rockstars, no whip crackers, nobody who argues with technical people from total ignorance, yanno, minimize the Dilbert factor? I'm mostly salty because I interviewed at a place where the team had all the right answers but I neglected to ask about upper management - I now am in a hell where the CEO nitpicks everything. tl;dr he outsourced twice, blames both offshore teams, is now mis-micro-managing the onshore team, admits he doesn't know what he's doing, but blames everyone but himself.

:q:

Trying to manage up with my current teamlead and boss but fiik if that will go anywhere. They keep saying 'sprint' but they're not even doing grooming.

abraham linksys
Sep 6, 2010

:darksouls:

Phobeste posted:

wait does this mean you have to check that ok variable every single god damned time you take a value out of the map or be subject to surprising downstream errors if the key didn’t have a value

oh boy i get to tell you about what actually might be even worse than a lack of generics: go uses zero values instead of having a concept of a nil value.

so let's say you got this:

code:
package main

type Butt struct {
	didFart bool
}

func main() {
	butts := make(map[string]Butt)
	
	butts["foo"] = Butt{true}
	foo := butts["foo"]
	println(foo.didFart)  // true, of course
	
	bar := butts["bar"]
	println(bar.didFart)  // some kind of error, right?
}
if you run this, the output you will get is not some kind of panic, as you might expect. it's not even nil, as might kind of make sense.

no, what you will see is:

quote:

true
false

this is because you get an empty Butt if it's not present in the map, which is the zero value of a struct. an empty struct will have a zero value for didFart, which is false, because it's a bool. this also applies for strings (""), ints (0), and floats (0.0).

now, you can represent the concept of nil in Go, but you have to use a pointer:

code:
func main() {
	butts := make(map[string]*Butt)
	butts["foo"] = &Butt{true}
	foo := butts["foo"]
	println(foo == nil)  // false
	println(foo.didFart) // true
	
	bar := butts["bar"]
	println(bar == nil)  // true
	println(bar.didFart) // segmentation fault!
}
this works more like how you'd expect. however, it also means that if you want to have a concept of a nullable primitive, you have to use a pointer - so if you wanted a nullable `didFart`, you need to store `didFart` as `*bool` on the struct.

now, you could make the argument of "well, who needs a nullable boolean anyways?" but you know what structs get encoded and decoded to? database fields. json fields. things that are nullable. which is why the sql package has to ship nullable types as separate structures. which, by default, you have to manually convert yourself for json encoding/decoding. which is why there is a whole package you can install for nullable values that you can use in json decoding and encoding. also go did not have a native sql.NullTime until 1.13, which is like a year ago.

and to actually answer your original question, they do at least tell you in a map whether or not it found a value, so you don't have to try to guess whether you purposefully stored a zero value or if a key is missing. that's why you check the second argument:

code:
func main() {
	butts := make(map[string]Butt)
	
	butts["foo"] = Butt{true}
	_, exists := butts["foo"]
	println(exists) // true
	
	_, err = butts["bar"]
	println(exists) // false
}
and if you're wondering "wait, but why didn't accessing a nonexistent value on a map just raise some sort of exception in the first place," i will just link you to this and sigh

abraham linksys fucked around with this message at 05:40 on May 9, 2020

abraham linksys
Sep 6, 2010

:darksouls:
it kind of rules how golang's zero values and error returns are like you tried to explain the concepts of null safety and option types to someone and they just completely loving missed the point as hard as they possibly could

Nomnom Cookie
Aug 30, 2009



tak posted:

I know what you mean but to be pedantic you can define an interface that wraps a sync.Map and expose a type-safe interface on top of it, if type assertions from interface{} are too scary and you really need a sync.Map instead of a plain map

you probably don't need a sync.Map though

or use a big boy language that provides a typed concurrent map instead of telling yourself it doesn’t hurt that bad

abraham linksys posted:

really the things that are most important to me about this websockets project (concurrency, building a little json protocol, small http api running alongside so i don't have to do rpc-over-websockets which is the fuckin worst) aren't that bad in go

like... if i did this in kotlin (or java), i'm not sure what i'd do differently. probably would use javalin's small websocket wrapper which gives you regular ol `onConnection/onMessage/onClose` callbacks instead of go's weird goroutine/for-select/channel poo poo, but i'd still have the same problem of stuff being multithreaded by default and that would require some concurrency work

if i did this in python with asyncio, it would be single-threaded making any in-memory state trivial to work with by comparison. so there is that, maybe i should just revisit python for the first time in a minute. honestly i'd probably just use node if i was going a dynamic-typed route though just b/c it's what i'm most familiar with.

do thread per connection in java and stop dealing with weird bullshit invented in the 60s and pushed on the world by a bunch of devs who can’t accept that error codes are obsolete

redleader
Aug 18, 2005

Engage according to operational parameters

Nomnom Cookie posted:

the only languages worth using in 2020 are java, rust, and python

c#, c++/cli, ironpython

Soricidus
Oct 21, 2010
freedom-hating statist shill

redleader posted:

c#, c++/cli, ironpython

please don’t suggest people write new python2 code in 2020

redleader
Aug 18, 2005

Engage according to operational parameters

Space Whale posted:

Also, Elixir.

elixir is a great option if you want to get in on the ruby 2.0 hype train early

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

Soricidus posted:

please don’t suggest people write new python2 code in 2020

my government place of work uses java 8 for greenfield projects. It's gonna be fun when we reach its end of life in ... january of last year

FlapYoJacks
Feb 12, 2009

Boiled Water posted:

my government place of work uses java 8 for greenfield projects. It's gonna be fun when we reach its end of life in ... january of last year

Java 8 to 11 is a very easy tranition.

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

ratbert90 posted:

Java 8 to 11 is a very easy tranition.

oh yeah, the technical transition is easy. Its the inertia of SAFe I have to fight. The business side of things absolutely runs things and the RTE side that's supposed to push back are all recruited from the business process pool. Its maddening

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

what i'm trying to get at is my place of work is almost literally the Phoenix Project as told by Gene Kim, Kevin Behr and George Spafford

Gaukler
Oct 9, 2012



:suicide:

tak
Jan 31, 2003

lol demowned
Grimey Drawer

Phobeste posted:

wait does this mean you have to check that ok variable every single god damned time you take a value out of the map or be subject to surprising downstream errors if the key didn’t have a value

no, you only need to do that if you need to differentiate a key being in the map with a nil/zero-value vs. the key not being in the map. if you don't need to know that, just use the single value return form without the ok

the concept of zero values is really cool and useful, and melds v. well with protobuf (which owns btw)

Adbot
ADBOT LOVES YOU

tak
Jan 31, 2003

lol demowned
Grimey Drawer

abraham linksys posted:


now, you can represent the concept of nil in Go, but you have to use a pointer:

lol

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