PythonからGoへのフレームワークのGUIポート。熊手とパンの分析

Pythonでは、絶望から抜け出す必要がありました。ML、ニューラルネットワーク、スクリプトなど、より便利なのはその上でした。しかし、時が経ち、コードの速度に対する不安が、より速く、より信頼性の高いものへとあなたを駆り立てます。





私のユニバーサルUniguiはPythonからのみ機能し、理論的にのみユニバーサルであったため、GUIフレームワークを移植する作業は面倒でした。その中で非常に簡潔なAPIが開発されましたが、これはGoバージョンで保持されているはずです。さらに、必要なデータを生成するための大量の自動化は、移植の対象ではありませんでした。 Goには、コンパイル順序の制御、プリプロセッサ、メタプログラミングが欠けており、トリッキーなSpartanエクスペリエンスが保証されています。





私が最初に直面した問題は、構造体初期化子内でのみ、promouted(ネストされた)フィールドを直接割り当てることができないことでした。構造に名前のないネストされた構造がある場合、そのフィールドには、初期化子を除いて、どこからでも外部ルートからアクセスできます。とりわけ、階​​層を置き換える場合のようにネストされたフィールドを使用するというアイデア全体が、疑わしく、使用するのが面倒になっているためです。不要な型を使用してネストされた長い初期化子を作成するようにユーザーに要求することは、猥褻さの極みです。 Pythonには明確な階層がありますが、すべてのGUI構造は完全にフラットで独立しています。





, Go , . , - , , , , , “ API”. , , . , , .   . Type_ a Type(…) *Type_. , , Go .





Go Json . nil ( ), nil nil a / [ ] . , — . k, Google, , == nil, = make(0, []Any). , == nil, reflect != nil. reflect.ValueOf(ptr).IsNil() , , true! , ..





hash. . . . . .





, ? , , Any — interface{}. ! ,  100% — . “ , !” 





. , , ( ) , , . , , . , ( ). Google





 MyField int json:"myfield"



, JSON . — - . ? , , — , , . .. !





  Dart _ . , Go Dart- , . . .  , Google , “” . , , , , ?





, map/filter/.. , RemoveAtIndex, , 1.17 , , , .





? ! fmt.Sprintf. - — , , — “ ”.





  .





  • — . , . , , ML- Go… 





  • /. , , Python-a Go — . — , , , . Python - .





  • / — Go. github ( ), . , Visual C++ ~20 , Edit & Continue . , Edit & Continue Go VS Code , , . --. ..





  • . . Go. , . , , , — . 





  • . , Go , 20% . 70% reflect . . , . . 





  • . ( 8000 ) Python Go.





Go:





package main
import . "github.com/Claus1/unigui-go"		

func screenTest(user* User)* Screen_{	
	table := Table("Videos",0, nil, []string{"Video", "Duration",  "Links", "Mine"},
	SeqSeq(Seq("opt_sync1_3_0.mp4", "30 seconds",  "@Refer to signal1", true),
		Seq("opt_sync1_3_0.mp4", "37 seconds",  "@Refer to signal8", false)))
			
	cleanButton := Button("Clean table", nil, "")
	selector := Select("Select", "All", nil, []string{"All","Based","Group"})
	block := Block("X Block", Seq(cleanButton, selector), table)
	block.Icon = "api"
	return Screen(block)	
}
func main(){			
	//register screens
	Register(screenTest, "Main", 0, "insights")	
	Start()
}
      
      



Python:





from unigui import *
name = "Main" #name of screen to show
icon = 'blur_linear' #MD icon of screen to show
order = 0 #order in the program menu
table = Table('Videos', 0, headers = ['Video', 'Duration',  'Links', 'Mine'],rows = [
    ['opt_sync1_3_0.mp4', '30 seconds',  '@Refer to signal1', True],
    ['opt_sync1_3_0.mp4', '37 seconds',  '@Refer to signal8', False]    
])
block = Block('X Block',
    [           
        Button('Clean table'),
        Select('Select', value='All', options=['All','Based','Group'])
    ], table, icon = 'api')
blocks = [block] #what to show on the screen
start('Test app')

      
      



Goを引き続き使用しますか?潜水艦を降りる場所..そして、Crystal、Nim、およびその他のシンプルで高度な言語を本番環境に導入して、Goに振り子を与えることを本当に望んでいます。これまでのところ、残念ながら、生産的なソフトウェアを開発するための光生産のニッチでは、それに代わるものは見当たりません。平和!





好奇心旺盛な人へのリンク:





行く 





Python 








All Articles