IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Autres langages Discussion :

Sortie de Nim 0.12


Sujet :

Autres langages

  1. #1
    Responsable Qt & Livres


    Avatar de dourouc05
    Homme Profil pro
    Ingénieur de recherche
    Inscrit en
    Août 2008
    Messages
    26 617
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur de recherche
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2008
    Messages : 26 617
    Points : 188 587
    Points
    188 587
    Par défaut Sortie de Nim 0.12
    Nim (connu, jusqu’il y a peu, sous le nom de Nimrod) est un langage de programmation « moderne » (comme c’est à la mode) aussi performant que le C (souvent indiqué comme une référence à ce niveau) : de manière générale, il souhaite donner un maximum de puissance à l’utilisateur sans sacrifier la performance (comme Rust ou Julia). En ce qui concerne ses caractéristiques, son système de typage est statique et son style impératif, bien que le langage soit multiparadigme : il mélange métaprogrammation, fonctionnel, passage de messages, procédural et orienté objet, avec un ramasse-miettes. Il ne dispose pas d’un compilateur, mais d’un transcompilateur qui produit du code C, C++ ou Objective-C en sortie… ou encore en JavaScript, ce qui facilite l’intégration avec l’environnement extérieur (il est aussi très facile d’appeler des fonctions externes C).

    De manière générale, la syntaxe rappelle Python (pour la délimitation des blocs) et Scala (pour les types et certaines syntaxes raccourcies), avec des types, mais aussi le renvoi implicite d’une variable (ce qui contribue à raccourcir le code… avec un peu d’habitude) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    proc reverse(s: string): string =
      result = "" 
      for i in countdown(high(s), 0):
        result.add s[i]
    
    var str1 = "Reverse This!"
    echo "Reversed: ", reverse(str1)
    La métaprogrammation est poussée plus loin qu’en C++ : elle permet de générer n’importe quel type de code à la compilation, en travaillant directement au niveau de l’AST du compilateur. Par exemple, la fonction suivante génère des fonctions dont le nom dépend des arguments. (Bien évidemment, ce système peut être utilisé dans des cas plus complexes.)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    import macros
    
    template abcProc(n: expr): stmt  =  
      proc n() = echo astToStr(n) 
    
    abcProc(A)
    abcProc(B)
    abcProc(C)
    L’un des concepts principaux derrière le langage concerne les aspects parallèles : chaque fil d’exécution peut communiquer avec les autres à l’aide de messages asynchrones, des canaux. Le ramasse-miettes peut donc fonctionner indépendamment pour chaque fil d’exécution : même en mettant l'un d'entre eux en pause, l’application peut toujours fonctionner ; ce système est donc adapté aux applications qui ne sont pas strictement temps réel, comme les jeux (mais contrairement à une bonne partie de l’électronique). Cependant, ces mécanismes sont encore expérimentaux.

    Cette nouvelle version apporte pas mal de changements qui cassent la rétrocompatibilité, comme l’envoi d’exceptions lors de l’accession à une clé non existante dans une table de hachage (au lieu d’un null). La grande nouveauté est cependant NimScript, un sous-ensemble très léger du langage qui peut être exécuté dans la machine virtuelle incluse, déjà notamment utilisée pour l’évaluation de fonctions lors de la compilation ; maintenant, ce système peut également être utilisé de manière plus générale, notamment pour remplacer le système de configuration existant. Par contre, l’accès au code C n’est pas encore possible, ce qui limite fortement les possibilités, mais est largement suffisant pour une description d’un paquet ou pour des scripts d’installation et de compilation.

    Sources : Nim version 0.12.0 released, Nim (programming language), Nimrod: A New Systems Programming Language, A cursory look at meta-programming in Nim.

    Et vous ?

    Connaissez-vous ce langage de programmation ? Qu'en pensez-vous ?

    Voir aussi

    Forum Langage de programmation
    Vous souhaitez participer aux rubriques Qt (tutoriels, FAQ, traductions) ou HPC ? Contactez-moi par MP.

    Créer des applications graphiques en Python avec PyQt5
    Créer des applications avec Qt 5.

    Pas de question d'ordre technique par MP !

  2. #2
    dsy
    dsy est déconnecté
    Membre habitué
    Profil pro
    Inscrit en
    Septembre 2002
    Messages
    105
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2002
    Messages : 105
    Points : 142
    Points
    142
    Par défaut
    Nim est un langage trés intéressant. Je pense qu'il pourrait remplacer Python pour des programmes hautes-performances notamment.

    Il est aussi rapide que C et C++ sur des algos équivalents :
    https://github.com/logicchains/LPATH...ter/writeup.md (rechercher "Haswell" dans la page)

    Il lui manque une bibliothèque aussi importante que Python :
    http://nim-lang.org/docs/lib.html

  3. #3
    Membre extrêmement actif
    Homme Profil pro
    Graphic Programmer
    Inscrit en
    Mars 2006
    Messages
    1 545
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Graphic Programmer
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 545
    Points : 3 941
    Points
    3 941
    Par défaut
    Nim ce veut aussi puissant que le C ? qu'entend t'on par puissant ? surtout quand je lis les mots : Ramasse-miettes et machine virtuelle.

  4. #4
    Chroniqueur Actualités
    Avatar de Patrick Ruiz
    Homme Profil pro
    Redacteur web
    Inscrit en
    Février 2017
    Messages
    1 837
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Redacteur web
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Février 2017
    Messages : 1 837
    Points : 51 403
    Points
    51 403
    Par défaut La version 1 de Nim, le langage doté d'un transpileur vers C, C++, JavaScript est disponible avec des ajouts
    La première version finale de Nim, le langage doté d'un transcompilateur vers C, C++, JavaScript est disponible
    Avec des ajouts

    En chemin vers sa première version finale, le langage de programmation Nim est passé par une 0.12 sortie il y a 4 ans puis par d’autres versions dont deux release candidates pour la version 1 (0.20.1 ou 1.0 RC1 et 0.20.2 ou 1.0 RC2) . Comme le signale l’équipe de développement : l’attente est terminée.

    Nom : nim language.png
Affichages : 193763
Taille : 97,4 Ko

    « La version 1.0 marque le début d'une base stable qui peut être utilisée dans les années à venir sachant que les futures versions de Nim seront rétrocompatibles avec le code que vous avez écrit avec la version actuelle », indique l’équipe de développement.

    Nim a fait surface en 2008 et le projet est porté par le programmeur allemand Andreas Rumpf. Nim est un langage de programmation à typage statique qui emprunte certains concepts d’autres comme Modula-3, Delphi, Ada, C++, Python ou encore Lisp. Illustration avec le code source d'une fonction de gestion des tournois au sein du jeu ReelValley par Onsetgame.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    import tables
    import times
    import sequtils
    import algorithm
    
    import nimx.view
    import nimx.button
    import nimx.matrixes
    import nimx.text_field
    import nimx.panel_view
    import core / notification_center
    
    import rod.rod_types
    import rod.viewport
    import rod.node
    import rod.component
    
    import json
    
    import rod.component.ui_component
    import nimx.table_view
    import nimx.scroll_view
    import strutils
    
    import utils.pause
    import utils.timesync
    
    import nimx.formatted_text
    
    import core.net.server
    import shared.director
    import shared.user
    
    import falconserver.map.building.builditem
    import core.slot.base_slot_machine_view
    import slots.slot_machine_registry
    import quest.quest_helpers
    
    import tournament
    
    import shared.window.rewards_window
    import shared.window.window_component
    import tournaments.tournament_result_window
    import shared.window.button_component
    import rod.component.text_component
    import shared.window.window_manager
    import utils.node_scroll
    import shared.gui.gui_module
    import shared.tutorial
    
    import shared.localization_manager
    
    import utils.falcon_analytics
    
    import rod.component.solid
    import utils.icon_component
    import core / helpers / [ boost_multiplier, reward_helper ]
    import core / features / booster_feature
    import core / zone
    
    
    type RoundedLabel = ref object
        node: Node
        activeLabel: Text
        inactiveLabel: Text
    
    proc newRoundedLabel(node: Node): RoundedLabel =
        result.new
        result.node = node
        result.activeLabel = node.mandatoryNode("active").getComponent(Text)
        result.inactiveLabel = node.mandatoryNode("inactive").getComponent(Text)
    
    proc setText(lbl: RoundedLabel, text: string, active: bool) =
        lbl.activeLabel.text = text
        lbl.inactiveLabel.text = text
        lbl.activeLabel.node.enabled = active
        lbl.inactiveLabel.node.enabled = not active
    
    
    type IconButton = ref object
        node: Node
        button: ButtonComponent
        label: Text
        chips_Icon: Node
        lock_Icon: Node
    
    proc newIconButton(node: Node, rect: Rect): IconButton =
        result.new
        result.node = node
        result.button = node.createButtonComponent(rect)
        result.label = node.mandatoryNode("title").getComponent(Text)
        let icons = node.findNode("icon_join")
        if not icons.isNil:
            result.chips_Icon = icons.mandatoryNode("ltp_chips_2.png")
            result.chips_Icon.enabled = false
            result.lock_Icon = icons.mandatoryNode("ltp_closed.png")
            result.lock_Icon.enabled = false
    
    
    
    type TournamentWindowItem* = ref object of RootObj
        node: Node
        tournament: Tournament
        title: Text
        timeToEnd: Text
        timeEnded: Text
        players: Text
        bet: Text
        prizeFund: Text
        participationHighlight: Node
    
        comingSoon_Button: IconButton
        comingSoon_Label: Text
    
        join_Button: IconButton
        join_Label: Text
    
        locked_Button: IconButton
        locked_Label: Text
    
        continue_Button: IconButton
        score_Label: Text
        scoreValue_Label: Text
    
        reward_Button: IconButton
        reward_Image: Node
    
        # locationIcons: ref Table[string, Node]
    
        finished_Icon: Node
        progressFiller: Node
        progressFillerFullScale: float
        noProgressFiller: Node
        chips_Icon: Node
        bucks_Icon: Node
        chips_Label: RoundedLabel
        players_Label: RoundedLabel
        time_Label: RoundedLabel
    
        icoComp: IconComponent
    
    
    proc update(i: TournamentWindowItem, t: Tournament)
    
    
    proc gainReward*(t: Tournament) =
        let tResultWindow = sharedWindowManager().show(TournamentResultWindow)
        tResultWindow.setUpTournament(t)
        sharedServer().claimTournamentReward(t.participationId, proc(res: JsonNode) =
            echo res
            if res["status"].getStr() == "Ok":
                t.participationId = ""
                t.rewardIsClaimed = true
                let chips = res["response"]["chips"].getBiggestInt()
                let bucks = res["response"]{"bucks"}.getBiggestInt()
                let tournPoints = res["response"]["tourPoints"].getBiggestInt()
                let ufoFreeRounds = res["response"]{"freeRounds"}.getBiggestInt()
    
                tResultWindow.onClose = proc() =
                    var rew = newSeq[Reward]()
                    if chips > 0:
                        rew.add(createReward(RewardKind.chips, chips))
                    if bucks > 0:
                        rew.add(createReward(RewardKind.bucks, bucks))
                    if tournPoints > 0:
                        rew.add(createReward(RewardKind.tourPoints, tournPoints))
                    if ufoFreeRounds > 0:
                        let r = createReward(RewardKind.freeRounds, ufoFreeRounds, $ufoSlot)
                        rew.add(r)
    
                    let rewWindow = sharedWindowManager().show(RewardWindow)
                    rewWindow.boxKind = RewardWindowBoxKind.red
                    rewWindow.rewards = rew
                    rewWindow.onClose = proc() =
                        currentNotificationCenter().postNotification("SHOW_TOURNAMENTS_WINDOW")
        )
    
    
    proc init(i: TournamentWindowItem, w: WindowComponent) =
        i.title = i.node.mandatoryNode("title_tournament").getComponent(Text)
        i.timeToEnd = i.node.mandatoryNode("time").getComponent(Text)
        i.timeEnded = i.node.mandatoryNode("tr_time_ended").getComponent(Text)
        i.players = i.node.mandatoryNode("players").getComponent(Text)
        i.bet = i.node.mandatoryNode("bet").getComponent(Text)
        i.prizeFund = i.node.mandatoryNode("prizepool").getComponent(Text)
        i.participationHighlight = i.node.mandatoryNode("ltp_light_in_menu.png")
        i.progressFiller = i.node.mandatoryNode("ltp_small_progress_bar_part.png")
        i.progressFillerFullScale = i.progressFiller.scaleX
        i.noProgressFiller = i.node.mandatoryNode("ltp_small_progress_bar_noprogress.png")
        i.finished_Icon = i.node.mandatoryNode("Finished.png")
    
        i.chips_Icon = i.node.mandatoryNode("1_chips_icon.png")
        i.bucks_Icon = i.node.mandatoryNode("1_bucks_icon.png")
        i.chips_Label = newRoundedLabel(i.node.mandatoryNode("chips_label"))
        i.chips_Label.setText(localizedString("TR_PRIZE_POOL_TITLE"), false)
    
        i.players_Label = newRoundedLabel(i.node.mandatoryNode("players_label"))
        i.players_Label.setText(localizedString("TR_PLAYERS_TITLE"), false)
    
        i.time_Label = newRoundedLabel(i.node.mandatoryNode("time_label"))
        i.time_Label.setText(localizedString("TR_TIME_TO_END"), false)
    
        # tournament not started yet
        i.comingSoon_Button = newIconButton(i.node.mandatoryNode("grey_button"), newRect(0, 0, 300, 84))
        i.comingSoon_Button.lock_Icon.enabled = true
        i.comingSoon_Label = i.node.mandatoryNode("TR_COMING_SOON").getComponent(Text)
    
        # may enter and has enough chips
        i.join_Button = newIconButton(i.node.mandatoryNode("orange_button_bicolor"), newRect(0, 0, 300, 84))
        i.join_Label = i.node.mandatoryNode("TR_JOIN!").getComponent(Text)
    
        # may enter, but has not enough chips
        i.locked_Button = newIconButton(i.node.mandatoryNode("grey_button_bicolor"), newRect(0, 0, 300, 84))
        i.locked_Button.label.text = localizedString("TR_LOCKED")
        i.locked_Button.lock_Icon.enabled = true
        i.locked_Label = i.node.mandatoryNode("locked_chips_title").getComponent(Text)
    
        # to continue already joined tournament
        i.continue_Button = newIconButton(i.node.mandatoryNode("Button_blue"), newRect(0, 0, 300, 84))
        i.continue_Button.label.text = localizedString("TR_CONTINUE")
        i.score_Label = i.node.mandatoryNode("TR_YOUR_SCORE").getComponent(Text)
        i.scoreValue_Label = i.node.mandatoryNode("score_value").getComponent(Text)
    
        i.reward_Button = newIconButton(i.node.mandatoryNode("Yellow_middle_button_tournaments"), newRect(0, 0, 300, 84))
        i.reward_Button.label.text = localizedString("TR_GET_REWARD")
        i.reward_Image = i.node.mandatoryNode("reward_tournament")
    
        i.node.mandatoryNode("Friends").enabled = false
    
        # i.locationIcons = newTable[string, Node]()
        # i.locationIcons["dreamTowerSlot"] = i.node.mandatoryNode("ltp_dream_tower_slot_1.png")
        # i.locationIcons["balloonSlot"] = i.node.mandatoryNode("ltp_windy_day_slot_copy_2.png")
        # i.locationIcons["candySlot"] = i.node.mandatoryNode("ltp_candy_shop_slot_copy.png")
    
        let scoreStars_Icon = i.node.mandatoryNode("Score.png")
        scoreStars_Icon.enabled = false
    
        let icoPlaceholder = i.node.findNode("placeholder")
        let icoSolid = icoPlaceholder.getComponent(Solid)
        icoSolid.color = newColor(0,0,0,0)
        i.icoComp = icoPlaceholder.component(IconComponent)
        i.icoComp.prefix = "common/lib/icons/precomps"
        i.icoComp.composition = "slot_logos_icons"
        i.icoComp.rect = newRect(newPoint(0, 0), icoSolid.size)
        # icoPlaceholder.removeComponent(Solid)
    
    
        i.join_Button.button.onAction do():
            if w.processClose:
                return
            sendEvent("tournament_open", %*{
                "chips_left": %currentUser().chips,
                "current_tournament_id": i.tournament.title,
                "time_to_current_tournament": timeLeft(i.tournament.endDate).int})
    
            w.closeButtonClick()
            sharedServer().joinTournament(i.tournament.id, proc(res: JsonNode) =
                    echo res
                    if res["status"].str == "Ok" and res.hasKey("partId"):
                        i.tournament.participationId = res["partId"].str
                        i.tournament.updateFromParticipantsResponse(res, preserveScore = false)
                        #i.update()
                        currentUser().updateWallet(res["chips"].getBiggestInt())
    
                        let scene = startSlotMachineGame(parseEnum[BuildingId](i.tournament.slotName), smkTournament)
                        scene.BaseMachineView.setTournament(i.tournament)
                )
    
        i.continue_Button.button.onAction do():
            if w.processClose:
                return
            sendEvent("tournament_reopen", %*{
                "chips_left": %currentUser().chips,
                "current_tournament_id": i.tournament.title,
                "time_to_current_tournament": timeLeft(i.tournament.endDate).int,
                "current_position": i.tournament.place,
                "is_prize": i.tournament.isPrizePlace()})
    
            w.closeButtonClick()
            let scene = startSlotMachineGame(parseEnum[BuildingId](i.tournament.slotName), smkTournament)
            scene.BaseMachineView.setTournament(i.tournament)
    
        i.reward_Button.button.onAction do():
            if w.processClose:
                return
            i.tournament.gainReward()
    
        # result.playBt.onAction do():
        #     var slotClassName = buildingIdToClassName[parseEnum[BuildingId](t.slotName)]
        #     let scene = currentDirector().moveToScene(slotClassName)
        #     scene.BaseMachineView.tournament = t
    
    
    proc runTimeLeft(t: Tournament): float =
        if t.endDate < 0:
            result = t.duration  # always running if no endDate set
        else:
            result = timeLeft(t.endDate)
    
    
    proc timerText(time: float): string =
        #result = time.fromSeconds().getGMTime().format("hh:mm:ss")
        result = $(time.int div 3600) & (time.int mod 3600).fromSeconds().getGMTime().format(":mm:ss")  # because we need 24+ hours duration to be handled too
    
    
    proc hasStarted(t: Tournament): bool = timeLeft(t.startDate) < 0
    proc isRunning(t: Tournament): bool = t.hasStarted and t.runTimeLeft > 0 and not t.isClosed
    proc hasEnoughChips(t: Tournament): bool = currentUser().chips >= t.entryFee
    proc slotIsAvailable(t: Tournament): bool = parseEnum[BuildingId](t.slotName) in activeSlots()  or  t.endDate < 0  # tutorial tournament
    proc alreadyJoined(t: Tournament): bool = t.participationId.len != 0
    proc isOpen(t: Tournament): bool = t.isRunning and not t.alreadyJoined
    proc joinConditionsMet(t: Tournament): bool = t.hasEnoughChips and t.slotIsAvailable
    proc mayContinue(t: Tournament): bool = t.isRunning and t.alreadyJoined
    proc mayClaimReward(t: Tournament): bool = t.isClosed and t.alreadyJoined and not t.rewardIsClaimed
    
    
    proc update(i: TournamentWindowItem, t: Tournament) =
        assert(not t.isNil)
        i.tournament = t
    
        #echo i.tournament.title, " - isRunning = ", isRunning, ",  mayJoin = ", mayJoin, ",  mayContinue = ", mayContinue, ",  mayClaimReward = ", mayClaimReward
        #echo "  runTimeLeft = ", runTimeLeft, ",  i.tournament.isClosed = ", i.tournament.isClosed
    
        i.participationHighlight.enabled = i.tournament.isRunning
        i.timeToEnd.node.enabled = not i.tournament.isClosed
        i.timeEnded.node.enabled = i.tournament.isClosed
        i.progressFiller.enabled = i.tournament.isRunning
        i.noProgressFiller.enabled = not i.tournament.isRunning
        i.players.node.enabled = i.tournament.hasStarted
    
        i.title.text = i.tournament.title
        #levelLabel.text = "L " & $t.level
        i.bet.text = $(i.tournament.bet div 1000) & "K"
        i.join_Button.chips_Icon.enabled = (i.tournament.entryFee > 0)
        i.comingSoon_Button.chips_Icon.enabled = (i.tournament.entryFee > 0)
    
        var entryFeeText: string
        if not t.slotIsAvailable:
            entryFeeText = localizedString("TR_LOCKED")
            i.locked_Label.text = localizedString("TR_BUILD_SLOT_TO_PLAY")
        elif i.tournament.entryFee > 0:
            entryFeeText = $(i.tournament.entryFee div 1000) & "K"
            i.locked_Label.text = localizedFormat("TR_AVAILABLE_WITH_CHIPS", entryFeeText)
        else:
            entryFeeText = localizedString("TR_FREE")
    
        i.comingSoon_Button.label.text = entryFeeText
        i.join_Button.label.text = entryFeeText
    
        if i.tournament.prizeFundBucks > 0:
            i.bucks_Icon.enabled = true
            i.chips_Icon.enabled = false
            i.prizeFund.text = $(i.tournament.prizeFundBucks)
        else:
            i.bucks_Icon.enabled = false
            i.chips_Icon.enabled = true
            i.prizeFund.text = $(i.tournament.prizeFundChips div 1000) & "K"
    
        if i.tournament.participationId.len != 0 and i.tournament.isRunning:
            i.scoreValue_Label.text = $i.tournament.myScore
        else:
            i.score_Label.node.enabled = false
            i.scoreValue_Label.node.enabled = false
    
        if i.tournament.participationId.len != 0 and not i.tournament.participants.isNil:
            i.tournament.sortParticipants()
            i.players.text = "<span style=\"color:FFFFFFFF\">$1</span><span style=\"fontSize:24\">/$2</span>" % [$i.tournament.place, $i.tournament.playersCount]
        else:
            i.players.text = $i.tournament.playersCount
    
        i.icoComp.name = $i.tournament.slotName
    
        if i.tournament.isRunning:
            i.time_Label.setText(localizedString("TR_TIME_TO_END"), false)
            i.timeToEnd.text = i.tournament.runTimeLeft.timerText()
            if i.tournament.endDate < 0:
                i.progressFiller.scaleX = 0.0
            else:
                i.progressFiller.scaleX = i.progressFillerFullScale * (1.0 - i.tournament.runTimeLeft / (i.tournament.endDate - i.tournament.startDate))
        elif not i.tournament.hasStarted:
             i.time_Label.setText(localizedString("TR_TIME_TO_START"), true)
             i.timeToEnd.text = timeLeft(i.tournament.startDate).timerText()
    
        let comingSoonEnabled = not i.tournament.hasStarted
        i.comingSoon_Button.node.enabled = comingSoonEnabled
        i.comingSoon_Button.button.enabled = comingSoonEnabled
        i.comingSoon_Label.node.enabled = comingSoonEnabled
    
        let joinEnabled = i.tournament.isOpen and i.tournament.joinConditionsMet
        i.join_Button.node.enabled = joinEnabled
        i.join_Button.button.enabled = joinEnabled
        i.join_Label.node.enabled = joinEnabled
    
        let lockEnabled = i.tournament.isOpen and not i.tournament.joinConditionsMet
        i.locked_Button.node.enabled = lockEnabled
        i.locked_Button.button.enabled = lockEnabled
        i.locked_Label.node.enabled = lockEnabled
    
        i.continue_Button.node.enabled = i.tournament.mayContinue
        i.continue_Button.button.enabled = i.tournament.mayContinue
        i.score_Label.node.enabled = i.tournament.mayContinue
    
        i.reward_Button.node.enabled = i.tournament.mayClaimReward
        i.reward_Button.button.enabled = i.tournament.mayClaimReward
        i.reward_Image.enabled = i.tournament.mayClaimReward
    
        i.finished_Icon.enabled = i.tournament.runTimeLeft <= 0 or i.tournament.isClosed
    
        #i.claimBt.enabled = i.tournament.isClosed and not i.tournament.rewardIsClaimed
    
    
    type TournamentsWindow* = ref object of WindowComponent
        updateTimer: ControlledTimer
        updateCountdown: int
        updateSpan: int
    
        title: Text
        desc: Text
        #item: TournamentWindowItem
        items: seq[TournamentWindowItem]
        tournaments: seq[Tournament]
        #onRemove*: proc()
        itemsRoot: Node
        firstItemPos: Vector3
        itemAnchor: Vector3
        itemGap: Coord
        scroller: NodeScroll
        cheatView : View
        boostMultiplier*: BoostMultiplier
    
    
    proc findActiveTournament(w: TournamentsWindow): Tournament =
        for ti in w.items:
            if not ti.isNil and timeLeft(ti.tournament.startDate) < 0 and timeLeft(ti.tournament.endDate) > 0:
                return ti.tournament
    
    
    proc findNextTournament(w: TournamentsWindow): Tournament =
        for ti in w.items:
            if not ti.isNil and timeLeft(ti.tournament.startDate) >= 0:
                return ti.tournament
    
    
    proc findRewardedTournament*(tournaments: seq[Tournament]): Tournament =
        for t in tournaments:
            if t.isClosed and t.participationId.len != 0 and not t.rewardIsClaimed:
                return t
    
    
    proc findCurrentTournament(w: TournamentsWindow): Tournament =
        for ti in w.items:
            if not ti.isNil and ti.tournament.participationId.len != 0:
                return ti.tournament
    
    
    proc newTournamentWindowItem(w: TournamentsWindow, index: int, t: Tournament): TournamentWindowItem =
        let content = newLocalizedNodeWithResource("common/gui/popups/precomps/Tournament_placeholder.json")
        #w.itemsRoot.addChild(resNode)
        w.scroller.addChild(content)
        result.new
        result.node = content
        result.tournament = t
        result.init(w)
        result.node.position = w.firstItemPos
        result.node.positionY = result.node.positionY + w.itemGap * index.Coord
        result.node.anchor = w.itemAnchor
    
        content.addAnimation(content.animationNamed("appear"))
        result.update(t)
    
    
    proc importance(t: Tournament): int =
        if t.mayClaimReward:
            result = 1
        elif t.mayContinue:
            result = 2
        elif t.isRunning:
            result = 3
        else:
            result = 4
    
    
    proc cmp(t1, t2: Tournament): int =
        result = cmp(t1.importance, t2.importance)
        if result != 0:
            return result
    
        if t1.isRunning:
            result = cmp(t2.slotIsAvailable, t1.slotIsAvailable)
            if result != 0:
                return result
    
            result = cmp(t2.prizeFundBucks, t1.prizeFundBucks)
            if result == 0:
                result = cmp(t2.prizeFundChips, t1.prizeFundChips)
            return result
    
        return cmp(t1.startDate, t2.startDate)
    
    
    proc updateContentFromResponse*(w: TournamentsWindow, tournaments: seq[Tournament]) =
        w.tournaments = tournaments.filter(proc (t: Tournament): bool = t.shouldShowInWindow)
        w.tournaments.sort do(t1, t2: Tournament) -> int:
            result = cmp(t1, t2)
    
        for item in w.items:
            if not item.isNil:
                item.node.removeFromParent()
        w.items = newSeq[TournamentWindowItem]()
        for i in 0 ..< w.tournaments.len:
            w.items.add(w.newTournamentWindowItem(i, w.tournaments[i]))
    
    
    proc updateOnTimer(w: TournamentsWindow) =
        w.updateCountdown.dec
        if w.updateCountdown <= 0:
            w.updateCountdown = w.updateSpan
            #v.requestUpdate()
        else:
            w.tournaments = w.tournaments.filter(proc (t: Tournament): bool = t.shouldShowInWindow)
            w.tournaments.sort do(t1, t2: Tournament) -> int:
                result = cmp(t1, t2)
            for i in 0 ..< w.tournaments.len:
                w.items[i].update(w.tournaments[i])
            for i in w.tournaments.len ..< w.items.len:
                if not w.items[i].isNil:
                    w.items[i].node.removeFromParent()
                    w.items[i].node = nil
                    w.items[i] = nil
    
    
    registerComponent(TournamentsWindow, "windows")
    
    
    const gapH = 5.Coord
    const bottomH = 40.Coord
    
    const gapW = 5.Coord
    const serviceButtonW = 150.Coord
    
    
    proc newTournamentsCheatButtons(v: View, w: TournamentsWindow) =
        var x = gapW
        let y = gapH
    
        let fastTournamentBt = Button.new(newRect(x, y, serviceButtonW, bottomH))
        fastTournamentBt.title = "Fast tournament"
        v.addSubview(fastTournamentBt)
        fastTournamentBt.onAction do():
            sharedServer().tournamentCreateFast proc(res: JsonNode) =
                echo "tournamentCreateFast = ", res
                w.updateContentFromResponse(parseTournamentsFromResponse(res["tournaments"]))
    
    
        x += serviceButtonW + gapW
        let tutorialTournamentBt = Button.new(newRect(x, y, serviceButtonW, bottomH))
        tutorialTournamentBt.title = "Tutorial tournament"
        v.addSubview(tutorialTournamentBt)
        tutorialTournamentBt.onAction do():
            sharedServer().getTutorialTournament proc(res: JsonNode) =
                echo "getTutorialTournament = ", res
                w.updateContentFromResponse(parseTournamentsFromResponse(res["tournaments"]))
    
    
    # proc update(v: TournamentsView) =
    #     v.updateCountdown.dec
    #     if v.updateCountdown <= 0:
    #         v.updateCountdown = v.updateSpan
    #         #v.requestUpdate()
    #     else:
    #         for i in v.items:
    #             i.update()
    
    proc hasCompletedTutorialTournament(w: TournamentsWindow): bool =
        for t in w.tournaments:
            if t.level == 0 and t.isClosed and not t.rewardIsClaimed:
                return true
        return false
    
    proc tutorialLogic(w: TournamentsWindow) =
        tsTournamentJoin.addTutorialFlowState(true)
        if isFrameClosed($tsTournamentJoin):
            if not isFrameClosed($tsFirstTournamentReward) and w.hasCompletedTutorialTournament():
                tsFirstTournamentReward.addTutorialFlowState(true)
            else:
                tsShowTpPanel.addTutorialFlowState(true)
    
    # var tournamentsView : TournamentsView = nil
    proc handleTournamentsResponse(w: TournamentsWindow, res: JsonNode) =
        if w.processClose:
            return
        let pv = currentDirector().currentScene
        #echo $res
        let tournaments = parseTournamentsFromResponse(res["tournaments"])
        # let rewardedT = tournaments.findRewardedTournament()
        # if not rewardedT.isNil:
        #     rewardedT.gainReward()
        # else:
        w.updateContentFromResponse(tournaments)
        let activeT = w.findActiveTournament()
        let nextT = w.findNextTournament()
        sharedAnalytics().wnd_tournaments_open(
            nextTournament = if nextT.isNil(): ""  else: nextT.title,
            activeTournament = if activeT.isNil(): ""  else: activeT.title,
            timeToNextTournament = if nextT.isNil(): -1  else: timeLeft(nextT.startDate).int,
            activeTournamentTimeLeft = if activeT.isNil(): -1  else: timeLeft(activeT.endDate).int)
    
        w.updateTimer = pv.setInterval( 1, proc() = w.updateOnTimer())
    
        if currentUser().cheatsEnabled and w.cheatView.isNil:
            w.cheatView.new()
            w.cheatView.init(newRect(250.Coord, gapH, gapW * 3 + serviceButtonW * 2, gapH*2 + bottomH))
            w.cheatView.newTournamentsCheatButtons(w)
            pv.addSubview(w.cheatView)
    
        w.tutorialLogic()
    
    method onInit*(w: TournamentsWindow) =
        w.updateSpan = 30
        w.updateCountdown = w.updateSpan
        let content = newLocalizedNodeWithResource("common/gui/popups/precomps/Tournament_window_layout.json")
        w.anchorNode.addChild(content)
    
        let toRemove = content.findNode("Tournament_placeholder$5")
        toRemove.removeFromParent()
    
        let tab = content.mandatoryNode("tabactive492px")
        tab.enabled = true
        tab.mandatoryNode("title_unactive").enabled = false
        tab.mandatoryNode("title_active").getComponent(Text).text = localizedString("TR_BUTTON_TITLE")
        tab.positionX = (tab.positionX + content.mandatoryNode("tabactive492px$7").positionX) / 2
    
        content.mandatoryNode("tabactive492px$7").enabled = false
        content.mandatoryNode("button_down").enabled = false
        content.mandatoryNode("button_up").enabled = false
        content.mandatoryNode("button_circle").enabled = false
        content.mandatoryNode("scrollbar_tournament.png").enabled = false
        #content.mandatoryNode("ltp_scrollbar_part1.png").enabled = false
        content.mandatoryNode("button_black_long").enabled = false
        #let btnClose = win.findNode("button_close")
    
        w.boostMultiplier = content.mandatoryNode("ltp_rectangle_26_copy_2.png").addTpBoostMultiplier(newVector3(214.0, -27.0, 0.0), 0.8)
    
        let btnClose = content.findNode("button_close")
        let closeAnim = btnClose.animationNamed("press")
        let bcp = w.anchorNode.newChild("close_animButton_parent")
        let buttonClose = bcp.createButtonComponent(closeAnim, newRect(btnClose.positionX + 10.0, btnClose.positionY + 10.0, 80.0, 80.0))
        buttonClose.onAction do():
            let active = w.findActiveTournament()
            let activeName = if active.isNil: "" else: active.title
            let activeTimeLeft = timeLeft(if active.isNil: 0.0 else: active.endDate).int div 60
            let next = w.findNextTournament()
            let nextName = if next.isNil: "" else: next.title
            let timeToNext = timeLeft(if next.isNil: 0.0 else: next.startDate).int div 60
            sharedAnalytics().wnd_tournaments_closed(nextName, activeName, timeToNext, activeTimeLeft)
    
            w.closeButtonClick()
    
        let itemPlaceholder = content.findNode("Tournament_placeholder")
        w.itemsRoot = newNode()
        w.itemsRoot.name = "itemsRoot"
        w.itemsRoot.positionX = 240
        w.itemsRoot.positionY = 220
        #itemPlaceholder.parent.addChild(w.itemsRoot)
        itemPlaceholder.parent.insertChild(w.itemsRoot, 5)
        w.firstItemPos = itemPlaceholder.position - w.itemsRoot.position
        w.itemAnchor = itemPlaceholder.anchor
        w.itemGap = itemPlaceholder.anchor.y * 2
        itemPlaceholder.removeFromParent()
    
        w.scroller = createNodeScroll(newRect(0, 0, itemPlaceholder.anchor.x * 2, w.itemGap * 2), w.itemsRoot)
        w.scroller.nodeSize = newSize(itemPlaceholder.anchor.x * 2, w.itemGap)
        w.scroller.scrollDirection = NodeScrollDirection.vertical
        w.scroller.bounces = true
        w.scroller.notDrawInvisible = true
    
        let btnDown = content.findNode("button_down")
        let downAnim = btnDown.animationNamed("press")
        let bdp = w.anchorNode.newChild("down_animButton_parent")
        let buttonDown = bdp.createButtonComponent(downAnim, newRect(btnDown.positionX + 10.0, btnDown.positionY + 10.0, 80.0, 80.0))
        buttonDown.onAction do():
            echo "down"
    
        let btnUP = content.findNode("button_up")
        let upAnim = btnUP.animationNamed("press")
        let bup = w.anchorNode.newChild("up_animButton_parent")
        let buttonUp = bup.createButtonComponent(upAnim, newRect(btnUP.positionX + 10.0, btnUP.positionY + 10.0, 80.0, 80.0))
        buttonUp.onAction do():
            echo "up"
    
        let tp = currentUser().tournPoints
        content.findNode("tournament_points").component(Text).text = $tp
    
        if tp == 0:
            sharedServer().getTutorialTournament proc(res: JsonNode) =
                handleTournamentsResponse(w, res)
        else:
            sharedServer().getTournamentsList nil, proc(res: JsonNode) =
                handleTournamentsResponse(w, res)
    
        # tw.applyFrameData()
    
    
    proc toggleTournamentsView*(pv: GameScene, s: Server) =
        let w = sharedWindowManager().show(TournamentsWindow)
    
    
    method beforeRemove*(w: TournamentsWindow) =
        if not w.cheatView.isNil:
            w.cheatView.removeFromSuperview()
            w.cheatView = nil
    
        if not w.boostMultiplier.isNil:
            w.boostMultiplier.onRemoved()
            w.boostMultiplier = nil
    
    
    method onShowed*(w: TournamentsWindow) =
        procCall w.WindowComponent.onShowed()
        # w.anchorNode.sceneView.GameScene.setTimeout(0.5) do():
    Le but initial de la conception de Nim était, comme l’explique Rumpf, de mettre sur pied un langage qui compile vers le C et est doté d’une base de code qui n’excède pas 20 000 lignes. À l’origine, il est prévu qu’un système de macros vienne compléter les fonctionnalités offertes par le noyau de base. Avec la sortie de la version 1, le compilateur et la bibliothèque standard comptent désormais pour 140 000 lignes de code.

    « Le compilateur actuel et les parties de la bibliothèque standard qu'il utilise ont environ 140 000 lignes de code, fonctionnent sur une pléthore de systèmes d'exploitation et d'architectures de processeurs, peuvent également compiler du code Nim en C++ et JavaScript et les capacités de métaprogrammation de Nim sont les meilleures de leur catégorie. Bien que le langage ne soit pas aussi petit que je le souhaiterais, il s'est avéré que la métaprogrammation ne peut pas remplacer tous les éléments constitutifs dont un langage moderne a besoin », indique Rumpf.


    Comme il est de coutume avec les langages qui ne disposent pas encore d’une certaine aura, les débats à propos de Nim portent sur les aspects susceptibles de le démarquer de l’existant. La compilation vers C, C++ et JavaScript revient dans les échanges. Certains y voient un avantage en ceci que pour des travailleurs de la filière développement web par exemple, le frontend et le backend peuvent être montés dans le même langage. En sus, possibilité liée à la précédente : la génération d’ exécutables pour une panoplie de plateformes parmi lesquelles Windows, Linux, BSD, macOS. D’avis d’observateurs, cet aspect permet à Nim de se démarquer de langages aux caractéristiques similaires parmi lesquels Rust, D et Ocaml.

    De plus, certains benchmarks révèlent que Nim est aussi rapide que C et C++ sur des algorithmes équivalents. Toutefois, c’est la richesse de bibliothèque qui semble être l’une de ses faiblesses. En effet, en comparaison à celle d’un langage comme Python, il y a encore du chemin.

    Dans tous les cas, l’équipe de développement assure que le langage est désormais stable ce qui l’ouvre à des essais sur des projets sérieux. À ce propos, Nim est compatible avec bon nombre d’éditeurs dont Visual Studio code, Atom, Emacs et Sublime Text. Le compilateur et les outils sont disponibles sous licence MIT.

    Source : Notes de version, FAQ du projet

    Et vous ?

    Qu’en pensez-vous ?

    Connaissez vous ce langage de programmation ? Si oui, quel est votre retour en ce qui le concerne ?

    Quels langages peut-il remplacer et dans quelles filières ?

    Voyez-vous Nim comme autre chose qu'un langage exotique ?

    Voir aussi :

    Quel avenir pour le langage C ? Un développeur expérimenté fait ses adieux au langage et livre ses inquiétudes quant à son avenir

    C2 : un langage qui se présente comme une évolution de C, plus rapide, sans fichiers d'en-tête, avec système de build intégré et d'autres changements

    Quel langage pourrait remplacer C ? Après avoir comparé Go, Rust et D, le choix d'Andrei Alexandrescu se porte sur D

    Pourquoi les langages C et C++ auraient-ils encore de nombreuses années devant eux ? Donnez votre avis
    Contribuez au club : Corrections, suggestions, critiques, ... : Contactez le service news et Rédigez des actualités

  5. #5
    Membre émérite
    Profil pro
    retraité
    Inscrit en
    Décembre 2010
    Messages
    806
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : retraité

    Informations forums :
    Inscription : Décembre 2010
    Messages : 806
    Points : 2 307
    Points
    2 307
    Par défaut
    Qu’en pensez-vous ?

    Connaissez vous ce langage de programmation ? Si oui, quel est votre retour en ce qui le concerne ?

    Quels langages peut-il remplacer et dans quelles filières ?

    Voyez-vous Nim comme autre chose qu'un langage exotique ?
    Non je ne connais pas
    Ben à priori beaucoup de langages peut être
    Mais vu qu'il arrive tard, cela va rester exotique.

  6. #6
    Membre expérimenté

    Homme Profil pro
    Retraite
    Inscrit en
    Octobre 2005
    Messages
    478
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Retraite
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 478
    Points : 1 338
    Points
    1 338
    Billets dans le blog
    1
    Par défaut
    Bonjour ,

    je viens de passer 5 h de farfouiller pour voir de quoi il en retourne . version 1

    Intéressant,
    une approche élaguant un bon nombres d'instructions.

    du point de vue regardant le langage l'option macro est magique , peut-être j'aurai dut dire méta (bien -sur on peut aussi en fabriquer avec le C++)

    ça me donne une idée de tester , avec une BD et UI natif , j'ai vue qu'il y aussi des lib et donc pdf .... enfin de quoi construire une application complète création mise à jour liste d'une table comme exemple .... curiosité histoire de voir ce qu'il a dans le ventre .

    aussi il me faut dire que cela me parait plus simple que rust... bon je ne compare pas (j'en vois déjà hurler ) mais j'ai comme l'impression d'un déjà vue sur la manière dont cela a été pensé.

    j'aime aussi les options du compilateur il y a de quoi améliorer la sécurité

    j'utilise le GCC 9.1 c/c++ 17 et j'entame la lecture de Racket de Jean.Paul.Roy (sheme) je suis à la retraite alors je m'amuse (après plus de 40 ans de pratique), bref je cherche une programmation méta ou faire ma programmation méta ....

  7. #7
    Membre expérimenté

    Homme Profil pro
    Retraite
    Inscrit en
    Octobre 2005
    Messages
    478
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Retraite
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 478
    Points : 1 338
    Points
    1 338
    Billets dans le blog
    1
    Par défaut
    bonjour,

    je travail avec linux ...


    installation IDE:
    j'ai installé visualstudio en snap nom -> code et pas visualstudio bref cela fonctionne j'ai l'habitude de me servir de Geany 1.35 et qui n'a pas de reconnaissance de nim on verra plus tard...


    installation de nim:
    pour fonctionner j'ai pris l'option la plus raisonnable et surtout la plus simple sans soucies pour le teste mais aussi la plus fonctionnel pas la peine de prendre le snap cela ne fonctionne pas à ce jour 01/10/2019 (lien briser lors de compilation)

    compile:
    nim -o:toto c -f test.nim ou nim -o:toto c test.nim

    nim -o:outfile(toto) c->compile -f ->"force la recompilation total" namesource



    impression:

    puis j'ai entamé le tutoriel 1

    ma première impression est que la mise en forme avec les indentations minutieuses sont à forte résolution de problèmes mais les gents de python n'auront aucun problème ( en bash ça sert aussi ) en C/C++ on pratique mais cela n'a pas trop d'incidence sauf pour de la prod et la lisibilité mais pour 15 lignes en tuto non ...

    la documentation est très bien faite il faut le dire

    la récupération des erreurs ce fait simplement la logique a l'air évidente ( je n'en suis qu'à la première partie lolll )

    l'os à ronger vas venir avec les class etc... les liens avec les lib .... le makefile ou le .cfg (je n'ai pas encore pioché cela)

    mais je me formalise pas trop venant du c/c++ je ne suis pas trop perdu.

    maintenant l’écriture direct avec la connaissance ...ben là il vas falloir attendre


    Question:
    ce que j'attends c'est est-ce que cela vas m'alléger le coding ...( erreur/pissage de ligne/compile.../réutilisation de code/enfin bref l'intendance de base//// référence croisé pour savoir quel module je dois retoucher ou impacte ) je ne parle pas de la profondeur de possibilité puisqu'on peut lier avec des lib (C/C++) en natif ..... Mais il n'y a qu'un expert dans ce langage qui peut renseigner sur le sujet (ps ne pas me sortir les states merci)...

    @bientôt

  8. #8
    Membre expérimenté

    Homme Profil pro
    Retraite
    Inscrit en
    Octobre 2005
    Messages
    478
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Retraite
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 478
    Points : 1 338
    Points
    1 338
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par Aiekick Voir le message
    Nim ce veut aussi puissant que le C ? qu'entend t'on par puissant ? surtout quand je lis les mots : Ramasse-miettes et machine virtuelle.
    nim-script est une particularité non obligatoire mais s'adresse pour faire du java-script d'après ce que j'ai lu dans la doc .... sinon c'est du compilé pure jus natif il y a bien-sur dans les nouvelles possibilité la possibilité de travailler avec python en direct ( je ne connais pas ) mais ce sont les new perso je teste déjà pour une appli standard et cela a l'air prometteur.

    dans le fichier .cfg qui sert à la compilation cc = gcc

  9. #9
    Membre expérimenté

    Homme Profil pro
    Retraite
    Inscrit en
    Octobre 2005
    Messages
    478
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Retraite
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2005
    Messages : 478
    Points : 1 338
    Points
    1 338
    Billets dans le blog
    1
    Par défaut installation et test NIM-lang
    Bonjour comme promis je fait mon retour sur mes essais avec NIM-lang


    https://nim-lang.org/

    l’installation*:

    si vous êtes sur Linnux:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    curl https://nim-lang.org/choosenim/init.sh -sSf | sh
    pour vos test il n’y a pas mieux … rien ne vous empêchera par la suite de faire une installation system.

    pour les conversions .c,.h … vers .nim

    pour que le gui soit avec GLADE ou à la main

    pour l’IDE je vais dire plutôt un éditeur de textes j'aurais dit GEANY (j'attends j'ai pas dis mon dernier mots)

    visual studio-Code allez le prendre sur un snap il sera à part et vous pourrez le mettre à jour facilement

    ce n'ai pas visual-studio le complet mais un vrais éditeur avec beaucoup de possibilité et Gratuis

    https://snapcraft.io/vscode

    choisir les plugins …. important par exemple*:

    nim
    pour travailler agréablement il est à jour et prend en charge comme le c/c++ de toutes façon il n'y a pas grande différence

    indent on space
    pour l’indentation et vis versa

    commande runner
    pour faire vos compilations ect

    dans le settings.json

    Code JSON : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    "command-runner.commands":
                 {
                       "Glade":"/usr/bin/glade $fileName",
                       "Nim-Debug":"./compile.sh DEBUG $fileName",
                       "Nim-Release":"./compile.sh PROD $fileName",
                       "RUN-NIM":"./$fileName",
                       "GLADE-conv":"$HOME/T_LIB/srcbuildnim -p $dir -f $fileName",
                       "CSS-conv":"$HOME/T_LIB/srccssnim -p $dir -f $fileNameWithoutExt"
                }

    cela vous permettra de coller une commande(s) :

    Code JSON : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    "runTerminalCommand.commands": 
                  [
                      {
                        "command":*"grep*-B2*gtk_builder_new_from_string*~/.nimble/pkgs/gintro-0.5.5/gintro/*",
                        "name":*"GREP-GTK"
                       }
                 ]

    bien utile pour faire la transcription GTK 3/4 .c en GTK nim lib --> Gintro

    de quoi vous mettre l’eau à la bouche*:

    http://ssalewski.de/gintroreadme.html


    vous permet de faire les repères facilement de toutes les variables identiques

    pour avoir plusieurs fichiers ouvert comme des onglets …. eh oui cela parait évident !!!


    aller ça devient sympathique

    Nom : Capture d’écran_2019-10-18_15-56-21.png
Affichages : 7130
Taille : 296,5 Ko

    ma façon de compiler*: ouf c'est comme un tout petit makefile sh ou bat ....
    de toutes façon nim c ....... prend tout en charge

    compile.sh
    Code bash : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    #!/bin/bash
     
    faStabilo='\033[7m'
    fcRouge='\033[31m'
    fcJaune='\033[33;1m'
    fcCyan='\033[36m'
     
     
    #-------------------------------------------------------------------
    # ccontrôle si projet nim
    #-------------------------------------------------------------------
    if [[ ! "$2" =~ '.nim' ]]; then
    echo -en $faStabilo$fcJaune"$2 -->"$faStabilo$fcRouge"ce n'est pas un fichier .nim \033[0;0m\\n"
    exit 0 
    fi
     
     
     
    mode=$1
     
    projet_src=$2
     
    projet_bin=${projet_src%.*}
     
     
    #-------------------------------------------------------------------
    # clean
    #-------------------------------------------------------------------
    if test -f $projet_bin ; then
    	rm -f $projet_bin
    fi
     
    #-------------------------------------------------------------------
    # compile
    #-------------------------------------------------------------------
    # force full option gtk
    # debug
    # nim  c --threads --passC:-flto -d:danger  -d:forceGtk   -o:$projet_bin   $projet_src
    # prod
    # nim  c  --verbosity:0 --hints:off --opt:size --threads --passC:-flto -d:danger  -d:forceGtk -d:release  -o:$projet_bin   $projet_src
     
     
     
    if [ "$mode" == "DEBUG" ] ; then 
    	nim  c  -f  -d:danger  -o:$projet_bin   $projet_src
    fi
     
    if [ "$mode" == "PROD" ] ; then 
    	nim  c  --verbosity:0 --hints:off  --opt:size  -d:danger -d:release -f  -o:$projet_bin   $projet_src
    fi
     
    #-------------------------------------------------------------------
    # resultat
    #-------------------------------------------------------------------
     
    	echo -en '\033[0;0m'	# video normal
     
    	if test -f "$projet_bin"; then
    		echo -en $faStabilo$fcCyan"BUILD $mode "$faStabilo$fcJaune"$projet_src -> $projet_bin\033[0;0m"
    		echo -en "  octet : " 
    		wc -c $projet_bin
    	else
    		echo -en $faStabilo$fcRouge"BUILD $mode "$faStabilo$fcJaune"$projet_src -> ERROR\033[0;0m\n"
    	fi
    exit

    les outils en open-source et beaucoup plus des exemples (ps je suis en plain test mais cela commence à être jouable )

    https://github.com/AS400JPLPC/NIM_etudes/

    @bientôt
    ça me plaît je crois que je vais allé au bout des tests.... lire le source manuel.nim

Discussions similaires

  1. Réponses: 16
    Dernier message: 18/07/2003, 17h16
  2. Comment rediriger la sortie vers /dev/null
    Par dclink dans le forum C
    Réponses: 4
    Dernier message: 24/06/2003, 18h23
  3. [LG]Entrées et sorties redirigée
    Par Lady dans le forum Langage
    Réponses: 17
    Dernier message: 10/05/2003, 18h33
  4. Rediriger le plux de sortie
    Par Groove dans le forum C
    Réponses: 5
    Dernier message: 17/04/2003, 17h16
  5. récupérer la valeur de sortie d'un thread
    Par jakouz dans le forum Langage
    Réponses: 3
    Dernier message: 31/07/2002, 11h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo